Function parse_hyperlinks::parser::wikitext::wikitext_text2dest
source · pub fn wikitext_text2dest(
i: &str
) -> IResult<&str, (Cow<'_, str>, Cow<'_, str>, Cow<'_, str>)>
Expand description
Parse an Wikitext inline hyperlink.
It returns either Ok((i, (link_text, link_destination, Cow::from("")))
or some error.
The parser expects to start at the link start ([
) to succeed.
use parse_hyperlinks::parser::Link;
use parse_hyperlinks::parser::wikitext::wikitext_text2dest;
use std::borrow::Cow;
let expected = (
"abc",
(
Cow::from("W3Schools"),
Cow::from("https://www.w3schools.com/"),
Cow::from(""),
),
);
assert_eq!(
wikitext_text2dest("[https://www.w3schools.com/ W3Schools]abc").unwrap(),
expected
);