如何在Markdown中编写注释,即HTML输出中未呈现的文本?我在Markdown项目中没有发现任何东西。
当前回答
如果您正在使用Jekyll或octopress,下面的操作也会起作用。
{% comment %}
These commments will not include inside the source.
{% endcomment %}
Liquid标记{%comment%}首先被解析,并在MarkDown处理器到达它之前被删除。访问者在尝试从浏览器查看源代码时将看不到。
其他回答
我使用标准的HTML标记,例如
<!---
your comment goes here
and here
-->
注意三点划线。其优点是,在生成TeX或HTML输出时,它可以与pandoc一起工作。有关更多信息,请访问pandoc讨论组。
另请参见由越来越多的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.
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引擎。
您可以这样做(YAML块):
~~~
# This is a
# multiline
# comment
...
我只尝试了乳胶输出,请为其他人确认。
这项小型研究证明并完善了马格努斯的答案
最独立于平台的语法是
(empty line)
[comment]: # (This actually is the most platform independent comment)
这两个条件都很重要:
使用#(而不是<>)注释前有空行。注释后的空行对结果没有影响。
严格的Markdown规范CommonMark仅适用于此语法(而不适用于<>和/或空行)
为了证明这一点,我们将使用Alexandre Mutel的Babelmark I。该工具检查大量Markdown实现上特定源代码的呈现。
(+-通过了测试,--没有通过,?-留下一些垃圾,这些垃圾在呈现的HTML中没有显示)。
无空行,使用<>13+15-注释前空行,使用<>20+,8-注释周围的空行,使用<>20+,8-没有空行,使用#13+1?14-注释前空行,使用#23+1?4-注释周围的空行,使用#23+1?4-带有3个连字符1+2的HTML注释?25-来自chl的答案(注意这是不同的语法)
这证明了上述陈述。
这些实现未通过所有7项测试。没有机会对它们使用excluded on render注释。
cebe/markdown 1.1.0cebe/markdown markdown额外1.1.0cebe/markdown GFM 1.1.0s9e\TextFormatter(Fatdown/PHP)
推荐文章
- 增强的for循环中的Null检查
- 如何从同一个YAML文件的其他地方引用YAML“设置”?
- 在VS Code中禁用“Comments are not allowed In JSON”错误
- Swift:理解// MARK
- 把if-elif-else语句放在一行中?
- 在构建中编写注释的语法是什么?gradle文件?
- Javascript函数前导bang !语法
- 如何将LaTeX与Markdown混合?
- extern关键字对C函数的影响
- 方括号[]在sql语句中有什么用?
- Java注释中的/**和/*
- PHP中的三个点(…)是什么意思?
- 乳胶渲染在README。md在Github上
- 关键字使用virtual+override vs. new
- 在Markdown Jekyll中使用图像说明