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 
 message


\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 '
<\/p>",
+      "expected_output":"
<\/p>",
       "bugdown_matches_marked": true
     },
     {
       "name": "two_unicode_emoji",
       "input": "\ud83d\udca9\ud83d\udca9",
-      "expected_output":"

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

<\/p>",
       "bugdown_matches_marked": true
     },
     {
       "name": "two_unicode_emoji_separated_by_text",
       "input": "\ud83d\udca9 word \ud83d\udca9",
-      "expected_output":"
 word 
<\/p>",
+      "expected_output":"
 word 
<\/p>",
       "bugdown_matches_marked": true
     },
     {
       "name": "miscellaneous_symbols_and_pictographs",
       "input": "Merry Christmas!!\ud83c\udf84",
-      "expected_output":"
Merry Christmas!!
<\/p>",
+      "expected_output":"
Merry Christmas!!
<\/p>",
       "bugdown_matches_marked": true
     },
     {
       "name": "miscellaneous_and_dingbats_emoji",
       "input": "\u2693\u2797",
-      "expected_output":"

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

<\/p>",
       "bugdown_matches_marked": true
     },
     {
       "name": "supplemental_symbols_and_pictographs",
       "input": "I am a robot \ud83e\udd16.",
-      "expected_output":"
I am a robot 
.<\/p>",
+      "expected_output":"
I am a robot 
.<\/p>",
       "bugdown_matches_marked": true
     },
     {
       "name": "miscellaneous_symbols_and_arrows",
       "input": "Black upward arrow \u2b06",
-      "expected_output":"
Black upward arrow 
<\/p>",
+      "expected_output":"
Black upward arrow 
<\/p>",
       "bugdown_matches_marked": true
     },
     {
       "name": "unicode_emoji_without_space",
       "input": "Extra\ud83d\udc7dTerrestrial",
-      "expected_output":"
Extra
Terrestrial<\/p>",
+      "expected_output":"
Extra
Terrestrial<\/p>",
       "bugdown_matches_marked": true
     },
     {
       "name": "unicode_emojis_new_line",
       "input": "\ud83d\udc7d\n\ud83d\udc7d",
-      "expected_output":"

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

\n
<\/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'





