[][src]Function markedit::link_with_url_containing

pub fn link_with_url_containing<S: AsRef<str>>(needle: S) -> impl Matcher

Matches the start of a link who's URL contains a certain string.

Examples

use pulldown_cmark::{Event, Tag};

let src = "Some text containing [a link to google](https://google.com/).";
let mut matcher = markedit::link_with_url_containing("google.com");

let events: Vec<_> = markedit::parse(src).collect();

let ix = matcher.first_match(&events).unwrap();

match &events[ix] {
    Event::Start(Tag::Link(_, url, _)) => assert_eq!(url.as_ref(), "https://google.com/"),
    _ => unreachable!(),
}