diff --git a/backend/app/channels/dingtalk.py b/backend/app/channels/dingtalk.py index 8fbb81eecb..742096b996 100644 --- a/backend/app/channels/dingtalk.py +++ b/backend/app/channels/dingtalk.py @@ -119,20 +119,16 @@ _TABLE_SEPARATOR_RE = re.compile(r"^\|[-:| ]+\|$", re.MULTILINE) def _split_markdown_table_row(row: str) -> list[str]: - r"""Keep escaped pipes and empty cells when removing the outer borders. - - Known boundary: the single-character lookbehind in the split pattern - cannot distinguish an escaped pipe (``\|``) from an escaped backslash - immediately followed by a real separator (``\\|``). A cell ending in a - literal backslash therefore absorbs the next cell: ``| foo\\ | bar |`` - splits as one cell instead of two. GFM counts consecutive backslashes - for this reason; doing so is out of scope here — this helper is - intentionally not a general Markdown parser. - """ - # ``(? **A**: {prefix}|suffix\n" if count % 2 else f"> **A**: {prefix}\n> **B**: suffix\n" + assert _convert_markdown_table(text) == expected + def test_fallback_adapter_preserves_table_values(self): text = "| Rule | Meaning |\n|---|---|\n| `foo\\|bar` | alternative |" assert _adapt_markdown_for_dingtalk(text) == "> **Rule**: **foo\\|bar**\n> **Meaning**: alternative\n"