summaryrefslogtreecommitdiff
path: root/packages/markdown/remark/src
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/markdown/remark/src
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/markdown/remark/src')
-rw-r--r--packages/markdown/remark/src/remark-shiki.ts22
1 files changed, 16 insertions, 6 deletions
diff --git a/packages/markdown/remark/src/remark-shiki.ts b/packages/markdown/remark/src/remark-shiki.ts
index eea0fd006..85463bd65 100644
--- a/packages/markdown/remark/src/remark-shiki.ts
+++ b/packages/markdown/remark/src/remark-shiki.ts
@@ -17,7 +17,22 @@ const remarkShiki = async (
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;
@@ -58,11 +73,6 @@ const remarkShiki = async (
'<pre class="shiki"',
`<pre is:raw class="astro-code${scopedClassName ? ' ' + scopedClassName : ''}"`
);
- // 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(