Comments (4)
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
from commonmark.jl.
Ok this makes sense, thanks!
from commonmark.jl.
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:
- https://babelmark.github.io/?text=1.+abc%0A2.+def%0A++1.+ghi
- https://babelmark.github.io/?text=1.+abc%0A2.+def%0A+++1.+ghi
- https://babelmark.github.io/?text=*+abc%0A*+def%0A++*+ghi
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).
from commonmark.jl.
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)
from commonmark.jl.
Related Issues (20)
- Problem testing `JuliaInterpreter` on Juno/Atom HOT 1
- `@cm_str` inside list comprehension
- Interpolate a vector of items HOT 2
- HypertextLiteral.jl + CommonMark.jl = 🤯 HOT 9
- Julia 1.0: no method matching get!(::getfield(CommonMark, Symbol("##106#108")), ::IdDict{CommonMark.Node,Dict{String,Int64}}, ::CommonMark.Node) HOT 2
- Content inside `<script>` inside paragraph HOT 5
- Tables fail when there are spaces between column definitions and pipes
- Keep reference links as references HOT 6
- Separate package for Markdown AST HOT 4
- Indentation within HTML block with empty lines HOT 1
- Markdown printing adds unwanted newlines HOT 1
- Table parsing fail for some unicode identifiers HOT 1
- Duplicate rules when enabling/disabling rules HOT 1
- Disabling LinkRule (but not ImageRule) does not disable link parsing HOT 1
- Error handling multi unicode text HOT 5
- Some detailed code issues HOT 3
- `benchmark/`: simplify
- Migrate to PrecompileTools HOT 3
- [Bug?] CommonMark Markdown Table cells are not CommonMark leaf blocks HOT 23
- Discoverability on JuliaHub: should be easier to find when searching for "Markdown" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commonmark.jl.