From 4ee10fd8f503123d874611b0c7abe5e26125b0fb Mon Sep 17 00:00:00 2001 From: Ganni Date: Mon, 2 Dec 2024 21:54:29 -0500 Subject: [PATCH] Change \n within tables to enter line breaks rather then start new cells --- src/components/markdown/RemarkRenderer.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/markdown/RemarkRenderer.tsx b/src/components/markdown/RemarkRenderer.tsx index 9504c0d5..5ab277bd 100644 --- a/src/components/markdown/RemarkRenderer.tsx +++ b/src/components/markdown/RemarkRenderer.tsx @@ -209,6 +209,11 @@ const RE_EMPTY_LINE = /^\s*?$/gm; */ const RE_PLUS = /^\s*\+(?:$|[^+])/gm; +/** + * Regex for replaceing a newline with
within a table + */ +const RE_TABLE_NEWLINE = /(?<=\|[^\|]*)\n(?=[^\|]*\|)/g; + /** * Sanitise Markdown input before rendering * @param content Input string @@ -217,6 +222,9 @@ const RE_PLUS = /^\s*\+(?:$|[^+])/gm; function sanitise(content: string) { return ( content + // Makes a newline within a table replace with
rather then start a new cell + .replace(RE_TABLE_NEWLINE, "
") + // Strip excessive blockquote or list indentation .replace(RE_RECURSIVE, (_, m0, m1) => m0 + m1)