ikatyang / tree-sitter-markdown

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

HTML Comments #25

Closed jghauser closed 3 years ago

jghauser commented 3 years ago

I'm using tree-sitter-markdown with nvim-treesitter, and I'm not sure whether what I'm seeing is some artifact from the combination of these two programs or an issue with tree-sitter-markdown. But just in case it's an issue with the parser, here's something I've found.

I've noticed that when an html comment (<!-- comment -->) begins a line, it seems to be recognised correctly as a comment (and highlighted with a sort of greyed out color in neovim). However, when a comment is inline (This is a sentence<!-- comment --> with a comment.), then the comment shows up just like normal text. Finally, when the line starts with a comment and also contains inline comments (<!-- comment -->This is a sentence<!-- comment --> with a comment.), then all comments are displayed correctly again.

ikatyang commented 3 years ago

According to the CommonMark spec, the case 1 and case 3 are considered html block and the case 2 is considered a paragraph with inline html, I guess the highlight query you used only configured the query for html block but not for inline html.

Here's the parsed tree from the playground, which is expected:

image

jghauser commented 3 years ago

Thanks, I'm closing this as it's not an issue with tree-sitter-markdown. I'll open an issue at nvim-treesitter to ask how to get the highlighting right.