@@ -1266,8 +1266,7 @@ crate struct RustCodeBlock {
12661266 /// The range in the markdown that the code within the code block occupies.
12671267 crate code : Range < usize > ,
12681268 crate is_fenced : bool ,
1269- crate syntax : Option < String > ,
1270- crate is_ignore : bool ,
1269+ crate lang_string : LangString ,
12711270}
12721271
12731272/// Returns a range of bytes for each code block in the markdown that is tagged as `rust` or
@@ -1283,7 +1282,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
12831282
12841283 while let Some ( ( event, offset) ) = p. next ( ) {
12851284 if let Event :: Start ( Tag :: CodeBlock ( syntax) ) = event {
1286- let ( syntax , code_start, code_end, range, is_fenced, is_ignore ) = match syntax {
1285+ let ( lang_string , code_start, code_end, range, is_fenced) = match syntax {
12871286 CodeBlockKind :: Fenced ( syntax) => {
12881287 let syntax = syntax. as_ref ( ) ;
12891288 let lang_string = if syntax. is_empty ( ) {
@@ -1294,8 +1293,6 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
12941293 if !lang_string. rust {
12951294 continue ;
12961295 }
1297- let is_ignore = lang_string. ignore != Ignore :: None ;
1298- let syntax = if syntax. is_empty ( ) { None } else { Some ( syntax. to_owned ( ) ) } ;
12991296 let ( code_start, mut code_end) = match p. next ( ) {
13001297 Some ( ( Event :: Text ( _) , offset) ) => ( offset. start , offset. end ) ,
13011298 Some ( ( _, sub_offset) ) => {
@@ -1304,8 +1301,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
13041301 is_fenced : true ,
13051302 range : offset,
13061303 code,
1307- syntax,
1308- is_ignore,
1304+ lang_string,
13091305 } ) ;
13101306 continue ;
13111307 }
@@ -1315,31 +1311,29 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
13151311 is_fenced : true ,
13161312 range : offset,
13171313 code,
1318- syntax,
1319- is_ignore,
1314+ lang_string,
13201315 } ) ;
13211316 continue ;
13221317 }
13231318 } ;
13241319 while let Some ( ( Event :: Text ( _) , offset) ) = p. next ( ) {
13251320 code_end = offset. end ;
13261321 }
1327- ( syntax , code_start, code_end, offset, true , is_ignore )
1322+ ( lang_string , code_start, code_end, offset, true )
13281323 }
13291324 CodeBlockKind :: Indented => {
13301325 // The ending of the offset goes too far sometime so we reduce it by one in
13311326 // these cases.
13321327 if offset. end > offset. start && md. get ( offset. end ..=offset. end ) == Some ( & "\n " ) {
13331328 (
1334- None ,
1329+ LangString :: default ( ) ,
13351330 offset. start ,
13361331 offset. end ,
13371332 Range { start : offset. start , end : offset. end - 1 } ,
13381333 false ,
1339- false ,
13401334 )
13411335 } else {
1342- ( None , offset. start , offset. end , offset, false , false )
1336+ ( LangString :: default ( ) , offset. start , offset. end , offset, false )
13431337 }
13441338 }
13451339 } ;
@@ -1348,8 +1342,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
13481342 is_fenced,
13491343 range,
13501344 code : Range { start : code_start, end : code_end } ,
1351- syntax,
1352- is_ignore,
1345+ lang_string,
13531346 } ) ;
13541347 }
13551348 }
0 commit comments