如何在Markdown中编写注释,即HTML输出中未呈现的文本?我在Markdown项目中没有发现任何东西。


当前回答

对于PandocMarkdown,我使用带有注释的反引号作为内联“代码”语法的语言

`here's a comment`{=comment}

这将在所有输出中自动过滤掉。它只是重载它们的代码语法,也适用于多行注释的代码块。我还没有尝试过,但我猜这对非潘多克·马克顿来说不起作用。

其他回答

你可以试试

[](
Your comments go here however you cannot leave
// a blank line so fill blank lines with
//
Something
)

以下方法非常有效

<empty line>
[whatever comment text]::

该方法利用语法通过引用创建链接由于使用[1]创建了链接引用:http://example.org不会呈现,同样,以下任何内容也不会呈现

<empty line>
[whatever]::
[whatever]:whatever
[whatever]: :
[whatever]: whatever
[whatever]: # whatever with spaces

另请参见由越来越多的Markdown工具支持的Critic Markup。

http://criticmarkup.com/

Comment {>> <<}

Lorem ipsum dolor sit amet.{>>This is a comment<<}

Highlight+Comment {== ==}{>> <<}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. {==Vestibulum at orci magna. Phasellus augue justo, sodales eu pulvinar ac, vulputate eget nulla.==}{>>confusing<<} Mauris massa sem, tempor sed cursus et, semper tincidunt lacus.

Pandoc有一个选项--删除注释,删除所有<!--html输出中的普通html注释-->。

https://pandoc.org/MANUAL.html#general-写入程序选项

使用mkdocs时,添加mkdocs.yml:

  - pymdownx.striphtml:
      strip_comments: true
      strip_js_on_attributes: false

然后在任何markdown文件中使用普通的html注释,如

<!-- this is a comment -->

将从html输出中删除。