diff --git a/frontend_tests/node_tests/markdown.js b/frontend_tests/node_tests/markdown.js index 196118313d..775b074d67 100644 --- a/frontend_tests/node_tests/markdown.js +++ b/frontend_tests/node_tests/markdown.js @@ -297,9 +297,9 @@ run_test('marked', () => { {input: 'mmm...:burrito:s', expected: '

mmm...:burrito:s

'}, {input: 'This is an :poop: message', - expected: '

This is an :poop: message

'}, + expected: '

This is an :poop: message

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

:poop:

'}, + expected: '

:poop:

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

\u{1f6b2}

' }, // Test only those realm filters which don't return True for @@ -349,7 +349,7 @@ run_test('marked', () => { {input: ':)', expected: '

:)

'}, {input: ':)', - expected: '

:slight_smile:

', + expected: '

:slight_smile:

', translate_emoticons: true}, // Test HTML Escape in Custom Zulip Rules {input: '@**

The Rogue One

**', diff --git a/static/js/markdown.js b/static/js/markdown.js index 298954b843..25239e83be 100644 --- a/static/js/markdown.js +++ b/static/js/markdown.js @@ -141,8 +141,9 @@ exports.is_status_message = function (raw_content, content) { }; function make_emoji_span(codepoint, title, alt_text) { - return '' + alt_text + + return '' + alt_text + ''; } diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index 5c90f8cc0a..91f6bf588a 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -1091,6 +1091,8 @@ def make_emoji(codepoint: str, display_string: str) -> Element: span = markdown.util.etree.Element('span') span.set('class', 'emoji emoji-%s' % (codepoint,)) span.set('title', title) + span.set('role', 'img') + span.set('aria-label', title) span.text = display_string return span diff --git a/zerver/tests/fixtures/markdown_test_cases.json b/zerver/tests/fixtures/markdown_test_cases.json index 5fc0b9e6f5..48fc50e45b 100644 --- a/zerver/tests/fixtures/markdown_test_cases.json +++ b/zerver/tests/fixtures/markdown_test_cases.json @@ -347,7 +347,7 @@ { "name": "many_emoji", "input": "test :smile: again :poop:\n:) foo:)bar x::y::z :wasted waste: :fakeemojithisshouldnotrender:", - "expected_output": "

test :smile: again :poop:
\n:) foo:)bar x::y::z :wasted waste: :fakeemojithisshouldnotrender:

", + "expected_output": "

test :smile: again :poop:
\n:) foo:)bar x::y::z :wasted waste: :fakeemojithisshouldnotrender:

", "text_content": "test \u263A again \ud83d\udca9\n:) foo:)bar x::y::z :wasted waste: :fakeemojithisshouldnotrender:" }, { @@ -360,14 +360,14 @@ { "name": "translate_emoticons_enabled", "input": ":)", - "expected_output": "

:slight_smile:

", + "expected_output": "

:slight_smile:

", "text_content": "\ud83d\ude42", "translate_emoticons": true }, { "name": "translate_emoticons", "input": ":) foo :( bar <3 with space : ) real emoji :slight_smile:", - "expected_output": "

:slight_smile: foo :frown: bar :heart: with space : ) real emoji :slight_smile:

", + "expected_output": "

:slight_smile: foo :frown: bar :heart: with space : ) real emoji :slight_smile:

", "text_content": "\ud83d\ude42 foo \ud83d\ude41 bar \u2764 with space : ) real emoji \ud83d\ude42", "translate_emoticons": true }, @@ -381,7 +381,7 @@ { "name": "translate_emoticons_newline", "input": ":) test\n:) test", - "expected_output": "

:slight_smile: test
\n:slight_smile: test

", + "expected_output": "

:slight_smile: test
\n:slight_smile: test

", "text_content": "\ud83d\ude42 test\n\ud83d\ude42 test", "translate_emoticons": true }, @@ -395,14 +395,14 @@ { "name": "translate_emoticons_at_sentence_end", "input": "Translate this :).", - "expected_output": "

Translate this :slight_smile:.

", + "expected_output": "

Translate this :slight_smile:.

", "text_content": "Translate this \ud83d\ude42.", "translate_emoticons": true }, { "name": "translate_emoticons_between_symbols", "input": "Translate this !:)?", - "expected_output": "

Translate this !:slight_smile:?

", + "expected_output": "

Translate this !:slight_smile:?

", "marked_expected_output": "

Translate this !:)?

", "text_content": "Translate this !\ud83d\ude42?", "translate_emoticons": true @@ -410,7 +410,7 @@ { "name": "random_emoji_1", "input": ":airplane:", - "expected_output": "

:airplane:

" + "expected_output": "

:airplane:

