Is this a valid list in CommonMark?
1. Foo
- Bar
- Baz
2. Qux
I am concerned about the validity of two leading spaces before each list marker, i.e. 1.
, 2.
, etc. Is it valid to provide leading spaces before the list marker?
I am unable to find anything in the spec that explicitly mentions that it is okay to have leading spaces before each list marker in the CommonMark spec at http://spec.commonmark.org/0.27/.
But there are many examples which seem to show leading spaces used before the list marker. For examples, see
But I would like the spec to clearly spell out that it is valid to put spaces before list markers. Can you find anything in the spec that clearly spells this out or at least implies this?
The specific rule is rule 4 of the list items section (which starts right after example 246):
- Indentation. If a sequence of lines Ls constitutes a list item according to rule #1, #2, or #3, then the result of indenting each line of Ls by 1-3 spaces (the same for each line) also constitutes a list item with the same contents and attributes. If a line is empty, then it need not be indented.
Examples 247, 248 and 249 then show one, two and three spaces respectively, all if which are interpreted as list items. Finally, example 250 shows four spaces of indent resulting in a code block.
Of course the rule for indented blocks states (emphasis added):
An indented code block is composed of one or more indented chunks separated by blank lines. An indented chunk is a sequence of non-blank lines, each indented four or more spaces. The contents of the code block are the literal contents of the lines, including trailing line endings, minus four spaces of indentation.
Therefore, anything with less than four spaces of indentation is not a code block. A couple paragraphs later we find the following:
If there is any ambiguity between an interpretation of indentation as a code block and as indicating that material belongs to a list item, the list item interpretation takes precedence:
The example given shows a nested list item which is indented four or more spaces. However, that same example also indents the parent list item two spaces, so the rule could apply to both.
For comparison, the original Markdown rules explicitly stated:
List markers typically start at the left margin, but may be indented by up to three spaces.
This concept has existed in Markdown for many years.