fix(feishu): render markdown tables as monospace code blocks - #20580
Closed
mytangyh wants to merge 1 commit into
Closed
fix(feishu): render markdown tables as monospace code blocks#20580mytangyh wants to merge 1 commit into
mytangyh wants to merge 1 commit into
Conversation
Feishu md tag does not render markdown tables. The previous approach fell back to plain text mode for messages containing tables, which lost all formatting. Instead, convert markdown tables to box-drawing characters inside fenced code blocks so the md renderer displays them in monospace with proper column alignment. Changes: - Add _convert_md_tables() that parses markdown tables and renders them with Unicode box-drawing characters wrapped in code fences - Handle CJK characters correctly using unicodedata.east_asian_width for proper column width calculation - Update _MARKDOWN_TABLE_RE to capture full tables including body rows - Modify _build_outbound_payload to convert tables before sending through the post (md) pipeline instead of falling back to text mode - Add 7 unit tests covering simple tables, CJK alignment, surrounding text, no-table passthrough, multiple tables, alignment markers, and empty cells
Collaborator
Author
|
Closing this PR — upstream already has commit 8e18d10 (fix(feishu): force text mode for markdown tables) by WuTianyi, which solves the same problem with a better approach (space-aligned monospace columns instead of box-drawing characters). The current code works well. No need for this redundant fix. |
8 tasks
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.
What does this PR do?
Fixes broken markdown table rendering in the Feishu platform adapter. Instead of falling back to plain text mode (which loses all formatting), markdown tables are now converted to Unicode box-drawing characters inside fenced code blocks, rendering in monospace with proper column alignment.
Related Issue
Fixes the issue where Feishu messages containing markdown tables were sent as unformatted plain text, causing tables to appear misaligned and unreadable.
Type of Change
Changes Made
gateway/platforms/feishu.py: Add_convert_md_tables()function that parses markdown tables and renders them with Unicode box-drawing characters (\u250c\u2500\u252c\u2500\u2510 etc.) wrapped in fenced code blocksgateway/platforms/feishu.py: Handle CJK characters correctly usingunicodedata.east_asian_widthfor proper column width calculationgateway/platforms/feishu.py: Update_MARKDOWN_TABLE_REregex to capture full tables including body rows (not just header + separator)gateway/platforms/feishu.py: Modify_build_outbound_payloadto convert tables through thepost(md) pipeline instead of falling back totextmodetests/gateway/test_feishu.py: Add 7 unit tests for_convert_md_tablescovering simple tables, CJK alignment, surrounding text, no-table passthrough, multiple tables, alignment markers, and empty cellsHow to Test
| Name | Value |\n|---|---|\n| foo | bar |)pytest tests/gateway/test_feishu.py::TestConvertMdTables -vChecklist
pytest tests/gateway/test_feishu.py -qand all 204 tests pass