Skip to content

fix(feishu): render markdown tables as native card elements - #20152

Open
Zeknes wants to merge 4 commits into
NousResearch:mainfrom
Zeknes:fix/feishu-md-table-rendering
Open

fix(feishu): render markdown tables as native card elements#20152
Zeknes wants to merge 4 commits into
NousResearch:mainfrom
Zeknes:fix/feishu-md-table-rendering

Conversation

@Zeknes

@Zeknes Zeknes commented May 5, 2026

Copy link
Copy Markdown

Feishu's post format with md tags cannot render markdown tables correctly. This fix detects markdown tables and sends them as interactive card elements with Feishu's native table component.

Changes:

  • Add _TABLE_RE regex to detect markdown tables in content
  • Add _parse_md_table() to parse MD tables into Feishu table elements
  • Add _build_card_elements() to split content into markdown + table elements
  • Add _split_elements_by_table_limit() for Feishu's 1-table-per-card limit
  • Add _build_outbound_payloads() for multi-table content
  • Update send() to handle interactive card errors with fallback
  • Columns use Feishu message API format (no tag field, with data_type)
  • _strip_md_formatting handles links, inline code, bold, italic, strikethrough

Feishu's post format with md tags cannot render markdown tables correctly.
This fix detects markdown tables and sends them as interactive card
elements with Feishu's native table component.

Changes:
- Add _TABLE_RE regex to detect markdown tables in content
- Add _parse_md_table() to parse MD tables into Feishu table elements
- Add _build_card_elements() to split content into markdown + table elements
- Add _split_elements_by_table_limit() for Feishu's 1-table-per-card limit
- Add _build_outbound_payloads() for multi-table content
- Update send() to handle interactive card errors with fallback
- Columns use Feishu message API format (no tag field, with data_type)
- _strip_md_formatting handles links, inline code, bold, italic, strikethrough

Reference: nanobot's Feishu channel implementation
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter comp/gateway Gateway runner, session dispatch, delivery labels May 5, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #12114 (same fix: render markdown tables via Feishu Card native table component). Also related to #19038 and #6003.

…ering

Resolve conflict in gateway/platforms/feishu.py:
- Keep card-based table rendering (interactive cards) over upstream's
  plain-text fallback approach
- Accept all other upstream changes: dedup timestamp tolerance,
  receive_id_type detection, bot identity refresh, and 185 other commits
- Remove dead _MARKDOWN_TABLE_RE regex (superseded by _TABLE_RE)
@Zeknes
Zeknes force-pushed the fix/feishu-md-table-rendering branch from 2f5b7d5 to 61373e7 Compare June 1, 2026 09:01
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for tackling a real Feishu rendering limitation. Current main still falls back to text for Markdown tables because post/md can render them blank (plugins/platforms/feishu/adapter.py:4524-4530), so the native-card direction remains relevant.

Problems

  • The new plural payload builder can return one card per table, but the new singular wrapper returns only payloads[0]. Current edit_message() calls that singular method once (plugins/platforms/feishu/adapter.py:1958), so a multi-table edit would drop later cards after this is ported.
  • The interactive fallback only handles errors matching _POST_CONTENT_INVALID_RE. Related maintainer feedback on fix(feishu): route tables and multi-line code blocks to CardKit 2.0 #19038 required a fallback when a card cannot be sent; this condition does not cover other interactive-card failures. The existing edit fallback is post-only (plugins/platforms/feishu/adapter.py:1963-1971).
  • The PR changes no tests despite adding parsing, fan-out, fallback, and chunking behavior.

Suggested changes

  • Port to plugins/platforms/feishu/adapter.py, define safe multi-table edit behavior, broaden interactive fallback, and add payload/send/edit tests including escaped-pipe cells and multi-table input.
  • Validate the Card JSON payload with a real Feishu bot.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
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 P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants