Markdown List With Numbers

Posted on  by admin
  1. Markdown Continue Numbering
  2. Markdown List With Numbers Printable

In ordered lists, each list item starts with a number. What's interesting about markdown in Jupyter notebooks is that you don't have to include the numbers yourself. You can start each list item with 1, for example, and when the markdown is displayed, the correct numbers will be filled in. . an asterisk starts an unordered list. and this is another item in the list + or you can also use the + character - or the - character To start an ordered list, write this: 1. This starts a list.with. numbers + this will show as number '2'. this will show as number '3.' Any number, +, -, or. will keep the list going. Ordered lists start with a number followed by a period for each list item. Unordered lists start with a. Begin each list item on a new line. In a Markdown file or widget, enter two spaces prior to the line break to begin a new paragraph, or enter two line breaks consecutively to begin a new paragraph. Ordered or numbered lists.

Here's a simple little trick that I don't see many people using. If you're writing an ordered list in markdown, you can just make the first item have a numerical prefix (1.), and continue with any other unordered list marker for the rest of the items in the list. It doesn't matter whether you prefer using *, +, or - (which are all valid list markers), prefixing the first item start with a 1. triggers the entire list to be an ordered list, even if there rest of the items are prefixed differently.

See the Pen zjDCo by Will Dages (@willdages) on CodePen.

Why is this helpful? If you've ever had to remove an item in an ordered list and then re-number all the items that came after the one you removed, you've felt the pain. By using stars after the first item, markdown will take care of the numbering for you, so there are no hassles when you want to remove or re-order something in the list. Note that markdown doesn't actually mess up the output when you remove an item in the middle (it won't show the list skipping from #2 to #4), but at this point you will have a difference between what's in your source, and what's rendered. Using unordered list markers for items 2-∞ feels much more like using a li inside of an ol in HTML.

This is part two in the Writing in Markdown series. If you prefer, read John Gruber's original guide. I will not be able to add anything new.

Markdown List With Numbers

Lists come in two flavors in Markdown. There are unordered lists and ordered lists. The first item in a list must be preceded by an empty line. A list item can contain other Markdown formatting, however the list bullet or item number can not. It must be plain text.

An unordered list is a simple bullet list. There's not much to an unordered list. It must be separated from a text block by one blank like and each list item must be preceded by a hyphen, plus or asterisk. I use hyphen characters ('-') exclusively for bullet lists. I have run into problems when using a mix of hyphens and asterisks with lists. Particularly, I have had issues when copying markdown into other applications.

To create nested lists, indent by one tab (or four spaces if you're antediluvian. Markdown processors will automatically vary the bullet character between list levels. That's the main reason it doesn't matter much whether I use an asterisk or dash for bullets.

Is converted to this:

  • Talk to Luke about his father
    • Skip the part where I leave him for dead
    • Don't mention the youngling 'thing'
  • Dinner with Yoda
    • Bring DEET
    • Bring Pepto
    • Dessert?
      • Wookie Pie
  • Stop by to see Anakin on Death Star
  • Submit restraining order against JarJar

But of course sometimes the order of items is crucial. That's where ordered lists come in. The sequence of an ordered list is defined by the sequence of the list items and not by the number prefix of the item

For example, even though the first line is prefixed as item #3 in the list, the Markdown is converted to display as item #1. The actual number is irrelevant. It is only there to indicate that the line should be considered as an ordered list item. Also note that unordered and ordered items can be commingled in the same list, but not at the same indentation level. An ordered list can contain a nested ordered list. But an unordered list items are converted to numbered list items if they are at the same indentation level as another numbered item.

Is converted to the list below. The originally drafted sequence would be lost in converting the Markdown to html or PDF.

  1. Stop by to see Anakin on Death Star
    1. Get a ride
    2. Wash robe
  2. Clean blood (and hand) off Anakin's old light saber
  3. Talk to Luke about his father
    • Skip the part where I leave him for dead
    • Don't mention the youngling 'thing'
  4. Dinner with Yoda
    • Bring DEET
    • Bring Pepto
    • Dessert?
      • Wookie Pie
  5. Submit restraining order against JarJar

Markdown Continue Numbering

As with all Markdown, these are just tags to interpret the start of a ul or ol html tag block. As long as the first item in a list, all subsequent list items will be interpreted as an ordered list. For example:

Generates this formatted list

Pack Suitcase

  1. Lightsaber
  2. Leisure brown robe
  3. Formal brown robe
  4. Night time brown robe
  5. Dress Sandals

Unfortunately, Markdown never implemented an option to start an ordered (numbered) list at an arbitrary number. The only option I have found is to create the list manually by escaping the Markdown using a <pre> or <code> block. These blocks tell the Markdown processor to skip interpretation of the list all together.

To generate this list:

Alternatively, I can skip the <pre> tag by indenting each list item with one tab (or four spaces). This just makes it a code block which also escapes the Markdown processor.

Markdown List With Numbers Printable

There are many more details about extending lists to include multiple paragraphs as well as code blocks. I highly recommend reading from the original source as handed down by Gruber.