From 6df5e388b754aef81d5cc2aed9a5993bd6d2612d Mon Sep 17 00:00:00 2001 From: csuadev <72958726+csuadev@users.noreply.github.com> Date: Thu, 22 Aug 2024 18:53:26 +0200 Subject: [PATCH] Revert "fix: Inconsistent Markdown Formatting in Custom Status Field (#32574)" This reverts commit 6cb79a0482eed9e350a445dc9629e5e85a4757c0. --- .changeset/kind-drinks-joke.md | 5 ----- apps/meteor/client/components/MarkdownText.tsx | 18 +++++++----------- 2 files changed, 7 insertions(+), 16 deletions(-) delete mode 100644 .changeset/kind-drinks-joke.md diff --git a/.changeset/kind-drinks-joke.md b/.changeset/kind-drinks-joke.md deleted file mode 100644 index b235f5556805..000000000000 --- a/.changeset/kind-drinks-joke.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@rocket.chat/meteor': patch ---- - -Fixed issue with asterisk-wrapped text not becoming bold when user enters profile custom status. diff --git a/apps/meteor/client/components/MarkdownText.tsx b/apps/meteor/client/components/MarkdownText.tsx index 3670bcc7cec0..c9af942f6e1c 100644 --- a/apps/meteor/client/components/MarkdownText.tsx +++ b/apps/meteor/client/components/MarkdownText.tsx @@ -16,21 +16,16 @@ type MarkdownTextParams = { withTruncatedText: boolean; } & ComponentProps; -const walkTokens = (token: marked.Token) => { - const boldPattern = /^\*.*\*$|^\*.*|.*\*$/; - const italicPattern = /^__(?=\S)([\s\S]*?\S)__(?!_)|^_(?=\S)([\s\S]*?\S)_(?!_)/; - if (boldPattern.test(token.raw)) { - token.type = 'strong'; - } else if (italicPattern.test(token.raw)) { - token.type = 'em'; - } -}; - -marked.use({ walkTokens }); const documentRenderer = new marked.Renderer(); const inlineRenderer = new marked.Renderer(); const inlineWithoutBreaks = new marked.Renderer(); +marked.Lexer.rules.gfm = { + ...marked.Lexer.rules.gfm, + strong: /^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/, + em: /^__(?=\S)([\s\S]*?\S)__(?!_)|^_(?=\S)([\s\S]*?\S)_(?!_)/, +}; + const linkMarked = (href: string | null, _title: string | null, text: string): string => `${text} `; const paragraphMarked = (text: string): string => text; @@ -117,6 +112,7 @@ const MarkdownText = ({ const markedHtml = /inline/.test(variant) ? marked.parseInline(new Option(content).innerHTML, markedOptions) : marked.parse(new Option(content).innerHTML, markedOptions); + if (parseEmoji) { // We are using the old emoji parser here. This could come // with additional processing use, but is the workaround available right now.