From ef64ada12ff3c6e7c4dbfde1b4291bc16b6f4cec Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Sun, 25 Feb 2024 02:34:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(plugin-shikiji):=20=E9=9D=9E=20twoslash=20?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=9D=97=20=E6=B7=BB=E5=8A=A0=20`v-pre`=20?= =?UTF-8?q?=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/plugin-shikiji/src/node/highlight.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) 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)