4

See this markdown:

hello
1. Point 1
2. Point 2

bye
2. Point 2
3. Point 3

Now see how it renders:

hello

  1. Point 1
  2. Point 2

bye 2. Point 2 3. Point 3

As you see, the numbered list items just display properly if the first item has the 1 before it. The block starting with "bye" doesn't show the numbered list properly.

To have the second code block work, you need to add an extra line in between:

bye

2. Point 2
3. Point 3

Which renders well:

bye

  1. Point 2
  2. Point 3

Is this the expected behaviour?

1 Answer 1

9

This is a CommonMark rule exception for ordered list markers.

5.2 List items

The following rules define list items:

Exceptions:

  1. When the first list item in a list interrupts a paragraph—that is, when it starts on a line that would otherwise count as paragraph continuation text—then (a) the lines Ls must not begin with a blank line, and (b) if the list item is ordered, the start number must be 1.

Both hello and bye, as used in the example, are considered paragraphs by CommonMark.

4.8 Paragraphs

A sequence of non-blank lines that cannot be interpreted as other kinds of blocks forms a paragraph.

Each paragraph is interrupted by a list, which does not need an empty line to separate the paragraph from the list

5.3 Lists

In CommonMark, a list can interrupt a paragraph. That is, no blank line is needed to separate a paragraph from a following list:

Example 273. (...)

In conclusion, the first rule mentioned is applied to the list items in paragraph bye because they interrupt the paragraph without a blank line in between, and in that case the exception is that: "if the list item is ordered, the start number must be 1".

The solution would be to use a blank line between the paragraph and the first list item to avoid the mentioned exception that will otherwise force the numbering to start at 1.

1
  • 1
    Thanks! What is weird is that both blocks themselves look exactly the same, so there is no external indicator that one is a numbered list, while the other is not considered as such. For this, the behaviour looks buggy. Oct 28, 2020 at 8:22

You must log in to answer this question.

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