Merge pull request #1744 from ilslv/1743-fix-title-consuming-events

Fix `SummaryParser::parse_title()` consuming events (#1743)
This commit is contained in:
Eric Huss 2022-03-27 14:38:00 -07:00 committed by GitHub
commit 15626294b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 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,18 @@ 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";