19

I have a Jekyll website, with Posts written in Markdown using the Kramdown parser.

I would like to add some raw HTML within the post. However when I try to add the HTML, it parses it as markdown (changing <'s to &lt; for example).

I have tried:

  • Adding the HTML in its own paragraph.
  • Including a .html file.
  • Adding markdown="0" to the HTML tag (also tried 1).
  • Indenting (and wrapping in triple back-tick) with all of the above.
  • Using raw tags

Example of what I have:

Some **markdown** `here`

<iframe src="asd"></iframe>

More *markdown*.

The iframe should be output as HTML, not parsed text.

I am using Github pages, so Jekyll extensions are not optional.

4

2 回答 2

12

HTML 被忽略,因为某些标签属性没有引号。例如width=500应该是width="500"

没有其他要求。HTML 在其自己的段落中,没有缩进并且被解析。

于 2015-05-14T10:03:56.507 回答
8

供其他人参考,为确保 Kramdown 不处理/解析 RAW HTML,markdown="0"可以添加该属性。这将确保 Kramdown 解析器不会触及 HTML 标签块。

例子:

Input Markdown: - hello

Output HTML:

          <ul>
           <li>hello</li>
          </ul>

使用属性markdown = "0"

Input markdown: <div markdown = "0"> - hello </div>

Output HTML: <div markdown = "0"> - hello </div>

Kramdown 文档中(提示:使用您的浏览器查找来查找关键字 'raw' 以跳到相关部分):

如果 HTML 标记具有属性 markdown="0",则该标记被解析为原始 HTML 块。

如果 HTML 标记具有属性 markdown="1",则使用该标记中解析语法的默认机制。

如果 HTML 标记具有属性 markdown="block",则标记的内容被解析为块级元素。

如果 HTML 标记具有属性 markdown="span",则标记的内容将被解析为跨度级别元素。

此外,所有通用 XML 标记都被解析为原始 HTML 块。

于 2015-05-15T16:24:58.093 回答