fix(feishu): convert md tables to code blocks instead of degrading to plain text - #40266
Closed
tedburner wants to merge 1 commit into
Closed
fix(feishu): convert md tables to code blocks instead of degrading to plain text#40266tedburner wants to merge 1 commit into
tedburner wants to merge 1 commit into
Conversation
When a markdown table is detected, convert it to a fenced code block instead of degrading the entire message to plain text.
Collaborator
alpindiay
reviewed
Jun 6, 2026
alpindiay
left a comment
There was a problem hiding this comment.
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_blocksis 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_tablecheck), non-table content passed through unchanged. - The
_MARKDOWN_TABLE_REregex 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.
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.
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:
After:
Changes
_convert_md_tables_to_code_blocks()function_build_outbound_payload()to convert tables instead of degrading to plain text