@@ -377,6 +377,10 @@ impl<'a> SummaryParser<'a> {
377
377
items. push ( item) ;
378
378
}
379
379
Some ( Event :: Start ( Tag :: List ( ..) ) ) => {
380
+ // Skip this tag after comment bacause it is not nested.
381
+ if items. is_empty ( ) {
382
+ continue ;
383
+ }
380
384
// recurse to parse the nested list
381
385
let ( _, last_item) = get_last_link ( & mut items) ?;
382
386
let last_item_number = last_item
@@ -696,6 +700,33 @@ mod tests {
696
700
assert_eq ! ( got, should_be) ;
697
701
}
698
702
703
+ #[ test]
704
+ fn parse_numbered_chapters_separated_by_comment ( ) {
705
+ let src = "- [First](./first.md)\n <!-- this is a comment -->\n - [Second](./second.md)" ;
706
+
707
+ let should_be = vec ! [
708
+ SummaryItem :: Link ( Link {
709
+ name: String :: from( "First" ) ,
710
+ location: PathBuf :: from( "./first.md" ) ,
711
+ number: Some ( SectionNumber ( vec![ 1 ] ) ) ,
712
+ nested_items: Vec :: new( ) ,
713
+ } ) ,
714
+ SummaryItem :: Link ( Link {
715
+ name: String :: from( "Second" ) ,
716
+ location: PathBuf :: from( "./second.md" ) ,
717
+ number: Some ( SectionNumber ( vec![ 2 ] ) ) ,
718
+ nested_items: Vec :: new( ) ,
719
+ } ) ,
720
+ ] ;
721
+
722
+ let mut parser = SummaryParser :: new ( src) ;
723
+ let _ = parser. stream . next ( ) ;
724
+
725
+ let got = parser. parse_numbered ( ) . unwrap ( ) ;
726
+
727
+ assert_eq ! ( got, should_be) ;
728
+ }
729
+
699
730
/// This test ensures the book will continue to pass because it breaks the
700
731
/// `SUMMARY.md` up using level 2 headers ([example]).
701
732
///
0 commit comments