[][src]Function parse_hyperlinks::parser::asciidoc::adoc_link

pub fn adoc_link(
    i: &str
) -> IResult<&str, (Cow<'_, str>, Cow<'_, str>, Cow<'_, str>)>

Parses an Asciidoc link. The parser returns either Ok((i, (link_text, link_destination, link_title))) or some error. link_title is always the empty Cow::Borrowed("").

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 \n.

When ist starts at a whitespace no further guarantee is required.

use parse_hyperlinks::parser::asciidoc::adoc_link;
use std::borrow::Cow;

assert_eq!(
  adoc_link(r#"https://destination[name]abc"#),
  Ok(("abc", (Cow::from("name"), Cow::from("https://destination"), Cow::from(""))))
);