Markdown generates invalid html for a list immediately followed by a quote

Michel Fortin michel.fortin at michelf.com
Wed May 23 10:01:31 EDT 2007


Le 2007-05-22 à 23:48, Matt Kraai a écrit :


> * foo

> > bar

> > baz


Although it should certainly be valid HTML, the output Markdown
should generate for that is a pretty tricky question in my opinion. I
see three valid interpretations according to the Markdown syntax
documentation. Here is the simplest:

<ul>
<li>foo
> bar
> baz</li>
</ul>

It also happens to be PHP Markdown's output. bar and baz are taken as
part of the list item since the following lines do not need to be
indented, and since the list item does not contain any blank line the
content gets treated as a span-level, hence no blockquote.

The next one is what most people would expect I think:

<ul>
<li>foo</li>
</ul>

<blockquote>
<p>bar
baz</p>
</blockquote>

Blockquote markers are obeyed and are on the same level as the list
since they aren't indented.

Third option:

<ul>
<li><p>foo</p>

<blockquote>
<p>bar
baz</p>
</blockquote></li>
</ul>

Blockquote markers are seen as inside the list item since adjacent
lines do not need indentation, and are obeyed making the list item
content's block-level.

I think, as a general rule, the explicit syntax should take
precedence over the lazy one. This would make the second option above
the preferred one over the others. Other tricky cases could work like
the following.

A list item containing a "foo" paragraph and a "bar baz" blockquote:

* foo
> bar
> baz

A list item containing a "foo" paragraph and a "bar" blockquote,
followed by a "baz" blockquote:

* foo
> bar
> baz

A list item containing a "foo" paragraph, followed by a "bar baz"
blockquote:

* foo
> bar
baz

A list item containing "foo" (no paragraph), followed by a blockquote
containing "bar", followed by a list item containing "baz" (no
paragraph):

* foo
> bar
* baz

Basically, I'd eliminate any "half-lazy" syntax were you can be lazy
about list item indentation while not being lazy on blockquote
markers. This just creates confusion; syntax markers shouldn't be
allowed to be lazy.

Removing half-lazy things would also fix a surprising issue with
blockquotes:

> foo
> > bar
> baz

This would be seen as a blockquote containing a "foo" paragraph, a
nested "bar" blockquote and a "baz" paragraph, instead of the
completly counter-intuitive output produced today. To make "baz" part
of the nested blockquote, you would either go the explicit route:

> foo
> > bar
> > baz

or the lazy route:

> foo
> > bar
baz

but not something in between.


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




More information about the Markdown-Discuss mailing list