Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
387 views
in Technique[技术] by (71.8m points)

syntax - Markdown中的评论(Comments in Markdown)

What is the syntax for storing a comment in a markdown file, eg a CVS $Id$ comment at the top of the file?

(将注释存储在markdown文件中的语法是什么,例如文件顶部的CVS $ Id $注释?)

I found nothing on the markdown project .

(降价项目我什么都没发现。)

  ask by Betamos translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I believe that all the previously proposed solutions (apart from those that require specific implementations) result in the comments being included in the output HTML, even if they are not displayed.

(我相信所有先前提出的解决方案(除了需要特定实现的解决方案之外)导致注释包含在输出HTML中,即使它们未被显示。)

If you want a comment that is strictly for yourself (readers of the converted document should not be able to see it, even with "view source") you could (ab)use the link labels (for use with reference style links) that are available in the core Markdown specification:

(如果你想要一个严格意义上的评论(转换文档的读者不应该看到它,即使使用“查看源”)你可以(ab)使用链接标签(用于参考样式链接)可用于Markdown核心规范:)

http://daringfireball.net/projects/markdown/syntax#link

(http://daringfireball.net/projects/markdown/syntax#link)

That is:

(那是:)

[comment]: <> (This is a comment, it will not be included)
[comment]: <> (in  the output file unless you use it in)
[comment]: <> (a reference style link.)

Or you could go further:

(或者你可以走得更远:)

[//]: <> (This is also a comment.)

To improve platform compatibility (and to save one keystroke) it is also possible to use # (which is a legitimate hyperlink target) instead of <> :

(为了提高平台兼容性(并保存一次击键),还可以使用# (这是一个合法的超链接目标)而不是<> :)

[//]: # (This may be the most platform independent comment)

For maximum portability it is important to insert a blank line before and after this type of comments, because some Markdown parsers do not work correctly when definitions brush up against regular text.

(为了获得最大的可移植性,在此类注释之前和之后插入一个空行非常重要,因为当定义与常规文本相比时,某些Markdown解析器无法正常工作。)

The most recent research with Babelmark shows that blank lines before and after are both important.

(Babelmark最近的研究表明,前后的空白线都很重要。)

Some parsers will output the comment if there is no blank line before, and some parsers will exclude the following line if there is no blank line after.

(如果之前没有空行,一些解析器将输出注释,并且如果之后没有空行,则一些解析器将排除以下行。)

In general, this approach should work with most Markdown parsers, since it's part of the core specification.

(通常,这种方法应该适用于大多数Markdown解析器,因为它是核心规范的一部分。)

(even if the behavior when multiple links are defined, or when a link is defined but never used, is not strictly specified).

((即使定义了多个链接时的行为,或者定义了链接但从未使用过时,也未严格指定)。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...