import DOMPurify from 'isomorphic-dompurify'; export function sanitize(input: string): string { return DOMPurify.sanitize(input, { ALLOWED_TAGS: [] }); } /** Sanitize HTML produced by react-markdown — allows safe formatting tags only. */ export function sanitizeMarkdownHtml(input: string): string { return DOMPurify.sanitize(input, { ALLOWED_TAGS: [ 'p', 'br', 'strong', 'b', 'em', 'i', 'a', 'ul', 'ol', 'li', 'code', 'pre', 'blockquote', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', ], ALLOWED_ATTR: ['href', 'target', 'rel'], }); }