// Lightweight safe Markdown to HTML parsing function — shared by blog posts and AI itinerary results. export function renderMarkdownToHtml(md: string): string { if (!md) return '' let html = md .replace(/&/g, '&') .replace(//g, '>') // Bold html = html.replace(/\*\*(.*?)\*\*/g, '$1') html = html.replace(/__(.*?)__/g, '$1') // Italic html = html.replace(/\*(.*?)\*/g, '$1') html = html.replace(/_(.*?)_/g, '$1') // Headings html = html.replace(/^### (.*?)$/gm, '
$1') // Links html = html.replace(/\[(.*?)\]\((.*?)\)/g, '$1') // Paragraphs const blocks = html.split(/\n\n+/) html = blocks.map(block => { const trimmed = block.trim() if (!trimmed) return '' if (trimmed.startsWith('