fix: improve loading
This commit is contained in:
parent
70645180aa
commit
dbf4362d8b
4 changed files with 22 additions and 14 deletions
|
@ -59,11 +59,11 @@ export function contentToVNode(
|
|||
return `<img src="${emoji.url}" alt="${name}" class="custom-emoji" />`
|
||||
return `:${name}:`
|
||||
})
|
||||
// handle codeblocks
|
||||
// handle code frames
|
||||
.replace(/<p>(```|~~~)([\s\S]+?)\1(\s|<br\s?\/?>)*<\/p>/g, (_1, _2, raw) => {
|
||||
const plain = htmlToText(`<p>${raw}</p>`).trim()
|
||||
const [lang, ...rest] = plain.split(/\n/)
|
||||
return `<custom-code lang="${lang || ''}" code="${encodeURIComponent(rest.join('\n'))}" />`
|
||||
return `<custom-code lang="${lang?.trim().toLowerCase() || ''}" code="${encodeURIComponent(rest.join('\n'))}" />`
|
||||
})
|
||||
|
||||
const tree = parseFragment(content)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue