Function md_text2dest

Source
pub fn md_text2dest(
    i: &str,
) -> IResult<&str, (Cow<'_, str>, Cow<'_, str>, Cow<'_, str>)>
Expand description

Parses a Markdown inline link.

This parser expects to start at the beginning of the link [ to succeed.

use parse_hyperlinks::parser::Link;
use parse_hyperlinks::parser::markdown::md_text2dest;
use std::borrow::Cow;

assert_eq!(
  md_text2dest(r#"[text](<dest> "title")abc"#),
  Ok(("abc", (Cow::from("text"), Cow::from("dest"), Cow::from("title"))))
);

assert_eq!(
  md_text2dest(r#"<scheme:dest>abc"#),
  Ok(("abc", (Cow::from("scheme:dest"), Cow::from("scheme:dest"), Cow::from(""))))
);
assert_eq!(
  md_text2dest(r#"<foo@dest>abc"#),
  Ok(("abc", (Cow::from("foo@dest"), Cow::from("mailto:foo@dest"), Cow::from(""))))
);