tree-sitter-grammars / tree-sitter-markdown

Markdown grammar for tree-sitter
MIT License
374 stars 45 forks source link

bug: Latex injections appear multiple times in AST #147

Open camoz opened 1 month ago

camoz commented 1 month ago

Did you check existing issues?

Describe the bug

When I edit a markdown file, latex injections appear multiple times in the AST shown by :InspectTree. I'm not sure if this is a bug, but it seems weird and I wanted to report it.

Steps To Reproduce/Bad Parse Tree

  1. Have nvim-treesitter plugin with markdown* and latex parsers installed
  2. :set ft=markdown
  3. paste

    some text
    
    $\alpha = 1$
  4. :InspectTree

Result: The inline math is present multiple times in the AST, specifically it is present where the cursor is in the picture below. If there are n paragraphs before the inline math in the markdown file, the inline math is is present n+1 times in the AST.

screen_2024-05-07_051336

Additional Info

Expected Behavior/Parse Tree

I would expect the inline math to show only once in the AST.

ribru17 commented 1 month ago

I think this might be an issue with the neovim injection logic, tree-sitter parse gives the correct AST (at least when looking at just the (latex_block) nodes)