如何在Markdown中编写注释,即HTML输出中未呈现的文本?我在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引擎。

其他回答

Pandoc有一个选项--删除注释,删除所有<!--html输出中的普通html注释-->。

https://pandoc.org/MANUAL.html#general-写入程序选项

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

我编写了一个小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工具支持的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.

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

<span hidden> Some texts </span>

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

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