diff --git a/src/inline.rs b/src/inline.rs index 41d3da0..46b2fe6 100644 --- a/src/inline.rs +++ b/src/inline.rs @@ -557,8 +557,9 @@ impl<'s> Parser<'s> { self.input.span = self.input.span.after(len); self.push(EventKind::Enter(Autolink)); self.push(EventKind::Str); + self.push(EventKind::Exit(Autolink)); self.input.span = self.input.span.after(1); - return self.push(EventKind::Exit(Autolink)); + return Some(Continue); } } None @@ -1507,22 +1508,22 @@ mod test { "", (Enter(Autolink), "https://example.com"), (Str, "https://example.com"), - (Exit(Autolink), ">") + (Exit(Autolink), "https://example.com") ); test_parse!( "", (Enter(Autolink), "a@b.c"), (Str, "a@b.c"), - (Exit(Autolink), ">"), + (Exit(Autolink), "a@b.c"), ); test_parse!( "", (Enter(Autolink), "http://a.b"), (Str, "http://a.b"), - (Exit(Autolink), ">"), + (Exit(Autolink), "http://a.b"), (Enter(Autolink), "http://c.d"), (Str, "http://c.d"), - (Exit(Autolink), ">") + (Exit(Autolink), "http://c.d"), ); test_parse!("", (Str, "")); } diff --git a/src/lib.rs b/src/lib.rs index c825214..bf9063d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1540,6 +1540,36 @@ mod test { ); } + #[test] + fn autolink() { + test_parse!( + "\n", + Start(Paragraph, Attributes::new()), + Start( + Link("proto:url".into(), LinkType::AutoLink), + Attributes::new() + ), + Str("proto:url".into()), + End(Link("proto:url".into(), LinkType::AutoLink)), + End(Paragraph), + ); + } + + #[test] + fn email() { + test_parse!( + "\n", + Start(Paragraph, Attributes::new()), + Start( + Link("name@domain".into(), LinkType::Email), + Attributes::new() + ), + Str("name@domain".into()), + End(Link("name@domain".into(), LinkType::Email)), + End(Paragraph), + ); + } + #[test] fn footnote_references() { test_parse!(