Skip to content

Inline HTML comments are output as visible text #466

Open

Description

@adamdehaven

Environment

  • Operating System: macOS (Darwin)
  • Node Version: v24.6.0
  • Package Manager: pnpm@10.8.0
  • Comark Version: 0.7.0
  • Framework: None (also reproduced with Vue / Nuxt 4.5.2 via @comark/nuxt 0.7.0, client render and SSR)

Comark Version

0.7.0

Reproduction

npm i comark@0.7.0
// 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 &lt;!-- note --&gt; 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/nuxt 0.7.0, both client-side and in SSR output.

Logs

Not applicable; the reproduction above shows the full output.

Activity

  1. 0froq commented on Oct 19, 2026

    @0froq

    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.

  2. added a commit that references this issue on Oct 19, 2026
    a6f0ca5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions