You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Telegram messages show raw Markdown instead of formatted text #24
Messages sent to Telegram show raw Markdown syntax instead of rendered formatting. Bold text shows as **text**, and links show as [text](url) instead of being clickable.
Example output in Telegram
Right now in **Antwerp**, the temperature is approximately **6°C (43°F)**, with a feels-like temperature of around **4°C**. There are brief showers occurring in the area, and conditions are quite chilly and wintry. Humidity is high at around 93%.
Sources:
- [Weather Today - Antwerp, Belgium (Weather Atlas)](https://www.weather-atlas.com/en/belgium/antwerp)
- [Antwerp Current Weather (AccuWeather)](https://www.accuweather.com/en/be/antwerp/27046/current-weather/27046)
- [BBC Weather - Antwerp](https://www.bbc.com/weather/2803138)
Expected
Bold text should be rendered as bold, and links should be clickable.
Notes
The AI model outputs standard Markdown (**bold**, [text](url)), but Telegram requires either:
Markdown v1 parse mode — natively supports *bold*, _italic_, `code`, and [links](url). Only needs **bold** → *bold* conversion.
HTML parse mode — needs Markdown → HTML conversion.
MarkdownV2 parse mode — requires escaping all special characters, which conflicts with the AI's standard Markdown output.
Proposed Solution:
Instead of using MarkdownV2 (which is highly sensitive to special character escaping and prone to errors with AI-generated text), I propose converting the AI's Markdown output to HTML before sending it to the Telegram API.
Implementation Details:
Library: Use commonmark-java within the Gradle build to handle the conversion efficiently.
Formatting Logic: Implement a utility service to map standard Markdown tags (**, ) to Telegram-compatible HTML tags (, ).
API Update: Set the parse_mode to HTML in the outgoing SendMessage payload.
This approach is more robust than regex-based string replacement and ensures that links and bold text render correctly across all Telegram clients.
Could you please assign this issue to me? I can have a PR ready shortly.
I’ve implemented the Markdown → HTML conversion using CommonMark and integrated it with Telegram’s HTML parse mode.
I also added a unit test (formatsMarkdownToHtmlAndSetsParseMode) to verify that Markdown is correctly transformed into Telegram-compatible HTML.
The test is passing locally. However, for full end-to-end validation with actual bot responses, I would need an OpenAI API key, which I currently don’t have.
Please let me know if you’d like me to validate this in any other way or make further improvements.
Hi @Mohammedamaan5714 , can you make a pull request? Thanks for your contribution!
Can you make a pull request? Then we can check your code and validate it in a real environment!
Activity
Mohammedamaan5714 commentedon Mar 23, 2026
Proposal to fix Markdown rendering issues using HTML ParseMode
Hi @iNicholasBE ,
I would like to work on this issue.
Proposed Solution:
Instead of using MarkdownV2 (which is highly sensitive to special character escaping and prone to errors with AI-generated text), I propose converting the AI's Markdown output to HTML before sending it to the Telegram API.
Implementation Details:
Library: Use commonmark-java within the Gradle build to handle the conversion efficiently.
Formatting Logic: Implement a utility service to map standard Markdown tags (**, ) to Telegram-compatible HTML tags (, ).
API Update: Set the parse_mode to HTML in the outgoing SendMessage payload.
This approach is more robust than regex-based string replacement and ensures that links and bold text render correctly across all Telegram clients.
Could you please assign this issue to me? I can have a PR ready shortly.
rdehuyss commentedon Mar 23, 2026
Hi @Mohammedamaan5714 - sounds like a good plan!
Markdown to html is indeed also my preferred solution.
Mohammedamaan5714 commentedon Mar 26, 2026
Hi @rdehuyss,
I’ve implemented the Markdown → HTML conversion using CommonMark and integrated it with Telegram’s HTML parse mode.
I also added a unit test (formatsMarkdownToHtmlAndSetsParseMode) to verify that Markdown is correctly transformed into Telegram-compatible HTML.
The test is passing locally. However, for full end-to-end validation with actual bot responses, I would need an OpenAI API key, which I currently don’t have.
Please let me know if you’d like me to validate this in any other way or make further improvements.
iNicholasBE commentedon Mar 26, 2026
Hi @Mohammedamaan5714 , can you make a pull request? Thanks for your contribution!
Can you make a pull request? Then we can check your code and validate it in a real environment!
Mohammedamaan5714 commentedon Mar 26, 2026
Hi @rdehuyss, I have opened a PR for this. Please review when you get time.
rdehuyss commentedon Mar 26, 2026
Will do! Probably for somewhere end of today. Thx!
gnhf ClawRunr#24: Phase 8 Backend REST API: созданы 5 контроллеров (T…
gnhf ClawRunr#24: Реализован 10.4 Tool deny patterns — ToolDenyProper…