import { marked } from 'marked' /** * Server-side Markdown → HTML converter. * Converts AI-generated markdown notes into TipTap-compatible rich text HTML. * Uses 'marked' for standard GFM compliance and reliability. */ export function markdownToHtml(markdown: string): string { if (!markdown || !markdown.trim()) return '' // marked.parse returns a string (or a promise if async is true, but we use sync) const html = marked.parse(markdown, { gfm: true, breaks: true, }) as string return html.trim() }