feat(feishu): auto-convert markdown tables to native table component - #41980
Closed
UniGood wants to merge 1 commit into
Closed
feat(feishu): auto-convert markdown tables to native table component#41980UniGood wants to merge 1 commit into
UniGood wants to merge 1 commit 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.
4 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.
Problem
Feishu's post-type
mdelements cannot render markdown tables. When the adapter detects a table in outbound content, it falls back to plain text — the user sees raw pipe characters like| Name | Age |instead of a proper table.Solution
Intercept markdown tables in
_build_outbound_payload()and convert them to Feishu card v2 interactive cards using the nativetablecomponent. The card renders tables as proper interactive tables with columns, rows, and pagination.No LLM involved — pure regex detection + string parsing, zero additional latency.
Changes
gateway/platforms/feishu.py_build_table_card_payload(content)— Parses markdown table content and builds a Feishu card v2 JSON with native table component. ReturnsNoneon failure (caller falls back to plain text)._build_feishu_table_element(seg)— Builds a Feishu card v2tablecomponent 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()Behavior
Testing
All 216 tests pass:
python -m pytest tests/gateway/test_feishu.py -x -q