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
Feature request: add front matter support #32
Comments
In nvim-treesitter this is done by querying content between two consecutive thematic breaks, but this is of course not very accurate and stable. So this seems like a good idea. |
Last time I tried nvim-treesitter, front-matter wasn't supported. 🤔 Are you saying that I can have a query that is not tied to AST elements? I.e. just simply check for --- at the beginning and make an injection for this? |
Yes kind of. In realtiy it checks for thematic breaks, so it doesn't work to great. You can see the query in nvim-treesitter here. To use this you may need to update nvim-treesitter of course. |
I have noticed that the neovim treesitter query works if there is an extra space at the end of the frontmatter. here is an example Screen.Recording.2022-03-02.at.9.21.49.AM.mov |
This is implemented in the newest version. (Update the nvim-treesitter plugin and run |
Currently both pluses and minuses cause the content to be parsed as YAML as that is the behavior. I'm not sure why, probably because I made a mistake writing the query. It's easy to fix with |
Rationale
Markdown is a quite popular choice for writing content for static sites or documentation. Majority of existing tooling supports so called "front matter" that allows to attach some metadata to the document.
See example https://gohugo.io/content-management/front-matter/
Suggestion
Front matter is neither a part of the standard nor standardize among existing tooling. Nevertheless, it seems community pretty much settled on two front matter formats:
YAML is used in case of
---
separator. E.g:TOML is used in case of
+++
separator. E.g:It would be nice to support both YAML and TOML injections for this 2 most popular choices. I'm sure it would cover 99% of cases.
The text was updated successfully, but these errors were encountered: