fix(feishu): use post(md) for messages containing markdown tables - #58391
fix(feishu): use post(md) for messages containing markdown tables#58391liuhao1024 wants to merge 1 commit into
Conversation
Feishu's post-type 'md' elements now support GFM tables (CommonMark 0.31 + GFM). The previous workaround that forced table-containing messages to plain 'text' type stripped ALL formatting (bold, lists, code blocks) and rendered the table itself as raw pipe characters. Remove the _MARKDOWN_TABLE_RE guard and merge table detection into _MARKDOWN_HINT_RE so tables trigger post(md) mode like other markdown features. Fixes NousResearch#58269
teknium1
left a comment
There was a problem hiding this comment.
Thanks for tracing this to the table-specific fallback. The premise remains present on current main: plugins/platforms/feishu/adapter.py:4528-4538 sends the reported pipe-bounded table shape as text, and Feishu’s current message-content documentation supports GFM through post/md.
Problems
- The new alternative at
plugins/platforms/feishu/adapter.py:155requires both the header and separator row to begin with|. GFM allows outer pipes to be omitted, soA | B\n--- | ---\n1 | 2still misses_MARKDOWN_HINT_REand takes thetextfallback atplugins/platforms/feishu/adapter.py:4535-4538.
Suggested changes
- Make the outer pipes optional in the table detector and add a regression test for that valid GFM form, asserting
postplus anmdelement.
Automated hermes-sweeper review.
|
|
||
| _MARKDOWN_HINT_RE = re.compile( | ||
| r"(^#{1,6}\s)|(^\s*[-*]\s)|(^\s*\d+\.\s)|(^\s*---+\s*$)|(```)|(`[^`\n]+`)|(\*\*[^*\n].+?\*\*)|(~~[^~\n].+?~~)|(<u>.+?</u>)|(\*[^*\n]+\*)|(\[[^\]]+\]\([^)]+\))|(^>\s)", | ||
| r"(^#{1,6}\s)|(^\s*[-*]\s)|(^\s*\d+\.\s)|(^\s*---+\s*$)|(```)|(`[^`\n]+`)|(\*\*[^*\n].+?\*\*)|(~~[^~\n].+?~~)|(<u>.+?</u>)|(\*[^*\n]+\*)|(\[[^\]]+\]\([^)]+\))|(^>\s)|(^\|.*\|\n\|[-|: ]+\|)", |
There was a problem hiding this comment.
This requires outer pipes on both header and delimiter rows, but GFM permits them to be omitted. Please recognize A | B\n--- | ---\n1 | 2 as well and add a matching send-payload regression test; otherwise that valid table still falls through to text.
|
Closing — this was fixed on main by #68121, which removes the |
What does this PR do?
Removes the outdated
_MARKDOWN_TABLE_REguard that forced table-containing Feishu messages to plaintexttype. Feishu'spost(md)element now supports GFM tables (CommonMark 0.31 + GFM), so the workaround is no longer needed and actively harms message quality — it strips all formatting (bold, lists, code blocks) and renders tables as raw pipe characters.Table detection is merged into
_MARKDOWN_HINT_REso tables triggerpost(md)mode like other markdown features.Related Issue
Fixes #58269
Type of Change
Changes Made
plugins/platforms/feishu/adapter.py: Removed_MARKDOWN_TABLE_REregex and its guard in_build_outbound_payload()that forcedtexttype for table content. Added table pattern^\|.*\|\n\|[-|: ]+\|to_MARKDOWN_HINT_REso tables triggerpost(md)mode.tests/gateway/test_feishu.py: Addedtest_send_uses_post_for_markdown_tableto verify table content is sent asposttype withmdtag.How to Test
pytest tests/gateway/test_feishu.py::TestAdapterBehavior::test_send_uses_post_for_markdown_table -xvs— should pass.pytest tests/gateway/test_feishu.py -q— all 206 tests should pass.| Col A | Col B |\n|---|---|\n| 1 | 2 |). Observed result: the table renders with grid lines and other markdown (bold, lists) is preserved.Checklist
Code
fix(scope):)pytest tests/ -qand all tests passDocumentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/A