export function MarkdownRenderer({ content }: { content: string }) { let html = content .replace(/&/g, '&') .replace(//g, '>') html = html.replace( /^```[\w]*\n([\s\S]*?)^```$/gm, (_m, code: string) => `
${code.trimEnd()}
` ) html = html.replace( /^(\|.+\|)\n(\|[\s:|-]+\|)\n((?:\|.+\|\n?)*)/gm, (_m, header: string, _sep: string, body: string) => { const ths = header.split('|').filter((c: string) => c.trim()).map((c: string) => `${c.trim()}` ).join('') const rows = body.trim().split('\n').map((row: string) => { const tds = row.split('|').filter((c: string) => c.trim()).map((c: string) => `${c.trim()}` ).join('') return `${tds}` }).join('') return `${ths}${rows}
` } ) html = html.replace(/^### (.+)$/gm, '

$1

') html = html.replace(/^## (.+)$/gm, '

$1

') html = html.replace(/\*\*(.+?)\*\*/g, '$1') html = html.replace(/`([^`]+)`/g, '$1') html = html.replace(/^- (.+)$/gm, '
  • $1
  • ') html = html.replace(/((?:]*>.*<\/li>\n?)+)/g, '') html = html.replace(/^(\d+)\. (.+)$/gm, '
  • $2
  • ') html = html.replace(/^(?!<[hultdp]|$)(.+)$/gm, '

    $1

    ') return
    }