-
-
Notifications
You must be signed in to change notification settings - Fork 566
Closed
Description
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Describe the bug
Hi,
When using transformerRenderWhitespace together with the structure: "inline" setting I receive this error:
TypeError: Cannot read properties of undefined (reading 'forEach')
at Object.root (http://localhost:3000/node_modules/.vite/deps/@shikijs_transformers.js?v=82b8e6ae:538:21)
at tokensToHast (http://localhost:3000/node_modules/.vite/deps/chunk-EBWDM6ZB.js?v=82b8e6ae:1315:92)
at codeToHast (http://localhost:3000/node_modules/.vite/deps/chunk-EBWDM6ZB.js?v=82b8e6ae:1188:10)
at codeToHtml (http://localhost:3000/node_modules/.vite/deps/chunk-EBWDM6ZB.js?v=82b8e6ae:1400:27)
at Object.codeToHtml (http://localhost:3000/node_modules/.vite/deps/chunk-EBWDM6ZB.js?v=82b8e6ae:1842:37)
at Proxy.highlightCode (http://localhost:3000/lib/markdownHelpers.ts:89:22)
at Proxy._sfc_render (http://localhost:3000/components/CodeBlock.vue:37:23)
at renderComponentRoot (http://localhost:3000/node_modules/.vite/deps/chunk-IWYC5R2O.js?v=82b8e6ae:8581:17)
at ReactiveEffect.componentUpdateFn [as fn] (http://localhost:3000/node_modules/.vite/deps/chunk-IWYC5R2O.js?v=82b8e6ae:7403:46)
at ReactiveEffect.run (http://localhost:3000/node_modules/.vite/deps/chunk-IWYC5R2O.js?v=82b8e6ae:481:19)Here is my test setup:
const code = `
const foo = 'bar'
console.log(foo)
`;
appEl.innerHTML = await codeToHtml(code, {
lang: 'js',
theme: 'nord',
structure: "inline", // try removing this
transformers: [
transformerRenderWhitespace(),
],
});Packages:
{
"name": "shiki-bug2",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"devDependencies": {
"typescript": "~5.7.2",
"vite": "^6.2.0"
},
"dependencies": {
"@shikijs/transformers": "^3.1.0",
"shiki": "^3.1.0"
}
}Repro over here
Reproduction
https://stackblitz.com/~/github.com/marpe/shiki-structure-whitespace-bug
Contributes
- I am willing to submit a PR to fix this issue
- I am willing to submit a PR with failing tests
Metadata
Metadata
Assignees
Labels
No labels