From b69801d33f7ff4d041c9549cc322ab32bdf1751d Mon Sep 17 00:00:00 2001 From: Sol Fisher Romanoff Date: Mon, 1 Aug 2022 16:13:14 +0300 Subject: [PATCH] Fix code blocks not working in MFM --- src/components/rich_content/rich_content.jsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx index 634236ef..0c1e2c0c 100644 --- a/src/components/rich_content/rich_content.jsx +++ b/src/components/rich_content/rich_content.jsx @@ -124,6 +124,14 @@ export default { } const renderMisskeyMarkdown = (content) => { + // Untangle code blocks from
tags + const codeblocks = content.match(/()?(~~~|```)\w*.+?\2\1?/g) + if (codeblocks) { + codeblocks.forEach((pre) => { + content = content.replace(pre, pre.replaceAll('
', '\n')) + }) + } + marked.use(markedMfm, { mangle: false, gfm: false, -- 2.34.1