fix(feishu): preserve markdown examples in multi-backtick code spans (#8460)

This commit is contained in:
Jasper 2026-11-21 17:26:18 -08:00 committed by GitHub
parent 9ba9bfad41
commit f95d77f961
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -161,7 +161,8 @@ _LONE_SURROGATE = re.compile("[\ud800-\udfff]")
# A markdown image marker, rewritten for the card so Feishu never sees one.
_MARKDOWN_IMAGE = re.compile(r"!\[(?P<alt>[^\]]*)\]\((?P<target>[^)\s]*)[^)]*\)")
_FENCED_CODE = re.compile(r"(?ms)^[ \t]*(?P<fence>`{3,}|~{3,})[^\n]*\n.*?^[ \t]*(?P=fence)[ \t]*$")
_INLINE_CODE_SPAN = re.compile(r"`[^`\n]*`")
# Both delimiters are complete backtick runs of the same length.
_INLINE_CODE_SPAN = re.compile(r"(?<!`)(?P<ticks>`+)(?!`)[^\n]*?(?<!`)(?P=ticks)(?!`)")
# A fence a streamed snapshot cut open: what follows its opener is still code.
_UNCLOSED_FENCE = re.compile(r"(?m)^[ \t]*(?P<fence>`{3,}|~{3,})[^\n]*$")

View File

@ -240,6 +240,9 @@ async def test_reply_without_running_card_and_push_without_source_split_too(feis
("plain answer", "plain answer", False),
# Code renders literally in a card, so the shown source must not change.
("inline `![a](b)` keeps its marker", "inline `![a](b)` keeps its marker", True),
("example ``![a](b)`` and ![c](d)", "example ``![a](b)`` and [c](d)", True),
("example ``use ` before ![a](b)`` and ![c](d)", "example ``use ` before ![a](b)`` and [c](d)", True),
("unclosed `` before ![c](d)", "unclosed `` before [c](d)", False),
("```\n![a](b)\n```", "```\n![a](b)\n```", True),
# A snapshot streamed before the closing fence arrives keeps its open block literal.
("```\n![a](b)", "```\n![a](b)", True),