summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Giuseppe La Torre <giuseppelt@users.noreply.github.com> 2023-01-11 14:54:09 +0100
committerGravatar GitHub <noreply@github.com> 2023-01-11 21:54:09 +0800
commit23dc9ea96a10343852d965efd41fe6665294f1fb (patch)
treea99327e63fcde8f2ce4a17131b6ac3317bf4e7a3
parent840412128b00a04515156e92c314a929d6b94f6d (diff)
downloadastro-23dc9ea96a10343852d965efd41fe6665294f1fb.tar.gz
astro-23dc9ea96a10343852d965efd41fe6665294f1fb.tar.zst
astro-23dc9ea96a10343852d965efd41fe6665294f1fb.zip
Fix `Code.astro` shiki css class replace logic (#5829)
-rw-r--r--.changeset/sweet-rocks-count.md5
-rw-r--r--packages/astro/components/Code.astro2
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/sweet-rocks-count.md b/.changeset/sweet-rocks-count.md
new file mode 100644
index 000000000..7f6228934
--- /dev/null
+++ b/.changeset/sweet-rocks-count.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fix `Code.astro` shiki css class replace logic
diff --git a/packages/astro/components/Code.astro b/packages/astro/components/Code.astro
index 8bd3476a1..5066b9594 100644
--- a/packages/astro/components/Code.astro
+++ b/packages/astro/components/Code.astro
@@ -37,7 +37,7 @@ const { code, lang = 'plaintext', theme = 'github-dark', wrap = false } = Astro.
/** Replace the shiki class name with a custom astro class name. */
function repairShikiTheme(html: string): string {
// Replace "shiki" class naming with "astro"
- html = html.replace('<pre class="shiki"', '<pre class="astro-code"');
+ html = html.replace(/<pre class="(.*?)shiki(.*?)"/, '<pre class="$1astro-code$2"');
// Handle code wrapping
// if wrap=null, do nothing.
if (wrap === false) {