From e26eccd7fe38d0f0f424e784a2e77cd80a5b3c03 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 03:21:53 +0800 Subject: [PATCH] feat: support lang in code block --- composables/content.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composables/content.ts b/composables/content.ts index b9152121..d4857138 100644 --- a/composables/content.ts +++ b/composables/content.ts @@ -125,7 +125,10 @@ function treeToText(input: Node): string { pre = '\n' if (input.nodeName === 'code') { - pre = '````\n' + const clz = input.attrs.find(attr => attr.name === 'class') + const lang = clz?.value.replace('language-', '') + + pre = `\`\`\`${lang || ''}\n` post = '\n```' }