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.

Marcus Hughes
  • 4,289
  • 1
  • 21
  • 35

2 Answers2

12

The HTML was being ignored because some tag attr's did not have quotes. For example width=500 should have been width="500"

Nothing else was required. The HTML is in its own paragraphs with no indentation and it is parsed.

Marcus Hughes
  • 4,289
  • 1
  • 21
  • 35
8

For others as reference, to ensure that Kramdown does not process/parse RAW HTML, the attribute markdown="0" can be added. This will ensure that the Kramdown parser does not touch the block of HTML tag.

Example:

Input Markdown: - hello

Output HTML:

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

Using the attribute markdown = "0":

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

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

From the Kramdown documentation (hint:use your browsers find to look for the keyword 'raw' to jump down to relevant sections):

If an HTML tag has an attribute markdown="0", then the tag is parsed as raw HTML block.

If an HTML tag has an attribute markdown="1", then the default mechanism for parsing syntax in this tag is used.

If an HTML tag has an attribute markdown="block", then the content of the tag is parsed as block level elements.

If an HTML tag has an attribute markdown="span", then the content of the tag is parsed as span level elements.

Also, all general XML tags are parsed as raw HTML blocks.

matrixanomaly
  • 5,865
  • 2
  • 32
  • 50