Decode html-encoded characters inside pre tags
ci/woodpecker/pr/woodpecker Pipeline was successful Details

This commit is contained in:
Sol Fisher Romanoff 2022-08-02 12:37:18 +03:00
parent 6380e6c4c2
commit 6441ff45a9
Signed by untrusted user who does not match committer: nbsp
GPG Key ID: 9D3F2B64F2341B62
1 changed files with 9 additions and 2 deletions

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;', "'")
)
})
}