@@ -1316,8 +1316,7 @@ crate struct RustCodeBlock {
1316
1316
/// The range in the markdown that the code within the code block occupies.
1317
1317
crate code : Range < usize > ,
1318
1318
crate is_fenced : bool ,
1319
- crate syntax : Option < String > ,
1320
- crate is_ignore : bool ,
1319
+ crate lang_string : LangString ,
1321
1320
}
1322
1321
1323
1322
/// Returns a range of bytes for each code block in the markdown that is tagged as `rust` or
@@ -1333,7 +1332,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
1333
1332
1334
1333
while let Some ( ( event, offset) ) = p. next ( ) {
1335
1334
if let Event :: Start ( Tag :: CodeBlock ( syntax) ) = event {
1336
- let ( syntax , code_start, code_end, range, is_fenced, is_ignore ) = match syntax {
1335
+ let ( lang_string , code_start, code_end, range, is_fenced) = match syntax {
1337
1336
CodeBlockKind :: Fenced ( syntax) => {
1338
1337
let syntax = syntax. as_ref ( ) ;
1339
1338
let lang_string = if syntax. is_empty ( ) {
@@ -1344,8 +1343,6 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
1344
1343
if !lang_string. rust {
1345
1344
continue ;
1346
1345
}
1347
- let is_ignore = lang_string. ignore != Ignore :: None ;
1348
- let syntax = if syntax. is_empty ( ) { None } else { Some ( syntax. to_owned ( ) ) } ;
1349
1346
let ( code_start, mut code_end) = match p. next ( ) {
1350
1347
Some ( ( Event :: Text ( _) , offset) ) => ( offset. start , offset. end ) ,
1351
1348
Some ( ( _, sub_offset) ) => {
@@ -1354,8 +1351,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
1354
1351
is_fenced : true ,
1355
1352
range : offset,
1356
1353
code,
1357
- syntax,
1358
- is_ignore,
1354
+ lang_string,
1359
1355
} ) ;
1360
1356
continue ;
1361
1357
}
@@ -1365,31 +1361,29 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
1365
1361
is_fenced : true ,
1366
1362
range : offset,
1367
1363
code,
1368
- syntax,
1369
- is_ignore,
1364
+ lang_string,
1370
1365
} ) ;
1371
1366
continue ;
1372
1367
}
1373
1368
} ;
1374
1369
while let Some ( ( Event :: Text ( _) , offset) ) = p. next ( ) {
1375
1370
code_end = offset. end ;
1376
1371
}
1377
- ( syntax , code_start, code_end, offset, true , is_ignore )
1372
+ ( lang_string , code_start, code_end, offset, true )
1378
1373
}
1379
1374
CodeBlockKind :: Indented => {
1380
1375
// The ending of the offset goes too far sometime so we reduce it by one in
1381
1376
// these cases.
1382
1377
if offset. end > offset. start && md. get ( offset. end ..=offset. end ) == Some ( & "\n " ) {
1383
1378
(
1384
- None ,
1379
+ LangString :: default ( ) ,
1385
1380
offset. start ,
1386
1381
offset. end ,
1387
1382
Range { start : offset. start , end : offset. end - 1 } ,
1388
1383
false ,
1389
- false ,
1390
1384
)
1391
1385
} else {
1392
- ( None , offset. start , offset. end , offset, false , false )
1386
+ ( LangString :: default ( ) , offset. start , offset. end , offset, false )
1393
1387
}
1394
1388
}
1395
1389
} ;
@@ -1398,8 +1392,7 @@ crate fn rust_code_blocks(md: &str, extra_info: &ExtraInfo<'_>) -> Vec<RustCodeB
1398
1392
is_fenced,
1399
1393
range,
1400
1394
code : Range { start : code_start, end : code_end } ,
1401
- syntax,
1402
- is_ignore,
1395
+ lang_string,
1403
1396
} ) ;
1404
1397
}
1405
1398
}
0 commit comments