1
0

fix: render code block

This commit is contained in:
三咲智子 2022-11-25 15:25:44 +08:00
parent bbc8ed5307
commit 36ea7f6b4e
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
2 changed files with 1 additions and 4 deletions

View File

@ -60,7 +60,7 @@ export function contentToVNode(
return `:${name}:`
})
// handle code frames
.replace(/<p>(```|~~~)([\s\S]+?)\1(\s|<br\s?\/?>)*<\/p>/g, (_1, _2, raw) => {
.replace(/<p>(```|~~~)([\s\S]+?)\1/g, (_1, _2, raw) => {
const plain = htmlToText(`<p>${raw}</p>`).trim()
const [lang, ...rest] = plain.split(/\n/)
return `<custom-code lang="${lang?.trim().toLowerCase() || ''}" code="${encodeURIComponent(rest.join('\n'))}"></custom-code>`

View File

@ -15,9 +15,6 @@ export function highlightCode(code: string, lang: Lang) {
'vitesse-dark',
'vitesse-light',
],
langs: [
lang,
],
})
})
}