diff options
Diffstat (limited to 'packages/astro-parser/src/parse/state/fragment.ts')
-rw-r--r-- | packages/astro-parser/src/parse/state/fragment.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/astro-parser/src/parse/state/fragment.ts b/packages/astro-parser/src/parse/state/fragment.ts new file mode 100644 index 000000000..97398b227 --- /dev/null +++ b/packages/astro-parser/src/parse/state/fragment.ts @@ -0,0 +1,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; +} |