Fix Code.astro
shiki css class replace logic (#5829)
This commit is contained in:
parent
840412128b
commit
23dc9ea96a
2 changed files with 6 additions and 1 deletions
5
.changeset/sweet-rocks-count.md
Normal file
5
.changeset/sweet-rocks-count.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix `Code.astro` shiki css class replace logic
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue