markdown-it / markdown-ast-spec

Markdown AST spec
6 stars 5 forks source link

Line indent info for each line (blockquotes, lists) #1

Open puzrin opened 7 years ago

puzrin commented 7 years ago

Problem

How to store this info in AST?

Checklist

geyang commented 7 years ago

Each node can have:

^____- [ ] some text↩
 ^--^ indent
     ^ bullet-list token
      ^ space
       ^____________^ list content
                     ^ end of line (carriage return)
        ^_^ task-list token (todo)

A potential solution is:

AST:
[ 
    <bullet-list-open toke-content="-   " indent="        ">,
    <inline>list content blah blah blah</inline>,
    <bullet-list-close token-content="↩">
]

as long as this AST syntax is consistent it's fine. I don't know how other parsers do it but my guess is they either emphasize speed, easy of quick lookup, ease of consumption or storage space requirements.

I think if we stick with what markdonw-it uses now, incremental changes in the token array is going to allow current plug-ins to work.

but you might not want current plug-ins to work to force plug-in upgrade, so that they are more consistent. This is a general trade-off that you might need to consider. A plug-in compatibility warning might be enough to push people to go do it right though.