Categories
  • Development 10
  • News 4
  • Thoughts 5
  • Tutorials 3
  • Reviews 2
Will Dages
  • Posts
  • OMGBOTS
  • Projects
  • Categories
  • Ordered Lists in Markdown

    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.

    # List

    1. First item

    * second item + third item - fourth item

    For an ordered list, you only need to make the first item start with a numbered marker. After that, you can use any other list marker for the rest of the list. This way, when you need to remove or re-order an item later, you don't have to manually change the rest of the affected numbers.

    Messed up list

    1. First item
    2. Second item
    3. Fourth item

    Note that in this case above, we deleted the third item. Markdown is, like above, taking care of the numbering for us. But how annoying is it to look at the source and see a difference between the number you wrote, and the one it rendered?

    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.

    Posted on August 7, 2014 by Will Dages.
  • Yeoman/Bower Issue: Missing bower_components directory

  • Parse Javascript API: Logging your API Requests

  • Ask to speak with their supervisor

  • Don't use X for Close Buttons

  • Clearing your mind with a walk (updated)

  • $0 in Chrome Dev Tools

  • Powered by Anchor CMS

  • Plinko

Next →
© 2023 Will Dages. All rights reserved.
  • Twitter
  • GitHub
  • RSS