Skip to content

fix(feishu): wrap markdown tables in code fences for post rendering - #22222

Closed
asdlem wants to merge 2 commits into
NousResearch:mainfrom
asdlem:fix/feishu-table-codefence
Closed

fix(feishu): wrap markdown tables in code fences for post rendering#22222
asdlem wants to merge 2 commits into
NousResearch:mainfrom
asdlem:fix/feishu-table-codefence

Conversation

@asdlem

@asdlem asdlem commented May 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Previously, when a message contained a markdown table, _build_outbound_payload() forced the entire message into plain-text mode ("text" type). This was because Feishu's post-type md elements don't render tables, and sending tables as post caused the message to appear blank.

This PR changes the approach: instead of dropping the whole message to plain text (losing all formatting), markdown tables are now wrapped in code fences and kept in post mode. The result is that bold, links, and code blocks render correctly while tables display as monospace text — an improvement over losing all formatting.

Changes

  • gateway/platforms/feishu.py
    • Add _convert_markdown_tables_to_code_blocks() — wraps each standalone markdown table in a code fence, while respecting existing fenced blocks
    • Add _is_table_header_line() — detects start-of-table lines
    • Remove the _MARKDOWN_TABLE_RE → text-mode fallback in _build_outbound_payload()

Test Plan

  • Messages with markdown tables + surrounding bold/links should render the non-table portions with markdown formatting
  • Messages with tables inside existing code fences should be left untouched
  • Pure text messages (no markdown hints) should still go through text mode as before

asdlem added 2 commits May 9, 2026 11:01
Previously, messages containing markdown tables were forced into
plain-text mode because Feishu's post-type 'md' elements don't
render tables. This lost all other markdown formatting (bold,
links, code blocks) for the entire message.

Now, markdown tables are converted to fenced code blocks while
keeping the message in post mode. The rest of the message renders
with full markdown, and tables display as monospace text.

- Add _convert_markdown_tables_to_code_blocks() helper
- Add _is_table_header_line() table detection
- Remove the has_table → text-mode fallback in _build_outbound_payload()
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/feishu Feishu / Lark adapter labels May 9, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing fix with #19015 and #21872 — all wrap Feishu markdown tables in code fences to prevent blank rendering. Note: this PR includes unrelated .gitmodules and tinker-atropos changes that should be removed.

@asdlem

asdlem commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

Closing: wrong approach. Will re-submit with correct fix.

@asdlem asdlem closed this May 9, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing comment body.

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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants