Ah, one quick Markdown lesson I learned recently.

If you've got Markdown inside of "real" block-level html tags, it's not supposed to be rendered.

<div>This is **some Markdown**.</div>

That shouldn't be bold. It renders as...

This is **some Markdown**.

Unexpected, but (with a hat tip to this SO answer), apparently correct behavior according to The Grubes:

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. Markdown is smart enough not to add extra (unwanted)ย <p>ย tags around HTML block-level tags.

...

Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you canโ€™t use Markdown-styleย emphasisย inside an HTML block.

Welcome to the land of unintended consequences. It looks like the deal was "stop adding all these danged <p> tags around my inline block-level html; it'd duping the breaks," and we got, "stop ALL markdown rendering in block tags" instead.

There is, however, a non-standard workaround, as described by Python-Markdown's docs:

Theย markdownย attribute can be assigned one of three values:ย "1",ย "block", orย "span".

Note: The expressions โ€œblock-levelโ€ and โ€œspan-levelโ€ as used in this document refer to an elementโ€™s designation according to the HTML specification. Whereas theย "span"ย andย "block"ย values assigned to theย markdownย attribute refer to the Markdown parserโ€™s behavior.

markdown="1"

When theย markdownย attribute is set toย "1", then the parser will use the default behavior for that specific tag.

So if you have

<div markdown="1">This is **some Markdown**.</div>

you should have

This is some Markdown.

... but I need to add that to MarkUpDown if I want to support it. And since it's not like someone is going to add that that doesn't want it, I guess I should!

Labels: , , ,