Skip to content

🐛 FIX: Allow an HTML comment whose text ends with a hyphen - #478

Open
Shriraj1901 wants to merge 1 commit into
executablebooks:masterfrom
Shriraj1901:fix-inline-comment-ending-in-dash
Open

Shriraj1901 wants to merge 1 commit into
executablebooks:masterfrom
Shriraj1901:fix-inline-comment-ending-in-dash

Conversation

@Shriraj1901

Copy link
Copy Markdown

CommonMark 0.31 only forbids --> inside the text of an HTML comment, so <!-- note ---> and <!-----> are valid raw HTML (cmark, commonmark.js and markdown-it 15 all pass them through). The inline HTML regex still used the older grammar, which cannot match a text that ends in -, so these comments were rendered as escaped text:

MarkdownIt("commonmark").renderInline("<!-- note --->")
# '&lt;!-- note ---&gt;'

Match the text lazily up to the first --> instead. Unterminated comments are still rejected before the regex runs, so the scan cannot go past a terminator that exists.

CommonMark 0.31 only forbids `-->` inside the text of an HTML comment, so
`<!-- note --->` and `<!----->` are valid raw HTML (cmark, commonmark.js and
markdown-it 15 all pass them through). The inline HTML regex still used the
older grammar, which cannot match a text that ends in `-`, so these comments
were rendered as escaped text:

    MarkdownIt("commonmark").renderInline("<!-- note --->")
    # '&lt;!-- note ---&gt;'

Match the text lazily up to the first `-->` instead. Unterminated comments are
still rejected before the regex runs, so the scan cannot go past a terminator
that exists.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant