mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-23 02:17:21 +00:00
Created Text Formatting (markdown)
parent
0bc3beb870
commit
a8e02818f7
47
Text-Formatting.md
Normal file
47
Text-Formatting.md
Normal file
@ -0,0 +1,47 @@
|
||||
Pyrogram, just like [Telegram Bot API](https://core.telegram.org/bots/api#formatting-options), supports basic Markdown formatting for messages; it uses the same syntax as Telegram Desktop's and is enabled by default. Beside bold, italic, and pre-formatted code, **Pyrogram does also support inline URLs and inline mentions of users**.
|
||||
|
||||
Here is the complete syntax you can use when sending or editing messages:
|
||||
|
||||
<pre>
|
||||
**bold text**
|
||||
|
||||
__italic text__
|
||||
|
||||
[inline URL](http://www.example.com/)
|
||||
|
||||
[inline mention of a user](tg://user?id=123456789)
|
||||
|
||||
`inline fixed-width code`
|
||||
|
||||
```block_language
|
||||
pre-formatted fixed-width code block
|
||||
```
|
||||
</pre>
|
||||
|
||||
## Code snippets
|
||||
|
||||
- Inline entities (bold, italic, ...):
|
||||
|
||||
``` python
|
||||
client.send_message(
|
||||
chat_id="me",
|
||||
text="**bold**, __italic__, [mention](tg://user?id=23122162), [url](https://pyrogram.ml), `code`"
|
||||
)
|
||||
```
|
||||
|
||||
**Note:** Mentions are only guaranteed to work if you have already contacted the user.
|
||||
|
||||
- Code blocks:
|
||||
|
||||
<pre lang="python">
|
||||
client.send_message(
|
||||
chat_id="me",
|
||||
text=(
|
||||
# Code block language is optional
|
||||
"``` python\n"
|
||||
"for i in range(10):\n"
|
||||
" print(i)\n"
|
||||
"```"
|
||||
)
|
||||
)
|
||||
</pre>
|
Loading…
x
Reference in New Issue
Block a user