Skip to content

Commit

Permalink
only create highlighter once
Browse files Browse the repository at this point in the history
  • Loading branch information
hipstersmoothie committed Feb 14, 2021
1 parent b27cf03 commit e815721
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ interface PluginOptions {
langs?: shiki.ILanguageRegistration[]
}

let highlighter: shiki.Highlighter

function attacher(options: PluginOptions = {}) {
const {theme = 'github-light', useBackground = true, langs = []} = options

let highlighter: shiki.Highlighter

return transformer

async function transformer(tree: NodeWithChildren) {
highlighter = await shiki.getHighlighter({
highlighter ||= await shiki.getHighlighter({
theme,
langs: [...BUNDLED_LANGUAGES, ...langs]
})
Expand Down

0 comments on commit e815721

Please sign in to comment.