Skip to content

Reserved Telegram characters ().-_ when using Markdown parse_mode. #553

Closed

Description

@arshamalh

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.

Activity

  1. modified the milestone: v3.0.1 on Sep 25, 2022
  2. demget commented on Oct 1, 2022

    @demget
    Collaborator

    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.

  3. eekstunt commented on Apr 2, 2026

    @eekstunt

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址