From 262b931810e874623977c2c8d0c6a9464fd1991d Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Fri, 8 Jul 2022 15:36:18 +0100 Subject: [PATCH] fix: actually render HTML out instead of obliterating it --- src/components/markdown/RemarkRenderer.tsx | 18 +++++++++++++++--- src/components/markdown/plugins/mentions.tsx | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/components/markdown/RemarkRenderer.tsx b/src/components/markdown/RemarkRenderer.tsx index 9501a66f..05025ff1 100644 --- a/src/components/markdown/RemarkRenderer.tsx +++ b/src/components/markdown/RemarkRenderer.tsx @@ -173,7 +173,12 @@ const Container = styled.div<{ largeEmoji: boolean }>` /** * Regex for matching execessive blockquotes */ -const RE_QUOTE = /(^[>\s][>\s])[>\s]+([^]+)$/gm; +const RE_QUOTE = /(^[>\s][>\s])[>\s]+([^]+$)/gm; + +/** + * Regex for matching open angled bracket + */ +const RE_OPEN_BRACKET = /\s][>\s])[>\s]+([^]+)$/gm; * @returns Sanitised string */ function sanitise(content: string) { - // Strip excessive blockquote indentation - return content.replace(RE_QUOTE, (_, m0, m1) => m0 + m1); + return ( + content + // Strip excessive blockquote indentation + .replace(RE_QUOTE, (_, m0, m1) => m0 + m1) + // Map < to HTML entity LT + // (otherwise all HTML is just obliterated, + // not even displayed as plain text) + .replace(RE_OPEN_BRACKET, "<") + ); } /** diff --git a/src/components/markdown/plugins/mentions.tsx b/src/components/markdown/plugins/mentions.tsx index 1411dcf5..917d8cda 100644 --- a/src/components/markdown/plugins/mentions.tsx +++ b/src/components/markdown/plugins/mentions.tsx @@ -12,6 +12,8 @@ const Mention = styled.a` align-items: center; display: inline-flex; + cursor: pointer; + font-weight: 600; background: var(--secondary-background); border-radius: calc(var(--border-radius) * 2);