Function parse_hyperlinks_extras::parser::parse::take_img[][src]

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

Consumes the input until the parser finds an HTML formatted inline image (Link::Image).

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_extras::parser::parse::take_img;
use std::borrow::Cow;

let i = r#"abc<img src="destination1" alt="text1">abc
abc<img src="destination2" alt="text2">abc
"#;

let (i, r) = take_img(i).unwrap();
assert_eq!(r.0, "abc");
assert_eq!(r.1, Link::Image(Cow::from("text1"), Cow::from("destination1")));
let (i, r) = take_img(i).unwrap();
assert_eq!(r.0, "abc\nabc");
assert_eq!(r.1, Link::Image(Cow::from("text2"), Cow::from("destination2")));