diff --git a/.changeset/olive-jars-grab.md b/.changeset/olive-jars-grab.md new file mode 100644 index 000000000..653953679 --- /dev/null +++ b/.changeset/olive-jars-grab.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Bugfix: fixes double
 tags generated from markdown code blocks
diff --git a/packages/astro/package.json b/packages/astro/package.json
index 59505a3f9..2c793e714 100644
--- a/packages/astro/package.json
+++ b/packages/astro/package.json
@@ -8,7 +8,7 @@
   "exports": {
     ".": "./astro.mjs",
     "./snowpack-plugin": "./snowpack-plugin.cjs",
-    "./components/*.astro": "./components/*.astro",
+    "./components/*": "./components/*",
     "./runtime/svelte": "./dist/frontend/runtime/svelte.js"
   },
   "imports": {
diff --git a/packages/astro/src/compiler/transform/prism.ts b/packages/astro/src/compiler/transform/prism.ts
index 6f8eb5bba..3b2674618 100644
--- a/packages/astro/src/compiler/transform/prism.ts
+++ b/packages/astro/src/compiler/transform/prism.ts
@@ -19,8 +19,11 @@ export default function (module: Script): Transformer {
       html: {
         Element: {
           enter(node) {
-            if (node.name !== 'code') return;
-            const className = getAttrValue(node.attributes, 'class') || '';
+            if (node.name !== 'pre') return;
+            const codeEl = node.children && node.children[0];
+            if (!codeEl || codeEl.name !== 'code') return;
+
+            const className = getAttrValue(codeEl.attributes, 'class') || '';
             const classes = className.split(' ');
 
             let lang;
@@ -33,10 +36,9 @@ export default function (module: Script): Transformer {
 
             if (!lang) return;
 
-            let code;
-            if (node.children?.length) {
-              code = node.children[0].data;
-            }
+            let codeData = codeEl.children && codeEl.children[0];
+            if (!codeData) return;
+            let code = codeData.data as string;
 
             const repl = {
               start: 0,