onMatch method

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

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) {
  final url = match[1]!;
  final text = parser.encodeHtml ? escapeHtml(url) : url;
  final anchor = Element.text('a', text);

  final destination = normalizeLinkDestination(url);
  anchor.attributes['href'] =
      parser.encodeHtml ? escapeHtml(destination) : destination;
  parser.addNode(anchor);

  return true;
}