Wrap codeblocks w/ element? #504
Answered
by
pngwn
AutomateAaron
asked this question in
Q&A
-
I'm trying to wrap the code blocks w/ an element so that I can style them in a particular way. My thinking was to use the highlighter configuration to pass in a custom function which wraps the default function. However, I'm having trouble importing the default function. Is there a way to import this? |
Beta Was this translation helpful? Give feedback.
Answered by
pngwn
Apr 23, 2023
Replies: 1 comment 7 replies
-
Hey import { mdsvex, escapeSvelte } from "mdsvex"
import { getHighlighter } from "shiki"
mdsvex({
highlight: {
highlighter: async (code, lang) => {
const highlightedCode = await mdsvexHighlight(code, lang)
return highlightedCode ? escapeSvelte(highlightedCode) : ""
},
},
}),
async function mdsvexHighlight(code, lang) {
const highlighter = await getHighlighter({
theme: "rose-pine",
langs: ["html", "css", "js", "svelte", "php", "cmd"],
})
return highlighter.codeToHtml(code, { lang })
} |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think that's what they are asking. @AaronNBrock could you file an issue asking for this please? I'll try to take care of it soon.