fix(frontmatter): Be more specific about trailing character span

This commit is contained in:
Ed Page 2025-09-16 11:43:20 -05:00
parent 5b4d0cfad8
commit b674a60384
2 changed files with 6 additions and 6 deletions

View File

@ -150,9 +150,11 @@ impl<'s> ScriptSource<'s> {
let after_closing_fence = after_closing_fence.trim_matches(is_whitespace);
if !after_closing_fence.is_empty() {
// extra characters beyond the original fence pattern
let after_start = after_closing_fence.offset_from(&raw);
let after_end = after_start + after_closing_fence.len();
return Err(FrontmatterError::new(
format!("unexpected characters after frontmatter close"),
close_end..content_start,
after_start..after_end,
)
.push_visible_span(open_start..open_end));
}

View File

@ -1,8 +1,6 @@
[ERROR] unexpected characters after frontmatter close
--> script:2:4
|
1 | ---
2 | ---cargo
| ____^
3 | | //~^ ERROR: extra characters after frontmatter close are not allowed
| |_^
1 | ---
2 | ---cargo
| ^^^^^