fix: render lang of code block
parent
714b8d2bb1
commit
0ada9e0448
|
@ -60,10 +60,9 @@ export function contentToVNode(
|
||||||
return `:${name}:`
|
return `:${name}:`
|
||||||
})
|
})
|
||||||
// handle code frames
|
// handle code frames
|
||||||
.replace(/<p>(```|~~~)([\s\S]+?)\1/g, (_1, _2, raw) => {
|
.replace(/<p>(```|~~~)([\w]*)([\s\S]+?)\1/g, (_1, _2, lang, raw) => {
|
||||||
const plain = htmlToText(`<p>${raw}</p>`).trim()
|
const code = htmlToText(`<p>${raw}</p>`)
|
||||||
const [lang, ...rest] = plain.split(/\n/)
|
return `<custom-code lang="${lang?.trim().toLowerCase() || ''}" code="${encodeURIComponent(code)}"></custom-code>`
|
||||||
return `<custom-code lang="${lang?.trim().toLowerCase() || ''}" code="${encodeURIComponent(rest.join('\n'))}"></custom-code>`
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const tree = parseFragment(content)
|
const tree = parseFragment(content)
|
||||||
|
|
Loading…
Reference in New Issue