Function parse_hyperlinks_html::parser::parse::take_link[][src]

pub fn take_link(i: &str) -> IResult<&str, (&str, Link<'_>)>
Expand description

Consumes the input until the parser finds an HTML formatted hyperlink text2dest (Link::Text2Dest).

The parser consumes the finding and returns Ok((remaining_input, (skipped_input, Link))) or some error.

HTML

use parse_hyperlinks::parser::Link;
use parse_hyperlinks_html::parser::parse::take_link;
use std::borrow::Cow;

let i = "abc<a href=\"dest1\" title=\"title1\">text1</a>abc\
         abc<a href=\"dest2\" title=\"title2\">text2</a>abc";

let (i, r) = take_link(i).unwrap();
assert_eq!(r.0, "abc");
assert_eq!(r.1, Link::Text2Dest(Cow::from("text1"), Cow::from("dest1"), Cow::from("title1")));
let (i, r) = take_link(i).unwrap();
assert_eq!(r.0, "abcabc");
assert_eq!(r.1, Link::Text2Dest(Cow::from("text2"), Cow::from("dest2"), Cow::from("title2")));