Nesting markdown inside of an HTML tag

When wrapping our markdown content with HTML tags, the markdown is not processed. Here is how we overcame the issue.

We like markdown a lot. It really is a great way to write content for the web. The other day we wanted to add just a touch of structure to our text and needed to wrap the text with an HTML tag so that we could add in some css.

The issue we had was that when you do something like this …

1<div class="some-cool-style">
2# Heading
3Lorem ipsum dolor sit amet.
4</div>

… you have the problem that your markdown is not parsed at all. This is because the markdown specification says that it shouldn’t!

The work around was to use section tags instead of div tags.

1<section class="some-cool-style">
2# Heading
3Lorem ipsum dolor sit amet.
4</section>

Keep this tip handy, you will most certainly use it one day. Happy writing!

by Craig Sullivan
launch.ly

10 Jul 2012