Fix theme handling
This commit is contained in:
parent
ef5a72ecae
commit
0387b8518a
4 changed files with 10 additions and 3 deletions
7
.changeset/few-peas-hunt.md
Normal file
7
.changeset/few-peas-hunt.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
'@astrojs/markdoc': minor
|
||||
'@astrojs/markdown-remark': minor
|
||||
'astro': minor
|
||||
---
|
||||
|
||||
Update internal `shiki` syntax highlighter to `shikiji`. Existing docs on `shiki` still stays the same, but `shikiji` will help make bundling simpler and easier to maintain.
|
|
@ -103,7 +103,7 @@ const html = highlighter.codeToHtml(code, {
|
|||
},
|
||||
root(node) {
|
||||
// theme.id for shiki -> shikiji compat
|
||||
const themeName = typeof theme === 'string' ? theme : (theme as any).id || theme.name;
|
||||
const themeName = typeof theme === 'string' ? theme : theme.name;
|
||||
if (themeName === 'css-variables') {
|
||||
// Replace special color tokens to CSS variables
|
||||
visit(node as any, 'element', (child) => {
|
||||
|
|
|
@ -97,7 +97,7 @@ export default async function shiki({
|
|||
}
|
||||
|
||||
// theme.id for shiki -> shikiji compat
|
||||
const themeName = typeof theme === 'string' ? theme : (theme as any).id || theme.name;
|
||||
const themeName = typeof theme === 'string' ? theme : theme.name;
|
||||
if (themeName === 'css-variables') {
|
||||
html = html.replace(/style="(.*?)"/g, (m) => replaceCssVariables(m));
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ export function remarkShiki({
|
|||
}
|
||||
|
||||
// theme.id for shiki -> shikiji compat
|
||||
const themeName = typeof theme === 'string' ? theme : (theme as any).id || theme.name;
|
||||
const themeName = typeof theme === 'string' ? theme : theme.name;
|
||||
if (themeName === 'css-variables') {
|
||||
html = html.replace(/style="(.*?)"/g, (m) => replaceCssVariables(m));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue