forked from Mirrors/elk
fix: render code block
This commit is contained in:
parent
bbc8ed5307
commit
36ea7f6b4e
2 changed files with 1 additions and 4 deletions
|
@ -60,7 +60,7 @@ export function contentToVNode(
|
||||||
return `:${name}:`
|
return `:${name}:`
|
||||||
})
|
})
|
||||||
// handle code frames
|
// 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 plain = htmlToText(`<p>${raw}</p>`).trim()
|
||||||
const [lang, ...rest] = plain.split(/\n/)
|
const [lang, ...rest] = plain.split(/\n/)
|
||||||
return `<custom-code lang="${lang?.trim().toLowerCase() || ''}" code="${encodeURIComponent(rest.join('\n'))}"></custom-code>`
|
return `<custom-code lang="${lang?.trim().toLowerCase() || ''}" code="${encodeURIComponent(rest.join('\n'))}"></custom-code>`
|
||||||
|
|
|
@ -15,9 +15,6 @@ export function highlightCode(code: string, lang: Lang) {
|
||||||
'vitesse-dark',
|
'vitesse-dark',
|
||||||
'vitesse-light',
|
'vitesse-light',
|
||||||
],
|
],
|
||||||
langs: [
|
|
||||||
lang,
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue