ikatyang / tree-sitter-markdown

Markdown grammar for tree-sitter
https://ikatyang.github.io/tree-sitter-markdown
MIT License
183 stars 29 forks source link

Nodes for math mode (mathjax) #37

Open IndianBoy42 opened 3 years ago

IndianBoy42 commented 3 years ago

Would it be possible to extend the parser to find mathjax expressions ($blah$ $$blah$$) so that we can use that in queries?

MageJohn commented 3 years ago

I'd love to see this! I have a feeling though that it shouldn't get added here, as the goal of this project is to conform to a published spec. MathJax expressions like that are a syntax extension to Github Flavoured Markdown.

That said, syntax extensions to Markdown are widely used, so having some support for them would be great. Perhaps the way to do it would be to support some kind of extension or plugin system for the grammar.

@ikatyang, do you think something like that might be possible? I don't know much about tree-sitter grammars yet, but I understand they are implemented in JavaScript. I imagine then that it should be possible to allow a plugin to transform the grammar before returning it to tree-sitter.

Entoryvekum commented 1 year ago

I don't familiar with tree-sitter either, but I believe parsing math block will be similar to emphasis block (italics and bold).