fix shiki css class replace logic in md and mdx integrations (#5837)

This commit is contained in:
Giuseppe La Torre 2023-01-12 13:15:51 +01:00 committed by GitHub
parent c53b1fca07
commit 12f65a4d55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View file

@ -0,0 +1,6 @@
---
'@astrojs/mdx': patch
'@astrojs/markdown-remark': patch
---
fix shiki css class replace logic

View file

@ -66,7 +66,7 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }:
// <span class="line"
// 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"`);
// Add "user-select: none;" for "+"/"-" diff symbols
if (node.lang === 'diff') {
html = html.replace(

View file

@ -70,8 +70,8 @@ const remarkShiki = async (
// Replace "shiki" class naming with "astro" and add "is:raw".
html = html.replace(
'<pre class="shiki"',
`<pre is:raw class="astro-code${scopedClassName ? ' ' + scopedClassName : ''}"`
/<pre class="(.*?)shiki(.*?)"/,
`<pre is:raw class="$1astro-code$2${scopedClassName ? ' ' + scopedClassName : ''}"`
);
// Add "user-select: none;" for "+"/"-" diff symbols
if (node.lang === 'diff') {