fix(feishu): convert markdown pipe tables to fenced text blocks befor… - #51458
fix(feishu): convert markdown pipe tables to fenced text blocks befor…#51458leeyo921 wants to merge 1 commit into
Conversation
…e send Feishu post-type md elements do not render markdown tables reliably. Previously, pipe-table content was force-sent as plain text, leaving the raw |---| markup visible to users. This change converts markdown pipe tables to fenced ```text blocks deterministically in the outbound payload builder — no model rewrite, no retry, no format scoring. - Skips tables already inside existing fenced code blocks. - Col-aligns cells and strips the separator row. - Preserves rich post delivery for mixed markdown + table content. - Adds three targeted tests (send path, skip-existing, payload shape).
Related (saturated cluster): Feishu markdown-table rendering. This uses the fenced-code-block approach (same idea as closed #19015 / open #36877), competing with the interactive-card cluster tracked under canonical bug #21778 / PR #12114 (and #25453). Same goal, different mechanism — related, not a duplicate. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for preserving rich-post delivery while reusing the existing fenced-code-block path. The underlying issue remains on current main: plugins/platforms/feishu/adapter.py:4524-4534 still routes detected tables to raw text.
Problems
plugins/platforms/feishu/adapter.py:574checks_MARKDOWN_TABLE_REbefore normalizing CRLF at :577. Since that regex requires a literal\nimmediately after the header row,\r\ntables skip conversion and retain the current raw-text behavior.plugins/platforms/feishu/adapter.py:558-562useslen()andljust()for visual alignment. CJK cells are wider than their code-point length;agent/markdown_tables.py:1-14,49-62already documents and handles this withwcswidth.
Suggested changes
- Normalize line endings before the detection guard and add a CRLF payload test.
- Make code-block padding display-width-aware and cover a CJK alignment case.
This is an automated hermes-sweeper review.
| The transform is intentionally local and deterministic: no model rewrite, no | ||
| prose changes, and no conversion inside existing fenced code blocks. | ||
| """ | ||
| if not content or not _MARKDOWN_TABLE_RE.search(content): |
There was a problem hiding this comment.
Normalize line endings before this guard. _MARKDOWN_TABLE_RE requires |\n|, so a standard CRLF table fails here and never reaches the replace("\r\n", "\n") at line 577; it remains on the raw text fallback.
|
|
||
| normalized_rows = [row + [""] * (column_count - len(row)) for row in rows] | ||
| widths = [ | ||
| max(len(row[column]) for row in normalized_rows) |
There was a problem hiding this comment.
len() measures code points rather than rendered columns, so CJK cells in the PR's target platform will not line up in the fenced block. Use display-cell width (as agent/markdown_tables.py does with wcswidth) for both width calculation and padding.
…e send
Feishu post-type md elements do not render markdown tables reliably. Previously, pipe-table content was force-sent as plain text, leaving the raw |---| markup visible to users.
This change converts markdown pipe tables to fenced ```text blocks deterministically in the outbound payload builder — no model rewrite, no retry, no format scoring.
What does this PR do?
Related Issue
Fixes #
Type of Change
Changes Made
How to Test
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs