parse method

  1. @override
Node parse(
  1. BlockParser parser
)
override

Implementation

@override
Node parse(BlockParser parser) {
  var lines = <String>[];
  String? tag;
  while (!parser.isDone) {
    var match = _setextPattern.firstMatch(parser.current);
    if (match == null) {
      // More text.
      lines.add(parser.current);
      parser.advance();
      continue;
    } else {
      // The underline.
      tag = (match[1]![0] == '=') ? 'h1' : 'h2';
      parser.advance();
      break;
    }
  }

  var contents = UnparsedContent(lines.join('\n').trimRight());

  return Element(tag!, [contents]);
}