Skip to main content

Crate markdown_stream

Crate markdown_stream 

Source
Expand description

markdown-stream — an incremental, streaming CommonMark/GFM parser.

Pure std, no runtime dependencies. Feed bytes to a StreamParser with Parser::write and consume the flat Event stream it emits; call Parser::flush at end of input. The event stream is independent of how the input is chunked (split-equivalence) — this is what makes the parser usable on a live token stream from an LLM.

The parser is append-only and chunk-safe; renderers (markdown-html, markdown-terminal) consume the events and never re-parse Markdown.

Structs§

BlockData
Variant-specific payload for an EnterBlock event. Defaults are empty/zero for blocks that carry no extra data (paragraphs, blockquotes, …).
InlineStyle
Inline styling carried on a Text event. Multiple flags may apply at once (e.g. bold + italic). link is set for text inside a link/image.
Link
A link or image target carried on a styled Text event.
ListData
List metadata carried on an EnterBlock(List) event.
Span
A byte range in the source, with the 1-based line/column of its start.
StreamParser

Enums§

Alignment
Column alignment for GFM table columns.
BlockKind
The kind of block an EnterBlock/ExitBlock event refers to.
Event
One parser event. The stream is a depth-first walk: every EnterBlock is eventually balanced by an ExitBlock of the same kind.
Inline
The kind of inline span an EnterInline/ExitInline event opens or closes.

Traits§

Parser
An incremental, chunk-safe Markdown parser.

Functions§

parse
Parse a complete document to a Vec<Event> (convenience over the streaming API).
parse_gfm
Parse a complete document with GFM-only extensions enabled (extended autolinks, task-list items), in addition to the always-on strikethrough and tables.