Skip to content

Commit

Permalink
import regex
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Mar 24, 2021
1 parent 638f48c commit 222e8e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/parse/state/fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions src/compiler/parse/state/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 222e8e1

Please sign in to comment.