Fix theme handling

This commit is contained in:
bluwy 2023-10-06 21:53:46 +08:00
parent ef5a72ecae
commit 0387b8518a
4 changed files with 10 additions and 3 deletions

View 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.

View file

@ -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) => {

View file

@ -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));
}

View file

@ -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));
}