Files
maher 703f50a09d
Some checks failed
Build / run (push) Has been cancelled
first commit
2025-10-29 11:42:25 +01:00

20 lines
520 B
TypeScript
Executable File

export function highlightAllCode(
el: HTMLElement,
themeMode: 'light' | 'dark' = 'dark',
) {
el.querySelectorAll('pre code').forEach(e => {
highlightCode(e as HTMLElement, themeMode);
});
}
export async function highlightCode(
el: HTMLElement,
themeMode: 'light' | 'dark' = 'dark',
) {
const {hljs} = await import('@common/text-editor/highlight/highlight');
if (!el.dataset.highlighted) {
el.classList.add(themeMode === 'dark' ? 'hljs-dark' : 'hljs-light');
hljs.highlightElement(el);
}
}