import { marked } from "marked"; const defaultCss = ` body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 14px; line-height: 1.6; color: #1a1a1a; max-width: 100%; } h1 { font-size: 2em; margin-bottom: 0.5em; border-bottom: 1px solid #eee; padding-bottom: 0.3em; } h2 { font-size: 1.5em; margin-bottom: 0.5em; } h3 { font-size: 1.25em; } code { background: #f4f4f4; padding: 2px 6px; border-radius: 3px; font-size: 0.9em; } pre { background: #f4f4f4; padding: 16px; border-radius: 6px; overflow-x: auto; } pre code { background: none; padding: 0; } table { border-collapse: collapse; width: 100%; margin: 1em 0; } th, td { border: 1px solid #ddd; padding: 8px 12px; text-align: left; } th { background: #f8f8f8; font-weight: 600; } blockquote { border-left: 4px solid #ddd; margin: 1em 0; padding: 0.5em 1em; color: #666; } img { max-width: 100%; } `; export function markdownToHtml(md, css) { const html = marked.parse(md, { async: false }); return wrapHtml(html, css || defaultCss); } export function wrapHtml(body, css) { return ` ${body}`; }