slack_regex: Update Slack regex handle multiline strings.

This prep commit modifies the Slack text regex in
`slack_message_conversion.py` to use the `re.MULTILINE` flag capture
formatted strings that are adjacent to newline or end of line.

These kinds of strings are likely not uncommon to be generated by Slack
exporter itself and our Slack message block and attachment formatters
(`render_blocks` and `render_attachments`) also produces them.

This also fixes Slack webhook integration's
`test_message_with_complex_formatted_texts` which was previously
expecting false output.

Fixes part of #30827.
This commit is contained in:
PieterCK
2024-11-19 16:05:06 +07:00
committed by Tim Abbott
parent 6c1818fa46
commit 8992435caf
3 changed files with 12 additions and 2 deletions

View File

@@ -183,7 +183,7 @@ def convert_markdown_syntax(text: str, pattern: str, zulip_keyword: str) -> str:
+ match.group(6)
)
return regex.sub(pattern, replace_slack_format, text, flags=re.VERBOSE)
return regex.sub(pattern, replace_slack_format, text, flags=re.VERBOSE | re.MULTILINE)
def convert_slack_workspace_mentions(text: str) -> str: