// Best-effort Markdown → WhatsApp formatting. WhatsApp: *bold*, _italic_, ~strike~, ```mono```. // Covers the common inline marks; nested/edge Markdown falls through as plain text (acceptable // for chat bubbles). Upgrade to a real Markdown AST only if flows lean on rich formatting. export function mdToWhatsApp(md: string): string { let s = md; s = s.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1 ($2)'); // links → text (url) s = s.replace(/^([ \t]*)[*+][ \t]+/gm, '$1- '); // * item / + item → - item (a bullet, not italic) s = s.replace(/(?