Function parse_hyperlinks::iterator::first_hyperlink
source · pub fn first_hyperlink(
i: &str
) -> Option<(Cow<'_, str>, Cow<'_, str>, Cow<'_, str>)>
Expand description
Recognizes hyperlinks in all supported markup languages
and returns the first hyperlink found as tuple:
Some((link_text, link_destination, link_title))
.
Returns None
if no hyperlink is found.
This function resolves link references.
use parse_hyperlinks::iterator::first_hyperlink;
use std::borrow::Cow;
let i = r#"abc[t][u]abc
[u]: v "w"
abc"#;
let r = first_hyperlink(i);
assert_eq!(r, Some((Cow::from("t"), Cow::from("v"), Cow::from("w"))));