@@ -14,7 +14,22 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }:
14
14
const cacheID : string = typeof theme === 'string' ? theme : theme . name ;
15
15
let highlighterAsync = highlighterCacheAsync . get ( cacheID ) ;
16
16
if ( ! highlighterAsync ) {
17
- highlighterAsync = getHighlighter ( { theme } ) ;
17
+ highlighterAsync = getHighlighter ( { theme } ) . then ( ( hl ) => {
18
+ hl . setColorReplacements ( {
19
+ '#000001' : 'var(--astro-code-color-text)' ,
20
+ '#000002' : 'var(--astro-code-color-background)' ,
21
+ '#000004' : 'var(--astro-code-token-constant)' ,
22
+ '#000005' : 'var(--astro-code-token-string)' ,
23
+ '#000006' : 'var(--astro-code-token-comment)' ,
24
+ '#000007' : 'var(--astro-code-token-keyword)' ,
25
+ '#000008' : 'var(--astro-code-token-parameter)' ,
26
+ '#000009' : 'var(--astro-code-token-function)' ,
27
+ '#000010' : 'var(--astro-code-token-string-expression)' ,
28
+ '#000011' : 'var(--astro-code-token-punctuation)' ,
29
+ '#000012' : 'var(--astro-code-token-link)' ,
30
+ } ) ;
31
+ return hl ;
32
+ } ) ;
18
33
highlighterCacheAsync . set ( cacheID , highlighterAsync ) ;
19
34
}
20
35
const highlighter = await highlighterAsync ;
@@ -52,11 +67,6 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }:
52
67
53
68
// Replace "shiki" class naming with "astro".
54
69
html = html . replace ( '<pre class="shiki"' , `<pre class="astro-code"` ) ;
55
- // Replace "shiki" css variable naming with "astro".
56
- html = html . replace (
57
- / s t y l e = " ( b a c k g r o u n d - ) ? c o l o r : v a r \( - - s h i k i - / g,
58
- 'style="$1color: var(--astro-code-'
59
- ) ;
60
70
// Add "user-select: none;" for "+"/"-" diff symbols
61
71
if ( node . lang === 'diff' ) {
62
72
html = html . replace (
0 commit comments