diff --git a/plugins/plugin-shikiji/src/node/highlight.ts b/plugins/plugin-shikiji/src/node/highlight.ts index 1669a7dd..48e23454 100644 --- a/plugins/plugin-shikiji/src/node/highlight.ts +++ b/plugins/plugin-shikiji/src/node/highlight.ts @@ -24,6 +24,7 @@ import { defaultHoverInfoProcessor, transformerTwoslash } from './rendererTransf const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz', 10) const cache = new LRUCache(64) +const vueRE = /-vue$/ const RE_ESCAPE = /\[\\\!code/g const mustacheRE = /\{\{.*?\}\}/g @@ -91,6 +92,7 @@ export async function highlight( return (str: string, lang: string, attrs: string) => { lang = lang || defaultLang + const vPre = vueRE.test(lang) ? '' : 'v-pre' const key = str + lang + attrs @@ -150,6 +152,15 @@ export async function highlight( }, })) } + else { + inlineTransformers.push({ + name: 'vuepress:v-pre', + pre(node) { + if (vPre) + node.properties['v-pre'] = '' + }, + }) + } if ( (whitespace && attributes.whitespace !== false)