"use client"; import { useEffect, useState } from "react"; import { cn } from "@/lib/utils"; export function SafeMarkdown({ text, className, lines, }: { text: string; className?: string; lines?: 2 | 3; }) { const [html, setHtml] = useState(""); useEffect(() => { if (!text) { setHtml(""); return; } void (async () => { const { marked } = await import("marked"); const DOMPurify = (await import("dompurify")).default; const raw = await marked(text); setHtml(DOMPurify.sanitize(raw)); })(); }, [text]); if (!html) { return (
{text}
); } return (
); }