parseChildLines method

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

Implementation

@override
List<Line> parseChildLines(BlockParser parser) {
  final children = <String>[];
  // As one empty line should not split footnote definition, use this flag.
  var shouldBeBlock = false;
  late final syntaxList = parser.blockSyntaxes
      .where((s) => !_excludingPattern.contains(s.pattern));

  // Every line is footnote's children util two blank lines or a block.
  while (!parser.isDone) {
    final line = parser.current.content;
    if (line.trim().isEmpty) {
      children.add(line);
      parser.advance();
      shouldBeBlock = true;
      continue;
    } else if (line.startsWith('    ')) {
      children.add(line.substring(4));
      parser.advance();
      shouldBeBlock = false;
    } else if (shouldBeBlock || _isBlock(syntaxList, line)) {
      break;
    } else {
      children.add(line);
      parser.advance();
    }
  }
  return children.map(Line.new).toList(growable: false);
}