Skip to content

Commit

Permalink
fix: curly braces inside Shiki (#2545)
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanM04 authored Feb 8, 2022
1 parent c88a995 commit f0952a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/astro/components/Code.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/markdown/remark/src/remark-shiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f0952a8

Please sign in to comment.