Merged
Merged
Conversation
Previously, PTB is producing incorrect results when formatting a message into the Markdown v2 format (Message.(text|caption)_markdown_v2). Specifically, when there is any of the need-to-escape characters _*~`>#+-=|{}.! appear in a nested entities, the last few characters was repeated at the end of the range.
For example
| Message | What PTB gives | Expected result |
|---|---|---|
<b><hashtag>#boldhashtag</hashtag></b> |
*#boldhashtag*g |
*#boldhashtag* |
<b><i>a{b+c}d</i></b> |
*_a\{b\+c\}d_\\}d* |
*_a\{b\+c\}d_* |
* <hashtag /> is used here just to represent the hashtag entity, Telegram does not support such a tag.
The issue is suspected to be caused by the used of escaped text sequence for nested entities, which is causing a discrepancy in the length of text due to the introduction of \.
This PR fixes the issue by using the original text (orig_text) as a basis for nested entity parsing. It also includes updated tests to address this issue.
blueset
changed the title
Fix: overly escape and offset error markdown v2 symbols when nested
Fix: overly escape and offset error for markdown v2 symbols when nested
blueset
changed the title
Fix: overly escape and offset error for markdown v2 symbols when nested
Fix: overly escape and offset error for markdown v2 and HTML symbols when nested
Labels
None yet