Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll: How to get markdown parsing inside blocks using Kramdown?

Per the Kramdown docs, setting the option parse_block_html should allow for processing of markdown (Kramdown) syntax inside html blocks.

In my _config.yml, I have the settings as:

---
name: Blog Name
markdown: kramdown
kramdown: 
  parse_block_html: true
---

Then in a post .md file, I try something like:

# Headline1
------------

<div>
  # Headline2
  ------------
</div>

The markdown content inside the div is not translated into HTML upon jekyll build. What am I missing? (Also, is there an easier way to do it in any of the other markdown syntaxes, e.g. RedCarpet?)

like image 1000
pete Avatar asked Mar 10 '14 02:03

pete


People also ask

What is Kramdown?

kramdown (sic, not Kramdown or KramDown, just kramdown) is a free MIT-licensed Ruby library for parsing and converting a superset of Markdown.

Does Jekyll use Kramdown?

Please note that Jekyll uses Kramdown's HTML converter. Kramdown options used only by other converters, such as remove_block_html_tags (used by the RemoveHtmlTags converter), will not work.


2 Answers

Try to use an inner declaration, and remove indentation (unless you want it to be treated as code):

# Headline1
------------

{::options parse_block_html="true" /}
<div>
# Headline2
------------
</div>
like image 106
njk Avatar answered Oct 13 '22 15:10

njk


You can add a markdown="1" attribute to your <div>, if I read well the HTML Blocks part of the Kramdown doc:

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

# Headline1
------------

<div markdown="1">
  # Headline2
  ------------
</div>
like image 27
Nicolas Hoizey Avatar answered Oct 13 '22 14:10

Nicolas Hoizey