mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
fix(plugin-shikiji): 非 twoslash 代码块 添加 v-pre 指令
This commit is contained in:
parent
ff18a9b267
commit
ef64ada12f
@ -24,6 +24,7 @@ import { defaultHoverInfoProcessor, transformerTwoslash } from './rendererTransf
|
||||
const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz', 10)
|
||||
const cache = new LRUCache<string, string>(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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user