Skip to content

Commit

Permalink
chore: upgrade shiki v3
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Feb 25, 2025
1 parent 63cc459 commit 4cb6f3e
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 70 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
},
"dependencies": {
"@nuxt/kit": "^3.15.2",
"@shikijs/transformers": "^1.27.2",
"@shikijs/transformers": "^3.0.0",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.4",
"@vue/compiler-core": "^3.5.13",
Expand Down Expand Up @@ -105,7 +105,7 @@
"remark-rehype": "^11.1.1",
"remark-stringify": "^11.0.0",
"scule": "^1.3.0",
"shiki": "^1.27.2",
"shiki": "^3.0.0",
"ufo": "^1.5.4",
"unified": "^11.0.5",
"unist-builder": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineNuxtConfig({
default: 'vitesse-light',
dark: 'material-theme-palenight'
},
shikiEngine: 'javascript',
shikiEngine: 'oniguruma',
preload: [
'sql'
]
Expand Down
2 changes: 1 addition & 1 deletion playground/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ onMounted(() => {
<Editor v-model:code="source" class="flex-1" />
<!-- MDC AST -->
<code class="text-xs px-2 py-1">MDC AST</code>
<Editor :code="JSON.stringify(ast?.body, null, 2)" language="json" class="flex-1" read-only />
<Editor :code="JSON.stringify(ast?.body, null, 2) || ''" language="json" class="flex-1" read-only />
</div>
<div class="flex-1 h-full flex flex-col border-2 border-neutral-900">
<code class="text-xs px-2 py-1">Source -> MDC -> Render</code>
Expand Down
125 changes: 61 additions & 64 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/templates/mdc-highlighter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function mdcHighlighter({
'import { getMdcConfigs } from \'#mdc-configs\'',
shikiEngine === 'javascript'
? 'import { createJavaScriptRegexEngine } from \'shiki/engine/javascript\''
: 'import { createWasmOnigEngine } from \'shiki/engine/oniguruma\'',
: 'import { createOnigurumaEngine } from \'shiki/engine/oniguruma\'',
code,
'const bundledLangs = {',
...Array.from(langsMap.entries())
Expand All @@ -94,7 +94,7 @@ export async function mdcHighlighter({
}),
shikiEngine === 'javascript'
? 'const engine = createJavaScriptRegexEngine({ forgiving: true })'
: `const engine = createWasmOnigEngine(() => import('shiki/wasm'))`,
: `const engine = createOnigurumaEngine(() => import('shiki/wasm'))`,
'const highlighter = createShikiHighlighter({ bundledLangs, bundledThemes, options, getMdcConfigs, engine })',
'export default highlighter'
].join('\n')
Expand Down

0 comments on commit 4cb6f3e

Please sign in to comment.