explain why in commonmark:
- one
- a
- two
- b
there need to be 3 vs 2 spaces in this mixed list I am confused
explain why in commonmark:
there need to be 3 vs 2 spaces in this mixed list I am confused
I’ll search for information about CommonMark’s specific indentation rules for mixed lists.
Search Google
Found 930 results for ‘CommonMark mixed ordered unordered list indentation spaces rules’
Browse Web
Reading https://commonmark.org/help/tutorial/10-nestedLists.html
Search Google
Found 913 results for ‘CommonMark spec list item indentation content indent calculation’
Browse Web
Reading https://spec.commonmark.org/0.31.2/#list-items
Let me search for a more specific section about list item content indentation:
Search Google
Found 15 results for ‘CommonMark list item content indent “3 spaces” ordered unordered marker width’
Let me explain why your mixed list needs different indentation! This is actually one of the more subtle aspects of CommonMark’s list rules.
In CommonMark, the indentation required for list content depends on the width of the list marker plus the spaces after it. Let me break down your example:
1. one
- a
2. two
- b
For the ordered list item "1. ":
1. is 2 characters wideSo any continuation content (including nested lists) needs to be indented 3 spaces to align with where “one” starts.
For the unordered list item "- ":
- is 1 character wideSo content under the unordered list items only needs 2 spaces.
From the CommonMark specification[1]:
“If a sequence of lines Ls constitute a sequence of blocks Bs starting with a character other than a space or tab, and M is a list marker of width W followed by 1 ≤ N ≤ 4 spaces of indentation, 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.”
In your case:
Think of it as aligning with where the text starts:
1. one ← text starts at column 4 (after 3 spaces)
- a ← indent 3 spaces to align with "one"
2. two
- b
If you used only 2 spaces for the nested list under an ordered item, it wouldn’t align properly and might not be recognized as nested content.