Expand description
Markdown → Doc.
CommonMark nests; a Doc does not. Indent counts list nesting only:
- a list item’s first paragraph becomes its marker block (bullet, ordered, task) at one level shallower than the open list count, and anything else in that item becomes a child at the list count itself;
- a blockquote’s paragraphs each become a
BlockKind::Quote. Being inside a quote decides a block’s kind, never its depth — an indent a blockquote contributed could not be reproduced in the output, and the document would move every time it was read; - everything else keeps its kind at the open list count.
Mixed containers therefore flatten: > - a yields a bullet and loses the
quote. That is the cost of the flat model, and the fixed-point test in
[crate::serialize] is what keeps it from mattering — whatever the first
parse decides is stable from then on.
The parse also normalizes what markdown itself would not preserve: leading and trailing whitespace per line, blank lines at a block’s edges, headings and table cells flattened to one line, and ordered runs renumbered consecutively. Each of those is a place where writing the document back out and reading it again would otherwise land somewhere new.