Skip to content
Permalink
Browse files Browse the repository at this point in the history
fix: Improve message rendering (#12748)
  • Loading branch information
atomrc committed Mar 30, 2022
1 parent 6f3bcf8 commit d144552
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/script/util/messageRenderer.ts
Expand Up @@ -138,7 +138,7 @@ export const renderMessage = (message: string, selfId: QualifiedId | null, menti
if (containsMentions) {
// disable code highlighting if there is a mention in there
// highlighting will be wrong anyway because this is not valid code
return code;
return escape(code);
}
return hljs.highlightAuto(code).value;
},
Expand All @@ -148,7 +148,7 @@ export const renderMessage = (message: string, selfId: QualifiedId | null, menti
const cleanString = (hashedString: string) =>
escape(
Object.entries(mentionTexts).reduce(
(text, [mentionHash, mention]) => text.replace(mentionHash, mention.text),
(text, [mentionHash, mention]) => text.replace(mentionHash, () => mention.text),
hashedString,
),
);
Expand Down Expand Up @@ -214,7 +214,7 @@ export const renderMessage = (message: string, selfId: QualifiedId | null, menti
const parsedText = Object.keys(mentionTexts).reduce((text, mentionHash) => {
const mentionMarkup = renderMention(mentionTexts[mentionHash]);

return text.replace(mentionHash, mentionMarkup);
return text.replace(mentionHash, () => mentionMarkup);
}, mentionlessText);
return parsedText;
};
Expand Down

0 comments on commit d144552

Please sign in to comment.