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
Reserved Telegram characters ().-_ when using Markdown parse_mode. #553
When using Markdown or MarkdownV2, some characters ()_-. are reserved by Telegram itself and should be escaped unless we get an error, if the case of underline, we don't even get a clear error.
Errors:
telegram: Bad Request: can't parse entities: Character '(' is reserved and must be escaped with the preceding '\' (400)
exit status 0xc000013a
The worst-case scenario with the underline:
telegram: Bad Request: can't parse entities: Can't find end of Italic entity at byte offset 30 (400)
And after investigating the results, I realized it's because of underline character.
You must care about escaping by yourself, it's your responsibility to be sure the message is correct in chosen formatting option. Otherwise, markdown features won't even work. Using HTML is the safest option if you don't want to care about it.
For anyone still landing here: instead of escaping or switching to HTML, you can skip parse_mode and send plain text + entities. Telegram applies formatting from entities directly (much better approach, more stable)
Activity
demget commentedon Oct 1, 2022
You must care about escaping by yourself, it's your responsibility to be sure the message is correct in chosen formatting option. Otherwise, markdown features won't even work. Using HTML is the safest option if you don't want to care about it.
eekstunt commentedon Apr 2, 2026
For anyone still landing here: instead of escaping or switching to HTML, you can skip parse_mode and send plain text + entities. Telegram applies formatting from entities directly (much better approach, more stable)
I ported telegramify-markdown (Python, 600+ stars) to Go: telegramify-markdown-go. Use it in my bot daily, no escaping issues since.
Add escaping helpers for every parse mode
Return a typed, located error for "can't parse entities"