parse method

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

Implementation

@override
Node? parse(BlockParser parser) {
  final lines = parser.linesToConsume;
  if (lines.length < 2) {
    return null;
  }

  // Remove the last line which is a marker.
  lines.removeLast();

  final marker = parser.current.content.trim();
  final level = (marker[0] == '=') ? '1' : '2';
  final content = lines.map((e) => e.content).join('\n').trimRight();

  parser.advance();
  return Element('h$level', [UnparsedContent(content)]);
}