8000 Twoslash code highlighter breaks when rendering hover that has a js code block in it. · Issue #403 · anza-xyz/kit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Twoslash code highlighter breaks when rendering hover that has a js code block in it. #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
steveluscher opened this issue Apr 24, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@steveluscher
Copy link
Collaborator

Consider console.log(). Its docs look like this (notice the code fence inside the docblock):

/**
 * Prints to `stdout` with newline. Multiple arguments can be passed, with the
 * first used as the primary message and all additional used as substitution
 * values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html)
 * (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args)).
 *
 * ```js
 * const count = 5;
 * console.log('count: %d', count);
 * // Prints: count: 5, to stdout
 * console.log('count:', count);
 * // Prints: count: 5, to stdout
 * ```
 *
 * See [`util.format()`](https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args) for more information.
 * @since v0.1.100
 */

When Twoslash goes to render a codeblock with console.log() in it, it tries to recursively render the js code fence inside the docs for console.log(). When it does so, we get this:

./content/docs/upgrade-guide.mdx
Error evaluating Node.js code
ShikiError: upgrade-guide.mdx:ShikiError: Language `js` not found, you may need to load it first
    [at Object.getLanguage (file:///home/sol/src/kit/docs/node_modules/.pnpm/@shikijs+core@3.3.0/node_modules/@shikijs/core/dist/index.mjs:1756:13)]
    [at codeToTokensBase (file:///home/sol/src/kit/docs/node_modules/.pnpm/@shikijs+core@3.3.0/node_modules/@shikijs/core/dist/index.mjs:809:29)]
    [at file:///home/sol/src/kit/docs/node_modules/.pnpm/@shikijs+core@3.3.0/node_modules/@shikijs/core/dist/index.mjs:1015:21]
    [at <anonymous>]
    [at codeToTokensWithThemes (file:///home/sol/src/kit/docs/node_modules/.pnpm/@shikijs+core@3.3.0/node_modules/@shikijs/core/dist/index.mjs:1014:31)]
    [at codeToTokens (file:///home/sol/src/kit/docs/node_modules/.pnpm/@shikijs+core@3.3.0/node_modules/@shikijs/core/dist/index.mjs:1109:25)]
    [at codeToHast (file:///home/sol/src/kit/docs/node_modules/.pnpm/@shikijs+core@3.3.0/node_modules/@shikijs/core/dist/index.mjs:1168:7)]
    [at Object.codeToHast (file:///home/sol/src/kit/docs/node_modules/.pnpm/@shikijs+core@3.3.0/node_modules/@shikijs/core/dist/index.mjs:1155:36)]
    [at code (file:///home/sol/src/kit/docs/node_modules/.pnpm/fumadocs-twoslash@3.1.1_@types+react-dom@19.0.4_@types+react@19.0.12__@types+react@19.0_9e9244c803143d69682599df624dac14/node_modules/fumadocs-twoslash/dist/index.js:118:23)]
    [at Object.one (file:///home/sol/src/kit/docs/node_modules/.pnpm/mdast-util-to-hast@13.2.0/node_modules/mdast-util-to-hast/lib/state.js:254:14)]

Related: fuma-nama/fumadocs#1095 (comment)

@steveluscher steveluscher added the bug Something isn't working label Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant
0