Skip to content
Snippets Groups Projects
Unverified Commit 6cb79a04 authored by Kishan Lal Rai's avatar Kishan Lal Rai Committed by GitHub
Browse files

fix: Inconsistent Markdown Formatting in Custom Status Field (#32574)

parent 0b0d4d8c
No related branches found
No related tags found
No related merge requests found
---
'@rocket.chat/meteor': patch
---
Fixed issue with asterisk-wrapped text not becoming bold when user enters profile custom status.
......@@ -16,16 +16,21 @@ type MarkdownTextParams = {
withTruncatedText: boolean;
} & ComponentProps<typeof Box>;
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 =>
`<a href="${href}" rel="nofollow noopener noreferrer">${text}</a> `;
const paragraphMarked = (text: string): string => text;
......@@ -112,7 +117,6 @@ 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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment