mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
fix: curly braces inside Shiki (#2545)
This commit is contained in:
parent
c88a9951e4
commit
f0952a8e5b
2 changed files with 4 additions and 4 deletions
|
@ -35,8 +35,8 @@ 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"');
|
||||
// Replace "shiki" class naming with "astro" and add "data-astro-raw".
|
||||
html = html.replace('<pre class="shiki"', '<pre data-astro-raw class="astro-code"');
|
||||
// Replace "shiki" css variable naming with "astro".
|
||||
html = html.replace(/style="(background-)?color: var\(--shiki-/g, 'style="$1color: var(--astro-code-');
|
||||
// Handle code wrapping
|
||||
|
|
|
@ -40,8 +40,8 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }:
|
|||
visit(tree, 'code', (node) => {
|
||||
let html = highlighter.codeToHtml(node.value, { lang: node.lang ?? 'plaintext' });
|
||||
|
||||
// Replace "shiki" class naming with "astro".
|
||||
html = html.replace('<pre class="shiki"', '<pre class="astro-code"');
|
||||
// Replace "shiki" class naming with "astro" and add "data-astro-raw".
|
||||
html = html.replace('<pre class="shiki"', '<pre data-astro-raw class="astro-code"');
|
||||
// Replace "shiki" css variable naming with "astro".
|
||||
html = html.replace(/style="(background-)?color: var\(--shiki-/g, 'style="$1color: var(--astro-code-');
|
||||
// Handle code wrapping
|
||||
|
|
Loading…
Reference in a new issue