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


当前回答

我编写了一个小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;
}

其他回答

将注释放在非eval、非echo R块中怎么样?即。,

```{r echo=FALSE, eval=FALSE}
All the comments!
```

对我来说似乎很好。

Vim Instant Markdown用户需要使用

<!---
First comment line...
//
_NO_BLANK_LINES_ARE_ALLOWED_
//
_and_try_to_avoid_double_minuses_like_this_: --
//
last comment line.
-->

以下方法非常有效

<empty line>
[whatever comment text]::

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

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

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

`here's a comment`{=comment}

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

此Markdown注释不会在带有Jekyll的GitHub Pages网站上呈现

[whatever]: text

因为Jekyll使用Liquid模板语言来处理模板,所以这个Liquid注释也不会在使用Jekyll的GitHubPages网站上呈现

{% comment %}
This is a long comment string 

Newline

Stuff
{% endcomment %}