6

How do I correctly get numbered lists to work?

I am using Chrome on Mac and have been manually numbering lists of items because I am struggling to get the rich text formatting work. However I was ashamed today to find someone has had to go through and fix all my answers.

Is there a trick to it? How to get auto numbering. When I try I get this:

  1. One Two
  2. List item

Three

  1. List item
6

Stack Exchange uses Markdown for its markup language and the Markdown documentation has this to say about list items:

Ordered lists use numbers followed by periods:

1.  Bird
2.  McHale
3.  Parish

It’s important to note that the actual numbers you use to mark the list have no effect on the HTML output Markdown produces. The HTML Markdown produces from the above list is:

<ol>
<li>Bird</li>
<li>McHale</li>
<li>Parish</li>
</ol>

So a numbered list is best formed by just doing:

1.  Bird
1.  McHale
1.  Parish

As for having better formatting within the items in your list, like multiple paragraphs, the documentation says:

If list items are separated by blank lines, Markdown will wrap the items in <p> tags in the HTML output. For example, this input:

*   Bird

*   Magic

will turn into:

<ul>
<li><p>Bird</p></li>
<li><p>Magic</p></li>
</ul>

List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab:

1.  This is a list item with two paragraphs. Lorem ipsum dolor
    sit amet, consectetuer adipiscing elit. Aliquam hendrerit
    mi posuere lectus.

    Vestibulum enim wisi, viverra nec, fringilla in, laoreet
    vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
    sit amet velit.

2.  Suspendisse id sem consectetuer libero luctus adipiscing.

To put a blockquote within a list item, the blockquote’s > delimiters need to be indented.

To put a code block within a list item, the code block needs to be indented twice — 8 spaces or two tabs.

If you view the source for this answer you'll see how I used those last two statements above through out this answer to format things.

So if you take your example from above, which has the following Markdown format:

 1. One
Two
 2. List item

Three

 1. List item

And use the rules from Daring Fireball, the best you can do is:

1. One

   Two

1. List item

   Three

1. List item

To get the rendered output:

  1. One

    Two

  2. List item

    Three

  3. List item

I'm making a bit of a guess on what your expected rendering was, but that's a reasonably advanced example of using lists.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .