onMatch method

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

Adds a Text node to parser and returns true if there is a substitute, as long as the preceding character (if any) is not a /.

Otherwise, the parser is advanced by the length of match and false is returned.

Implementation

@override
bool onMatch(InlineParser parser, Match match) {
  if (substitute.isEmpty ||
      (match.start > 0 &&
          match.input.substring(match.start - 1, match.start) == '/')) {
    // Just use the original matched text.
    parser.advanceBy(match.match.length);
    return false;
  }

  // Insert the substitution.
  parser.addNode(Text(substitute));
  return true;
}