onMatch method
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(InlineParser parser, Match match) {
var chars = match.match;
var char = chars.codeUnitAt(1);
// Insert the substitution. Why these three charactes are replaced with
// their equivalent HTML entity referenced appears to be missing from the
// CommonMark spec, but is very present in all of the examples.
// https://talk.commonmark.org/t/entity-ification-of-quotes-and-brackets-missing-from-spec/3207
if (parser._encodeHtml) {
if (char == $double_quote) {
parser.addNode(Text('"'));
} else if (char == $lt) {
parser.addNode(Text('<'));
} else if (char == $gt) {
parser.addNode(Text('>'));
} else {
parser.addNode(Text(chars[1]));
}
} else {
parser.addNode(Text(chars[1]));
}
return true;
}