import { marked } from "marked"; marked.setOptions({ gfm: true, breaks: true, headerIds: false, mangle: false, sanitize: false, smartLists: true, smartypants: false, }); function applyShortcodes(md, ctx = {}) { md = md.replace(/{{\s*channels\s*}}/g, () => { if (!ctx.kanaly) return ""; const html = ctx.kanaly .map( (k) => `
` ) .join(""); return `
${html}
`; }); return md; } export default function FuzMarkdown({ text, ctx = {} }) { if (!text) return null; let processed = applyShortcodes(text, ctx); processed = processed.replace( /\[([^\]]+)\]\(#([^) "]+)(?:\s+"([^"]+)")?\)/g, (match, label, modalId, title) => { return `${label}`; } ); processed = processed.replace( /\[([^\]]+)\]\("([^"]+)"(?:\s+"([^"]+)")?\s+btn\)/g, (match, label, href, title) => { return `
${label}
`; } ); const html = marked(processed); return (
); }