parse method

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

Implementation

@override
Node parse(BlockParser parser) {
  final lines = <String>[];
  late String tag;
  while (!parser.isDone) {
    final 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;
    }
  }

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

  return Element(tag, [contents]);
}