diff --git a/src/core/display.test.ts b/src/core/display.test.ts index ea833fd..4057a59 100644 --- a/src/core/display.test.ts +++ b/src/core/display.test.ts @@ -88,6 +88,14 @@ describe('formatReasoningDisplay', () => { expect(result.text).toBe('
Thinking\na < b & c > d
'); }); + it('converts markdown bold and italic to HTML tags in telegram output', () => { + const result = formatReasoningDisplay('**Responding with warmth**\nSome text with *emphasis* here', 'telegram'); + expect(result.parseMode).toBe('HTML'); + expect(result.text).toBe( + '
Thinking\nResponding with warmth\nSome text with emphasis here
', + ); + }); + it('formats non-signal/telegram channels as markdown blockquote', () => { const result = formatReasoningDisplay('line 1\n line 2', 'discord'); expect(result).toEqual({ text: '> **Thinking**\n> line 1\n> line 2' }); diff --git a/src/core/display.ts b/src/core/display.ts index 8884559..edde551 100644 --- a/src/core/display.ts +++ b/src/core/display.ts @@ -231,13 +231,18 @@ export function formatReasoningDisplay( return { text: `**Thinking**\n_${truncated}_` }; } if (channelId === 'telegram' || channelId === 'telegram-mtproto') { - // Telegram: use HTML blockquote to bypass telegramify-markdown spacing + // Telegram: use HTML blockquote to bypass telegramify-markdown spacing. + // Convert basic markdown inline formatting to HTML tags so bold/italic + // render correctly instead of showing raw ** and * characters. const escaped = truncated .replace(/&/g, '&') .replace(//g, '>'); + const html = escaped + .replace(/\*\*(.+?)\*\*/g, '$1') + .replace(/\*(.+?)\*/g, '$1'); return { - text: `
Thinking\n${escaped}
`, + text: `
Thinking\n${html}
`, parseMode: 'HTML', }; }