Recipes
Repeated highlighting (JavaScript / TypeScript)
Reuse a JavaScript or TypeScript highlighter for repeated synchronous highlights.
import {createHighlighter} from '@lumis-sh/lumis'
import {htmlInline} from '@lumis-sh/lumis/formatters'
import web from '@lumis-sh/wasm-bundle-web'
import frappe from '@lumis-sh/themes/catppuccin_frappe'
const hl = await createHighlighter({
languages: [web],
})
await hl.loadLanguage('javascript')
const html = hl.highlight(
'const x = 1',
htmlInline({language: 'javascript', theme: frappe}),
)See JavaScript / TypeScript for the reusable highlighter workflow.