|
|
@ -1,13 +1,7 @@
|
|
|
|
import { customAlphabet } from 'nanoid'
|
|
|
|
import { customAlphabet } from 'nanoid'
|
|
|
|
import c from 'picocolors'
|
|
|
|
import c from 'picocolors'
|
|
|
|
import type { ShikiTransformer } from 'shiki'
|
|
|
|
import type { ShikiTransformer } from 'shiki'
|
|
|
|
import {
|
|
|
|
import { bundledLanguages, getHighlighter, isSpecialLang } from 'shiki'
|
|
|
|
addClassToHast,
|
|
|
|
|
|
|
|
bundledLanguages,
|
|
|
|
|
|
|
|
getHighlighter,
|
|
|
|
|
|
|
|
isPlaintext as isPlainLang,
|
|
|
|
|
|
|
|
isSpecialLang
|
|
|
|
|
|
|
|
} from 'shiki'
|
|
|
|
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
transformerCompactLineOptions,
|
|
|
|
transformerCompactLineOptions,
|
|
|
|
transformerNotationDiff,
|
|
|
|
transformerNotationDiff,
|
|
|
@ -85,7 +79,7 @@ export async function highlight(
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: 'vitepress:add-class',
|
|
|
|
name: 'vitepress:add-class',
|
|
|
|
pre(node) {
|
|
|
|
pre(node) {
|
|
|
|
addClassToHast(node, 'vp-code')
|
|
|
|
this.addClassToHast(node, 'vp-code')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -113,7 +107,7 @@ export async function highlight(
|
|
|
|
|
|
|
|
|
|
|
|
if (lang) {
|
|
|
|
if (lang) {
|
|
|
|
const langLoaded = highlighter.getLoadedLanguages().includes(lang as any)
|
|
|
|
const langLoaded = highlighter.getLoadedLanguages().includes(lang as any)
|
|
|
|
if (!langLoaded && !isPlainLang(lang) && !isSpecialLang(lang)) {
|
|
|
|
if (!langLoaded && !isSpecialLang(lang)) {
|
|
|
|
logger.warn(
|
|
|
|
logger.warn(
|
|
|
|
c.yellow(
|
|
|
|
c.yellow(
|
|
|
|
`\nThe language '${lang}' is not loaded, falling back to '${
|
|
|
|
`\nThe language '${lang}' is not loaded, falling back to '${
|
|
|
|