@@ -567,11 +567,12 @@ struct SummaryLine<'a, I: Iterator<Item = Event<'a>>> {
567
567
inner : I ,
568
568
started : bool ,
569
569
depth : u32 ,
570
+ skipped_tags : u32 ,
570
571
}
571
572
572
573
impl < ' a , I : Iterator < Item = Event < ' a > > > SummaryLine < ' a , I > {
573
574
fn new ( iter : I ) -> Self {
574
- SummaryLine { inner : iter, started : false , depth : 0 }
575
+ SummaryLine { inner : iter, started : false , depth : 0 , skipped_tags : 0 }
575
576
}
576
577
}
577
578
@@ -601,13 +602,15 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
601
602
let is_allowed_tag = match event {
602
603
Event :: Start ( ref c) => {
603
604
if is_forbidden_tag ( c) {
605
+ self . skipped_tags += 1 ;
604
606
return None ;
605
607
}
606
608
self . depth += 1 ;
607
609
check_if_allowed_tag ( c)
608
610
}
609
611
Event :: End ( ref c) => {
610
612
if is_forbidden_tag ( c) {
613
+ self . skipped_tags += 1 ;
611
614
return None ;
612
615
}
613
616
self . depth -= 1 ;
@@ -616,6 +619,9 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
616
619
}
617
620
_ => true ,
618
621
} ;
622
+ if !is_allowed_tag {
623
+ self . skipped_tags += 1 ;
624
+ }
619
625
return if !is_allowed_tag {
620
626
if is_start {
621
627
Some ( Event :: Start ( Tag :: Paragraph ) )
@@ -1096,11 +1102,11 @@ impl MarkdownItemInfo<'_> {
1096
1102
}
1097
1103
1098
1104
impl MarkdownSummaryLine < ' _ > {
1099
- pub ( crate ) fn into_string ( self ) -> String {
1105
+ pub ( crate ) fn into_string_with_has_more_content ( self ) -> ( String , bool ) {
1100
1106
let MarkdownSummaryLine ( md, links) = self ;
1101
1107
// This is actually common enough to special-case
1102
1108
if md. is_empty ( ) {
1103
- return String :: new ( ) ;
1109
+ return ( String :: new ( ) , false ) ;
1104
1110
}
1105
1111
1106
1112
let mut replacer = |broken_link : BrokenLink < ' _ > | {
@@ -1110,17 +1116,26 @@ impl MarkdownSummaryLine<'_> {
1110
1116
. map ( |link| ( link. href . as_str ( ) . into ( ) , link. new_text . as_str ( ) . into ( ) ) )
1111
1117
} ;
1112
1118
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) ;
1114
1122
1115
1123
let mut s = String :: new ( ) ;
1116
1124
1117
- let without_paragraphs = LinkReplacer :: new ( SummaryLine :: new ( p ) , links) . filter ( |event| {
1125
+ let without_paragraphs = LinkReplacer :: new ( & mut summary , links) . filter ( |event| {
1118
1126
!matches ! ( event, Event :: Start ( Tag :: Paragraph ) | Event :: End ( Tag :: Paragraph ) )
1119
1127
} ) ;
1120
1128
1121
1129
html:: push_html ( & mut s, without_paragraphs) ;
1122
1130
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
1124
1139
}
1125
1140
}
1126
1141
0 commit comments