parseChildLines method

  1. @override
List<String> parseChildLines(
  1. BlockParser parser
)
override

Implementation

@override
List<String> parseChildLines(BlockParser parser) {
  // Grab all of the lines that form the blockquote, stripping off the ">".
  var childLines = <String>[];

  bool encounteredCodeBlock = false;
  while (!parser.isDone) {
    var match = pattern.firstMatch(parser.current);
    if (match != null) {
      final line = match[1]!;
      childLines.add(line);
      encounteredCodeBlock = _indentPattern.hasMatch(line);
      parser.advance();
      continue;
    }

    // A paragraph continuation is OK. This is content that cannot be parsed
    // as any other syntax except Paragraph, and it doesn't match the bar in
    // a Setext header.
    // Because indented code blocks cannot interrupt paragraphs, a line
    // matched CodeBlockSyntax is also paragraph continuation text.
    final otherMatched =
        parser.blockSyntaxes.firstWhere((s) => s.canParse(parser));
    if (otherMatched is ParagraphSyntax ||
        (!encounteredCodeBlock && otherMatched is CodeBlockSyntax)) {
      childLines.add(parser.current);
      parser.advance();
    } else {
      break;
    }
  }

  return childLines;
}