@@ -599,10 +599,19 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
599599 let mut ignore = false ;
600600 let mut edition = None ;
601601 let mut ticks_unbalanced = false ;
602- let mut text_to_check: Vec < ( CowStr < ' _ > , Range < usize > ) > = Vec :: new ( ) ;
602+ let mut text_to_check: Vec < ( CowStr < ' _ > , Range < usize > , isize ) > = Vec :: new ( ) ;
603603 let mut paragraph_range = 0 ..0 ;
604+ let mut code_level = 0 ;
605+
604606 for ( event, range) in events {
605607 match event {
608+ Html ( tag) => {
609+ if tag. starts_with ( "<code" ) {
610+ code_level += 1 ;
611+ } else if tag. starts_with ( "</code" ) {
612+ code_level -= 1 ;
613+ }
614+ } ,
606615 Start ( CodeBlock ( ref kind) ) => {
607616 in_code = true ;
608617 if let CodeBlockKind :: Fenced ( lang) = kind {
@@ -652,16 +661,15 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
652661 "a backtick may be missing a pair" ,
653662 ) ;
654663 } else {
655- for ( text, range) in text_to_check {
664+ for ( text, range, assoc_code_level ) in text_to_check {
656665 if let Some ( span) = fragments. span ( cx, range) {
657- markdown:: check ( cx, valid_idents, & text, span) ;
666+ markdown:: check ( cx, valid_idents, & text, span, assoc_code_level ) ;
658667 }
659668 }
660669 }
661670 text_to_check = Vec :: new ( ) ;
662671 } ,
663672 Start ( _tag) | End ( _tag) => ( ) , // We don't care about other tags
664- Html ( _html) => ( ) , // HTML is weird, just ignore it
665673 SoftBreak | HardBreak | TaskListMarker ( _) | Code ( _) | Rule => ( ) ,
666674 FootnoteReference ( text) | Text ( text) => {
667675 paragraph_range. end = range. end ;
@@ -694,7 +702,7 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
694702 // Don't check the text associated with external URLs
695703 continue ;
696704 }
697- text_to_check. push ( ( text, range) ) ;
705+ text_to_check. push ( ( text, range, code_level ) ) ;
698706 }
699707 } ,
700708 }
0 commit comments