plusparse/block_parser library
Block parser: walks the document line-by-line and produces block-level MdNodes, recursing into the inline parser for text content and into itself for the content of containers (list items, block quotes). Error-tolerant: it never throws on malformed or partial (streaming) input.
Containers follow CommonMark: a list item owns the lines indented to its
content column, a block quote the lines carrying its >, and either one
also takes a "lazy" line — an unmarked line that only continues the
paragraph left open inside it. The same pass, run without the inline
parser, collects the document's link and footnote definitions
(collectDefinitions), so a definition counts exactly where the parser
accepts one.
Classes
- DefinitionSink
- What collectDefinitions found.
Functions
-
collectDefinitions(
List< String> lines, MarkdownBlockRegistry? registry, [MarkdownHtml? html]) → DefinitionSink -
The definitions in
lines, found by the block pass itself: what it accepts as a definition, and every[^label]reference in the text it would hand to the inline parser, in reading order. -
documentLines(
String src) → List< String> -
srcsplit into lines: line endings normalised, and the empty line after a final line ending dropped — it is the end of the last line, not a line. -
parseBlocks(
List< String> lines, bool useDollar, [MarkdownBlockRegistry? registry, MarkdownDefinitions defs = MarkdownDefinitions.empty, MarkdownHtml? html]) → List<MdNode> -
parseDocument(
String src, bool useDollar, [MarkdownBlockRegistry? registry, MarkdownDefinitions? definitions, MarkdownHtml? html]) → MdDocument -
Parses
src. Link and footnote definitions are collected fromsrcitself unlessdefinitionsis given — the incremental view passes the whole document's, because it parses one segment at a time. -
stripBlockTags(
String t, MarkdownHtml html) → String? -
twithout the wrapper tags at its start and end —<div …>,</p>,<details>,<summary>— or null when it has none. Empty when the line was nothing but such tags.