You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proposal: Standardize a native syntax for Markdown comments #844
The core spirit and mission of CommonMark is to standardize Markdown to ensure interoperability across different platforms. However, the lack of a standardized syntax for comments (text that is ignored by renderers and not outputted to HTML) remains a major omission.
Because the spec has left this out, a highly fragmented ecosystem has emerged. There is a deep disconnect between markdown editors and markdown viewers:
The HTML Comment Hack (): Many users rely on this, but it is technically passed through to the HTML output. This leaks internal notes to the production source code, which is highly undesirable for security, privacy, and file size reasons.
The Link Reference Hack ([^comment]: or [//]: #): Various editors and parsers have adopted different link-label hacks to trick compilers into ignoring text.
Custom Syntaxes (%%comment%%): Apps like Obsidian use their own internal formatting, which completely breaks portability when the file is read by standard CommonMark parsers like GitHub or Jekyll.
This creates "disconnected camps" where a document containing comments looks perfect in a specific editor but leaks or breaks entirely when published to a standard viewer.
I would like to propose a native, standardized syntax for comments within the CommonMark specification.
A syntax that explicitly instructs the compiler to omit the wrapped text from the final abstract syntax tree (AST) or HTML output entirely.
Possible syntax directions already popular in the community include:
- %% Comment here %% (Used by Obsidian)
- [//]: # (Comment here) (A strictly regulated version of the link hack)
- // and /* */ already popular with a few languages
- A dedicated syntax like [# Comment here #] or similar blocks.
Continuing to rely on the <!-- HTML comment --> approach, which fails the requirement of keeping draft notes hidden from the final production source code, or accepting that Markdown files will continue to lose portability between different vendor apps.
Standardizing comments aligns perfectly with CommonMark’s goal. It resolves a massive point of friction for technical writers, content creators, and developers who need to leave notes, TODOs, or metadata in their files without leaking them to the end-user.
Isn't this better made by parsers adding an option to remove HTML comments? Wouldn't minification already remove HTML comments?
When a standard definition is missing, then every parser implements their own method and they, just as it is now, may support one form of hack, but not all of them.
If this group pick any of existing, or designates a new marker for comments, then the entire industry will follow.
Activity
Crissov commentedon Oct 6, 2026
Could you please edit your post to mark up (or down) spans of code? I think at least one detail got lost in rendering.
Velocifyer commentedon Oct 7, 2026
Isn't this better made by parsers adding an option to remove HTML comments? Wouldn't minification already remove HTML comments?
taufik-nurrohman commentedon Oct 7, 2026
If only CommonMark support footnotes, I would use that as comment feature:
CobraCarbonator commentedon Oct 8, 2026
When a standard definition is missing, then every parser implements their own method and they, just as it is now, may support one form of hack, but not all of them.
If this group pick any of existing, or designates a new marker for comments, then the entire industry will follow.
jgm commentedon Oct 8, 2026
For completeness, two more existing ways of doing comments (from pandoc):
--strip-commentsflag that strips out HTML comments.