File tree Expand file tree Collapse file tree 1 file changed +80
-2
lines changed Expand file tree Collapse file tree 1 file changed +80
-2
lines changed Original file line number Diff line number Diff line change @@ -217,17 +217,29 @@ fn split_source(input: &str) -> CargoResult<Source<'_>> {
217
217
source. content = content;
218
218
}
219
219
220
+ // Experiment: let us try which char works better
221
+ let tick_char = source
222
+ . content
223
+ . chars ( )
224
+ . filter ( |c| [ '`' , '#' , '-' ] . contains ( c) )
225
+ . next ( )
226
+ . unwrap_or ( '`' ) ;
227
+
220
228
let tick_end = source
221
229
. content
222
230
. char_indices ( )
223
- . find_map ( |( i, c) | ( c != '`' ) . then_some ( i) )
231
+ . find_map ( |( i, c) | ( c != tick_char ) . then_some ( i) )
224
232
. unwrap_or ( source. content . len ( ) ) ;
225
233
let ( fence_pattern, rest) = match tick_end {
226
234
0 => {
227
235
return Ok ( source) ;
228
236
}
229
237
1 | 2 => {
230
- anyhow:: bail!( "found {tick_end} backticks in rust frontmatter, expected at least 3" )
238
+ if tick_char == '#' {
239
+ // Attribute
240
+ return Ok ( source) ;
241
+ }
242
+ anyhow:: bail!( "found {tick_end} `{tick_char}` in rust frontmatter, expected at least 3" )
231
243
}
232
244
_ => source. content . split_at ( tick_end) ,
233
245
} ;
@@ -358,6 +370,72 @@ strip = true
358
370
time="0.1.25"
359
371
```
360
372
fn main() {}
373
+ "# ) ,
374
+ ) ;
375
+ }
376
+
377
+ #[ test]
378
+ fn test_dash ( ) {
379
+ snapbox:: assert_matches (
380
+ r#"[[bin]]
381
+ name = "test-"
382
+ path = [..]
383
+
384
+ [dependencies]
385
+ time = "0.1.25"
386
+
387
+ [package]
388
+ autobenches = false
389
+ autobins = false
390
+ autoexamples = false
391
+ autotests = false
392
+ build = false
393
+ edition = "2021"
394
+ name = "test-"
395
+
396
+ [profile.release]
397
+ strip = true
398
+
399
+ [workspace]
400
+ "# ,
401
+ si ! ( r#"---
402
+ [dependencies]
403
+ time="0.1.25"
404
+ ---
405
+ fn main() {}
406
+ "# ) ,
407
+ ) ;
408
+ }
409
+
410
+ #[ test]
411
+ fn test_hash ( ) {
412
+ snapbox:: assert_matches (
413
+ r#"[[bin]]
414
+ name = "test-"
415
+ path = [..]
416
+
417
+ [dependencies]
418
+ time = "0.1.25"
419
+
420
+ [package]
421
+ autobenches = false
422
+ autobins = false
423
+ autoexamples = false
424
+ autotests = false
425
+ build = false
426
+ edition = "2021"
427
+ name = "test-"
428
+
429
+ [profile.release]
430
+ strip = true
431
+
432
+ [workspace]
433
+ "# ,
434
+ si ! ( r#"###
435
+ [dependencies]
436
+ time="0.1.25"
437
+ ###
438
+ fn main() {}
361
439
"# ) ,
362
440
) ;
363
441
}
You can’t perform that action at this time.
0 commit comments