Merge pull request #1744 from ilslv/1743-fix-title-consuming-events
Fix `SummaryParser::parse_title()` consuming events (#1743)
This commit is contained in:
commit
15626294b0
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue