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
@override
bool tryMatch(InlineParser parser, [int? startMatchPos]) {
if (parser.pos > 0 && parser.charAt(parser.pos - 1) == $backquote) {
// Not really a match! We can't just sneak past one backtick to try the
// next character. An example of this situation would be:
//
// before ``` and `` after.
// ^--parser.pos
return false;
}
var match = pattern.matchAsPrefix(parser.source!, parser.pos);
if (match == null) {
return false;
}
parser.writeText();
if (onMatch(parser, match)) parser.consume(match.match.length);
return true;
}