tree-sitter-grammars / tree-sitter-markdown

Markdown grammar for tree-sitter
MIT License
411 stars 52 forks source link

Extend front matter support #128

Open alexmozaidze opened 9 months ago

alexmozaidze commented 9 months ago

Feature

Allow specifying language to use in front matter like so:

---toml
answer = 42
---

Reason

11ty uses gray-matter for parsing front matter, which supports using any language as front matter, but doesn't support +++ notation for TOML.

+++ support workaround for gray-matter In order to hack in support for `+++`, you have to make `+++` a delimiter, and make TOML the default engine. Here's an example with 11ty config: ```js const toml = require("@iarna/toml"); module.exports = function(cfg) { cfg.setFrontMatterParsingOptions({ engines: { toml: toml.parse.bind(toml) }, language: "toml", delimiters: "+++", }); }; ```