评论在Markdown [英] Comments in Markdown

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

问题描述

在markdown文件中存储注释的语法是什么?一个CVS $ Id $注释在文件的顶部?我在 markdown项目中找不到任何内容。

解决方案

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



如果你想要一个严格意义的注释(转换后的文档的读者不应该看到它,即使有视图源),你可以(ab)使用链接标签参考样式链接),它们在核心Markdown规范中可用:



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



这是:

  [comment]:<> (这是一个注释,它不会被包括)
[comment]:<> (在输出文件中,除非你使用它)
[comment]:<> (参考样式链接)

或者您可以进一步:

  [//]:<> (这也是一个注释。)

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

  [//]:#(这可能是最独立于平台的注释)

在这种类型的注释之前和之后插入一个空白行也可能是谨慎的,因为一些Markdown解析器可能不喜欢链接定义刷新常规文本。 p>

这应该适用于大多数Markdown解析器,因为它是核心规范的一部分。 (即使定义了多个链接时,或者定义了但从未使用的链接时,也不会严格指定)。


What is the syntax for storing a comment in a markdown file, e.g. a CVS $Id$ comment at the top of the file? I found nothing on the markdown project.

解决方案

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.

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

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)

It may also be prudent to insert a blank line before and after this type of comments, because some Markdown parsers may not like link definitions brushing up against regular text.

This 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天全站免登陆