summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/parse/state/fragment.ts2
-rw-r--r--src/compiler/parse/state/setup.ts8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/parse/state/fragment.ts b/src/compiler/parse/state/fragment.ts
index eb72551c6..97398b227 100644
--- a/src/compiler/parse/state/fragment.ts
+++ b/src/compiler/parse/state/fragment.ts
@@ -5,7 +5,7 @@ import text from './text.js';
import { Parser } from '../index.js';
export default function fragment(parser: Parser) {
- if (parser.match('---')) {
+ if (parser.html.children.length === 0 && parser.match_regex(/^---/m)) {
return setup;
}
diff --git a/src/compiler/parse/state/setup.ts b/src/compiler/parse/state/setup.ts
index b3c21b106..f64d8c52b 100644
--- a/src/compiler/parse/state/setup.ts
+++ b/src/compiler/parse/state/setup.ts
@@ -3,6 +3,14 @@
import { Parser } from '../index.js';
export default function setup(parser: Parser): void {
+ // TODO: Error if not at top of file? currently, we ignore / just treat as text.
+ // if (parser.html.children.length > 0) {
+ // parser.error({
+ // code: 'unexpected-token',
+ // message: 'Frontmatter scripts only supported at the top of file.',
+ // });
+ // }
+
const start = parser.index;
parser.index += 3;
const content_start = parser.index;