tree-sitter-grammars / tree-sitter-markdown

Markdown grammar for tree-sitter
MIT License
430 stars 56 forks source link

bug: inline LaTeX formulae are not highlighted #176

Closed Silzinc closed 3 days ago

Silzinc commented 4 days ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

tree-sitter 0.20.8

Describe the bug

Hello!

Very simply, even after disabling the plugins I use around markdown and reinstalling mardown and markdown_inline parsers on treesitter neovim, it just won't highlight mathematics formulae (example below).

I learnt that some other people had a similar issue that was solved long ago, so I guess it is a problem in my config, but after disabling and re-enabling every bit that seemed relevant, I found no solution. Thank you in advance for helping me out!

Steps To Reproduce/Bad Parse Tree

  1. Open a Markdown file
  2. Write some text with a formula (example below)

Expected Behavior/Parse Tree

The formulae are highlighted and do not remain blank.

Repro

Here is the Gaussian integral:

$$
\int_{-\infty}^{\infty} e^{-x^2} \mathrm d x = \sqrt{\pi}
$$

Image

tbung commented 3 days ago

What do you get if you move your cursor over a part of the equation and run :Inspect? Also, do you have the latex parser installed as well? Whats the output of :checkhealth nvim-treesitter?

Highlighting works for me, so I am pretty sure this issue is completely unrelated to the markdown parser.

Silzinc commented 3 days ago

Oh I did not think the latex parser would be required for this. I had uninstalled it because I did not use it in regular tex files. This solved my problem, thank you!

tbung commented 3 days ago

Yes, in all instances where you have some other language within a language there are queries basically saying "parse this part as this other language" (called injections) and treesitter needs the other parser to do that, so this also applies to all languages you want to highlight in markdown code blocks.

Glad I could help!