closing ul/li getting wrapped in p

Stephen Haberman stephenh at chase3000.com
Sat Oct 30 19:19:19 EDT 2004


Hi,

I was seeing some funny behavior with sublists, like:

* A
  * B
* C

Becoming:

<ul>
<li>A
<ul>
<li>B</li>
</ul>

<p></li>
<li>C</li>
</ul></p>

Note the extra new line in there. When an <li> has a child <ul>, and when
that <ul> is later closed, there are two \n put after it. This extra new
line before the closing </li> tag is caught by FormParagraphs which
mistakenly wraps the closing </li> ... </ul> fragment in a p tag.

Changing (~line 775 - I've made some other changes to my Markdown.pl that
could throw the number off):

$result = "<$list_type>\n" . $result . "</$list_type>\n\n"; 

To (dropping one of the \n):

$result = "<$list_type>\n" . $result . "</$list_type>\n";

For me works beautifully as the sequences of closing tags (e.g. </ul></li>)
are kept only one \n apart and, without the extra \n, from being processing
by FormParagraphs.

This results in the much nicer HTML:

<ul>
<li>A
<ul>
<li>B</li>
</ul></li>
<li>C</li>
</ul>

So I thought I'd send in the pseudo-patch. I haven't seen any bad side
affects of this change, and I use lists/sublists quite a lot, but without
some automated test suite, or an in-code comment as to why two \n was used
in the first place, I might be breaking some boundary cases in some other
rules. I honestly don't think so, but you never know.

Thanks,
Stephen





More information about the Markdown-discuss mailing list