views:

62

answers:

3

I just wrote some markdown and it doesn't seem to render correctly.

Is it legal syntax to have an ordered list, followed by newlines, then followed by an unordered list? Or is this a bug in bluecloth?

For example:

1. One
2. Two
3. Three

* Apple
* Banana
* Carrot

Bluecloth creates a single <ul> and nests apple, banana and carrot as <li>'s under it. Stackoverflow's post editor (wmd?) does this too.

Am I just doing it wrong? Surely this is a common usage case...

+1  A: 

I can't help with a solution, but I can confirm that I get exactly the same problem with Text::Markdown, the perl port of Markdown.

Mike
A: 

Guess nobody knows!

I've submitted this as a bug report to bluecloth's maintainer.

nfm
+1  A: 

I do believe that this is not a bug, but an intended "feature", of sorts.

It appears that all lists are really the same, and whitespace separation is allowed (it simply increases vertical spacing)

* this is

* a spaced out

* unordered list
  • this is

  • a spaced out

  • unordered list

What determines the character of the list? The first item does. This is why:

1. This is number one
15. This is number two
7. This is number three

turns into:

  1. This is number one
  2. This is number two
  3. This is number three

Essentially, markdown determines the character of the ordered list by the character of the first item, and basically "ignores" the list "identifiers" subsequently. If you read the official Markdown specifications, this is expected behavior. (it is even defined behavior that 2. will start an ordered list at index 1)

Now, by the virtue that Markdown essentially ignores subsequent list identifiers after the first one, it makes sense that

1. This is the first thing
* This is the second
9. This is the third

renders to:

  1. This is the first thing
    • This is the second
  2. This is the third

and, subsequently:

* Hello, world
1. I am unordered

turns into:

  • Hello, world
    1. I am unordered

Again, note that whitespace is only implemented by <p>'s in the rendered list, and does not separate list items

See more of the list implementation here

This doesn't explicitly say "lists are defined by their first item*, but I believe that the behavior of the unordered list numberings being ignored after the first identifier is an obvious case to show this.

Justin L.