summaryrefslogtreecommitdiff
path: root/packages/integrations/mdx
diff options
context:
space:
mode:
authorGravatar Juan Martín Seery <me@juanm04.com> 2022-08-28 08:23:37 -0300
committerGravatar GitHub <noreply@github.com> 2022-08-28 08:23:37 -0300
commita2e8e76c303e8d6f39c24c122905a10f06907997 (patch)
tree84920ece4d0f31355dda36468e93d6ca721fe89f /packages/integrations/mdx
parent270852370a4ab44b4489f4ed91841f026b7df071 (diff)
downloadastro-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')
-rw-r--r--packages/integrations/mdx/package.json2
-rw-r--r--packages/integrations/mdx/src/remark-shiki.ts22
2 files changed, 17 insertions, 7 deletions
diff --git a/packages/integrations/mdx/package.json b/packages/integrations/mdx/package.json
index e3a5f12a9..0df60afda 100644
--- a/packages/integrations/mdx/package.json
+++ b/packages/integrations/mdx/package.json
@@ -40,7 +40,7 @@
"remark-frontmatter": "^4.0.1",
"remark-gfm": "^3.0.1",
"remark-smartypants": "^2.0.0",
- "shiki": "^0.10.1",
+ "shiki": "^0.11.1",
"unist-util-visit": "^4.1.0",
"vfile": "^5.3.2"
},
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(