1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-05 00:19:59 +00:00

feat: support lang in code block

This commit is contained in:
三咲智子 2022-11-26 03:21:53 +08:00
parent d9d2a946a4
commit e26eccd7fe
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E

View file

@ -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```'
}