onMatch method

  1. @override
bool onMatch(
  1. InlineParser parser,
  2. Match match
)

Processes match, adding nodes to parser and possibly advancing parser.

Returns whether the caller should advance parser by match[0].length.

Implementation

@override
bool onMatch(md.InlineParser parser, Match match) {
  final display = match[2] != null || match[3] != null;
  final tex = (match[1] ?? match[2] ?? match[3] ?? match[4])!.trim();
  parser.addNode(
    md.Element.text(inlineMathTag, tex)..attributes['display'] = '$display',
  );
  return true;
}