Closed tlienart closed 3 years ago
Nested lists are tricky syntax, they need the child element markers to be indented in line with the start of the list item's content, i.e
julia> a = """
1. abc
2. def
1. ghi
"""
"1. abc\n2. def\n 1. ghi\n"
julia> p(a)
1. abc
2. def
1. ghi
which is the equivalent to the second, unordered list above.
This is how markdown, commonmark at least, is meant to handle nested lists: see the below babelmark tests:
and the spec for list syntax: https://spec.commonmark.org/0.29/#lists.
https://www.johnmacfarlane.net/beyond-markdown.html is a nice read about the list syntax shortcomings (among other things).
Ok thanks! So it's a question of number of spaces? (4 in your example instead of 2?) The thing that confuses me is that there's the same number in both cases yet in the second one it picks up the "child" element.
(I see that the common mark editor does exactly the same thing so feel free to close this issue and I can just refer people to it and tell them to use 4 spaces for indentation)
Ok thanks! So it's a question of number of spaces? (4 in your example instead of 2?) The thing that confuses me is that there's the same number in both cases yet in the second one it picks up the "child" element.
It's not really to do with any particular set number of spaces, it's relative to the lines above. See for example:
julia> cm"""
100000. one
1. two
""" |> CommonMark.ast_dump
Document
List
Item
Paragraph
Text
"one"
SoftBreak
""
Text
"1"
Text
"."
Text
" two"
julia> cm"""
100000. one
1. two
""" |> CommonMark.ast_dump
Document
List
Item
Paragraph
Text
"one"
List
Item
Paragraph
Text
"two"
Where the first list marker 100000.
is much wider than 4 spaces, so any child lists need to start from much further to the right. Once you start putting in weird amounts of indentation the parser consistency drops somewhat: https://babelmark.github.io/?text=+++100000.+one%0A++++1.+two
Ok this makes sense, thanks!
Is this meant to be?
or must sub-levels be indicated differently for ordered lists?