4

Numbered lists are easy:

  1. Item1
  2. Item2

This is how it looks when I'm typing this question:

enter image description here

Reversed numbered lists are not that easy:

  1. Item2
  2. Item1

This is how it looks when I'm typing this question:

enter image description here

As you see, I want "2, 1" and I get "2, 3".

Are there any plans implementing reversed numbered lists?

8
  • 1
    Maybe the easiest way to support that is by allowing HTML with <li value="2"> but at the moment only <a> and <img> tags are allowed to have attributes, any other tags with attributes will be stripped. Adding this might have side-effects on other content on the page. I wouldn't hold my breath until this is implemented.
    – rene
    Commented Apr 26 at 8:11
  • 2
    Note that there is a workaround when you need control over the numbers: meta.stackexchange.com/a/234385
    – rene
    Commented Apr 26 at 8:14
  • talk.commonmark.org/t/descending-ordered-lists/1068/7, stackoverflow.com/q/30106203/11107541. if commonmark doesn't support it, dunno how you're gonna get it from MarkDig except as an extension.
    – starball
    Commented Apr 26 at 8:45
  • @rene: Thanks for your quick reply, but your solution consists of simply stopping the numbering feature (meaning that I must end my lines with two spaces in order to go to the next line).
    – Dominique
    Commented Apr 26 at 8:49
  • @starball: I tried, starting a line with 1-., as mentioned in your URL, but it seems not to work here. (Pardon my ignorance, but I have no idea what commonmark is)
    – Dominique
    Commented Apr 26 at 8:50
  • 1
    @Dominique I didn't mean to link to /7 in that discourse thread. it just happened because I was scrolled to that point. it's a thread on extensions to commonmark (see the tag).
    – starball
    Commented Apr 26 at 8:52
  • 1
    @Dominique commonmark is the standard/dialect of markdown that stack exchange uses on the Q&A sites for posts. Commented Apr 26 at 14:04
  • What exactly is the practical use case for this? Commented Apr 27 at 13:12

2 Answers 2

9

I dislike the workarounds that rely on escaped text. At that point, you might as well dispense with the pretense of a numbered list entirely, and use something more descriptive that won't inadvertently render as a list if you somehow lose the escaping. E.g.,

3 verses remaining: sing,

Second stage is cut
We're now in orbit
Stabilizers up
Running perfect
Starting to collect
Requested data
"What will it affect
When all is done?"
Thinks Major Tom

2 verses remaining: sing,

Back at ground control
There is a problem
"Go to rockets full"
Not responding
"Hello Major Tom
Are you receiving?
Turn the thrusters on
We're standing by"
There's no reply

1 verse remaining: sing,

Far beneath the ship
The world is mourning
They don't realize
He's alive
No one understands
But Major Tom sees
"Now the light commands
This is my home
I'm coming home"

That said... If you're determined to achieve the appearance of an inverted list, the CommonMark spec provides an option: use a separate list for each list item.

4. Four
<!-- -->
3. Three
<!-- -->
2. Two
<!-- -->
1. One
   Earth below us
   Drifting, falling
   Floating weightless
   Calling, calling home
  1. Four
  1. Three
  1. Two
  1. One
    Earth below us
    Drifting, falling
    Floating weightless
    Calling, calling home
5

Here is a reverse numbered list.

3. Item three
2. Item two
1. Item one

Markdown:

3\. Item three  
2\. Item two    
1\. Item one  
            ^^-- two spaces after each item

I don't think that's an unreasonable workaround, assuming your list items are short.

Because of the workaround, you do lose the nice indenting and line spacing:

3. If the text here is really long and it has to line wrap, it falls immediately to the margin instead of the nice indenting you might expect otherwise, and it is just treated like a sentence in this paragraph unless you add a line break before the next item.
2. Item two
1. Item one

Compared to wrongly numbered but nicely formatted:

  1. If the text here is really long and it has to line wrap, it is indented nicely and still has a bit of padding before the next item in the list. But the numbers don't obey.
  2. Item two
  3. Item one

If your content is beefier, or you are concerned about accessibility, I might suggest it deserves a Markdown table rather than an ordered list. Then you can put whatever numbers you want in each cell, still get the benefit of formatting and padding, and don't mess with screen readers.

3 If the text here is really long and it has to line wrap, it is indented nicely and still has a bit of padding before the next item in the list.
2 Item two
1 Item one

As mentioned in the comments, there are extensions to Markdown that can make this work easier, but they aren't implemented here. The other answer aside from this one on Stack Overflow is worth a read, too, as well as this post on the CommonMark Discussion forum.

3
  • 4
    By escaping the list, you lose the semantic information too, which means that screen readers won't be able to navigate it as well. (Using a table, however, would allow other screen reader features to be used.)
    – Laurel
    Commented Apr 26 at 15:31
  • For more information about the table approach, see Hey, It’s Still OK to Use Tables. (Excerpt: "If you only have one axis of information, use a list." – but in the face of technical restrictions like we have on Stack Exchange, the other stuff in the article applies.)
    – wizzwizz4
    Commented Apr 26 at 16:33
  • For bigger lists use this Excel VBA macro for generating a Markdown table
    – MT1
    Commented Apr 26 at 16:54

You must log in to answer this question.

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