@@ -339,6 +339,20 @@ impl<'a, I: Iterator<Item = Event<'a>>> SummaryLine<'a, I> {
339
339
}
340
340
}
341
341
342
+ fn check_if_allowed_tag ( t : & Tag ) -> bool {
343
+ match * t {
344
+ Tag :: Paragraph
345
+ | Tag :: CodeBlock ( _)
346
+ | Tag :: Item
347
+ | Tag :: Emphasis
348
+ | Tag :: Strong
349
+ | Tag :: Code
350
+ | Tag :: Link ( _, _)
351
+ | Tag :: BlockQuote => true ,
352
+ _ => false ,
353
+ }
354
+ }
355
+
342
356
impl < ' a , I : Iterator < Item = Event < ' a > > > Iterator for SummaryLine < ' a , I > {
343
357
type Item = Event < ' a > ;
344
358
@@ -350,12 +364,28 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for SummaryLine<'a, I> {
350
364
self . started = true ;
351
365
}
352
366
let event = self . inner . next ( ) ;
353
- match event {
354
- Some ( Event :: Start ( ..) ) => self . depth += 1 ,
355
- Some ( Event :: End ( ..) ) => self . depth -= 1 ,
356
- _ => { }
367
+ let mut is_start = true ;
368
+ let is_allowed_tag = match event {
369
+ Some ( Event :: Start ( ref c) ) => {
370
+ self . depth += 1 ;
371
+ check_if_allowed_tag ( c)
372
+ }
373
+ Some ( Event :: End ( ref c) ) => {
374
+ self . depth -= 1 ;
375
+ is_start = false ;
376
+ check_if_allowed_tag ( c)
377
+ }
378
+ _ => true ,
379
+ } ;
380
+ if is_allowed_tag == false {
381
+ if is_start {
382
+ Some ( Event :: Start ( Tag :: Paragraph ) )
383
+ } else {
384
+ Some ( Event :: End ( Tag :: Paragraph ) )
385
+ }
386
+ } else {
387
+ event
357
388
}
358
- event
359
389
}
360
390
}
361
391
@@ -688,8 +718,7 @@ impl<'a> fmt::Display for MarkdownSummaryLine<'a> {
688
718
}
689
719
} ;
690
720
691
- let p = Parser :: new_with_broken_link_callback ( md, Options :: empty ( ) ,
692
- Some ( & replacer) ) ;
721
+ let p = Parser :: new_with_broken_link_callback ( md, Options :: empty ( ) , Some ( & replacer) ) ;
693
722
694
723
let mut s = String :: new ( ) ;
695
724
0 commit comments