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


当前回答

另请参见由越来越多的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-写入程序选项

我编写了一个小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注释样式。

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

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

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

你可以试试

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