Comment parsing in @lezer/markdown

I am working on extracting comments from the markdown content, and noticed this inconsistency between @lezer/markdown and cmark parser.

The simplest example is <!-- Hello -->World. @lezer/markdown Tends to treat the entire string as a comment:

Whereas cmark only views the wrapped content as comment:

Is this by design or a bug? Thanks.

The CommonMark spec indicates that blocks that start with an HTML comment are HTML blocks. The Markdown parser was doing no further parsing on such blocks. This patch makes it so that the HTML parser is run on them, to make the highlighting less surprising in cases where there’s content after the comment.

Thanks for the quick fix!

Hi @marijn thank you again for the change, do you think if we can tag a new release?

Definitely. I’ve tagged 1.4.3.

1 Like