File tree 1 file changed +6
-5
lines changed
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -176,18 +176,19 @@ impl<'s> ScriptSource<'s> {
176
176
}
177
177
_ => rest. split_at ( fence_end) ,
178
178
} ;
179
+ let nl_fence_pattern = format ! ( "\n {fence_pattern}" ) ;
179
180
let ( info, content) = rest. split_once ( "\n " ) . unwrap_or ( ( rest, "" ) ) ;
180
181
let info = info. trim ( ) ;
181
182
if !info. is_empty ( ) {
182
183
source. info = Some ( info) ;
183
184
}
184
185
source. content = content;
185
186
186
- let Some ( ( frontmatter , content ) ) = source. content . split_once ( fence_pattern ) else {
187
+ let Some ( frontmatter_nl ) = source. content . find ( & nl_fence_pattern ) else {
187
188
anyhow:: bail!( "no closing `{fence_pattern}` found for frontmatter" ) ;
188
189
} ;
189
- source. frontmatter = Some ( frontmatter ) ;
190
- source. content = content;
190
+ source. frontmatter = Some ( & source . content [ ..frontmatter_nl + 1 ] ) ;
191
+ source. content = & source . content [ frontmatter_nl + nl_fence_pattern . len ( ) .. ] ;
191
192
192
193
let ( line, content) = source
193
194
. content
@@ -543,8 +544,8 @@ fn main() {}
543
544
str![ [ r##"
544
545
shebang: "#!/usr/bin/env cargo\n"
545
546
info: None
546
- frontmatter: "Hello"
547
- content: "World\n---\n \nfn main() {}\n"
547
+ frontmatter: "Hello---\nWorld\n "
548
+ content: "\nfn main() {}\n"
548
549
549
550
"## ] ] ,
550
551
) ;
You can’t perform that action at this time.
0 commit comments