Merge pull request 'Decode html-encoded characters inside pre tags' (#101) from sfr/pleroma-fe:mfm-htmlencode into develop
ci/woodpecker/push/woodpecker Pipeline was successful Details

Reviewed-on: AkkomaGang/pleroma-fe#101
This commit is contained in:
floatingghost 2022-08-04 07:52:58 +00:00
commit 9421aa1d39
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;', "'")
)
})
}