list corner case

Tom Humiston tom at
Tue Sep 9 14:26:58 EDT 2008

The syntax (supplemented by the cheatsheet on Gruber's dingus page)
already gives us the rules. All we're talking about here is what to do
when a text appears to invoke rules in a contradictory fashion. So I
think it's a matter of simply sorting out the priority of these rules.

- If you want an unordered list, you start with a hyphen, plus, or

- If you want an ordered list, you start with a number and a dot. You
don't get to choose the individual numbers beyond the first (and any
attempt will be ignored), and (in the current version, at least) even
the first will, no matter what, be interpreted as 1.

- If you want a list nested within another, you add indentation.

I've noted the above in the order they're presented by Gruber, more or
less. And I think there's at least an idea that each is more specific
than the one before, or occurs "in nature" less generally. As with CSS
rules, I'd give precedence to specificity.

Let's look at the OP's example:

- foo
2. bar*

Nested? No -- there's no indentation. Ordered? No -- it doesn't start
with a number. List? Yes; it starts with a hyphen.

* In all examples, I've substituted foo, bar, and baz in place of
number words to avoid confusion.

Aristotle's first examples:

* foo
* bar
1. baz
2. quux
* qux

- foo
- bar
1. baz
1. quux
- qux

These come out identical to the first example: Nested? No. Ordered? No
(again, look at the first list item, then compare it with the rule for
indicating an ordered list). And thirdly, are they lists at all? Yes:
one list begins with an asterisk, the other a hyphen.

Waylan's example:

- foo
2. bar (with four spaces before)

Nested? Yes, it's indented -- which makes 'bar' the beginning of a
separate list. Is this separate list ordered? Yes. This leaves only
the outer list, which is clearly unordered.

Yuri's example:

0. foo
- bar
2. baz

Nested? No. Ordered? Yes -- it begins with a number (clearly to be
rendered, according to the rule for ordered lists, as 1 followed by 2
and 3).

Aristotle's second example:

1. foo
1. bar
1. baz

Nested? No -- there's no indentation. Ordered? Yes; there's a number
(any number) and a dot before the first item. Again, to be rendered,
according to the rule, as 1, 2, 3.

Albert's example (or examples):

1. Albert
- flowers
- bicycle

2. Lucy
- food
- water
- wine

Nested? No. Ordered? Yes, both of them. Two separate lists? Yes.

In all of the above, I've used Gruber's syntax to create a three-step
flowchart, but for greater elucidation we could slice it differently:
First let us ask, is there nesting, and second, is the list ordered or
unordered? Based on the syntax, the first question needs only to look
for an indent, and the second needs only to check the first item's
marker type.

Further, the syntax and its examples state that ANY number (plus a
dot) before the first item will trigger an ordered list, and that ANY
number before a subsequent item will serve only to identify it as
another list item. So -- happily -- the presence of digits and marks
that don't follow a linear sequence, no matter what they say of the
intent of the author or user, needn't concern us.


All of this is to say that we've been chasing corner cases when we
don't need to. Corner cases refer to the superset of possible inputs.
And given the philosophy implied in Gruber's overview, including the
statement that Markdown's "syntax is very small, corresponding only to
a very small *subset* of HTML tags" (emphasis mine), I think this
focus on corner cases, and the attending abhorrence for the ambiguity
that Markdown's syntax explicity allows, is clearly against Markdown's

Bowerbird is right. The syntax says enough about it. Let it go.

More information about the Markdown-Discuss mailing list