blueset · GitHub

Merged

Merged

Conversation

@blueset

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.

Signed-off-by: Eana Hufwe <ilove@1a23.com>

@blueset 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

Jan 11, 2021
Signed-off-by: Eana Hufwe <ilove@1a23.com>

@blueset 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

Jan 12, 2021

@Bibo-Joshi

Labels

None yet

Read the original on github.com ↗