From 0ada9e0448714e1f31691ea55e90cff313528408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Sat, 26 Nov 2022 11:15:04 +0800 Subject: [PATCH] fix: render lang of code block --- composables/content.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/composables/content.ts b/composables/content.ts index d48571384..b0b2476d6 100644 --- a/composables/content.ts +++ b/composables/content.ts @@ -60,10 +60,9 @@ export function contentToVNode( return `:${name}:` }) // handle code frames - .replace(/

(```|~~~)([\s\S]+?)\1/g, (_1, _2, raw) => { - const plain = htmlToText(`

${raw}

`).trim() - const [lang, ...rest] = plain.split(/\n/) - return `` + .replace(/

(```|~~~)([\w]*)([\s\S]+?)\1/g, (_1, _2, lang, raw) => { + const code = htmlToText(`

${raw}

`) + return `` }) const tree = parseFragment(content)