/** * Convertit du Markdown Mistral en HTML avec inline styles. * Inline styles = zéro dépendance CSS, fonctionne dans tout contexte Vue (scoped, v-html, etc.) */ export function useMarkdown() { const S = { p: 'style="margin:0 0 0.45em;line-height:1.6;"', strong: 'style="font-weight:700;"', em: 'style="font-style:italic;"', h2: 'style="font-weight:700;display:block;margin-bottom:0.2em;"', h3: 'style="font-weight:700;display:block;font-size:0.95em;margin-bottom:0.15em;"', ul: 'style="margin:0.3em 0 0.3em 1.2em;padding:0;list-style:disc;"', li: 'style="margin-bottom:0.15em;"', a: 'style="text-decoration:underline;opacity:0.85;"', } function render(text: string): string { if (!text) return '' let html = text .replace(/&/g, '&').replace(//g, '>') .replace(/^### (.+)$/gm, `$1`) .replace(/^## (.+)$/gm, `$1`) .replace(/^# (.+)$/gm, `$1`) .replace(/\*\*(.+?)\*\*/g, `$1`) .replace(/\*(.+?)\*/g, `$1`) .replace(/^[-•]\s+(.+)$/gm, `
  • $1
  • `) .replace(/\[([^\]]+)\]\(([^)]+)\)/g, `$1`) html = html.replace(/(]*>.*<\/li>\n?)+/g, m => ``) html = html.replace(/\n{2,}/g, `

    `) html = html.replace(/\n/g, '
    ') return `

    ${html}

    ` } return { render } }