tryMatch method
Tries to match at the parser's current position.
The parser's position can be overriden with startMatchPos
.
Returns whether or not the pattern successfully matched.
Implementation
bool tryMatch(InlineParser parser, [int? startMatchPos]) {
startMatchPos ??= parser.pos;
final startMatch = pattern.matchAsPrefix(parser.source, startMatchPos);
if (startMatch == null) {
return false;
}
// Write any existing plain text up to this point.
parser.writeText();
if (onMatch(parser, startMatch)) {
parser.consume(startMatch[0]!.length);
}
return true;
}