Skip to content

fix(markdown): support HTML comments - #4576

Open
phanirithvij wants to merge 1 commit into
highlightjs:mainfrom
phanirithvij:fix/markdown-html-comments
Open

phanirithvij wants to merge 1 commit into
highlightjs:mainfrom
phanirithvij:fix/markdown-html-comments

Conversation

@phanirithvij

@phanirithvij phanirithvij commented Nov 3, 2026 •

Copy link
Copy Markdown

CommonMark (§ 4.6) defines HTML comments () as valid Markdown elements.

Changes

Previously, markdown.js only matched tags starting with ASCII letters or underscores in INLINE_HTML, missing <!--.

As a result, content inside HTML comments was parsed as raw markdown prose.
Any underscore inside a comment (e.g. <!-- note_to_self --> or notebook metadata comments like <!-- livebook:{"default_language":"python"} -->) would trigger an unclosed _emphasis_ span, mistakenly italicizing the rest of the document.

Add HTML_COMMENT using hljs.COMMENT('<!--', '-->') with zero relevance to CONTAINABLE and top-level contains.

Checklist

  • Added markup tests, or they don't apply here because...
  • I have read and followed our AI-assisted contributions policy (human review, no slop)
    • I've reviewed and tested this change for our https://ngi.nixos.org/ website.
    • Assisted-by: Antigravity (Gemini 3.8 Flash high)

CommonMark (§ 4.6) defines HTML comments (<!-- ... -->) as valid Markdown
elements. Previously, markdown.js only matched tags starting with ASCII
letters or underscores in INLINE_HTML, missing `<!--`.

As a result, content inside HTML comments was parsed as raw markdown prose.
Any underscore inside a comment (e.g. `<!-- note_to_self -->` or notebook
metadata comments like `<!-- livebook:{"default_language":"python"} -->`)
would trigger an unclosed `_emphasis_` span, mistakenly italicizing the rest
of the document.

Add `HTML_COMMENT` using `hljs.COMMENT('<!--', '-->')` with zero relevance
to CONTAINABLE and top-level contains.

Assisted-by: Antigravity (Gemini 3.8 Flash high)
Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
@phanirithvij
phanirithvij force-pushed the fix/markdown-html-comments branch from eae5cfa to c850b2b Compare November 3, 2026 08:17
@phanirithvij
phanirithvij marked this pull request as ready for review November 3, 2026 08:35

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