I have some embedded HTML in my Markdown (bulleted list within a table). Is there a way to indent my HTML without Pandoc treating it as a verbatim code block?
Pandoc can convert between numerous markup and word processing formats, including, but not limited to, various flavors of Markdown, HTML, LaTeX and Word docx.
Markdown supports HTML, so if you need to, say, embed a YouTube video, you can just copy and paste the embed code from them, drop it into a Markdown document, and you should be good to go.
An extension can be enabled by adding +EXTENSION to the format name and disabled by adding -EXTENSION . For example, --from markdown_strict+footnotes is strict Markdown with footnotes enabled, while --from markdown-footnotes-pipe_tables is pandoc's Markdown without footnotes or pipe tables.
Sort of, but you have to change Pandoc's defaults.
The Markdown rules expressly prohibit this:
The only restrictions are that block-level HTML elements — e.g.
<div>
,<table>
,<pre>
,<p>
, etc. — must be separated from surrounding content by blank lines, and the start and end tags of the block should not be indented with tabs or spaces.
However, if you notice, the above quoted rule does specifically state that only "the start and end tags of the block should not be indented." There is no restriction from indenting the content inside the "the start and end tags". In fact, the content between ""the start and end tags" is not even processed as Markdown, so feel free to indent away. In other words, this is completely acceptable:
<table>
<thead>
<tr>
<th>A header</th>
</tr>
</thead>
</table>
Except that it doesn't work in Pandoc by default. As explained in Pandoc's documentation:
Standard Markdown allows you to include HTML “blocks”: blocks of HTML between balanced tags that are separated from the surrounding text with blank lines, and start and end at the left margin. Within these blocks, everything is interpreted as HTML, not Markdown; so (for example),
*
does not signify emphasis.Pandoc behaves this way when the
markdown_strict
format is used; but by default, pandoc interprets material between HTML block tags as Markdown.
Therefore you either need to use the raw_html
extension or the markdown_strict
output format.
For "strict mode" use:
pandoc --from markdown_strict
Or to not use strict mode but still get the HTML behavior you want (disable markdown_in_html_blocks
extension and enable raw_html
extension):
pandoc --from markdown-markdown_in_html_blocks+raw_html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With