Skip to content

feat(feishu): render Markdown tables as native card table component#38453

Open
TonyHe-Lab wants to merge 2 commits into
NousResearch:mainfrom
TonyHe-Lab:feat/feishu-table-rendering
Open

feat(feishu): render Markdown tables as native card table component#38453
TonyHe-Lab wants to merge 2 commits into
NousResearch:mainfrom
TonyHe-Lab:feat/feishu-table-rendering

Conversation

@TonyHe-Lab

Copy link
Copy Markdown

Summary

Markdown tables in Feishu messages currently display as raw pipe-separated text because Feishu's post message type does not support table rendering.

This PR switches outbound messages to use Feishu interactive cards (JSON schema 2.0) with the native table component, while keeping non-table content as markdown elements within the same card.

Changes

gateway/platforms/feishu.py

  • New _parse_markdown_table(): parses | col | col | lines into Feishu table component JSON (columns, rows, header_style)
  • New _split_content_and_tables(): line-by-line scanner that groups consecutive table lines and converts them, collecting non-table lines into markdown elements
  • Rewritten _build_outbound_payload(): always returns interactive msg_type with schema 2.0 card structure, mixing markdown + table elements
  • Expanded _POST_CONTENT_INVALID_RE regex to match additional Feishu card error messages
  • Updated fallback logic in send_message, edit_message, _feishu_send_with_retry to handle interactive alongside post

tests/gateway/test_feishu.py

  • Updated 7 tests to assert interactive card structure with schema: "2.0" and body.elements instead of post type

Test Results

All 205 Feishu adapter tests pass.

Before / After

Before: Table messages show as raw | | | plain text
After: Tables render natively as Feishu card table component with headers and cell borders

TonyHE added 2 commits June 4, 2026 04:27
…onent

- Parse Markdown pipe tables into Feishu JSON 2.0 'table' component
  via new _parse_markdown_table() and _split_content_and_tables() methods
- Rewrite _build_outbound_payload() to always return 'interactive' card
  with schema 2.0, mixing markdown elements and table components
- Expand _POST_CONTENT_INVALID_RE to match additional Feishu card error
  messages (failed to create card content, card contains images)
- Update fallback logic in send_message, edit_message, and
  _feishu_send_with_retry to handle 'interactive' msg_type alongside 'post'
- Update 7 tests to assert 'interactive' card structure instead of 'post'
- All 205 feishu adapter tests pass
Previously table cells used data_type='text' with manual markdown
stripping. Feishu table component supports data_type='markdown' (v7.14+)
which renders bold, italic, links, images etc natively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/feishu Feishu / Lark adapter type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants