feat(feishu): auto-convert markdown tables to native table component - #43882
Closed
UniGood wants to merge 2 commits into
Closed
feat(feishu): auto-convert markdown tables to native table component#43882UniGood wants to merge 2 commits into
UniGood wants to merge 2 commits into
Conversation
Feishu post-type 'md' elements cannot render markdown tables. When the adapter detects a table in outbound content, it now converts it to a Feishu card v2 interactive card using the native 'table' component instead of falling back to plain text with raw pipe characters. No LLM involved — pure regex detection + string parsing, zero additional latency. Changes: - _build_table_card_payload(): Parses markdown tables and builds a Feishu card v2 JSON with native table component (columns + rows). - _build_feishu_table_element(): Builds the table element dict. - _parse_table_segments(): Splits content into text/table segments. - _TABLE_MAX_ROWS = 50: Truncation threshold for large tables. - Modified _build_outbound_payload() to try card conversion first. - 11 new tests covering single table, mixed text+table, multiple tables, large table truncation, malformed input, and alignment marker stripping.
…rsion - Change default card title from '📊 数据' to '📊 Data' - Change truncation message from Chinese to English - Update test assertion to match new English message
Collaborator
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?
Converts markdown tables in Feishu outbound messages to native Feishu card v2 interactive tables, replacing the previous plain-text fallback with raw pipe characters.
Related Issue
Fixes #41980
Type of Change
Changes Made
Noneon failure (caller falls back to plain text).tablecomponent dict from a parsed table segment (columns + rows)._parse_table_segments(content)— Splits content into alternating text/table segments. Tables are parsed into header + rows dicts._TABLE_MAX_ROWS = 50— Truncation threshold; large tables get a warning note._build_outbound_payload()— Tries card conversion first when table detected; falls back to plain text on failure.tests/gateway/test_feishu.pyTestBuildTableCardPayloadcovering:_build_outbound_payload()How to Test
All 216 tests pass.
Checklist