Markdown reverse ordered list?

I don't know of a plain Markdown solution, but for those who are willing to consider pretty common markdown extensions, you can achieve this using kramdown. In Kramdown, you can add any attribute to any HTML block. So, all you need to do is:

0. first item
0. second item
0. another item
{: reversed="reversed"}

This will add the reversed attribute to your <ol> block and will generate the desired effect.

See the kramdown documentation for the syntax.


The documentation states (in part):

It’s important to note that the actual numbers you use to mark the list have no effect on the HTML output Markdown produces. ... [examples excluded for clarity and brevity] ...

The point is, if you want to, you can use ordinal numbers in your ordered Markdown lists, so that the numbers in your source match the numbers in your published HTML. But if you want to be lazy, you don’t have to.

If you do use lazy list numbering, however, you should still start the list with the number 1. At some point in the future, Markdown may support starting ordered lists at an arbitrary number.

In fact, a few implementations have started to support the start attribute (one example); however, it is rare. And even then, only the number of the first item is referenced. The numbers given to the rest of the items are still ignored.

I am not aware of any implementation which supports the reverse attribute. Besides, how would the parser detect it? Would all the numbers need to be checked by the parser? Or just the first two?

As HTML does not really provide a way to manually define the number of each and every list item manually, there is no reason for a Markdown parser to care about which numbers are assigned to each individual item. Therefore most (all?) don't.

Of course, Markdown does support raw HTML. As the Syntax Rules state:

For any markup that is not covered by Markdown’s syntax, you simply use HTML itself.

Therefore, you can manually define your list in raw HTML within your Markdown document:

A paragraph of Markdown text

<ol reversed>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

More Markdown text.

And the philosophy behind why that is the correct way to do it is explained this way:

Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is not to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert.