Scheduling infrastructure for absolutely everyone.
fix: unordered list issue (#23454)
Bandhan Majumder5c51b0632f16
diff --git a/packages/lib/markdownToSafeHTML.ts b/packages/lib/markdownToSafeHTML.tsindex 0c272fa5f27..b805b1a3355 100644--- a/packages/lib/markdownToSafeHTML.ts+++ b/packages/lib/markdownToSafeHTML.ts@@ -15,7 +15,7 @@ export function markdownToSafeHTML(markdown: string | null) {const safeHTML = sanitizeHtml(html);- const safeHTMLWithListFormatting = safeHTML+ let safeHTMLWithListFormatting = safeHTML.replace(/<ul>/g,"<ul style='list-style-type: disc; list-style-position: inside; margin-left: 12px; margin-bottom: 4px'>"@@ -26,5 +26,12 @@ export function markdownToSafeHTML(markdown: string | null) {).replace(/<a\s+href=/g, "<a target='_blank' class='text-blue-500 hover:text-blue-600' href=");+ // Match: <li>Some text </li><li><ul>...</ul></li>+ // Convert to: <li>Some text <ul>...</ul></li>+ safeHTMLWithListFormatting = safeHTMLWithListFormatting.replace(+ /<li>([^<]+|<strong>.*?<\/strong>)<\/li>\s*<li>\s*<ul([^>]*)>([\s\S]*?)<\/ul>\s*<\/li>/g,+ "<li>$1<ul$2>$3</ul></li>"+ );+return safeHTMLWithListFormatting;}diff --git a/packages/lib/markdownToSafeHTMLClient.ts b/packages/lib/markdownToSafeHTMLClient.tsindex a377608f60c..434f4aa9c84 100644--- a/packages/lib/markdownToSafeHTMLClient.ts+++ b/packages/lib/markdownToSafeHTMLClient.ts@@ -15,7 +15,7 @@ export function markdownToSafeHTMLClient(markdown: string | null) {const safeHTML = DOMPurify.sanitize(html);- const safeHTMLWithListFormatting = safeHTML+ let safeHTMLWithListFormatting = safeHTML.replace(/<ul>/g,"<ul style='list-style-type: disc; list-style-position: inside; margin-left: 12px; margin-bottom: 4px'>"@@ -26,5 +26,12 @@ export function markdownToSafeHTMLClient(markdown: string | null) {).replace(/<a\s+href=/g, "<a target='_blank' class='text-blue-500 hover:text-blue-600' href=");+ // Match: <li>Some text </li><li><ul>...</ul></li> or+ // Convert to: <li>Some text <ul>...</ul></li>+ safeHTMLWithListFormatting = safeHTMLWithListFormatting.replace(+ /<li>([^<]+|<strong>.*?<\/strong>)<\/li>\s*<li>\s*<ul([^>]*)>([\s\S]*?)<\/ul>\s*<\/li>/g,+ "<li>$1<ul$2>$3</ul></li>"+ );+return safeHTMLWithListFormatting;}