"use client";

import { marked } from "marked";
import DOMPurify from "dompurify";

export async function formatText(text: string): Promise<string> {
  const dirtyHtml = await marked.parse(text);
  if (typeof window !== "undefined") {
    return DOMPurify.sanitize(dirtyHtml);
  }
  return dirtyHtml;
}
