v1.38: Markdown in Assistenten-Antworten rendern (**fett**, *kursiv*, code)
Sichtung live im Browser: Widget-Lasche/Panel/Chat geprueft, Chat beantwortet Frage korrekt; Kimi liefert Markdown, das zuvor als roher Text mit ** sichtbar war. Mini-Renderer in AssistChat (nur Text-Auszeichnungen, kein HTML).
This commit is contained in:
@@ -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 (
|
||||
<strong key={i} className="font-semibold">
|
||||
{teil.slice(2, -2)}
|
||||
</strong>
|
||||
)
|
||||
if (teil.startsWith('*') && teil.endsWith('*') && teil.length > 2)
|
||||
return <em key={i}>{teil.slice(1, -1)}</em>
|
||||
if (teil.startsWith('`') && teil.endsWith('`') && teil.length > 2)
|
||||
return (
|
||||
<code key={i} className="rounded bg-black/10 px-1 text-[0.85em] dark:bg-white/10">
|
||||
{teil.slice(1, -1)}
|
||||
</code>
|
||||
)
|
||||
return <span key={i}>{teil}</span>
|
||||
})
|
||||
}
|
||||
|
||||
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)}
|
||||
</div>
|
||||
{m.rolle === 'user' && (
|
||||
<span className="mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800">
|
||||
|
||||
Reference in New Issue
Block a user