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, every one of them carrying the GFM alert kind the blockquote opened with. 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.
Functions§
- is_
image - Whether a URL or a path names a picture, by the only thing either says about itself without being fetched — its extension, against what gpui can decode.
- is_url
- Whether
sourceis exactly one bare URL, and nothing else. - parse
- Parse a markdown document.
- parse_
at - Parse markdown, and say where
offsetin it landed in the document. - parse_
with parsewith the app’s own marks — seecrate::Marks.