@@ -128,13 +128,26 @@ impl<'s> ScriptSource<'s> {
128
128
. unwrap_or_else ( || input. eof_offset ( ) ) ,
129
129
) ;
130
130
let content_start = input. current_token_start ( ) ;
131
- let after_closing_fence = after_closing_fence. trim_matches ( is_whitespace) ;
132
- if !after_closing_fence. is_empty ( ) {
133
- // extra characters beyond the original fence pattern, even if they are extra `-`
131
+ let extra_dashes = after_closing_fence
132
+ . chars ( )
133
+ . take_while ( |b| * b == FENCE_CHAR )
134
+ . count ( ) ;
135
+ if 0 < extra_dashes {
136
+ let extra_start = close_end;
137
+ let extra_end = extra_start + extra_dashes;
134
138
return Err ( FrontmatterError :: new (
135
- format ! ( "unexpected characters after frontmatter close " ) ,
136
- close_end..content_start ,
139
+ format ! ( "closing code fence has {extra_dashes} more `-` than the opening fence " ) ,
140
+ extra_start..extra_end ,
137
141
) ) ;
142
+ } else {
143
+ let after_closing_fence = after_closing_fence. trim_matches ( is_whitespace) ;
144
+ if !after_closing_fence. is_empty ( ) {
145
+ // extra characters beyond the original fence pattern
146
+ return Err ( FrontmatterError :: new (
147
+ format ! ( "unexpected characters after frontmatter close" ) ,
148
+ close_end..content_start,
149
+ ) ) ;
150
+ }
138
151
}
139
152
140
153
source. content = content_start..content_end;
@@ -584,7 +597,7 @@ content: "\nfn main() {}\n"
584
597
fn main() {}
585
598
"# ,
586
599
) ,
587
- str![ "unexpected characters after frontmatter close " ] ,
600
+ str![ "closing code fence has 2 more `-` than the opening fence " ] ,
588
601
) ;
589
602
}
590
603
@@ -621,7 +634,7 @@ time="0.1.25"
621
634
fn main() {}
622
635
"# ,
623
636
) ,
624
- str![ "unexpected characters after frontmatter close " ] ,
637
+ str![ "closing code fence has 1 more `-` than the opening fence " ] ,
625
638
) ;
626
639
}
627
640
0 commit comments