@@ -1193,6 +1193,7 @@ crate struct RustCodeBlock {
11931193 crate code : Range < usize > ,
11941194 crate is_fenced : bool ,
11951195 crate syntax : Option < String > ,
1196+ crate is_ignore : bool ,
11961197}
11971198
11981199/// Returns a range of bytes for each code block in the markdown that is tagged as `rust` or
@@ -1208,7 +1209,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC
12081209
12091210 while let Some ( ( event, offset) ) = p. next ( ) {
12101211 if let Event :: Start ( Tag :: CodeBlock ( syntax) ) = event {
1211- let ( syntax, code_start, code_end, range, is_fenced) = match syntax {
1212+ let ( syntax, code_start, code_end, range, is_fenced, is_ignore ) = match syntax {
12121213 CodeBlockKind :: Fenced ( syntax) => {
12131214 let syntax = syntax. as_ref ( ) ;
12141215 let lang_string = if syntax. is_empty ( ) {
@@ -1219,6 +1220,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC
12191220 if !lang_string. rust {
12201221 continue ;
12211222 }
1223+ let is_ignore = lang_string. ignore != Ignore :: None ;
12221224 let syntax = if syntax. is_empty ( ) { None } else { Some ( syntax. to_owned ( ) ) } ;
12231225 let ( code_start, mut code_end) = match p. next ( ) {
12241226 Some ( ( Event :: Text ( _) , offset) ) => ( offset. start , offset. end ) ,
@@ -1229,6 +1231,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC
12291231 range : offset,
12301232 code,
12311233 syntax,
1234+ is_ignore,
12321235 } ) ;
12331236 continue ;
12341237 }
@@ -1239,14 +1242,15 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC
12391242 range : offset,
12401243 code,
12411244 syntax,
1245+ is_ignore,
12421246 } ) ;
12431247 continue ;
12441248 }
12451249 } ;
12461250 while let Some ( ( Event :: Text ( _) , offset) ) = p. next ( ) {
12471251 code_end = offset. end ;
12481252 }
1249- ( syntax, code_start, code_end, offset, true )
1253+ ( syntax, code_start, code_end, offset, true , is_ignore )
12501254 }
12511255 CodeBlockKind :: Indented => {
12521256 // The ending of the offset goes too far sometime so we reduce it by one in
@@ -1258,9 +1262,10 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC
12581262 offset. end ,
12591263 Range { start : offset. start , end : offset. end - 1 } ,
12601264 false ,
1265+ false ,
12611266 )
12621267 } else {
1263- ( None , offset. start , offset. end , offset, false )
1268+ ( None , offset. start , offset. end , offset, false , false )
12641269 }
12651270 }
12661271 } ;
@@ -1270,6 +1275,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_, '_>) -> Vec<RustC
12701275 range,
12711276 code : Range { start : code_start, end : code_end } ,
12721277 syntax,
1278+ is_ignore,
12731279 } ) ;
12741280 }
12751281 }
0 commit comments