Anakhand
Anakhand

Reputation: 3028

Why is '.' a reserved character in MarkdownV2 in Telegram's Bot API?

As of Telegram's Bot API version 4.5, the API supports a new text format, MarkdownV2. This is an enhanced version of the previous Markdown support.

The "specification" for MarkdownV2 says:

  • Inside (...) part of inline link definition, all ')' and '\' must be escaped with a preceding '\' character.
  • In all other places characters '_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!' must be escaped with the preceding character '\'.

Why does the dot . character need to be escaped? As far as I can see, it isn't used in any formatting syntax. The syntax examples that Telegram provides certainly doesn't use . in that way:

To use this mode, pass MarkdownV2 in the parse_mode field. Use the following syntax in your message:

*bold \*text*
_italic \*text_
__underline__
~strikethrough~
*bold _italic bold ~italic bold strikethrough~ __underline italic bold___ bold*
[inline URL](http://www.example.com/)
[inline mention of a user](tg://user?id=123456789)
`inline fixed-width code`
```
pre-formatted fixed-width code block
```
```python
pre-formatted fixed-width code block written in the Python programming language
```

Upvotes: 20

Views: 14806

Answers (1)

Chris
Chris

Reputation: 137109

I don't know about Telegram specifically, but Markdown uses . as part of ordered lists, e.g.:

1. One
1. Two
1. Three

which renders as:

  1. One
  2. Two
  3. Three

Note that in the original spec the number used doesn't matter; Markdown renumbers for you.

In contrast,

1\. One
1\. Two
1\. Three

renders as

1. One 1. Two 1. Three

Upvotes: 14

Related Questions