mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-10 13:18:25 +00:00
94e4cb9d9d
* chore(deps): upgrade dependencies across workspace and unify shared versions Co-authored-by: ericfennis <11825403+ericfennis@users.noreply.github.com> * chore(deps): finish workspace dependency upgrade and align versions * fix: keep vitest on 4.1.10, drop deprecated baseUrl, reformat with prettier * fix(lucide-react): drop inert outDir so TS 6 rootDir check passes --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ericfennis <11825403+ericfennis@users.noreply.github.com>
32 lines
905 B
TypeScript
32 lines
905 B
TypeScript
import { bundledLanguages, type ThemeRegistration } from 'shiki';
|
|
import { createHighlighter } from 'shiki';
|
|
|
|
export type ThemeOptions =
|
|
ThemeRegistration | { light: ThemeRegistration; dark: ThemeRegistration };
|
|
|
|
const highLightCode = async (code: string, lang: string, active?: boolean) => {
|
|
const highlighter = await createHighlighter({
|
|
themes: ['github-light', 'github-dark'],
|
|
langs: Object.keys(bundledLanguages),
|
|
});
|
|
|
|
const highlightedCode = highlighter
|
|
.codeToHtml(code, {
|
|
lang,
|
|
themes: {
|
|
light: 'github-light',
|
|
dark: 'github-dark',
|
|
},
|
|
defaultColor: false,
|
|
})
|
|
.replace('shiki-themes', 'shiki-themes vp-code');
|
|
|
|
return `<div class="language-${lang} ${active ? 'active' : ''}">
|
|
<button title="Copy Code" class="copy"></button>
|
|
<span class="lang">${lang}</span>
|
|
${highlightedCode}
|
|
</div>`;
|
|
};
|
|
|
|
export default highLightCode;
|