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


当前回答

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

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

对我来说似乎很好。

其他回答

以下方法非常有效

<empty line>
[whatever comment text]::

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

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

我使用标准的HTML标记,例如

<!---
your comment goes here
and here
-->

注意三点划线。其优点是,在生成TeX或HTML输出时,它可以与pandoc一起工作。有关更多信息,请访问pandoc讨论组。

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

如果您正在使用Jekyll或octopress,下面的操作也会起作用。

{% comment %} 
    These commments will not include inside the source.
{% endcomment %}

Liquid标记{%comment%}首先被解析,并在MarkDown处理器到达它之前被删除。访问者在尝试从浏览器查看源代码时将看不到。

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引擎。