summaryrefslogtreecommitdiff
path: root/packages/astro-parser/src/parse/state/fragment.ts
blob: 97398b227ca63d12782b796923530ba8260c5576 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import tag from './tag.js';
import setup from './setup.js';
import mustache from './mustache.js';
import text from './text.js';
import { Parser } from '../index.js';

export default function fragment(parser: Parser) {
  if (parser.html.children.length === 0 && parser.match_regex(/^---/m)) {
    return setup;
  }

  if (parser.match('<')) {
    return tag;
  }

  if (parser.match('{')) {
    return mustache;
  }

  return text;
}