summaryrefslogtreecommitdiff
path: root/packages/astro-parser/src/parse/state/fragment.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/astro-parser/src/parse/state/fragment.ts')
-rw-r--r--packages/astro-parser/src/parse/state/fragment.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/packages/astro-parser/src/parse/state/fragment.ts b/packages/astro-parser/src/parse/state/fragment.ts
index 97398b227..d3b30f329 100644
--- a/packages/astro-parser/src/parse/state/fragment.ts
+++ b/packages/astro-parser/src/parse/state/fragment.ts
@@ -2,6 +2,8 @@ import tag from './tag.js';
import setup from './setup.js';
import mustache from './mustache.js';
import text from './text.js';
+import codefence from './codefence.js';
+import codespan from './codespan.js';
import { Parser } from '../index.js';
export default function fragment(parser: Parser) {
@@ -9,6 +11,15 @@ export default function fragment(parser: Parser) {
return setup;
}
+ // Fenced code blocks are pretty complex in the GFM spec
+ // https://github.github.com/gfm/#fenced-code-blocks
+ if (parser.match_regex(/[`~]{3,}/)) {
+ return codefence;
+ }
+ if (parser.match_regex(/(?<!\\)`{1,2}/)) {
+ return codespan;
+ }
+
if (parser.match('<')) {
return tag;
}