fix: unordered list issue (#23454)

* fix: uordered list issue

* changes

* revert

* Update EventMeta.tsx

---------

Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
This commit is contained in:
Bandhan Majumder
2025-08-30 15:37:10 +00:00
committed by GitHub
co-authored by Anik Dhabal Babu
parent 73b0693632
commit 5c51b0632f
2 changed files with 16 additions and 2 deletions
+8 -1
View File
@@ -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;
}
+8 -1
View File
@@ -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;
}