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.

zulip_updates: Fix line removal logic for bulleted lists.

Tim Abbott563485a37eeb
diff --git a/zerver/lib/message.py b/zerver/lib/message.py
index 3c41293d0a8..557de205f04 100644
--- a/zerver/lib/message.py
+++ b/zerver/lib/message.py
@@ -1444,4 +1444,4 @@ def set_visibility_policy_possible(user_profile: UserProfile, message: Message)
def remove_single_newlines(content: str) -> str:
content = content.strip("\n")
- return re.sub(r"(?<!\n)\n(?!\n)", " ", content)
+ return re.sub(r"(?<!\n)\n(?![\n0-9*-])", " ", content)
diff --git a/zerver/tests/test_zulip_update_announcements.py b/zerver/tests/test_zulip_update_announcements.py
index bbbed0af4ea..c5282b0a21f 100644
--- a/zerver/tests/test_zulip_update_announcements.py
+++ b/zerver/tests/test_zulip_update_announcements.py
@@ -180,3 +180,8 @@ class ZulipUpdateAnnouncementsTest(ZulipTestCase):
input_text = "This is a sentence.\nThis is another sentence.\nThis is a third sentence.\nThis is a fourth sentence."
expected_output = "This is a sentence. This is another sentence. This is a third sentence. This is a fourth sentence."
self.assertEqual(remove_single_newlines(input_text), expected_output)
+
+ # Bulleted lists on lines.
+ input_text = "- This is a bullet.\n- This is another bullet.\n\n1. This is a list\n1. This is more list."
+ expected_output = "- This is a bullet.\n- This is another bullet.\n\n1. This is a list\n1. This is more list."
+ self.assertEqual(remove_single_newlines(input_text), expected_output)