Bug or expected? Markdown sometimes doesn't work inside `div` tags

There seem to be certain weird edgecases in which markdown doesn’t work inside HTML tags.

Is this a bug or an expected behavior? If it is expected, then what is the reason behind it?

Demo: commonmark.js demo

Source:

This, <div>**Works** as expected</div>

-- --

So does

<span>**this**</span>

-- --

But 

<div style="color: red">**this does not!** <== Bug!</div>
2 Likes

This looks like a bug, but unrelated to the style attribute. Using a non-span tag such as div or p when the tag starts a new line causes the problem.

x <p>**this appears as bold text**</p>

<p>**this does not appear as bold text**</p>
1 Like

What’s the procedure to getting this fixed in the future specs? I’m new to these forums. Thanks :slight_smile:

We ask @jgm, the author of the spec, if the behaviour is intentional or a bug. It appears to relate to whether the HTML tag is a block level tag or phrasing content (and some tags can be both).

Related discussion:

@chrisalley points the reason. This works according to the spec.

In this case:

x <p>**this appears as bold text**</p>

you have two raw HTML inlines <p> and </p>, and a strong emphasis inline between them.

In this case:

<p>**this does not appear as bold text**</p>

you have an HTML block of type 6. An HTML block is a group of lines that whose data is not interpreted as markdown.