collectLines static method
MarkdownDefinitions
collectLines(
- List<
String> lines, { - MarkdownBlockRegistry? blockRegistry,
- MarkdownHtml? html,
collect over a document already split into lines.
The block parser's own pass finds them, without parsing any inline content, so a definition counts exactly where the parser consumes one: at the start of a block, inside quotes and list items too, and never in fenced code, block maths, HTML comments or custom blocks. The first definition of a label wins.
Implementation
static MarkdownDefinitions collectLines(
List<String> lines, {
MarkdownBlockRegistry? blockRegistry,
MarkdownHtml? html,
}) {
// Every definition has `]:` in it, and most documents have none.
if (!lines.any(_hasLabelColon)) {
return empty;
}
final found = collectDefinitions(lines, blockRegistry, html);
if (found.links.isEmpty && found.footnoteDefinitions.isEmpty) {
return empty;
}
final footnotes = <String, int>{};
for (final label in found.referenced) {
if (found.footnoteDefinitions.contains(label)) {
footnotes[label] = footnotes.length + 1;
}
}
return MarkdownDefinitions._(
found.links,
footnotes,
found.footnoteDefinitions,
null,
);
}