@@ -60,6 +60,15 @@ export async function createMarkdownRenderer(
6060 if ( ! options ?. noHighlighter ) {
6161 const themes = options ?. theme ?? DEFAULT_THEME ;
6262 const langs = options ?. languages ?? DEFAULT_LANGUAGES ;
63+ const colorReplacements = {
64+ '#6f42c1' : 'var(--shiki-purple)' ,
65+ '#032f62' : 'var(--shiki-dark-blue)' ,
66+ '#24292e' : 'var(--shiki-navy)' ,
67+ '#d73a49' : 'var(--shiki-red)' ,
68+ '#005cc5' : 'var(--shiki-blue)' ,
69+ '#22863a' : 'var(--shiki-green)' ,
70+ '#e36209' : 'var(--shiki-orange)' ,
71+ } ;
6372
6473 const highlighter = await createHighlighter ( {
6574 langs,
@@ -70,7 +79,23 @@ export async function createMarkdownRenderer(
7079 markedShiki ( {
7180 highlight ( code , lang , _ ) {
7281 try {
73- return highlighter . codeToHtml ( code , { lang, themes } ) ;
82+ return highlighter . codeToHtml ( code , {
83+ lang,
84+ themes,
85+ colorReplacements : {
86+ 'github-light' : {
87+ ...colorReplacements ,
88+ '#fff' : 'var(--shiki-bg)' ,
89+ '#24292e' : 'var(--shiki-fg)' ,
90+ } ,
91+ 'github-dark' : {
92+ ...colorReplacements ,
93+ '#24292e' : 'var(--shiki-bg)' ,
94+ '#e1e4e8' : 'var(--shiki-fg)' ,
95+ } ,
96+ } ,
97+ defaultColor : 'light-dark()' ,
98+ } ) ;
7499 } catch {
75100 return `<pre><code>${ sanitizer ( code ) } </code></pre>` ;
76101 }
0 commit comments