diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js index 5afa1c5b32..c733ee84c4 100644 --- a/frontend_tests/node_tests/markdown.js +++ b/frontend_tests/node_tests/markdown.js @@ -221,7 +221,7 @@ var bugdown_data = JSON.parse(fs.readFileSync(path.join(__dirname, '../../zerver {input: 'This is an :poop: message', expected: '

This is an :poop: message

'}, {input: "\ud83d\udca9", - expected: '

\ud83d\udca9

'}, + expected: '

:poop:

'}, {input: '\u{1f937}', expected: '

\u{1f937}

' }, {input: 'This is a realm filter #1234 with text after it', diff --git a/static/js/markdown.js b/static/js/markdown.js index dcb843ed7f..b8ecfc9a84 100644 --- a/static/js/markdown.js +++ b/static/js/markdown.js @@ -118,9 +118,10 @@ function handleUnicodeEmoji(unicode_emoji) { var hex_value = unicode_emoji.codePointAt(0).toString(16); if (emoji.emojis_by_unicode.hasOwnProperty(hex_value)) { var emoji_url = emoji.emojis_by_unicode[hex_value]; - return '' + unicode_emoji + ''; + ' title="' + display_string + '">'; } return unicode_emoji; } diff --git a/version.py b/version.py index e56a0be889..ec54626880 100644 --- a/version.py +++ b/version.py @@ -1,2 +1,2 @@ ZULIP_VERSION = "1.6.0+git" -PROVISION_VERSION = '5.11' +PROVISION_VERSION = '5.12' diff --git a/zerver/fixtures/bugdown-data.json b/zerver/fixtures/bugdown-data.json index 8821134a94..13b74e6905 100644 --- a/zerver/fixtures/bugdown-data.json +++ b/zerver/fixtures/bugdown-data.json @@ -273,55 +273,55 @@ { "name": "unicode_emoji", "input": "\ud83d\udca9", - "expected_output":"

\"\ud83d\udca9\"<\/p>", + "expected_output":"

\":poop:\"<\/p>", "bugdown_matches_marked": true }, { "name": "two_unicode_emoji", "input": "\ud83d\udca9\ud83d\udca9", - "expected_output":"

\"\ud83d\udca9\"\"\ud83d\udca9\"<\/p>", + "expected_output":"

\":poop:\"\":poop:\"<\/p>", "bugdown_matches_marked": true }, { "name": "two_unicode_emoji_separated_by_text", "input": "\ud83d\udca9 word \ud83d\udca9", - "expected_output":"

\"\ud83d\udca9\" word \"\ud83d\udca9\"<\/p>", + "expected_output":"

\":poop:\" word \":poop:\"<\/p>", "bugdown_matches_marked": true }, { "name": "miscellaneous_symbols_and_pictographs", "input": "Merry Christmas!!\ud83c\udf84", - "expected_output":"

Merry Christmas!!\"\ud83c\udf84\"<\/p>", + "expected_output":"

Merry Christmas!!\":christmas_tree:\"<\/p>", "bugdown_matches_marked": true }, { "name": "miscellaneous_and_dingbats_emoji", "input": "\u2693\u2797", - "expected_output":"

\"\u2693\"\"\u2797\"<\/p>", + "expected_output":"

\":anchor:\"\":heavy_division_sign:\"<\/p>", "bugdown_matches_marked": true }, { "name": "supplemental_symbols_and_pictographs", "input": "I am a robot \ud83e\udd16.", - "expected_output":"

I am a robot \"\ud83e\udd16\".<\/p>", + "expected_output":"

I am a robot \":robot_face:\".<\/p>", "bugdown_matches_marked": true }, { "name": "miscellaneous_symbols_and_arrows", "input": "Black upward arrow \u2b06", - "expected_output":"

Black upward arrow \"\u2b06\"<\/p>", + "expected_output":"

Black upward arrow \":arrow_up:\"<\/p>", "bugdown_matches_marked": true }, { "name": "unicode_emoji_without_space", "input": "Extra\ud83d\udc7dTerrestrial", - "expected_output":"

Extra\"\ud83d\udc7d\"Terrestrial<\/p>", + "expected_output":"

Extra\":alien:\"Terrestrial<\/p>", "bugdown_matches_marked": true }, { "name": "unicode_emojis_new_line", "input": "\ud83d\udc7d\n\ud83d\udc7d", - "expected_output":"

\"\ud83d\udc7d\"
\n\"\ud83d\udc7d\"<\/p>", + "expected_output":"

\":alien:\"
\n\":alien:\"<\/p>", "bugdown_matches_marked": true }, { diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index d832485830..f60c51501c 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -700,7 +700,10 @@ class Avatar(markdown.inlinepatterns.Pattern): path_to_name_to_codepoint = os.path.join(settings.STATIC_ROOT, "generated", "emoji", "name_to_codepoint.json") name_to_codepoint = ujson.load(open(path_to_name_to_codepoint)) -unicode_emoji_list = set([name_to_codepoint[name] for name in name_to_codepoint]) + +path_to_codepoint_to_name = os.path.join(settings.STATIC_ROOT, "generated", "emoji", "codepoint_to_name.json") +with open(path_to_codepoint_to_name) as codepoint_to_name_file: + codepoint_to_name = ujson.load(codepoint_to_name_file) # All of our emojis(non ZWJ sequences) belong to one of these unicode blocks: # \U0001f100-\U0001f1ff - Enclosed Alphanumeric Supplement @@ -780,8 +783,9 @@ class UnicodeEmoji(markdown.inlinepatterns.Pattern): # type: (Match[Text]) -> Optional[Element] orig_syntax = match.group('syntax') codepoint = unicode_emoji_to_codepoint(orig_syntax) - if codepoint in unicode_emoji_list: - return make_emoji(codepoint, orig_syntax) + if codepoint in codepoint_to_name: + display_string = ':' + codepoint_to_name[codepoint] + ':' + return make_emoji(codepoint, display_string) else: return None diff --git a/zerver/tests/test_bugdown.py b/zerver/tests/test_bugdown.py index e1c6a28df0..95364f4f7d 100644 --- a/zerver/tests/test_bugdown.py +++ b/zerver/tests/test_bugdown.py @@ -528,11 +528,20 @@ class BugdownTest(ZulipTestCase): # type: () -> None msg = u'\u2615' # ☕ converted = bugdown_convert(msg) - self.assertEqual(converted, u'

\u2615

') + self.assertEqual(converted, u'

:coffee:

') msg = u'\u2615\u2615' # ☕☕ converted = bugdown_convert(msg) - self.assertEqual(converted, u'

\u2615\u2615

') + self.assertEqual(converted, u'

:coffee::coffee:

') + + def test_same_markup(self): + # type: () -> None + msg = u'\u2615' # ☕ + unicode_converted = bugdown_convert(msg) + + msg = u':coffee:' # ☕☕ + converted = bugdown_convert(msg) + self.assertEqual(converted, unicode_converted) def test_realm_patterns(self): # type: () -> None