|
|
@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
import { customAlphabet } from 'nanoid'
|
|
|
|
|
|
|
|
import c from 'picocolors'
|
|
|
|
import type { HtmlRendererOptions, IThemeRegistration } from 'shiki'
|
|
|
|
import type { HtmlRendererOptions, IThemeRegistration } from 'shiki'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
addClass,
|
|
|
|
addClass,
|
|
|
@ -10,7 +12,6 @@ import {
|
|
|
|
type Processor
|
|
|
|
type Processor
|
|
|
|
} from 'shiki-processor'
|
|
|
|
} from 'shiki-processor'
|
|
|
|
import type { ThemeOptions } from '../markdown'
|
|
|
|
import type { ThemeOptions } from '../markdown'
|
|
|
|
import { customAlphabet } from 'nanoid'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz', 10)
|
|
|
|
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz', 10)
|
|
|
|
|
|
|
|
|
|
|
@ -85,6 +86,18 @@ export async function highlight(
|
|
|
|
lang =
|
|
|
|
lang =
|
|
|
|
lang.replace(lineNoRE, '').replace(vueRE, '').toLowerCase() || defaultLang
|
|
|
|
lang.replace(lineNoRE, '').replace(vueRE, '').toLowerCase() || defaultLang
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const langLoaded = highlighter.getLoadedLanguages().includes(lang as any)
|
|
|
|
|
|
|
|
if (!langLoaded) {
|
|
|
|
|
|
|
|
console.warn(
|
|
|
|
|
|
|
|
c.yellow(
|
|
|
|
|
|
|
|
`The language '${lang}' is not loaded, falling back to '${
|
|
|
|
|
|
|
|
defaultLang || 'txt'
|
|
|
|
|
|
|
|
}' for syntax highlighting.`
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
lang = defaultLang
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const lineOptions = attrsToLines(attrs)
|
|
|
|
const lineOptions = attrsToLines(attrs)
|
|
|
|
const cleanup = (str: string) =>
|
|
|
|
const cleanup = (str: string) =>
|
|
|
|
str
|
|
|
|
str
|
|
|
|