gettalong / kramdown

kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions.
http://kramdown.gettalong.org
Other
1.72k stars 274 forks source link

div style spills out after div #686

Closed csaid closed 4 years ago

csaid commented 4 years ago

I'm noticing that div style spills out into text after the </div> whenever markdown mode is on.

This text is not italicized.

<img src="https://i.imgur.com/EJOjIMC.jpeg">
<div style="font-style:italic" markdown="1"> My italicized figure caption </div>

This text should not be italicized either, but it is.

The issue only goes away if I set markdown="0". However, I would like to be able to process markdown inside a <div></div>

I'm on Kramdown 2.3.0, as it is included in the latest version of Github Pages.

Thanks

chrissaid commented 4 years ago

Here's what gets produced:

<p>This text is not italicized.</p>

<p><img src="https://i.imgur.com/EJOjIMC.jpeg" /></p>
<div style="font-style:italic">
  <p>My italicized figure caption &lt;/div&gt;</p>

  <p>This text should not be italicized either, but it is.</p>
</div>
chrissaid commented 4 years ago

Update: I've solved my problem: I need needed to put the

tags on their own separate lines.

<div style="font-style:italic" markdown="1">
My italicized figure caption
</div>

This behavior seems surprising to me. Not sure if this counts as user error or not.

gettalong commented 4 years ago

Yes, this is expected behaviour, see https://kramdown.gettalong.org/syntax.html#html-blocks, the second list item "Parse as block-level elements:".