fletcher / MultiMarkdown-4

This project is now deprecated. Please use MultiMarkdown-6 instead!
https://github.com/fletcher/MultiMarkdown-5
Other
306 stars 59 forks source link

Invalid XML/HTML with Markdown inside nested block element tags #122

Closed mn4367 closed 9 years ago

mn4367 commented 9 years ago

The following input ...

</div markdown="1">
Text

Paragraph

Text
</div>

will lead to

<div>
Text

<p>Paragraph</p>
Text
</div>

which is correct. Neither a problem with this input:

<div markdown="1">
<div markdown="1">
Text

Paragraph

Text
</div>
</div>
<div>
<div>
Text

<p>Paragraph</p>
Text
</div>
</div>

But this one produces an invalid nesting of tags:

<div markdown="1">
<div markdown="1">
Text

Paragraph

Text
</div>

</div>
<div>
<div>
Text

<p>Paragraph</p>

<p>Text
</div></p>
</div>

Maybe it's a corner case but it rather shouldn't produce invalid XML/HTML. I'd prefer a rule where everything inside an HTML block element is never influenced by anything outside this block element, but I have to admit that it's probably not easy to achieve. One further observation, this input "corrects" the problem which seems to be a bit strange:

<div markdown="1">

<div markdown="1">
Text

Paragraph

Text
</div>

</div>
fletcher commented 9 years ago

Nothing inside an HTML block element is being influenced by anything outside. The "unbalanced" whitespace inside your outermost <div> is causing the irregularities -- meaning that the innermost <div> is not a block, but rather two unrelated tags (to MMD) that look related to you (<div> and </div>).

The last example you show is the correct one, where the innermost <div> is actually a Markdown block element, which is why you get the output you expect.

I agree that MMD shouldn't produce invalid HTML, but if you give it "incorrect" HTML/MMD there's not much I can do about it.