Skip to content

fix(feishu): convert md tables to code blocks instead of degrading to plain text - #40266

Closed
tedburner wants to merge 1 commit into
NousResearch:mainfrom
tedburner:fix/feishu-md-table-rendering
Closed

fix(feishu): convert md tables to code blocks instead of degrading to plain text#40266
tedburner wants to merge 1 commit into
NousResearch:mainfrom
tedburner:fix/feishu-md-table-rendering

Conversation

@tedburner

Copy link
Copy Markdown

Problem

When the Feishu gateway detects a markdown table in the content, it falls back to plain text mode for the ENTIRE message. This means all formatting (headings, bold, lists, code blocks) is lost.

Solution

Convert markdown tables to fenced code blocks (```text) which render properly in Feishu's post mode, while keeping the rest of the markdown as rich text.

Before:

  • Table detected → entire message → plain text ❌

After:

  • Table detected → table as code block → rest stays rich text ✅

Changes

  1. Added _convert_md_tables_to_code_blocks() function
  2. Modified _build_outbound_payload() to convert tables instead of degrading to plain text

When a markdown table is detected, convert it to a fenced code block
instead of degrading the entire message to plain text.
@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 Jun 6, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Overlaps open PR #21872 and the saturated Feishu table-rendering cluster (#27469) — same approach (tables → fenced code blocks while keeping rest as rich text). Suggest consolidating with the existing open PRs.

@alpindiay alpindiay left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — PR #40266: Feishu — Convert Markdown Tables to Code Blocks

Summary: Instead of falling back to plain text for the entire message when markdown tables are detected, converts only the table blocks to fenced ```text code blocks so the rest of the markdown (headings, bold, lists) still renders.

✅ Good

  • Much better UX: previously an entire message became plain text if it contained a table. Now only the table loses markdown rendering (becomes a code block), which is the best Feishu can do.
  • _convert_md_tables_to_code_blocks is clean: iterates lines, buffers table rows (lines starting and ending with |), flushes as fenced blocks.
  • Edge case handling: table at end of content (final flush in the if in_table check), non-table content passed through unchanged.
  • The _MARKDOWN_TABLE_RE regex check before conversion avoids unnecessary processing for non-table messages.

⚠️ Minor Notes

  • The table detection heuristic (stripped.startswith("|") and stripped.endswith("|") and len(stripped) > 2) could match non-table content like | inline pipe | in regular text. Extremely unlikely to be a real issue since markdown tables use multi-line |---| separators. The existing regex gate (_MARKDOWN_TABLE_RE) catches real tables first.

Verdict: Clean UX improvement. LGTM.

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