File tree 1 file changed +13
-5
lines changed
1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,11 @@ impl<'s> ScriptSource<'s> {
153
153
let without_spaces = rest. trim_start_matches ( [ ' ' , '\t' ] ) ;
154
154
let without_nl = without_spaces. trim_start_matches ( [ '\r' , '\n' ] ) ;
155
155
if without_nl == rest {
156
+ // nothing trimmed
156
157
break ;
158
+ } else if without_nl == without_spaces {
159
+ // frontmatter must come after a newline
160
+ return Ok ( source) ;
157
161
}
158
162
rest = without_nl;
159
163
}
@@ -468,18 +472,22 @@ fn main() {}
468
472
469
473
#[ test]
470
474
fn split_indent ( ) {
471
- assert_err (
472
- ScriptSource :: parse (
473
- r#"#!/usr/bin/env cargo
475
+ assert_source (
476
+ r#"#!/usr/bin/env cargo
474
477
---
475
478
[dependencies]
476
479
time="0.1.25"
477
480
----
478
481
479
482
fn main() {}
480
483
"# ,
481
- ) ,
482
- str![ "unexpected trailing content on closing fence: `-`" ] ,
484
+ str![ [ r##"
485
+ shebang: "#!/usr/bin/env cargo\n"
486
+ info: None
487
+ frontmatter: None
488
+ content: " ---\n [dependencies]\n time=\"0.1.25\"\n ----\n\nfn main() {}\n"
489
+
490
+ "## ] ] ,
483
491
) ;
484
492
}
485
493
You can’t perform that action at this time.
0 commit comments