Migrate from Markdown v1 to HTML parse mode#26
Merged
RichardAtCT merged 2 commits intomainfrom Feb 13, 2026
Merged
Conversation
Telegram's Markdown v1 parser is fragile with Claude's output — underscores in identifiers, asterisks, and brackets frequently cause parse failures. Switching to parse_mode="HTML" is more robust since only 3 characters need escaping (<, >, &) vs the many ambiguous Markdown v1 metacharacters. - Add src/bot/utils/html_format.py with escape_html() and markdown_to_telegram_html() replacing 3 inconsistent _escape_markdown fns - Update all handlers, orchestrator, middleware, and features to use HTML - Fix middleware bug where **bold** was sent without parse_mode - Add HTML send fallback: retry as plain text if Telegram rejects HTML - Update all tests for HTML assertions
Owner
Author
|
PR Review Summary
What looks good
Issues / questions
Suggested tests (if needed)
Verdict
|
Wraps user.first_name with escape_html() to prevent parse failures when names contain <, >, or & characters.
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.
Summary
<,>,&), making it far more robust.src/bot/utils/html_format.pywithescape_html()andmarkdown_to_telegram_html(), replacing 3 inconsistent_escape_markdownfunctions scattered across handlers.**bold**was sent withoutparse_mode, causing users to see literal asterisks in auth, rate limit, and security messages.Changes
Test plan
make test— all 271 tests passmake lint— black, isort, flake8 clean (mypy errors all pre-existing)