Skip to content

feat: --parse-mode {plain,html,md} (v1.1.0)#1

Merged
b1rd33 merged 1 commit into
mainfrom
feat/parse-mode
May 9, 2026
Merged

feat: --parse-mode {plain,html,md} (v1.1.0)#1
b1rd33 merged 1 commit into
mainfrom
feat/parse-mode

Conversation

@b1rd33
Copy link
Copy Markdown
Owner

@b1rd33 b1rd33 commented May 9, 2026

Summary

  • Adds --parse-mode {plain,html,md} flag on send, edit-msg, and the four upload-* media commands' captions.
  • Adds parse_mode kwarg to Client().messages.send() and a new Client().messages.edit() SDK method.
  • Behavior change: outbound default flips from Telethon's implicit Markdown to explicit plain text. Previously tg send "C# rocks" could surprise users because Telethon's send_message defaults parse_mode=() which falls back to Markdown. Now the default is explicit plain (parse_mode=None reaches Telethon).

Tests

  • 246 → 255 (+9). New coverage: html / md / plain on send, html / md on edit-msg, parse_mode on media captions (with negative test that omits parse_mode when no caption is set), SDK send + new SDK edit.

Test plan

  • CI matrix green on Ubuntu + macOS × Python 3.12, 3.13
  • `tg send --help` shows the new flag
  • Functional smoke against own Saved Messages: html / md / plain
  • SDK smoke: `Client().messages.send(parse_mode="html", ...)` + `Client().messages.edit(...)`

Out of scope

  • `forward` (Telethon `forward_messages` is caption-agnostic)
  • Custom parser objects (only the three string choices)
  • Read-side rendering — already preserved by Telegram entities

Adds explicit HTML and Markdown formatting on `send`, `edit-msg`,
and the four `upload-*` media commands' captions. SDK exposes the
new kwarg and gains a missing `Client().messages.edit()` method.

Behavior change: outbound default flips from Telethon's implicit
Markdown to plain text. Previously `tg send "C# rocks"` could
trigger surprise formatting because Telethon's send_message
defaults parse_mode=() which falls back to Markdown. The new
default is explicit `plain` (parse_mode=None reaches Telethon).
Pass `--parse-mode md` to opt back into Markdown.

- tgcli/commands/messages.py: --parse-mode on send + edit-msg, plumbed to Telethon calls
- tgcli/commands/media.py: --parse-mode in shared _add_media_args; only threaded when --caption is set
- tgcli/sdk.py: parse_mode kwarg on Client().messages.send; new edit() method
- tgcli/__init__.py: 1.1.0
- CHANGELOG.md: 1.1.0 section with explicit "Changed" note about default flip
- README.md: HTML / Markdown examples in CLI examples block
- docs/commands.md: --parse-mode added to write-flags table
- AGENTS.md: gotcha about default change

Tests: 246 -> 255 (+9 covering html/md/plain on send/edit/media/SDK).
@b1rd33 b1rd33 merged commit 2f8ca18 into main May 9, 2026
3 of 4 checks passed
@b1rd33 b1rd33 deleted the feat/parse-mode branch May 9, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant