Skip to content

Commit 23dc9ea

Browse files
authored
Fix Code.astro shiki css class replace logic (#5829)
1 parent 8404121 commit 23dc9ea

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/sweet-rocks-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fix `Code.astro` shiki css class replace logic

packages/astro/components/Code.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const { code, lang = 'plaintext', theme = 'github-dark', wrap = false } = Astro.
3737
/** Replace the shiki class name with a custom astro class name. */
3838
function repairShikiTheme(html: string): string {
3939
// Replace "shiki" class naming with "astro"
40-
html = html.replace('<pre class="shiki"', '<pre class="astro-code"');
40+
html = html.replace(/<pre class="(.*?)shiki(.*?)"/, '<pre class="$1astro-code$2"');
4141
// Handle code wrapping
4242
// if wrap=null, do nothing.
4343
if (wrap === false) {

0 commit comments

Comments
 (0)