@@ -567,11 +567,12 @@ struct SummaryLine<'a, I: Iterator<Item = Event<'a>>> {
567567 inner : I ,
568568 started : bool ,
569569 depth : u32 ,
570+ skipped_tags : u32 ,
570571}
571572
572573impl < ' a , I : Iterator < Item = Event < ' a > > > SummaryLine < ' a , I > {
573574 fn new ( iter : I ) -> Self {
574- SummaryLine { inner : iter, started : false , depth : 0 }
575+ SummaryLine { inner : iter, started : false , depth : 0 , skipped_tags : 0 }
575576 }
576577}
577578
@@ -601,13 +602,15 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
601602 let is_allowed_tag = match event {
602603 Event :: Start ( ref c) => {
603604 if is_forbidden_tag ( c) {
605+ self . skipped_tags += 1 ;
604606 return None ;
605607 }
606608 self . depth += 1 ;
607609 check_if_allowed_tag ( c)
608610 }
609611 Event :: End ( ref c) => {
610612 if is_forbidden_tag ( c) {
613+ self . skipped_tags += 1 ;
611614 return None ;
612615 }
613616 self . depth -= 1 ;
@@ -616,6 +619,9 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
616619 }
617620 _ => true ,
618621 } ;
622+ if !is_allowed_tag {
623+ self . skipped_tags += 1 ;
624+ }
619625 return if !is_allowed_tag {
620626 if is_start {
621627 Some ( Event :: Start ( Tag :: Paragraph ) )
@@ -1096,11 +1102,11 @@ impl MarkdownItemInfo<'_> {
10961102}
10971103
10981104impl MarkdownSummaryLine < ' _ > {
1099- pub ( crate ) fn into_string ( self ) -> String {
1105+ pub ( crate ) fn into_string_with_has_more_content ( self ) -> ( String , bool ) {
11001106 let MarkdownSummaryLine ( md, links) = self ;
11011107 // This is actually common enough to special-case
11021108 if md. is_empty ( ) {
1103- return String :: new ( ) ;
1109+ return ( String :: new ( ) , false ) ;
11041110 }
11051111
11061112 let mut replacer = |broken_link : BrokenLink < ' _ > | {
@@ -1110,17 +1116,26 @@ impl MarkdownSummaryLine<'_> {
11101116 . map ( |link| ( link. href . as_str ( ) . into ( ) , link. new_text . as_str ( ) . into ( ) ) )
11111117 } ;
11121118
1113- let p = Parser :: new_with_broken_link_callback ( md, summary_opts ( ) , Some ( & mut replacer) ) ;
1119+ let p = Parser :: new_with_broken_link_callback ( md, summary_opts ( ) , Some ( & mut replacer) )
1120+ . peekable ( ) ;
1121+ let mut summary = SummaryLine :: new ( p) ;
11141122
11151123 let mut s = String :: new ( ) ;
11161124
1117- let without_paragraphs = LinkReplacer :: new ( SummaryLine :: new ( p ) , links) . filter ( |event| {
1125+ let without_paragraphs = LinkReplacer :: new ( & mut summary , links) . filter ( |event| {
11181126 !matches ! ( event, Event :: Start ( Tag :: Paragraph ) | Event :: End ( Tag :: Paragraph ) )
11191127 } ) ;
11201128
11211129 html:: push_html ( & mut s, without_paragraphs) ;
11221130
1123- s
1131+ let has_more_content =
1132+ matches ! ( summary. inner. peek( ) , Some ( Event :: Start ( _) ) ) || summary. skipped_tags > 0 ;
1133+
1134+ ( s, has_more_content)
1135+ }
1136+
1137+ pub ( crate ) fn into_string ( self ) -> String {
1138+ self . into_string_with_has_more_content ( ) . 0
11241139 }
11251140}
11261141
0 commit comments