From 06868d6e831b6fe37642a2c608deaa61948e5c3d Mon Sep 17 00:00:00 2001 From: Manuel Date: Thu, 2 Nov 2023 10:15:29 +0100 Subject: [PATCH] fix: inline code not displayed when converting markdown text to plain text --- src/lib/FormatUtils/index.ts | 14 ++++++++++---- .../components/ProposalDetails/index.tsx | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/FormatUtils/index.ts b/src/lib/FormatUtils/index.ts index 086911c8..b27289b2 100644 --- a/src/lib/FormatUtils/index.ts +++ b/src/lib/FormatUtils/index.ts @@ -214,12 +214,18 @@ export const makrdownToPlainText = (markdownText: string): string => { return stringToTokens(withNewLines, markdownItInstance) .filter((t) => t.children !== null) .flatMap((t) => t.children) - .filter((t) => (t.type === 'text' && t.content !== '') || t.type === 'softbreak') + .filter( + (t) => + (t.type === 'text' && t.content !== '') || + t.type === 'softbreak' || + t.type === 'code_inline', + ) .reduce((previousValue, token) => { - if (token.type === 'text') { - return `${previousValue}${token.content} `; + if (token.type === 'softbreak') { + return `${previousValue}\n`; } - return `${previousValue}\n`; + + return `${previousValue}${token.content} `; }, ''); }; diff --git a/src/screens/GovernanceProposalDetails/components/ProposalDetails/index.tsx b/src/screens/GovernanceProposalDetails/components/ProposalDetails/index.tsx index 90e5453d..94046ddb 100644 --- a/src/screens/GovernanceProposalDetails/components/ProposalDetails/index.tsx +++ b/src/screens/GovernanceProposalDetails/components/ProposalDetails/index.tsx @@ -80,7 +80,7 @@ const ProposalDetails: React.FC = ({ proposal }) => { {/* Description */} {t('common:description')} - {proposal.description.replace(/\\n/gm, '\n')} + {proposal.description} {/* Plan */}