Skip to content

html comment after list causes all remaining content be commented out #3515

@mjbvz

Description

@mjbvz

Marked version: 14.1.3

Describe the bug
When a html comment appears directly after a list, the rest of the content can become incorrectly commented out

To Reproduce

Try rendering the markdown:

- list
<!--
- a
-->

More text

https://marked.js.org/demo/?text=-%20list%0A%3C!--%0A-%20a%0A--%3E%0A%0AMore%20text%0A&options=%7B%0A%20%22async%22%3A%20false%2C%0A%20%22breaks%22%3A%20false%2C%0A%20%22extensions%22%3A%20null%2C%0A%20%22gfm%22%3A%20true%2C%0A%20%22hooks%22%3A%20null%2C%0A%20%22pedantic%22%3A%20false%2C%0A%20%22silent%22%3A%20false%2C%0A%20%22tokenizer%22%3A%20null%2C%0A%20%22walkTokens%22%3A%20null%0A%7D&version=14.1.3

Expected behavior
The content after the comment is not shown. Looking at the html source, you can see that an unclosed comment is created which contains the rest of the document:

<ul>
<li>list<!--</li>
<li>a
--&gt;</li>
</ul>
<p>More text</p>

Seems to work on commonmark and for markdown-it

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions