parse
Parse pass: convert pulldown-cmark events into the
Block IR.enum Frame
enum FrameInternal stack frame tracking partially-parsed structures.
| Variant | Description |
|---|---|
BlockQuote { blocks: Vec<Block>, kind: Option<BlockQuoteKind> } |
An open block quote collecting its nested blocks. |
CodeBlock { content: String, lang: Option<String> } |
An open code block collecting its text verbatim. |
Emphasis(Vec<Inline>) |
An open emphasis span collecting its inlines. |
Heading { inlines: Vec<Inline>, level: HeadingLevel } |
An open heading collecting its inlines. |
Link { text: Vec<Inline>, url: String } |
An open link collecting the inlines of its visible text. |
List { .. } |
An open list; current is the item being filled, moved into items when the next item or the list ends. |
Paragraph(Vec<Inline>) |
An open paragraph collecting its inlines. |
Root(Vec<Block>) |
The bottom of the stack, holding the finished top-level blocks. |
Strong(Vec<Inline>) |
An open strong span collecting its inlines. |
fn parse
pub fn parse(input: &str) -> Vec<Block>Parse a markdown string into a flat list of top-level blocks.
| Parameter | Type | Description |
|---|---|---|
input |
&str | the markdown source, parsed with every pulldown-cmark extension enabled |
| returns | Vec<Block> | The top-level blocks in source order; nested blocks sit inside their containers. Tables and images lose their structure but keep their text; raw HTML, math, footnote references and task-list markers are dropped. |
fn push_block
fn push_block(stack: &mut [Frame], block: Block)Push a finished block into the nearest container that holds blocks.
| Parameter | Type | Description |
|---|---|---|
stack |
&mut [Frame] | the open frames, innermost last; a block goes to the root, a block quote or the current list item |
block |
Block | the finished block |
fn push_inline
fn push_inline(stack: &mut [Frame], inline: Inline)Push a finished inline into the nearest container that holds inlines.
Tight list items emit inline events without an enclosing paragraph; in that
case we lazily create a Block::Paragraph inside the current list item so
that text content is not lost.
| Parameter | Type | Description |
|---|---|---|
stack |
&mut [Frame] | the open frames, innermost last |
inline |
Inline | the finished inline element |