如何在Markdown中编写注释,即HTML输出中未呈现的文本?我在Markdown项目中没有发现任何东西。
当前回答
<!--- ... -->
不适用于PandocMarkdown(Pandoc1.12.2.1)。注释仍显示在html中。以下措施确实奏效:
Blank line
[^Comment]: Text that will not appear in html source
Blank line
然后使用+脚注扩展名。它本质上是一个从未被引用的脚注。
其他回答
您可以这样做(YAML块):
~~~
# This is a
# multiline
# comment
...
我只尝试了乳胶输出,请为其他人确认。
另一种方法是将注释放在样式化的HTML标记中。这样,您可以根据需要切换它们的可见性。例如,在CSS样式表中定义注释类。
.注释{display:none;}
然后,以下增强的MARKDOWN
我们不支持评论
在浏览器中显示如下
我们支持评论
如果您正在使用Jekyll或octopress,下面的操作也会起作用。
{% comment %}
These commments will not include inside the source.
{% endcomment %}
Liquid标记{%comment%}首先被解析,并在MarkDown处理器到达它之前被删除。访问者在尝试从浏览器查看源代码时将看不到。
<!--- ... -->
不适用于PandocMarkdown(Pandoc1.12.2.1)。注释仍显示在html中。以下措施确实奏效:
Blank line
[^Comment]: Text that will not appear in html source
Blank line
然后使用+脚注扩展名。它本质上是一个从未被引用的脚注。
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引擎。
推荐文章
- 在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中使用图像说明
- 有没有办法注释掉.ASPX页面中的标记?
- 在numpy数组中提取特定列