Skip to content

Commit 5c51b06

Browse files
fix: unordered list issue (calcom#23454)
* fix: uordered list issue * changes * revert * Update EventMeta.tsx --------- Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
1 parent 73b0693 commit 5c51b06

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

packages/lib/markdownToSafeHTML.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function markdownToSafeHTML(markdown: string | null) {
1515

1616
const safeHTML = sanitizeHtml(html);
1717

18-
const safeHTMLWithListFormatting = safeHTML
18+
let safeHTMLWithListFormatting = safeHTML
1919
.replace(
2020
/<ul>/g,
2121
"<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) {
2626
)
2727
.replace(/<a\s+href=/g, "<a target='_blank' class='text-blue-500 hover:text-blue-600' href=");
2828

29+
// Match: <li>Some text </li><li><ul>...</ul></li>
30+
// Convert to: <li>Some text <ul>...</ul></li>
31+
safeHTMLWithListFormatting = safeHTMLWithListFormatting.replace(
32+
/<li>([^<]+|<strong>.*?<\/strong>)<\/li>\s*<li>\s*<ul([^>]*)>([\s\S]*?)<\/ul>\s*<\/li>/g,
33+
"<li>$1<ul$2>$3</ul></li>"
34+
);
35+
2936
return safeHTMLWithListFormatting;
3037
}

packages/lib/markdownToSafeHTMLClient.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function markdownToSafeHTMLClient(markdown: string | null) {
1515

1616
const safeHTML = DOMPurify.sanitize(html);
1717

18-
const safeHTMLWithListFormatting = safeHTML
18+
let safeHTMLWithListFormatting = safeHTML
1919
.replace(
2020
/<ul>/g,
2121
"<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) {
2626
)
2727
.replace(/<a\s+href=/g, "<a target='_blank' class='text-blue-500 hover:text-blue-600' href=");
2828

29+
// Match: <li>Some text </li><li><ul>...</ul></li> or
30+
// Convert to: <li>Some text <ul>...</ul></li>
31+
safeHTMLWithListFormatting = safeHTMLWithListFormatting.replace(
32+
/<li>([^<]+|<strong>.*?<\/strong>)<\/li>\s*<li>\s*<ul([^>]*)>([\s\S]*?)<\/ul>\s*<\/li>/g,
33+
"<li>$1<ul$2>$3</ul></li>"
34+
);
35+
2936
return safeHTMLWithListFormatting;
3037
}

0 commit comments

Comments
 (0)