gfm-autolinks
A GitHub-flavored Markdown autolink matcher: https://github.github.com/gfm/#autolinks-extension-.
Usage
The match_start function matches from the start of the string,
and returns None or the generated autolink, and the number of characters matched.
use match_start;
match_start
// returns None
match_start
// returns Some(("http://example.com", 18))
match_start
// returns Some(("http://www.example.com", 15))
match_start
// returns Some(("mailto:me@hotmail.com", 14))
The match_index function matches from a given index,
and also returns None or the generated autolink, and the number of characters matched.
If the index is not 0, it will also apply the rule,
that the autolink must be preceded by a whitespace character or one of * _ ~ (.
Invalid index will return None.
use match_index;
match_index
// returns None
match_index
// returns Some(("http://www.example.com", 18))
match_index
// returns None
Note, no HTML escaping is performed, e.g.
use match_start;
match_start
// returns Some(("http://example.com?foo=bar&baz=qux", 34))
Acknowledgements
Originally adapted from comrak.