diff --git a/src/components/assist/AssistChat.tsx b/src/components/assist/AssistChat.tsx index 4c6a829..71729b5 100644 --- a/src/components/assist/AssistChat.tsx +++ b/src/components/assist/AssistChat.tsx @@ -8,6 +8,28 @@ export interface Nachricht { text: string } +/** Mini-Markdown für Antwort-Bubbles: **fett**, *kursiv*, `code` – sicher gerendert (kein HTML). */ +function formatierterText(text: string) { + const teile = text.split(/(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`)/g) + return teile.map((teil, i) => { + if (teil.startsWith('**') && teil.endsWith('**') && teil.length > 4) + return ( + + {teil.slice(2, -2)} + + ) + if (teil.startsWith('*') && teil.endsWith('*') && teil.length > 2) + return {teil.slice(1, -1)} + if (teil.startsWith('`') && teil.endsWith('`') && teil.length > 2) + return ( + + {teil.slice(1, -1)} + + ) + return {teil} + }) +} + const BEISPIELE = [ 'Welche Wohnungen stehen leer?', 'Wie hoch ist das monatliche Miet-Soll?', @@ -100,7 +122,7 @@ export default function AssistChat() { : 'bg-slate-100 text-slate-800 dark:bg-slate-800 dark:text-slate-100' }`} > - {m.text} + {formatierterText(m.text)} {m.rolle === 'user' && (