-
Notifications
You must be signed in to change notification settings - Fork 54
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
Doesn't highlight code? #152
Comments
Hard to say, I don't know that API very well, but perhaps the order of your plugins is wrong - shiki twoslash will highlight code outside of ```ts twoslash codeblocks. |
I think I have outlined the problem |
Fixed it! 🎉 const highlighter = await createShikiHighlighter({theme: 'dark-plus'});
const rendered = await unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkTwoslash)
.use(() => tree => {
visit(tree, 'code', node => {
const code = `
const msg = 'Hello, world!';
// ^?
`;
const twoslash = runTwoSlash(code, 'ts', {})
const html = renderCodeToHTML(twoslash.code, 'ts', {twoslash: true}, {}, highlighter, twoslash);
node.value = html;
node.type = 'html';
node.children = [];
})
})
.use(remarkRehype, {allowDangerousHtml: true})
.use(rehypeStringify, {allowDangerousHtml: true})
.process(`
\`\`\`ts
const msg = "this";
// ^?
\`\`\`
`);
console.log(String(rendered)); It's a hardcoded example, yes |
I'm using
remark-shiki-twoslash
:For some reason, this only wraps the code in a pre>code block:
Is this a bug or am I doing something completely wrong?
The text was updated successfully, but these errors were encountered: