From 81d661c4f193b67f69aa5698e0367c5d1386ec7b Mon Sep 17 00:00:00 2001 From: ilslv Date: Fri, 11 Feb 2022 12:33:22 +0300 Subject: [PATCH 1/3] Fix no initial title consuming events. --- src/book/summary.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/book/summary.rs b/src/book/summary.rs index 1ade05ecac..2427a3a2b5 100644 --- a/src/book/summary.rs +++ b/src/book/summary.rs @@ -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"; From 6c4974b5c6415c7ad6ac124af5e0a3b49de96259 Mon Sep 17 00:00:00 2001 From: ilslv Date: Fri, 11 Feb 2022 12:42:54 +0300 Subject: [PATCH 2/3] Fmt --- src/book/summary.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/book/summary.rs b/src/book/summary.rs index 2427a3a2b5..b5a740c26e 100644 --- a/src/book/summary.rs +++ b/src/book/summary.rs @@ -657,7 +657,10 @@ mod tests { let mut parser = SummaryParser::new(src); assert!(parser.parse_title().is_none()); - assert!(matches!(parser.next_event(), Some(Event::Start(Tag::Paragraph)))); + assert!(matches!( + parser.next_event(), + Some(Event::Start(Tag::Paragraph)), + )); } #[test] From b73d02fb8c058f0f29c2b10a40906e1b8beff8b5 Mon Sep 17 00:00:00 2001 From: ilslv Date: Fri, 11 Feb 2022 12:50:22 +0300 Subject: [PATCH 3/3] Remove colon to satisfy msrv --- src/book/summary.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/book/summary.rs b/src/book/summary.rs index b5a740c26e..4bb8e96985 100644 --- a/src/book/summary.rs +++ b/src/book/summary.rs @@ -659,7 +659,7 @@ mod tests { assert!(parser.parse_title().is_none()); assert!(matches!( parser.next_event(), - Some(Event::Start(Tag::Paragraph)), + Some(Event::Start(Tag::Paragraph)) )); }