Function parse_hyperlinks::parser::asciidoc::adoc_text2dest
source · pub fn adoc_text2dest(
i: &str
) -> IResult<&str, (Cow<'_, str>, Cow<'_, str>, Cow<'_, str>)>Expand description
Parses an Asciidoc inline link.
This parser expects to start at the first letter of http://,
https://, link:http:// or link:https:// (preceded by optional
whitespaces) to succeed.
When it starts at the letter h or l, the caller must guarantee, that:
- the parser is at the beginning of the input or
- the preceding byte is a newline
\nor - the preceding bytes are whitespaces or
- the preceding bytes are whitespaces or newline, followed by one of
[(<
When ist starts at a whitespace no further guarantee is required.
link_title is always the empty Cow::Borrowed("").
use parse_hyperlinks::parser::Link;
use parse_hyperlinks::parser::asciidoc::adoc_text2dest;
use std::borrow::Cow;
assert_eq!(
adoc_text2dest("https://destination[name]abc"),
Ok(("abc", (Cow::from("name"), Cow::from("https://destination"), Cow::from(""))))
);
assert_eq!(
adoc_text2dest("https://destination[]abc"),
Ok(("abc", (Cow::from("https://destination"), Cow::from("https://destination"), Cow::from(""))))
);
assert_eq!(
adoc_text2dest("https://destination abc"),
Ok((" abc", (Cow::from("https://destination"), Cow::from("https://destination"), Cow::from(""))))
);