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

Reviewed-on: AkkomaGang/pleroma-fe#101
This commit is contained in:
floatingghost 2022-08-04 07:52:58 +00:00
commit 9421aa1d39

View file

@ -124,11 +124,18 @@ export default {
} }
const renderMisskeyMarkdown = (content) => { 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) const codeblocks = content.match(/(<br\/>)?(~~~|```)\w*<br\/>.+?<br\/>\2\1?/g)
if (codeblocks) { if (codeblocks) {
codeblocks.forEach((pre) => { 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;', "'")
)
}) })
} }