Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

slack_regex: Remove unnecessary inner capture group.

PieterCKee34ccb8c2e5
diff --git a/zerver/data_import/slack_message_conversion.py b/zerver/data_import/slack_message_conversion.py
index f40accd6333..e710f696874 100644
--- a/zerver/data_import/slack_message_conversion.py
+++ b/zerver/data_import/slack_message_conversion.py
@@ -60,7 +60,7 @@ SLACK_STRIKETHROUGH_REGEX = r"""
[\p{P}\p{Zs}\p{S}]|^
)
(\~) # followed by a ~
- ([ -)+-}—]*)([ -}]+) # any character except ~
+ ([ -}]+) # any character except ~
(\~) # followed by a ~
(
# Capture punctuation, white space, symbols or end of
@@ -80,7 +80,7 @@ SLACK_ITALIC_REGEX = r"""
[\p{P}\p{Zs}\p{S}]|^
)
(\_)
- ([ -^`~—]*)([ -^`-~]+) # any character except _
+ ([ -^`-~]+) # any character except _
(\_)
(
(?![_`@\\\p{Pi}\p{Ps}])
@@ -95,7 +95,7 @@ SLACK_BOLD_REGEX = r"""
[\p{P}\p{Zs}\p{S}]|^
)
(\*)
- ([ -)+-~—]*)([ -)+-~]+) # any character except *
+ ([ -)+-~]+) # any character except *
(\*)
(
(?![*`@\\\p{Pi}\p{Ps}])
@@ -174,14 +174,7 @@ def convert_markdown_syntax(text: str, pattern: str, zulip_keyword: str) -> str:
"""
def replace_slack_format(match: regex.Match[str]) -> str:
- return (
- match.group(1)
- + zulip_keyword
- + match.group(3)
- + match.group(4)
- + zulip_keyword
- + match.group(6)
- )
+ return match.group(1) + zulip_keyword + match.group(3) + zulip_keyword + match.group(5)
return regex.sub(pattern, replace_slack_format, text, flags=re.VERBOSE | re.MULTILINE)