fix(feishu): render markdown tables via card v2 table component#12114
Open
lintingbin wants to merge 2 commits into
Open
fix(feishu): render markdown tables via card v2 table component#12114lintingbin wants to merge 2 commits into
table component#12114lintingbin wants to merge 2 commits into
Conversation
Feishu's post `md` and card `markdown` grammars silently drop GFM pipe tables, so a response containing a markdown table previously arrived as a message with the table rows missing. The same grammars do not render ATX headings or `<br>` tags either — those show as literal text. Route content that contains a GFM table to an interactive card JSON v2 payload. Each table is parsed and emitted as a native `table` component (with typed text columns and per-row cells); surrounding markdown rides along as `markdown` elements. For non-table markdown, the existing post `md` path is kept but headings are rewritten as `**bold**` lines and stray `<br>` tags are replaced with real newlines so emphasis and line breaks survive rendering. Refs Feishu docs: - https://open.feishu.cn/document/uAjLw4CM/ukzMukzMukzM/feishu-cards/card-json-v2-components/content-components/table - https://open.feishu.cn/document/server-docs/im-v1/message-content-description/create_json
Card v2 table cells default to data_type="text" which renders the cell verbatim — so `**13,316**` arrived with literal asterisks instead of bold. Detect inline markdown (bold/italic/code/link) per column and promote affected columns to data_type="lark_md" so Feishu renders the formatting. Plain-text columns keep the safer "text" type.
This was referenced Apr 26, 2026
12 tasks
This was referenced Apr 28, 2026
3 tasks
|
+1 for this approach. We've been running a local workaround (disabling the forced text fallback) but native Card v2 table rendering is clearly the better long-term fix. The unified handling of text segments + table segments, plus the heading/br fix-ups, makes this the most complete solution among the competing PRs. Happy to help test if needed. |
19 tasks
This was referenced May 9, 2026
This was referenced May 18, 2026
This was referenced May 18, 2026
|
We took a complementary approach based on OpenClaw's
Your native |
This was referenced May 20, 2026
This was referenced May 25, 2026
Open
This was referenced Jun 11, 2026
Open
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.
Summary
When Hermes sends a response containing a markdown table to Feishu/Lark, the table rows arrive missing — Feishu's post
mdand cardmarkdowngrammars both silently drop GFM pipe-table syntax, and the same grammars also render<br>tags and ATX headings as literal text. The result is a message where the data the user asked for simply isn't there.This PR routes any content that contains a GFM table to a card JSON v2 payload whose native
tablecomponent renders tabular data properly. Each GFM table is parsed and converted to a typedtableelement (text columns + per-row cells); the surrounding markdown is emitted asmarkdownelements in the same card.For non-table markdown, the existing post
mdpath is kept, but with two small fix-ups so the content no longer shows literal junk:# foo,## foo, …) are rewritten as**foo**bold lines (Feishumddoes not render any heading levels).<br>/<br/>HTML tags are replaced with real newlines (Feishumddoes not render HTML line-break tags).See
create_jsonfor the supported post-md grammar.Before
Arrives in Feishu as
### Income in the last 7 days(literal###, no heading), with the table rows stripped entirely.After
The same input arrives as a card with:
markdownelement containing**Income in the last 7 days**table(sortable, paginated) with the 3 columns and 2 rowsWhat's covered
_split_markdown_for_feishu(content)– parses content into ordered text / table segments._build_feishu_table_element(headers, rows)– emits a card v2tablecomponent (data_type: "text"cells; inline**bold**/`code`/ links survive verbatim)._build_markdown_card_payload(content)– builds the full card (schema: "2.0",body.elements)._transform_text_for_feishu(text)– rewrites headings → bold,<br>→\n._build_outbound_payload– routes tointeractivewhen tables are present, otherwise the existing post / text paths.Test plan
pytest tests/gateway/test_feishu.py— 109 passed (no regressions). New cases:test_transform_text_for_feishu_rewrites_headings_and_brtest_build_outbound_payload_routes_tables_to_interactive_cardtest_build_outbound_payload_keeps_non_table_markdown_on_posttest_card_splits_text_and_tables_in_ordertest_card_table_preserves_inline_markdown_in_cellstest_send_uses_interactive_card_for_table_markdowntest_build_post_payload_extracts_title_and_linksupdated to expect**Title**instead of# Title(the new heading transform).#, no literal<br>, no rows dropped).