如何将我的降价包装在HTML div中? [英] How can I wrap my markdown in an HTML div?
问题描述
我使用 MarkEd 实现 我有一些工作降价: 其中创建: 我想在div中包装降价部分,例如: 然而,这会返回以下HTML: 例如,没有降价,字面上'## Test heading'出现在HTML中。 我如何正确包装我的降价? 我发现了以下解决方法,但它是丑陋的,而不是一个实际的修复: 对于降价,这是设计。从Markdown参考的内联HTML 部分: 请注意,Markdown格式化语法不在块级HTML标记中处理。例如,您不能在HTML块中使用Markdown风格的强调。 允许使用跨度标记: 与块级HTML标记不同,Markdown语法在跨度级别标记中处理。 因此,根据您的使用情况,您可能会放弃使用 如果你使用的库实现 CommonMark ,你很幸运。例如 108 和 109 表明如果你在HTML块和markdown代码之间保留一个空行,内容将被解析为Markdown: 应该可以工作,但以下几点不应该存在: 并且,根据引用中的同一部分,有些实现会识别额外的 虽然它在StackOverflow中似乎不起作用但是: I am using MarkEd which implements GitHub flavoured markdown. I have some working markdown: Which creates: I would like to wrap that markdown section in a div, eg: However this returns the following HTML: Eg, no markdown, literally '## Test heading' appears in the HTML. How can I properly wrap my markdown in a div? I have found the following workaround, however it is ugly and not an actual fix:
For Markdown, This is by design. From the Inline HTML section of the Markdown reference: 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. But it is explicitly allowed for span-level tags: Unlike block-level HTML tags, Markdown syntax is processed within span-level tags. So, depending on your use-case, you might get away with using a If the library you use implements CommonMark, you are lucky. Example 108 and 109 of the spec show that if you keep an empty line in between the HTML block and the markdown code, the contents will be parsed as Markdown: should work, while the following shouldn't: And, again according to the same section in the reference, some implementations recognize an additional Though it doesn't seem to work in StackOverflow yet: 这篇关于如何将我的降价包装在HTML div中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
##测试标题
a段落。
##第二个标题
另一段
< h2 id =test-heading>测试标题< / h2>
< p>一段。< / p>
< h2 id =第二标题>第二个标题< / h2>
< p>另一段< / p>
< div class =blog-post>
##测试标题
一段。
##第二个标题
另一段
< / div>
< div class =blog-post>
##测试标题
一段。
##第二个标题
另一段
< / div>
< div class =blog-post>
< div>< / div>
##测试标题
一段。
##第二个标题
另一段
< / div>
Markdown
span
div
。
CommonMark
< div>
*强调*文字。
< / div>
< div>
*强调*文字。
< / div>
markdown = 1
属性,以启用对Markdown的解析。
测试** Markdown **在红色背景div内。
## Test heading
a paragraph.
## second heading
another paragraph
<h2 id="test-heading">Test heading</h2>
<p>a paragraph.</p>
<h2 id="second-heading">second heading</h2>
<p>another paragraph</p>
<div class="blog-post">
## Test heading
a paragraph.
## second heading
another paragraph
</div>
<div class="blog-post">
## Test heading
a paragraph.
## second heading
another paragraph
</div>
<div class="blog-post">
<div></div>
## Test heading
a paragraph.
## second heading
another paragraph
</div>
Markdown
span
instead of a div
.CommonMark
<div>
*Emphasized* text.
</div>
<div>
*Emphasized* text.
</div>
markdown=1
attribute on the HTML tag to enable parsing of Markdown inside it.