mirror of https://github.com/zulip/zulip.git
markdown: Change syntax of silent mentions ( _@person -> @_person).
This commit is contained in:
parent
cdce66813e
commit
57b9991396
|
@ -61,7 +61,7 @@ in bursts.
|
|||
- Added a ReviewBoard integration, and improved numerous existing integrations.
|
||||
- Added support for multi-line messages for the /me feature.
|
||||
- Added markdown rendering of text when displaying custom profile fields.
|
||||
- Added "silent mentions" syntax (`_@**Tim Abbott**`), which show
|
||||
- Added "silent mentions" syntax (`@_**Tim Abbott**`), which show
|
||||
visually, but don't trigger a notification to the target user.
|
||||
- Added support for using lightbox in compose preview.
|
||||
- Changes in date no longer force a repeated recipient bar. This
|
||||
|
|
|
@ -302,7 +302,7 @@ run_test('marked', () => {
|
|||
expected: '<p><span aria-label="poop" class="emoji emoji-1f4a9" role="img" title="poop">:poop:</span></p>'},
|
||||
{input: '\u{1f6b2}',
|
||||
expected: '<p>\u{1f6b2}</p>' },
|
||||
{input: 'Silent mention: _@**Cordelia Lear**',
|
||||
{input: 'Silent mention: @_**Cordelia Lear**',
|
||||
expected: '<p>Silent mention: <span class="user-mention silent" data-user-id="101">@Cordelia Lear</span></p>'},
|
||||
{input: '> Mention in quote: @**Cordelia Lear**\n\nMention outside quote: @**Cordelia Lear**',
|
||||
expected: '<blockquote>\n<p>Mention in quote: <span class="user-mention silent" data-user-id="101">@Cordelia Lear</span></p>\n</blockquote>\n<p>Mention outside quote: <span class="user-mention" data-user-id="101">@Cordelia Lear</span></p>'},
|
||||
|
|
|
@ -509,7 +509,7 @@ inline.zulip = merge({}, inline.breaks, {
|
|||
'\ud83d[\ude80-\udeff]|\ud83e[\udd00-\uddff]|' +
|
||||
'[\u2000-\u206F]|[\u2300-\u27BF]|[\u2B00-\u2BFF]|' +
|
||||
'[\u3000-\u303F]|[\u3200-\u32FF])'),
|
||||
usermention: /^((_?)@(?:\*\*([^\*]+)\*\*))/, // Match potentially multi-word string between @** **
|
||||
usermention: /^(@(_?)(?:\*\*([^\*]+)\*\*))/, // Match potentially multi-word string between @** **
|
||||
groupmention: /^@\*([^\*]+)\*/, // Match multi-word string between @* *
|
||||
stream: /^#\*\*([^\*]+)\*\*/,
|
||||
avatar: /^!avatar\(([^)]+)\)/,
|
||||
|
|
|
@ -254,7 +254,7 @@ def send_signup_message(sender: UserProfile, admin_realm_signup_notifications_st
|
|||
"stream",
|
||||
signup_notifications_stream.name,
|
||||
"signups",
|
||||
"_@**%s|%s** just signed up for Zulip. (total: %i)" % (
|
||||
"@_**%s|%s** just signed up for Zulip. (total: %i)" % (
|
||||
user_profile.full_name, user_profile.id, user_count
|
||||
)
|
||||
)
|
||||
|
@ -3491,7 +3491,7 @@ def do_rename_stream(stream: Stream,
|
|||
sender,
|
||||
stream,
|
||||
"welcome",
|
||||
"_@**%s|%d** renamed stream **%s** to **%s**" % (user_profile.full_name,
|
||||
"@_**%s|%d** renamed stream **%s** to **%s**" % (user_profile.full_name,
|
||||
user_profile.id,
|
||||
old_name, new_name)
|
||||
)
|
||||
|
|
|
@ -1358,7 +1358,7 @@ class BlockQuoteProcessor(markdown.blockprocessors.BlockQuoteProcessor):
|
|||
|
||||
def clean(self, line: str) -> str:
|
||||
# Silence all the mentions inside blockquotes
|
||||
line = re.sub(self.mention_re, lambda m: "_@{}".format(m.group('match')), line)
|
||||
line = re.sub(self.mention_re, lambda m: "@_{}".format(m.group('match')), line)
|
||||
|
||||
# And then run the upstream processor's code for removing the '>'
|
||||
return super().clean(line)
|
||||
|
|
|
@ -5,7 +5,7 @@ import re
|
|||
|
||||
# Match multi-word string between @** ** or match any one-word
|
||||
# sequences after @
|
||||
find_mentions = r'(?<![^\s\'\"\(,:<])(?P<silent>_?)@(?P<match>\*\*[^\*]+\*\*|all|everyone|stream)'
|
||||
find_mentions = r'(?<![^\s\'\"\(,:<])@(?P<silent>_?)(?P<match>\*\*[^\*]+\*\*|all|everyone|stream)'
|
||||
user_group_mentions = r'(?<![^\s\'\"\(,:<])@(\*[^\*]+\*)'
|
||||
|
||||
wildcards = ['all', 'everyone', 'stream']
|
||||
|
|
|
@ -984,7 +984,7 @@ class BugdownTest(ZulipTestCase):
|
|||
msg = Message(sender=sender_user_profile, sending_client=get_client("test"))
|
||||
user_id = user_profile.id
|
||||
|
||||
content = "_@**King Hamlet**"
|
||||
content = "@_**King Hamlet**"
|
||||
self.assertEqual(render_markdown(msg, content),
|
||||
'<p><span class="user-mention silent" '
|
||||
'data-user-id="%s">'
|
||||
|
@ -1052,10 +1052,10 @@ class BugdownTest(ZulipTestCase):
|
|||
content = "> @**King Hamlet**"
|
||||
self.assertEqual(render_markdown(msg, content), expected)
|
||||
self.assertEqual(msg.mentions_user_ids, set())
|
||||
content = "```quote\n_@**King Hamlet**\n```"
|
||||
content = "```quote\n@_**King Hamlet**\n```"
|
||||
self.assertEqual(render_markdown(msg, content), expected)
|
||||
self.assertEqual(msg.mentions_user_ids, set())
|
||||
content = "> _@**King Hamlet**"
|
||||
content = "> @_**King Hamlet**"
|
||||
self.assertEqual(render_markdown(msg, content), expected)
|
||||
self.assertEqual(msg.mentions_user_ids, set())
|
||||
|
||||
|
|
|
@ -193,4 +193,4 @@ class TestNotifyNewUser(ZulipTestCase):
|
|||
self.assertEqual(message.recipient.type, Recipient.STREAM)
|
||||
actual_stream = Stream.objects.get(id=message.recipient.type_id)
|
||||
self.assertEqual(actual_stream.name, Realm.INITIAL_PRIVATE_STREAM_NAME)
|
||||
self.assertIn('_@**Cordelia Lear|%d** just signed up for Zulip.' % (new_user.id), message.content)
|
||||
self.assertIn('@_**Cordelia Lear|%d** just signed up for Zulip.' % (new_user.id), message.content)
|
||||
|
|
|
@ -617,7 +617,7 @@ class StreamAdminTest(ZulipTestCase):
|
|||
# Inspect the notification message sent
|
||||
message = self.get_last_message()
|
||||
actual_stream = Stream.objects.get(id=message.recipient.type_id)
|
||||
message_content = '_@**King Hamlet|{}** renamed stream **stream_name1** to **stream_name2**'.format(user_profile.id)
|
||||
message_content = '@_**King Hamlet|{}** renamed stream **stream_name1** to **stream_name2**'.format(user_profile.id)
|
||||
self.assertEqual(message.sender.realm, user_profile.realm)
|
||||
self.assertEqual(actual_stream.name, 'stream_name2')
|
||||
self.assertEqual(message.recipient.type, Recipient.STREAM)
|
||||
|
@ -1962,7 +1962,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
|||
msg = self.get_second_to_last_message()
|
||||
self.assertEqual(msg.recipient.type, Recipient.STREAM)
|
||||
self.assertEqual(msg.sender_id, self.notification_bot().id)
|
||||
expected_msg = "_@**%s|%d** just created a new stream #**%s**." % (invitee_full_name, invitee_user.id, invite_streams[0])
|
||||
expected_msg = "@_**%s|%d** just created a new stream #**%s**." % (invitee_full_name, invitee_user.id, invite_streams[0])
|
||||
self.assertEqual(msg.content, expected_msg)
|
||||
|
||||
def test_successful_cross_realm_notification(self) -> None:
|
||||
|
@ -2030,7 +2030,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
|||
|
||||
msg = self.get_second_to_last_message()
|
||||
self.assertEqual(msg.sender_id, self.notification_bot().id)
|
||||
expected_msg = "_@**%s|%d** just created a new stream #**%s**." % (invitee_full_name, invitee_user.id, invite_streams[0])
|
||||
expected_msg = "@_**%s|%d** just created a new stream #**%s**." % (invitee_full_name, invitee_user.id, invite_streams[0])
|
||||
self.assertEqual(msg.content, expected_msg)
|
||||
|
||||
def test_non_ascii_stream_subscription(self) -> None:
|
||||
|
|
|
@ -389,7 +389,7 @@ def add_subscriptions_backend(
|
|||
stream_msg = "the following streams: %s" % (stream_strs,)
|
||||
else:
|
||||
stream_msg = "a new stream #**%s**." % created_streams[0].name
|
||||
msg = ("_@**%s|%d** just created %s" % (user_profile.full_name, user_profile.id, stream_msg))
|
||||
msg = ("@_**%s|%d** just created %s" % (user_profile.full_name, user_profile.id, stream_msg))
|
||||
|
||||
sender = get_system_bot(settings.NOTIFICATION_BOT)
|
||||
topic = 'Streams'
|
||||
|
|
Loading…
Reference in New Issue