markdown ="1"在p标签内不起作用 [英] markdown="1" not working inside the p tag

查看:231
本文介绍了markdown ="1"在p标签内不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此行<p id="article-content" markdown="1" >## Download tarball </p>,并且得到与HTML实际相同的文本.

I'm using this line <p id="article-content" markdown="1" >## Download tarball </p> and I'm getting the actual same text as HTML.

示例

任何帮助将不胜感激.

推荐答案

markdown="1"是一种通用的方法,尽管它是非标准的,但可以改变Markdown解析器的行为.具体来说,标准Markdown会忽略包装在块级HTML标记中的Markdown语法.启用适当的扩展名后,将markdown="1"作为属性添加到环绕HTML标记中,将指示Markdown解析器不要忽略标记内的Markdown语法.但是,您需要使用Markdown实现,其中包括对该功能的支持,如果默认情况下未启用该功能,则启用该功能.

markdown="1" is a common, albeit non-standard, method to alter the behavior of a Markdown parser. Specifically, standard Markdown ignores Markdown syntax wrapped inside block-level HTML tags. With an appropriate extension enabled, adding markdown="1" as an attribute to the wrapping HTML tag will instruct the Markdown parser to not ignore Markdown syntax within the tag. However, you need to be using a Markdown implementation which includes support for the feature and enable the feature if it is not enabled by default.

例如,PHP Markdown Extra 文档的功能方式:

For example, PHP Markdown Extra documents the feature this way:

Markdown Extra提供了一种将Markdown格式的文本放入其中的方法 任何块级标签.您可以通过添加markdown属性来实现此目的 值为1的标签-给出markdown="1"-像这样:

Markdown Extra gives you a way to put Markdown-formatted text inside any block-level tag. You do this by adding a markdown attribute to the tag with the value 1 — which gives markdown="1" — like this:

<div markdown="1">
This is *true* markdown text.
</div>

markdown="1"属性将被删除,并且<div>的内容 将从Markdown转换为HTML.最终结果看起来像 这个:

The markdown="1" attribute will be stripped and <div>’s content will be converted from Markdown to HTML. The end result will look like this:

<div>

<p>This is <em>true</em> markdown text.</p>

</div>

请注意,Markdown解析器会剔除markdown="1"属性,因为它不是有效的HTML属性.它仅对某些扩展的" Markdown解析器有意义.

Note that the Markdown parser strips out the markdown="1" attribute as it is not a valid HTML attribute. It only has meaning for some "extended" Markdown parsers.

为完整起见,原始的Markdown规则解释打包时会忽略Markdown语法在HTML中:

For completeness, the original Markdown rules explain that Markdown syntax is ignored when wrapped in HTML:

请注意,Markdown格式语法不会在其中处理 块级HTML标签.例如,您不能使用Markdown样式的*emphasis* 在HTML块中.

Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can’t use Markdown-style *emphasis* inside an HTML block.

情况就是这样,以下Markdown:

That being the case, the following Markdown:

<div>
This is *true* markdown text.
</div>

通过Markdown解析器时将生成以下HTML:

Would generate the following HTML when passed through a Markdown parser:

<div>
This is *true* markdown text.
</div>

这篇关于markdown ="1"在p标签内不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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