Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support frontmatter syntax #264

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

m4rch3n1ng
Copy link
Contributor

fixes #253
fixes #224

this parses rust frontmatter as specified in rfc 3503. like with raw strings (which this implementation takes quite a bit of inspiration from), the frontmatter content is parsed as a seperate node (frontmatter_content) to allow, for example, to add a toml language injection for the content.

i had to do a little hack because of tree-sitter automatically stripping all whitespace, meaning that i cannot always rely on having a newline before the ending fence. this means that it will incorrectly parse some things, but i think those are edge cases that are acceptable, because i couldn't figure out a way to make it stop stripping all whitespace between _frontmatter_start and frontmatter_content (which is also the cause for #251):

// this is technically valid rust and rustc doesn't consider the indented line
// as the ending fence, but instead the third line, while this pr already bails on the second line.
---
  ---
---

fn main() {}

no diff for rustc tests as rustc support for it is not yet merged.

@m4rch3n1ng m4rch3n1ng force-pushed the frontmatter branch 5 times, most recently from 88b9407 to 7c84e28 Compare March 6, 2025 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: frontmatter syntax support feature: frontmatter
1 participant