Improve numbered lists

markdown-it-review

(probus) #1

We’re struggling a bit with the parser and automatic formatting of posts. In particular, numbered lists. There are a couple of ways in which they drive our posters mad:

  • You can’t start a list from any other number than one, or have the
    list count down
  • You can’t skip numbers or have the same number for
    items
  • If you start a paragraph with a number, it get’s interpreted as a list even if it doesn’t have any other numbered items below it. This might not be a big problem when writing in English, but in my language that’s how you write ordinal numbers (1st, 2nd etc). Imagine starting your sentence with “3rd time it happened…” and the forum changing it into “1st time it happened…”

As an example
Gibson.com Top 50 Guitarists of All Time – 50 to 41

49. (tie) Ritchie Blackmore (Deep Purple, Rainbow)
49. (tie) Kurt Cobain (Nirvana)
47. (tie) Robert Fripp (King Crimson)
47. (tie) Andrés Segovia
42. (tie) Hubert Sumlin (Howlin’ Wolf, Muddy Waters)
42. (tie) Clarence White (The Kentucky Colonels, The Byrds)
42. (tie) Rory Gallagher (Taste, solo)
42. (tie) John Frusciante (Red Hot Chili Peppers)
42. (tie) Richard Thompson
41. David Gilmour (Pink Floyd)

turns out like this:

  1. (tie) Ritchie Blackmore (Deep Purple, Rainbow)
  2. (tie) Kurt Cobain (Nirvana)
  3. (tie) Robert Fripp (King Crimson)
  4. (tie) Andrés Segovia
  5. (tie) Hubert Sumlin (Howlin’ Wolf, Muddy Waters)
  6. (tie) Clarence White (The Kentucky Colonels, The Byrds)
  7. (tie) Rory Gallagher (Taste, solo)
  8. (tie) John Frusciante (Red Hot Chili Peppers)
  9. (tie) Richard Thompson
  10. David Gilmour (Pink Floyd)

Of course, one can use pre formatted text (as we do now), but it’s not ideal or intuitive. Is there any way to improve or configure this behaviour?


(Sam Saffron) #2

Pandoc has an extension to support specifying of the starting number:

It is a clear diversion and violation of the markdown spec.

We would be open to adding this functionality (optional - default off) to our markdown parser if contributed via the community. Would probably have to be upstreamed.

The <ol> tag does not support arbitrarily numbered lists, so if you were to allow “any order” we would have to construct a special div.

Our markdown parser is actually quite flexible, its possibly it could be hacked to support “floating” numbers but it would mean your forum would work differently to all other Discourse forums out there.

I agree that list support is not markdowns shining moment, and the spec has not moved in like forever.


(Jeff Atwood) #3
  1. pears
  2. apples

Using the html tags seems to work OK?

<ol start=4/><li>pears</li><li>apples</li></ol>

(Mait) #4

How about use ``` for special ol block?

```OL-AS-IS
3. …
4. …
49. …
56. …
```


(Sam Saffron) #5

Sure, but its arbitrarily insane that:

3. hello
4. goodbye

Produces

  1. hello
  2. goodbye

I understand that you want

1. bla
2. boo
2. baz

To produce

  1. bla
  2. boo
  3. baz

It allows you to easily insert stuff in a list.

But… not allowing you to pick the starting number. Arbitrarily insane


(Jeff Atwood) #6

Yeah, it should “stick” with the number you start at. We talked about that for markdown-next.

However you said

Which isn’t true…

<ol start=4/><li>pears</li><li>apples</li></ol>

(Sam Saffron) #7

Sorry, I explained that bad.

I meant ol does not support a list like this:

1. hello
7. goodbye 
3. farts

(Jeff Atwood) #8

Hello, goodbye, farts… this reminds me of every conversation you and I have had.


(Mark Elder) #9

I’m gonna necro this thread, since like, it’s not fixed.

I’m also finding that if you add a numbered list, then interrupt it for whatever reason, example:

  1. Entry one
  2. Entry two
  3. Entry three

URL

  1. Entry four

etc. the list reverts to 1 after the URL/interruption.

I also found that if you add in a bullet partway down the list, it turns all the numbers into bullets.

Pls, discourse gods, use your wand of fixing to resolve this madness.


(Sam Saffron) #10

Will be fixed when we upgrade to https://markdown-it.github.io/ later this year. Feel free to try it out there.


Markdown isn't processed inside tables
(Jeff Atwood) #11

Not “fixed” because it works that way in the spec. The behavior listed above is 100% correct per the official spec. We literally had to fork the project and create a new official spec. Takes time.


(Sam Saffron) #12
  1. bugs of beer on the wall

Nintey nine bugs of beer, eat one bug, what do you have?

  1. bugs of :beers: on wall

99. bugs of beer on the wall 

Nintey nine bugs of beer, eat one bug, what do you have? 

98. bugs of :beers: on wall

(Sam Saffron) #13