Fix no initial title consuming events.

This commit is contained in:
ilslv 2022-02-11 12:33:22 +03:00
parent 2213312938
commit 81d661c4f1
1 changed files with 13 additions and 0 deletions

View File

@ -536,6 +536,10 @@ impl<'a> SummaryParser<'a> {
// Skip a HTML element such as a comment line.
Some(Event::Html(_)) => {}
// Otherwise, no title.
Some(ev) => {
self.back(ev);
return None;
}
_ => return None,
}
}
@ -647,6 +651,15 @@ mod tests {
assert_eq!(got, should_be);
}
#[test]
fn no_initial_title() {
let src = "[Link]()";
let mut parser = SummaryParser::new(src);
assert!(parser.parse_title().is_none());
assert!(matches!(parser.next_event(), Some(Event::Start(Tag::Paragraph))));
}
#[test]
fn parse_title_with_styling() {
let src = "# My **Awesome** Summary";