1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// @ts-nocheck
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;
const setupScriptContent = parser.read_until(/^---/m);
const content_end = parser.index;
parser.eat('---', true);
const end = parser.index;
parser.js.push({
type: 'Script',
context: 'setup',
start,
end,
content: setupScriptContent,
// attributes,
// content: {
// start: content_start,
// end: content_end,
// styles,
// },
});
return;
}
|