" }, { "name": "zulip_emoji", @@ -421,18 +421,18 @@ { "name": "random_emoji_2", "input": ":poop:", - "expected_output": "

:poop:

" + "expected_output": "

:poop:

" }, { "name": "emojis_without_space", "input": ":cat:hello:dog::rabbit:", - "expected_output": "

:cat:hello:dog::rabbit:

", + "expected_output": "

:cat:hello:dog::rabbit:

", "text_content": "\ud83d\udc08hello\ud83d\udc15\ud83d\udc07" }, { "name": "emojis_newline", "input": ":cat:\n:dog:", - "expected_output": "

:cat:
\n:dog:

", + "expected_output": "

:cat:
\n:dog:

", "text_content": "\ud83d\udc08\n\ud83d\udc15" }, { @@ -444,67 +444,67 @@ { "name": "unicode_emoji", "input": "\ud83d\udca9", - "expected_output":"

:poop:

", + "expected_output":"

:poop:

", "text_content": "\ud83d\udca9" }, { "name": "two_unicode_emoji", "input": "\ud83d\udca9\ud83d\udca9", - "expected_output":"

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

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

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

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

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

Merry Christmas!!:holiday_tree:<\/p>", "text_content": "Merry Christmas!!\ud83c\udf84" }, { "name": "miscellaneous_and_dingbats_emoji", "input": "\u2693\u2797", - "expected_output":"

:anchor::division:<\/p>" + "expected_output":"

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

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

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

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

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

Extra:alien:Terrestrial<\/p>" + "expected_output":"

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

:alien:
\n:alien:

", + "expected_output":"

:alien:
\n:alien:

", "text_content": "\ud83d\udc7d\n\ud83d\udc7d" }, { "name": "emoji_alongside_punctuation", "input": ":smile:, :smile:; :smile:", - "expected_output": "

:smile:, :smile:; :smile:

" + "expected_output": "

:smile:, :smile:; :smile:

" }, { "name": "new_emoji_test", "input": ":avocado:, :kiwi:, :selfie:, :gear:, :comet:, :gold:", - "expected_output": "

:avocado:, :kiwi:, :selfie:, :gear:, :comet:, :gold:

" + "expected_output": "

:avocado:, :kiwi:, :selfie:, :gear:, :comet:, :gold:

" }, { "name": "emoji_pipeline_newline", "input": "The winner is:\nsmiley:smiley:", - "expected_output": "

The winner is:
\nsmiley:smiley:

" + "expected_output": "

The winner is:
\nsmiley:smiley:

" }, { "name": "emoji_pipeline_emphasis", @@ -514,7 +514,7 @@ { "name": "emoji_pipeline_link", "input": "Visit https:smiley://google.com.", - "expected_output": "

Visit https:smiley://google.com.

" + "expected_output": "

Visit https:smiley://google.com.

" }, { "name": "skin_tones_are_banned", diff --git a/zerver/tests/test_bugdown.py b/zerver/tests/test_bugdown.py index 39e618bb71..9ea0f76a20 100644 --- a/zerver/tests/test_bugdown.py +++ b/zerver/tests/test_bugdown.py @@ -551,7 +551,7 @@ class BugdownTest(ZulipTestCase): media_tweet_html = ('' 'http://twitter.com/NEVNBoston/status/421654515616849920/photo/1') - emoji_in_tweet_html = """Zulip is :100:% open-source!""" + emoji_in_tweet_html = """Zulip is :100:% open-source!""" def make_inline_twitter_preview(url: str, tweet_html: str, image_html: str='') -> str: ## As of right now, all previews are mocked to be the exact same tweet @@ -698,11 +698,11 @@ class BugdownTest(ZulipTestCase): def test_unicode_emoji(self) -> None: msg = u'\u2615' # ☕ converted = bugdown_convert(msg) - self.assertEqual(converted, u'

:coffee:

') + self.assertEqual(converted, u'

:coffee:

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

:coffee::coffee:

') + self.assertEqual(converted, u'

:coffee::coffee:

') def test_no_translate_emoticons_if_off(self) -> None: user_profile = self.example_user('othello') diff --git a/zerver/tests/test_notifications.py b/zerver/tests/test_notifications.py index d2206f6149..6c92d3ef87 100644 --- a/zerver/tests/test_notifications.py +++ b/zerver/tests/test_notifications.py @@ -856,7 +856,7 @@ class TestMissedMessages(ZulipTestCase): def test_fix_emoji(self) -> None: # An emoji. - test_data = '

See ' + \ + test_data = '

See ' + \ ':cloud_with_lightning_and_rain:.

' actual_output = fix_emojis(test_data, "http://example.com", "google") expected_output = '

See