summaryrefslogtreecommitdiff
path: root/packages/astro-parser/src/parse/state/text.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/astro-parser/src/parse/state/text.ts')
-rw-r--r--packages/astro-parser/src/parse/state/text.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/astro-parser/src/parse/state/text.ts b/packages/astro-parser/src/parse/state/text.ts
new file mode 100644
index 000000000..cca83f2d4
--- /dev/null
+++ b/packages/astro-parser/src/parse/state/text.ts
@@ -0,0 +1,24 @@
+// @ts-nocheck
+
+import { decode_character_references } from '../utils/html.js';
+import { Parser } from '../index.js';
+
+export default function text(parser: Parser) {
+ const start = parser.index;
+
+ let data = '';
+
+ while (parser.index < parser.template.length && !parser.match('---') && !parser.match('<') && !parser.match('{')) {
+ data += parser.template[parser.index++];
+ }
+
+ const node = {
+ start,
+ end: parser.index,
+ type: 'Text',
+ raw: data,
+ data: decode_character_references(data),
+ };
+
+ parser.current().children.push(node);
+}