fix: escape backticks within codeblocks
resolves https://github.com/elk-zone/elk/issues/970
This commit is contained in:
parent
a12d3d09b1
commit
8da4a8e78a
3 changed files with 11 additions and 1 deletions
|
@ -55,7 +55,10 @@ export function parseMastodonHTML(
|
|||
// Handle code blocks
|
||||
html = html
|
||||
.replace(/>(```|~~~)(\w*)([\s\S]+?)\1/g, (_1, _2, lang: string, raw: string) => {
|
||||
const code = htmlToText(raw).replace(/</g, '<').replace(/>/g, '>')
|
||||
const code = htmlToText(raw)
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/`/, '`')
|
||||
const classes = lang ? ` class="language-${lang}"` : ''
|
||||
return `><pre><code${classes}>${code}</code></pre>`
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue