Markdown 中的评论 [英] Comments in Markdown

查看:23
本文介绍了Markdown 中的评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Markdown 中编写注释,即未在 HTML 输出中呈现的文本?我在 Markdown 项目 上什么也没找到.

How do you write a comment in Markdown, i.e. text that is not rendered in the HTML output? I found nothing on the Markdown project.

推荐答案

我相信之前提出的所有解决方案(除了那些需要特定实现的解决方案)都会导致注释被包含在输出 HTML 中,即使它们不是显示.

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.

如果你想要一个严格针对你自己的评论(转换后的文档的读者应该看不到它,即使使用查看源代码")你可以(ab)使用链接标签(用于参考样式链接) 在核心 Markdown 规范中可用:

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:

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

即:

[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.)

或者你可以走得更远:

[//]: <> (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)

为了获得最大的可移植性,在这种类型的注释前后插入一个空行很重要,因为当定义与常规文本发生冲突时,某些 Markdown 解析器无法正常工作.Babelmark 的最新研究表明,前后空行都很重要.有的解析器前面没有空行会输出注释,有的解析器后面没有空行会排除下一行.

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. The most recent research with Babelmark shows that blank lines before and after are both important. 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.

一般来说,这种方法应该适用于大多数 Markdown 解析器,因为它是核心规范的一部分.(即使定义了多个链接时的行为,或者定义了一个链接但从未使用过的行为,也没有严格规定).

In general, this approach should work with most Markdown parsers, since it's part of the core specification. (even if the behavior when multiple links are defined, or when a link is defined but never used, is not strictly specified).

这篇关于Markdown 中的评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