* use sanitize-html instead * add list formatting * add lost changes from merging main * fixes caused by merge * remove dompurify * Revert "remove dompurify" This reverts commit 583bb623c7d3c0c7daa28e63ab2b1ac2da68c0d8. * sanitize already done in editor * Update yarn.lock --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Alex van Andel <me@alexvanandel.com>
24 lines
641 B
TypeScript
24 lines
641 B
TypeScript
import sanitizeHtml from "sanitize-html";
|
|
|
|
import { md } from "@calcom/lib/markdownIt";
|
|
|
|
export function markdownToSafeHTML(markdown: string | null) {
|
|
if (!markdown) return null;
|
|
|
|
const html = md.render(markdown);
|
|
|
|
const safeHTML = sanitizeHtml(html);
|
|
|
|
const safeHTMLWithListFormatting = safeHTML
|
|
.replace(
|
|
/<ul>/g,
|
|
"<ul style='list-style-type: disc; list-style-position: inside; margin-left: 12px; margin-bottom: 4px'>"
|
|
)
|
|
.replace(
|
|
/<ol>/g,
|
|
"<ol style='list-style-type: decimal; list-style-position: inside; margin-left: 12px; margin-bottom: 4px'>"
|
|
);
|
|
|
|
return safeHTMLWithListFormatting;
|
|
}
|