Open
Conversation
1077a3b to
609658b
Compare
Markdown is now legacy parse mode and was superseded by MarkdownV2 (as per Telegram bot API: https://core.telegram.org/bots/api#markdownv2-style). This change is reflected in aiogram's quote function, so in order to not add reduntant escape characters, it had to be updated. It also allows nested, underline and strikethrough entities, which may be nice in some future. Unfortunately, it means that a whole lot more characters now must be escaped. These characters: >#+-=|{}.! are not used in markup as of now but are still reserved and require escaping in any place of the message for some reason. For instance, .! reservation means that even translation strings themselves that have punctuation now have to be escaped when used in markdown, because formatter's field values are often should not be escaped (e. g. user links). Meanwhile, _{} reservation means that formatter's placeholders will be escaped with aiogram's markdown.escape_md function. So as a solution I've added an optional argument escape_md to i18n which escaped translation string but rolls back placeholders as they were afterwards. All in all, the style update is a mixed bag. There are some new features which can be useful, but it complicates string construction as reserved characters should be watched much more closely, and some choices for markup characters (in particular, punctuation marks . and !) are questionable to say the least. Signed-off-by: alfred richardsn <rchrdsn@protonmail.ch>
There is a bug in [aiogram](https://github.com/aiogram/aiogram) 2.8 which quotes markdown values as html and tagged 2.9 release outright breaks markdown helpers. It was fixed a couple of days ago in a referenced commit, so bot will use that version of aiogram as a temporary measurement until it will be tagged. Signed-off-by: alfred richardsn <rchrdsn@protonmail.ch>
Signed-off-by: alfred richardsn <rchrdsn@protonmail.ch>
Signed-off-by: alfred richardsn <rchrdsn@protonmail.ch>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Markdown is now legacy parse mode and was superseded by MarkdownV2 (as
per Telegram bot API: https://core.telegram.org/bots/api#markdownv2-style).
This change is reflected in aiogram's quote function, so in order to not
add reduntant escape characters, it had to be updated. It also allows
nested, underline and strikethrough entities, which may be nice in
some future.
Unfortunately, it means that a whole lot more characters now must be
escaped. These characters: >#+-=|{}.! are not used in markup as of now
but are still reserved and require escaping in any place of the message
for some reason. For instance, .! reservation means that even
translation strings themselves that have punctuation now have to be
escaped when used in markdown, because formatter's field values are
often should not be escaped (e. g. user links). Meanwhile, _{}
reservation means that formatter's placeholders will be escaped with
aiogram's markdown.escape_md function. So as a solution I've added an
optional argument escape_md to i18n which escaped translation string but
rolls back placeholders as they were afterwards.
All in all, the style update is a mixed bag. There are some new features
which can be useful, but it complicates string construction as reserved
characters should be watched much more closely, and some choices for
markup characters (in particular, punctuation marks . and !) are
questionable to say the least.
Signed-off-by: alfred richardsn rchrdsn@protonmail.ch
Proposed Changes
Should be tested on unstable bot more for merging.
By sending this contribution I hereby agree to the terms of Contributor License Agreement.