@@ -1266,8 +1266,7 @@ crate struct RustCodeBlock {
1266
1266
/// The range in the markdown that the code within the code block occupies.
1267
1267
crate code : Range < usize > ,
1268
1268
crate is_fenced : bool ,
1269
- crate syntax : Option < String > ,
1270
- crate is_ignore : bool ,
1269
+ crate lang_string : LangString ,
1271
1270
}
1272
1271
1273
1272
/// 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
1283
1282
1284
1283
while let Some ( ( event, offset) ) = p. next ( ) {
1285
1284
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 {
1287
1286
CodeBlockKind :: Fenced ( syntax) => {
1288
1287
let syntax = syntax. as_ref ( ) ;
1289
1288
let lang_string = if syntax. is_empty ( ) {
@@ -1294,8 +1293,6 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
1294
1293
if !lang_string. rust {
1295
1294
continue ;
1296
1295
}
1297
- let is_ignore = lang_string. ignore != Ignore :: None ;
1298
- let syntax = if syntax. is_empty ( ) { None } else { Some ( syntax. to_owned ( ) ) } ;
1299
1296
let ( code_start, mut code_end) = match p. next ( ) {
1300
1297
Some ( ( Event :: Text ( _) , offset) ) => ( offset. start , offset. end ) ,
1301
1298
Some ( ( _, sub_offset) ) => {
@@ -1304,8 +1301,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
1304
1301
is_fenced : true ,
1305
1302
range : offset,
1306
1303
code,
1307
- syntax,
1308
- is_ignore,
1304
+ lang_string,
1309
1305
} ) ;
1310
1306
continue ;
1311
1307
}
@@ -1315,31 +1311,29 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
1315
1311
is_fenced : true ,
1316
1312
range : offset,
1317
1313
code,
1318
- syntax,
1319
- is_ignore,
1314
+ lang_string,
1320
1315
} ) ;
1321
1316
continue ;
1322
1317
}
1323
1318
} ;
1324
1319
while let Some ( ( Event :: Text ( _) , offset) ) = p. next ( ) {
1325
1320
code_end = offset. end ;
1326
1321
}
1327
- ( syntax , code_start, code_end, offset, true , is_ignore )
1322
+ ( lang_string , code_start, code_end, offset, true )
1328
1323
}
1329
1324
CodeBlockKind :: Indented => {
1330
1325
// The ending of the offset goes too far sometime so we reduce it by one in
1331
1326
// these cases.
1332
1327
if offset. end > offset. start && md. get ( offset. end ..=offset. end ) == Some ( & "\n " ) {
1333
1328
(
1334
- None ,
1329
+ LangString :: default ( ) ,
1335
1330
offset. start ,
1336
1331
offset. end ,
1337
1332
Range { start : offset. start , end : offset. end - 1 } ,
1338
1333
false ,
1339
- false ,
1340
1334
)
1341
1335
} else {
1342
- ( None , offset. start , offset. end , offset, false , false )
1336
+ ( LangString :: default ( ) , offset. start , offset. end , offset, false )
1343
1337
}
1344
1338
}
1345
1339
} ;
@@ -1348,8 +1342,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
1348
1342
is_fenced,
1349
1343
range,
1350
1344
code : Range { start : code_start, end : code_end } ,
1351
- syntax,
1352
- is_ignore,
1345
+ lang_string,
1353
1346
} ) ;
1354
1347
}
1355
1348
}
0 commit comments