diff options
author | 2022-08-28 08:23:37 -0300 | |
---|---|---|
committer | 2022-08-28 08:23:37 -0300 | |
commit | a2e8e76c303e8d6f39c24c122905a10f06907997 (patch) | |
tree | 84920ece4d0f31355dda36468e93d6ca721fe89f /packages/integrations/mdx/src | |
parent | 270852370a4ab44b4489f4ed91841f026b7df071 (diff) | |
download | astro-a2e8e76c303e8d6f39c24c122905a10f06907997.tar.gz astro-a2e8e76c303e8d6f39c24c122905a10f06907997.tar.zst astro-a2e8e76c303e8d6f39c24c122905a10f06907997.zip |
chore: updated shiki (#4519)
* Upgraded shiki
* Use setColorReplacements
* no-shadow
* Changeset
Diffstat (limited to 'packages/integrations/mdx/src')
-rw-r--r-- | packages/integrations/mdx/src/remark-shiki.ts | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/packages/integrations/mdx/src/remark-shiki.ts b/packages/integrations/mdx/src/remark-shiki.ts index 76a1d275f..7bb944ce6 100644 --- a/packages/integrations/mdx/src/remark-shiki.ts +++ b/packages/integrations/mdx/src/remark-shiki.ts @@ -14,7 +14,22 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }: const cacheID: string = typeof theme === 'string' ? theme : theme.name; let highlighterAsync = highlighterCacheAsync.get(cacheID); if (!highlighterAsync) { - highlighterAsync = getHighlighter({ theme }); + highlighterAsync = getHighlighter({ theme }).then((hl) => { + hl.setColorReplacements({ + '#000001': 'var(--astro-code-color-text)', + '#000002': 'var(--astro-code-color-background)', + '#000004': 'var(--astro-code-token-constant)', + '#000005': 'var(--astro-code-token-string)', + '#000006': 'var(--astro-code-token-comment)', + '#000007': 'var(--astro-code-token-keyword)', + '#000008': 'var(--astro-code-token-parameter)', + '#000009': 'var(--astro-code-token-function)', + '#000010': 'var(--astro-code-token-string-expression)', + '#000011': 'var(--astro-code-token-punctuation)', + '#000012': 'var(--astro-code-token-link)', + }); + return hl; + }); highlighterCacheAsync.set(cacheID, highlighterAsync); } const highlighter = await highlighterAsync; @@ -52,11 +67,6 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }: // Replace "shiki" class naming with "astro". html = html.replace('<pre class="shiki"', `<pre class="astro-code"`); - // Replace "shiki" css variable naming with "astro". - html = html.replace( - /style="(background-)?color: var\(--shiki-/g, - 'style="$1color: var(--astro-code-' - ); // Add "user-select: none;" for "+"/"-" diff symbols if (node.lang === 'diff') { html = html.replace( |