parser library
An incremental Markdown parser designed for LLM output that arrives in small chunks.
This library imports nothing from Flutter, so it can run in isolates,
tests and Dart scripts. The package as a whole depends on the Flutter SDK,
so a project using it must be built with Flutter installed. Flutter apps
normally import llm_markdown_renderer.dart, which re-exports everything
here.
Classes
- Block
- A block-level Markdown node.
- BlockQuoteBlock
-
A block quote:
> text. - CodeBlock
-
A fenced (
```) or indented code block. - CodeHighlighter
- Turns lines of source code into syntax Tokens.
- HeadingBlock
-
An ATX (
# Title) or setext heading. - IncrementalMarkdownParser
- Parses Markdown incrementally, as it is streamed in chunks.
- Inline
- A node of inline Markdown content (text, emphasis, links, …).
- InlineCitation
-
A citation marker such as
[1],[1, 2]or[^1], as emitted by models that cite sources. - InlineCode
-
An inline code span:
`code`. - InlineEmphasis
-
Emphasized (usually italic) content:
*text*or_text_. - InlineImage
-
An image:
. - InlineLineBreak
- A hard line break (two trailing spaces or a trailing backslash).
- InlineLink
-
A hyperlink:
[label](url "title"),<url>or a barehttps://URL. - InlineMath
-
LaTeX math:
$…$or\(…\)inline,$$…$$in display style. - InlineSoftBreak
- A soft line break: a single newline inside a paragraph.
- InlineStrikethrough
-
Struck-through content:
~~text~~. - InlineStrong
-
Strongly emphasized (usually bold) content:
**text**. - InlineText
- A run of literal text.
- LanguageDefinition
- A language described as a set of named lexer states.
- LexRule
-
One lexing rule: when
patternmatches at the current position, the match becomes a token of kind and lexing continues in state next (or stays in the current state whennull). - LineHighlight
- The result of highlighting one line.
- ListBlock
- An ordered or unordered list.
- ListItem
- One item of a ListBlock.
- MarkdownDocument
- An immutable snapshot of a parsed (possibly still streaming) document.
- MarkdownParserOptions
- Feature switches for the Markdown parser.
- MathBlock
-
A display math block:
$$or\[alone on a line, up to the matching$$or\], or a whole line such as$$E=mc^2$$. - ParagraphBlock
- A paragraph of inline content.
- RuleBasedHighlighter
- A CodeHighlighter driven by small regular-expression lexers.
- TableBlock
- A GitHub-flavoured Markdown table.
- ThematicBreakBlock
-
A thematic break:
---,***or___. - ThinkingBlock
-
The reasoning of a "thinking" model:
<think>…</think>(or<thinking>…</thinking>), as emitted by DeepSeek R1, Qwen and others. - Token
-
A highlighted slice
[start, end)of a single line.
Enums
- TableAlignment
- Horizontal alignment of a table column.
- TokenKind
- The syntactic category of a Token, used to pick a colour from the theme.