"ol ul" list doesn't generate correct 2 level HTML


#1

I’m confused about one particular part of CommonMark.

It’s that the following 2 level lists all display correctly:

  • ul ul
  • ol ol
  • ul ol

While “ol ul” list does not. Example.

ul ul
* Item 1
* Item 2
  * Item 2a
  * Item 2b

ol ol
1. Item 1
2. Item 2
3. Item 3
   1. Item 3a
   2. Item 3b

ol ul
1. Item 1
2. Item 2
  * Item 2a
  * Item 2b

ul ol
- Item 1
- Item 2
- Item 3
   1. Item 3a
   2. Item 3b

Is this a bug, or a weird corner case of the specs?


#2

Property of the specs.

From https://spec.commonmark.org/0.28/#list-items:

Basic case. If a sequence of lines Ls constitute a sequence of blocks Bs starting with a non-whitespace character and not separated from each other by more than one blank line, and M is a list marker of width W followed by 1 ≤ N ≤ 4 spaces, then the result of prepending M and the following spaces to the first line of Ls , and indenting subsequent lines of Ls by W + N spaces, is a list item with Bs as its contents. The type of the list item (bullet or ordered) is determined by the type of its list marker. If the list item is ordered, then it is also assigned a start number, based on the ordered list marker.

There is W+N spaces of indentation, not just W.


#5

Thanks, it helped me fix the code. Practically speaking it means that the indented line should start visually below the previous line’s first “text” character (when using a fixed width font)?


#6

Zsolt Ero via CommonMark Discussion
noreply@talk.commonmark.org writes:

Thanks, it helped me fix the code. Practically speaking it means that the indented line should start visually below the previous line’s first “text” character (when using a fixed width font)?

Exactly.