feat(feishu): send GFM tables via Schema 2.0 interactive card#35781
Open
unstoppablesssss wants to merge 4 commits into
Open
feat(feishu): send GFM tables via Schema 2.0 interactive card#35781unstoppablesssss wants to merge 4 commits into
unstoppablesssss wants to merge 4 commits into
Conversation
Feishu post-type 'md' elements do not render GFM tables. Previously, _build_outbound_payload detected tables and forced a plain-text fallback, which lost ALL markdown formatting (headings, bold, links, etc.). Now _convert_gfm_tables_to_list() runs in send() and edit_message() BEFORE the outbound payload is built, converting GFM tables to bullet-list items: - Header row: - **col1** · **col2** - Data rows: - **col1** val1 · **col2** val2 Tables inside fenced code blocks are left untouched. After conversion, _MARKDOWN_TABLE_RE no longer matches, so the message goes through the normal post (md) pipeline with all formatting preserved.
The post-type 'md' renderer does not support GFM tables. Previously the adapter detected tables and force-downgraded the whole message to plain text (losing all formatting). Now _build_outbound_payload returns msg_type='interactive' with a Schema 2.0 interactive card payload when GFM tables are detected. The JSON 2.0 tag:markdown component renders CommonMark tables natively, preserving surrounding formatting.
Collaborator
|
Duplicate of #33310 (and part of the saturated Feishu markdown rendering cluster: #23861, #32488, #27469, #12114). Same approach: Schema 2.0 interactive card with |
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
Feishu post-type
mdelements do not render GFM tables. Previously,_build_outbound_payloaddetected tables and force-downgraded the entire message to plain text, losing all markdown formatting (headings, bold, links, code blocks).Solution
When GFM tables are detected, send a Schema 2.0 interactive card (
msg_type="interactive") instead. The JSON 2.0tag: markdowncomponent supports CommonMark tables natively, preserving all surrounding formatting.Changes
_build_interactive_card_payload(content)— builds a Schema 2.0 card with header + body.elements_build_outbound_payload()— returns("interactive", card_payload)when tables are detected, instead of force-texttag: markdownelements (~4K chars each) with newline-aware breaksTesting
Verified with
uv run python -c '...':_MARKDOWN_TABLE_RE.search(content)matches correctly"schema": "2.0"and correctbody.elementsstructurehermes sendto Feishu — table renders natively in Schema 2.0 card