Change \n within tables to enter line breaks rather then start new cells

pull/1140/head
Ganni 2024-12-02 21:54:29 -05:00 committed by GitHub
parent 22c960d193
commit 4ee10fd8f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 0 deletions

View File

@ -209,6 +209,11 @@ const RE_EMPTY_LINE = /^\s*?$/gm;
*/
const RE_PLUS = /^\s*\+(?:$|[^+])/gm;
/**
* Regex for replaceing a newline with <br> 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 <br> rather then start a new cell
.replace(RE_TABLE_NEWLINE, "<br>")
// Strip excessive blockquote or list indentation
.replace(RE_RECURSIVE, (_, m0, m1) => m0 + m1)