Decode html-encoded characters inside pre tags
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful

This commit is contained in:
Sol Fisher Romanoff 2022-08-02 12:37:18 +03:00
parent 6380e6c4c2
commit 6441ff45a9
No known key found for this signature in database
GPG key ID: 9D3F2B64F2341B62

View file

@ -124,11 +124,18 @@ export default {
}
const renderMisskeyMarkdown = (content) => {
// Untangle code blocks from <br> tags
// Untangle code blocks from <br> tags and other html encodings
const codeblocks = content.match(/(<br\/>)?(~~~|```)\w*<br\/>.+?<br\/>\2\1?/g)
if (codeblocks) {
codeblocks.forEach((pre) => {
content = content.replace(pre, pre.replaceAll('<br/>', '\n'))
content = content.replace(pre,
pre.replaceAll('<br/>', '\n')
.replaceAll('&amp;', '&')
.replaceAll('&lt;', '<')
.replaceAll('&gt;', '>')
.replaceAll('&quot', '"')
.replaceAll('&#39;', "'")
)
})
}