parseChildLines method

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

Implementation

@override
List<String?> parseChildLines(BlockParser parser) {
  final childLines = <String?>[];

  while (!parser.isDone) {
    final match = pattern.firstMatch(parser.current);
    if (match != null) {
      childLines.add(match[1]);
      parser.advance();
    } else {
      // If there's a codeblock, then a newline, then a codeblock, keep the
      // code blocks together.
      final nextMatch = parser.next != null ? pattern.firstMatch(parser.next!) : null;
      if (parser.current.trim() == '' && nextMatch != null) {
        childLines
          ..add('')
          ..add(nextMatch[1]);
        parser
          ..advance()
          ..advance();
      } else {
        break;
      }
    }
  }
  return childLines;
}