From 61a06c3f1aa389b10f0956747810250b85162365 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Sat, 17 Sep 2022 13:01:02 +0100 Subject: [PATCH] fix: re-write blockquote regex to include lists --- src/components/markdown/RemarkRenderer.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/markdown/RemarkRenderer.tsx b/src/components/markdown/RemarkRenderer.tsx index 71cf1d5e..1ba49491 100644 --- a/src/components/markdown/RemarkRenderer.tsx +++ b/src/components/markdown/RemarkRenderer.tsx @@ -180,9 +180,9 @@ const Container = styled.div<{ largeEmoji: boolean }>` `; /** - * Regex for matching execessive blockquotes + * Regex for matching execessive recursion of blockquotes and lists */ -const RE_QUOTE = /(^(?:>\s){5})[>\s]+(.*$)/gm; +const RE_RECURSIVE = /(^(?:[>*+-][^\S\r\n]*){5})(?:[>*+-][^\S\r\n]*)+(.*$)/gm; /** * Regex for matching multi-line blockquotes @@ -212,8 +212,8 @@ const RE_PLUS = /^\s*\+(?:$|[^+])/gm; function sanitise(content: string) { return ( content - // Strip excessive blockquote indentation - .replace(RE_QUOTE, (_, m0, m1) => m0 + m1) + // Strip excessive blockquote or list indentation + .replace(RE_RECURSIVE, (_, m0, m1) => m0 + m1) // Append empty character if string starts with html tag // This is to avoid inconsistencies in rendering Markdown inside/after HTML tags