fix shiki css class replace logic in md and mdx integrations (#5837)
This commit is contained in:
parent
c53b1fca07
commit
12f65a4d55
3 changed files with 9 additions and 3 deletions
6
.changeset/giant-chefs-rule.md
Normal file
6
.changeset/giant-chefs-rule.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
'@astrojs/mdx': patch
|
||||
'@astrojs/markdown-remark': patch
|
||||
---
|
||||
|
||||
fix shiki css class replace logic
|
|
@ -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(
|
||||
|
|
|
@ -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') {
|
||||
|
|
Loading…
Reference in a new issue