match method

MarkdownBlockMatch? match(
  1. List<String> lines,
  2. int startLine
)

Implementation

MarkdownBlockMatch? match(List<String> lines, int startLine) {
  final line = lines[startLine].trimLeft();
  if (line.isEmpty) return null;
  final candidates = _dispatch[line.codeUnitAt(0)];
  if (candidates == null) return null;
  for (final syntax in candidates) {
    if (!line.startsWith(syntax.prefix)) continue;
    final result = syntax.parse(lines, startLine);
    if (result == null) continue;
    if (result.endLine <= startLine ||
        result.endLine > lines.length ||
        result.node.type != syntax.type) {
      throw StateError('Invalid block match from ${syntax.type}.');
    }
    return result;
  }
  return null;
}