fix(discord): auto-convert markdown tables to bullet groups - #45781
fix(discord): auto-convert markdown tables to bullet groups#45781yashiels wants to merge 3 commits into
Conversation
4e4e0f8 to
4efc491
Compare
4efc491 to
bc44d5c
Compare
Move table-detection regex, row-splitting, and table-to-bullet conversion into gateway/platforms/helpers.py so both Discord and Telegram adapters can share them. Co-authored-by: Yashiel Sookdeo <yashiel@skyner.co.za>
Discord does not render GFM pipe tables — raw pipe characters display as garbage text. format_message now rewrites tables into bold-heading + bullet groups using the shared helpers. Fixes #21168 Co-authored-by: Yashiel Sookdeo <yashiel@skyner.co.za>
…pers.py Replace local _TABLE_SEPARATOR_RE, _is_table_row, and _split_markdown_table_row with imports from the shared module. Telegram-specific rendering stays local. Co-authored-by: Yashiel Sookdeo <yashiel@skyner.co.za>
bc44d5c to
44e343f
Compare
|
Rebased onto latest Approach note: This PR converts GFM tables to bold-heading + bullet groups rather than code fences. In practice, bullet groups read much better in Discord (especially mobile) than monospace code blocks for tabular agent output. Happy to pivot to code-fence wrapping if maintainers prefer that approach — the shared helpers in Conflict resolution: kept upstream's |
|
Rebased onto latest No CODEOWNERS file in repo; tagging Discord/gateway maintainers for review: @teknium1 @kshitijk4poor — would appreciate a look when you have a moment. Summary: Converts markdown tables to bullet groups in Discord Happy to pivot to code-fence wrapping if that's the preferred approach — bullets read better on Discord mobile in our testing. |
|
Merged via #53284. Your commits were cherry-picked with authorship preserved (rebase-merge) onto latest main. The original branch was 1086 commits behind, and Telegram had migrated from Thanks for the contribution! |
Summary
Discord does not render GFM pipe tables — raw pipe characters display as garbage text. This PR adds automatic table-to-bullet conversion in the Discord adapter's
format_message, matching the pattern Telegram already uses.Changes
1. Shared helpers (
gateway/platforms/helpers.py)TABLE_SEPARATOR_RE,is_table_row,split_markdown_table_row,_render_table_block, andconvert_table_to_bulletsdata_cells = cellsand skip the duplicate-heading bullet2. Discord adapter (
plugins/platforms/discord/adapter.py)format_messagenow callsconvert_table_to_bullets()instead of returning content as-is3. Telegram DRY (
gateway/platforms/telegram.py)_TABLE_SEPARATOR_RE,_is_table_row,_split_markdown_table_rowwith imports from shared helpers_render_table_block_for_telegram,_wrap_markdown_tables) stays localBefore / After (Discord)
Before: Raw pipe characters render as unreadable garbage:
After:
Tests
tests/gateway/test_table_helpers.py)tests/gateway/test_discord_format.py)Edge Cases Handled
---) are not mistaken for table separators|) supportedFixes #21168