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


当前回答

<!--- ... --> 

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

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

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

其他回答

您可以这样做(YAML块):

~~~
# This is a
# multiline
# comment
...

我只尝试了乳胶输出,请为其他人确认。

使用mkdocs时,添加mkdocs.yml:

  - pymdownx.striphtml:
      strip_comments: true
      strip_js_on_attributes: false

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

<!-- this is a comment -->

将从html输出中删除。

我编写了一个小awk程序来过滤添加到文本中的#omitbegine和#omitend标记。我使用awk将其输出通过管道传输到pandoc可以处理的临时文件。像这样:

awk-f省略过滤器.awk aim2_article.md>aim2_aArticle_tmp.md

pandoc--pdf engine=xelatex--lua filter=pagebreak.lua--filter pandoc crossref--citeproc aim2_article_tmp.md-o aim2_aarticle.pdf

这里是省略筛选器.awk:

/#omitbegin/ {
    insideOmit = 1;
}

! insideOmit {
    print $0
}

/#omitend/ {
    insideOmit = 0;
}

披露:我写了这个插件。

由于问题没有指定特定的markdown实现,我想提到python markdown的Comments插件,它实现了上述相同的pandoc注释样式。

以下方法非常有效

<empty line>
[whatever comment text]::

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

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