Inline HTML comments are output as visible text
Environment
- Operating System:
macOS (Darwin) - Node Version:
v24.6.0 - Package Manager:
[email protected] - Comark Version:
0.7.0 - Framework:
None(also reproduced with Vue / Nuxt 4.5.2 via@comark/nuxt0.7.0, client render and SSR)
Comark Version
0.7.0
Reproduction
npm i [email protected]
// repro.mjs
import { parseMarkdown } from 'comark'
const doc = await parseMarkdown('Hello <!-- note --> world')
console.log(JSON.stringify(doc.nodes))
// [["p",{},"Hello <!-- note --> world"]]
Description
An HTML comment on its own line becomes a comment node, which is correct (see SPEC/COMARK/comment.md). An HTML comment inside a line of text becomes part of the text, so renderers show <!-- note --> to the reader.
Input
Hello <!-- note --> world
Actual output
<p>Hello <!-- note --> world</p>
The reader sees: Hello <!-- note --> world.
Expected output
<p>Hello <!-- note --> world</p>
The reader sees: Hello world. This matches GitHub and @nuxtjs/mdc.
Additional context
- This is a regression from
@nuxtjs/mdc, which parses the inline comment as a comment node, so migrated documents keep the comment invisible. - The same behavior was verified in a Nuxt 4.5.2 app using
@comark/nuxt0.7.0, both client-side and in SSR output.
Logs
Not applicable; the reproduction above shows the full output.
Hi! I looked into this. On current main the parser already turns inline comments into comment nodes (fixed by the refactor in #401), so this mainly affects the published 0.7.0. There's a related bug still on main: when the AST is stringified back to Markdown, an inline comment gets a block separator after it, so Hello <!-- note --> world becomes two paragraphs. I'll open a PR to fix this.