fletcher / peg-multimarkdown

An implementation of MultiMarkdown in C, using a PEG grammar - a fork of jgm's peg-markdown. No longer under active development - see MMD 5.
Other
523 stars 55 forks source link

HTML tags with markdown=1 produce invalid (X)HTML #77

Closed oawhyte closed 13 years ago

oawhyte commented 13 years ago

I've experienced some trouble using HTML tags with markdown=1. It seems that any empty lines cause the closing tag to be treated as a paragraph, and wrapped in <p></p> tags, which obviously results in invalid (X)HTML. This also differs from the behaviour of the --process-html command-line option, which is better-behaved. Here's an example:

Input:

<!-- 1 -->
<div id="div1" markdown=1>
Some text with a [link](http://www.website.com) inside
</div>

<!-- 2 -->
<div id="div2" markdown=1>

Some text with a [link](http://www.website.com) inside
</div>

<!-- 3 -->
<div id="div3" markdown=1>
Some text with a [link](http://www.website.com) inside

</div>

<!-- 4 -->
<div id="div4" markdown=1>

Some text with a [link](http://www.website.com) inside

</div>

Output:

<!-- 1 -->
<div id="div1" >
Some text with a <a href="http://www.website.com">link</a> inside
</div>

<!-- 2 -->
<div id="div2" >

<p>Some text with a <a href="http://www.website.com">link</a> inside
</div></p>

<!-- 3 -->
<div id="div3" >
Some text with a <a href="http://www.website.com">link</a> inside

<p></div></p>

<!-- 4 -->
<div id="div4" >

<p>Some text with a <a href="http://www.website.com">link</a> inside</p>

<p></div></p>

The only div that is converted to valid (X)HTML in the output is div1. The others all mix the </div> tag into a <p></p>.

If I remove markdown=1 from all the divs, and pass the --process-html option to multimarkdown instead, I get the following output:

<!-- 1 -->
<div id="div1">
Some text with a <a href="http://www.website.com">link</a> inside
</div>
<!-- 2 -->
<div id="div2">
Some text with a <a href="http://www.website.com">link</a> inside
</div>
<!-- 3 -->
<div id="div3">
Some text with a <a href="http://www.website.com">link</a> inside
</div>
<!-- 4 -->
<div id="div4">

<p>Some text with a <a href="http://www.website.com">link</a> inside</p>
</div>

In this case, valid (X)HTML is produced for all the divs, and in div4 the text is treated as a paragraph, which seems sensible.

fletcher commented 13 years ago

the --process-html and markown=1 functions work in entirely different ways. I think this is as good as it's going to get unless someone else submits some different code.