Text after div tags does not get rendered properly

Text that appears on a line directly following a div tag does not render correctly. Placing a blank line after the line with the div solves it.

<div>divved text</div>
[a link]( `/admin/email/templates`.) **italic**
divved text
[a link]( `/admin/email/templates`.) **italic**

Screenshot:

Other html doesn’t cause the problem:

<small>small text</small>
[a link]( `/admin/email/templates`.) **italic**

small text
a link italic

<span>spanned text</span>
[a link]( `/admin/email/templates`.) **italic**

spanned text
a link italic


My guess is that once html is detected, the following line is both sucked into the processor and subsequently not parsed for markdown. You can test this by putting some text on the line after the div and at the beginning of the next line:

<div>divved text</div> end of div
beginning of markdown [a link]( `/admin/email/templates`.) **italic**
divved text
end of div beginning of markdown [a link]( `/admin/email/templates`.) **italic**

Screenshot:

It is fully specified, standards-compliant behavior defined by the CommonMark spec § 4.6 — HTML blocks.

The key rule is HTML block type 6. The CommonMark spec explicitly lists div(along with p, blockquote, table, h1–h6, ul, ol, li, hr, etc.) as a block-level tag. When the parser encounters a line starting with one of these tags, it opens an HTML block with this end condition:

End condition: line is followed by a blank line.

Your other examples are inline elements, and behave differently.

Thanks! That’s what I was afraid of.

In making my report simple, I forgot to mention that the issue came up when a user inserted the <div data-theme-toc="true"> </div> code to insert a table of contents. It seems like it’s an issue for the developer of that feature if anyone.

Okay that’s interesting. So it doesn’t happen at all without the ToC? (with other divs I mean)

It’s the precise positioning of the <div data-theme-toc="true"> </div>. In this case it was the first thing in the post and text started on the next line. We wouldn’t have even noticed if that first line didn’t contain markdown. Not sure if that makes sense.

If you put a blank line after that code, everything works. Hence Data-theme-toc="true" should be placed at the top of a post in it's own paragraph.