Spaces:
Sleeping
Sleeping
File size: 614 Bytes
ece21ed | 1 2 3 4 5 6 7 8 9 10 11 12 13 | import { marked } from 'marked';
import DOMPurify from 'dompurify';
// Render markdown to SANITIZED HTML. Agent output and skill files can contain
// untrusted content (an agent may echo something it read from the web or a
// repo), and we inject the result via dangerouslySetInnerHTML into a page that
// has full backend/shell access — so it must be sanitized. marked does not
// sanitize; DOMPurify strips scripts, event handlers, and dangerous URLs.
export function renderMarkdown(md: string): string {
const html = marked.parse(md ?? '', { async: false }) as string;
return DOMPurify.sanitize(html);
}
|