|
|
|
@ -2,14 +2,12 @@ import { customAlphabet } from 'nanoid'
|
|
|
|
|
import c from 'picocolors'
|
|
|
|
|
import type { ShikijiTransformer } from 'shikiji'
|
|
|
|
|
import {
|
|
|
|
|
addClassToHast,
|
|
|
|
|
bundledLanguages,
|
|
|
|
|
getHighlighter,
|
|
|
|
|
addClassToHast,
|
|
|
|
|
isPlaintext as isPlainLang,
|
|
|
|
|
isSpecialLang
|
|
|
|
|
} from 'shikiji'
|
|
|
|
|
import type { Logger } from 'vite'
|
|
|
|
|
import type { MarkdownOptions, ThemeOptions } from '../markdown'
|
|
|
|
|
import {
|
|
|
|
|
transformerCompactLineOptions,
|
|
|
|
|
transformerNotationDiff,
|
|
|
|
@ -18,6 +16,8 @@ import {
|
|
|
|
|
transformerNotationHighlight,
|
|
|
|
|
type TransformerCompactLineOption
|
|
|
|
|
} from 'shikiji-transformers'
|
|
|
|
|
import type { Logger } from 'vite'
|
|
|
|
|
import type { MarkdownOptions, ThemeOptions } from '../markdown'
|
|
|
|
|
|
|
|
|
|
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz', 10)
|
|
|
|
|
|
|
|
|
@ -65,9 +65,9 @@ export async function highlight(
|
|
|
|
|
|
|
|
|
|
const highlighter = await getHighlighter({
|
|
|
|
|
themes:
|
|
|
|
|
typeof theme === 'string' || 'name' in theme
|
|
|
|
|
? [theme]
|
|
|
|
|
: [theme.light, theme.dark],
|
|
|
|
|
typeof theme === 'object' && 'light' in theme && 'dark' in theme
|
|
|
|
|
? [theme.light, theme.dark]
|
|
|
|
|
: [theme],
|
|
|
|
|
langs: [...Object.keys(bundledLanguages), ...(options.languages || [])],
|
|
|
|
|
langAlias: options.languageAlias
|
|
|
|
|
})
|
|
|
|
@ -169,15 +169,10 @@ export async function highlight(
|
|
|
|
|
},
|
|
|
|
|
...userTransformers
|
|
|
|
|
],
|
|
|
|
|
meta: {
|
|
|
|
|
__raw: attrs
|
|
|
|
|
},
|
|
|
|
|
...(typeof theme === 'string' || 'name' in theme
|
|
|
|
|
? { theme }
|
|
|
|
|
: {
|
|
|
|
|
themes: theme,
|
|
|
|
|
defaultColor: false
|
|
|
|
|
})
|
|
|
|
|
meta: { __raw: attrs },
|
|
|
|
|
...(typeof theme === 'object' && 'light' in theme && 'dark' in theme
|
|
|
|
|
? { themes: theme, defaultColor: false }
|
|
|
|
|
: { theme })
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return fillEmptyHighlightedLine(restoreMustache(highlighted))
|
|
|
|
|