diff options
author | 2023-01-11 14:54:09 +0100 | |
---|---|---|
committer | 2023-01-11 21:54:09 +0800 | |
commit | 23dc9ea96a10343852d965efd41fe6665294f1fb (patch) | |
tree | a99327e63fcde8f2ce4a17131b6ac3317bf4e7a3 | |
parent | 840412128b00a04515156e92c314a929d6b94f6d (diff) | |
download | astro-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.md | 5 | ||||
-rw-r--r-- | packages/astro/components/Code.astro | 2 |
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) { |