File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 / < u l > / 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 + h r e f = / 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+ / < l i > ( [ ^ < ] + | < s t r o n g > .* ?< \/ s t r o n g > ) < \/ l i > \s * < l i > \s * < u l ( [ ^ > ] * ) > ( [ \s \S ] * ?) < \/ u l > \s * < \/ l i > / g,
33+ "<li>$1<ul$2>$3</ul></li>"
34+ ) ;
35+
2936 return safeHTMLWithListFormatting ;
3037}
Original file line number Diff line number Diff 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 / < u l > / 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 + h r e f = / 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+ / < l i > ( [ ^ < ] + | < s t r o n g > .* ?< \/ s t r o n g > ) < \/ l i > \s * < l i > \s * < u l ( [ ^ > ] * ) > ( [ \s \S ] * ?) < \/ u l > \s * < \/ l i > / g,
33+ "<li>$1<ul$2>$3</ul></li>"
34+ ) ;
35+
2936 return safeHTMLWithListFormatting ;
3037}
You can’t perform that action at this time.
0 commit comments