Skip to content

Commit 1562629

Browse files
authored
Merge pull request #1744 from ilslv/1743-fix-title-consuming-events
Fix `SummaryParser::parse_title()` consuming events (#1743)
2 parents 6cab045 + b73d02f commit 1562629

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/book/summary.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,10 @@ impl<'a> SummaryParser<'a> {
536536
// Skip a HTML element such as a comment line.
537537
Some(Event::Html(_)) => {}
538538
// Otherwise, no title.
539+
Some(ev) => {
540+
self.back(ev);
541+
return None;
542+
}
539543
_ => return None,
540544
}
541545
}
@@ -647,6 +651,18 @@ mod tests {
647651
assert_eq!(got, should_be);
648652
}
649653

654+
#[test]
655+
fn no_initial_title() {
656+
let src = "[Link]()";
657+
let mut parser = SummaryParser::new(src);
658+
659+
assert!(parser.parse_title().is_none());
660+
assert!(matches!(
661+
parser.next_event(),
662+
Some(Event::Start(Tag::Paragraph))
663+
));
664+
}
665+
650666
#[test]
651667
fn parse_title_with_styling() {
652668
let src = "# My **Awesome** Summary";

0 commit comments

Comments
 (0)