Markdown barfs on this document

Michel Fortin michel.fortin at michelf.com
Thu Jan 27 09:52:02 EST 2005


Le 27 janv. 2005, à 1:51, Joe Chellman a écrit :

> Have I found a bug, or is my Markdown malformed?  Everything seems 
> fine to me.  This article has been sitting around for (as you might 
> see) many months now, and I found these bum paragraphs when I went to 
> do some editing today.

Your text source is fine. This is a known bug -- sort of. Nested lists 
of the same type are known to cause problems. Your is just one example 
of what can happen. Here is a test case that trigger the same problem 
as your text:

	3.  Paragraph

		1. Sub-list

		Paragraph

		* Sub-list

	This is a [link](http://to.nowhere/).

	*   List

It (incorrectly) produce this (line numbers added by me):

	 1: <ol>
	 2: <li><p>Paragraph</p>
	 3:
	 4: <ol>
	 5: <li>Sub-list</li>
	 6: </ol>
	 7:
	 8: <p>Paragraph</p>
	 9:
	10: <ul>
	11: <li>Sub-list</li>
	12: </ul></li>
	13: </ol>
	14:
	15: This is a [link](http://to.nowhere/).
	16:
	17: <ul>
	18: <li>List</li>
	19: </ul>

What happens is that after the lists are processed, the html block 
parser checks for block tags to ensure they won't be enclosed inside 
paragraphs, but the parser does not understand correctly nested blocks. 
The first block it sees start at line 1 and ends at line 6. The second 
one start from line 10 and ends at first "ul" tag alone on it's line -- 
that's line 19.

Therefore everything between line 6 and 19 is part of the HTML block 
and not processed as paragraphs. Span-level elements like links are not 
converted either.

I'm thinking of a simple hackish way to sole this: remove the newline 
before a closing "ul" or "ol" tag when it is inside another one. There 
is already a global variable keeping track of the nesting level that 
could be used for this.


Michel Fortin
michel.fortin at michelf.com
http://www.michelf.com/


More information about the Markdown-Discuss mailing list