collect static method

MarkdownDefinitions collect(
  1. String source, {
  2. MarkdownBlockRegistry? blockRegistry,
  3. MarkdownHtml? html,
})

Every definition in source, found where the block parser accepts one — see collectLines.

html is the HTML the parse understands, when not the default: an HTML block element decides which lines are Markdown at all.

Implementation

static MarkdownDefinitions collect(
  String source, {
  MarkdownBlockRegistry? blockRegistry,
  MarkdownHtml? html,
}) {
  // Every definition has `]:` in it. Most replies have none, and this keeps
  // the per-token cost of asking to one scan.
  if (!_hasLabelColon(source)) {
    return empty;
  }
  final lines =
      (source.contains('\r')
              ? source.replaceAll('\r\n', '\n').replaceAll('\r', '\n')
              : source)
          .split('\n');
  return collectLines(lines, blockRegistry: blockRegistry, html: html);
}