|
|
@ -1,6 +1,11 @@
|
|
|
|
import { customAlphabet } from 'nanoid'
|
|
|
|
import { customAlphabet } from 'nanoid'
|
|
|
|
import c from 'picocolors'
|
|
|
|
import c from 'picocolors'
|
|
|
|
import type { HtmlRendererOptions, IThemeRegistration } from 'shiki'
|
|
|
|
import {
|
|
|
|
|
|
|
|
BUNDLED_LANGUAGES,
|
|
|
|
|
|
|
|
type HtmlRendererOptions,
|
|
|
|
|
|
|
|
type ILanguageRegistration,
|
|
|
|
|
|
|
|
type IThemeRegistration
|
|
|
|
|
|
|
|
} from 'shiki'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
addClass,
|
|
|
|
addClass,
|
|
|
|
createDiffProcessor,
|
|
|
|
createDiffProcessor,
|
|
|
@ -58,6 +63,7 @@ const errorLevelProcessor = defineProcessor({
|
|
|
|
|
|
|
|
|
|
|
|
export async function highlight(
|
|
|
|
export async function highlight(
|
|
|
|
theme: ThemeOptions = 'material-theme-palenight',
|
|
|
|
theme: ThemeOptions = 'material-theme-palenight',
|
|
|
|
|
|
|
|
languages: ILanguageRegistration[] = [],
|
|
|
|
defaultLang: string = '',
|
|
|
|
defaultLang: string = '',
|
|
|
|
logger: Pick<Logger, 'warn'> = console
|
|
|
|
logger: Pick<Logger, 'warn'> = console
|
|
|
|
): Promise<(str: string, lang: string, attrs: string) => string> {
|
|
|
|
): Promise<(str: string, lang: string, attrs: string) => string> {
|
|
|
@ -74,6 +80,7 @@ export async function highlight(
|
|
|
|
|
|
|
|
|
|
|
|
const highlighter = await getHighlighter({
|
|
|
|
const highlighter = await getHighlighter({
|
|
|
|
themes: hasSingleTheme ? [theme] : [theme.dark, theme.light],
|
|
|
|
themes: hasSingleTheme ? [theme] : [theme.dark, theme.light],
|
|
|
|
|
|
|
|
langs: [...BUNDLED_LANGUAGES, ...languages],
|
|
|
|
processors
|
|
|
|
processors
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|