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


当前回答

这在GitHub上有效:

[](Comment text goes here)

生成的HTML如下所示:

<a href="Comment%20text%20goes%20here"></a>

这基本上是一个空链接。显然,您可以在渲染文本的源代码中阅读,但无论如何您都可以在GitHub上阅读。

其他回答

<!--- ... --> 

不适用于PandocMarkdown(Pandoc1.12.2.1)。注释仍显示在html中。以下措施确实奏效:

Blank line
[^Comment]:  Text that will not appear in html source
Blank line

然后使用+脚注扩展名。它本质上是一个从未被引用的脚注。

以下方法非常有效

<empty line>
[whatever comment text]::

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

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

如果它在VS代码中,那么还有另一个好选项:

<span hidden> Some texts </span>

与“HTML注释标记”相比,它具有在编辑区域保持语法高亮显示的优势,以及为语义标记添加属性的能力,如<span notice hidden>。

警告:根据常识,不要在源代码中包含个人信息。

kramdown基于Ruby的markdown引擎,这是Jekyll的默认引擎,因此GitHubPages通过其扩展语法内置了注释支持:

{::comment}
This text is completely ignored by kramdown - a comment in the text.
{:/comment}

Do you see {::comment}this text{:/comment}?
{::comment}some other comment{:/}

这样做的好处是允许在线评论,但缺点是不能移植到其他Markdown引擎。

这在GitHub上有效:

[](Comment text goes here)

生成的HTML如下所示:

<a href="Comment%20text%20goes%20here"></a>

这基本上是一个空链接。显然,您可以在渲染文本的源代码中阅读,但无论如何您都可以在GitHub上阅读。