Skip to content

Commit 378bc91

Browse files
committed
fix(frontmatter): Be more precise in multi-frontmatter error
1 parent e49cd3d commit 378bc91

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/cargo/util/frontmatter.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,15 @@ impl<'s> ScriptSource<'s> {
120120

121121
source.content = content_start..content_end;
122122

123-
let repeat = Self::parse(source.content())?;
124-
if repeat.frontmatter.is_some() {
123+
if let Some(nl_end) = strip_ws_lines(input.as_ref()) {
124+
let _ = input.next_slice(nl_end);
125+
}
126+
let fence_length = input
127+
.as_ref()
128+
.char_indices()
129+
.find_map(|(i, c)| (c != FENCE_CHAR).then_some(i))
130+
.unwrap_or_else(|| input.eof_offset());
131+
if 0 < fence_length {
125132
return Err(FrontmatterError::new(format!(
126133
"only one frontmatter is supported"
127134
)));

0 commit comments

Comments
 (0)