closing ul/li getting wrapped in p

Stephen Haberman stephenh at
Sat Oct 30 19:19:19 EDT 2004


I was seeing some funny behavior with sublists, like:

* A
  * B
* C




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 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:


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.


More information about the Markdown-discuss mailing list