From 754b29ba0852bd487dae99b165b9ab46dfb8bc8e Mon Sep 17 00:00:00 2001 From: yantene Date: Mon, 9 Oct 2017 05:11:22 +0900 Subject: [PATCH 1/2] Add test about emoji presentation selector --- test/twemoji_test.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/twemoji_test.rb b/test/twemoji_test.rb index da5d83a..e98d13d 100644 --- a/test/twemoji_test.rb +++ b/test/twemoji_test.rb @@ -83,6 +83,14 @@ def test_find_by_escaped_unicode assert_equal ":heart_eyes:", Twemoji.find_by_unicode("\u{1f60d}") end + def test_find_by_code_including_emoji_presentation_selector + assert_equal ":eye::left_speech_bubble:", Twemoji.find_by_code("1f441-fe0f-200d-1f5e8-fe0f") + end + + def test_find_by_unicode_including_emoji_presentation_selector + assert_equal ":eye::left_speech_bubble:", Twemoji.find_by_unicode("\u{1f441}\u{fe0f}\u{200d}\u{1f5e8}\u{fe0f}") + end + def test_parse_plus_one expected = %(👍) @@ -211,7 +219,7 @@ def test_parse_by_unicode_multiple_html expected = %(

🍪🎂

) aria_label = ->(name) { 'emoji: ' + name.gsub(":", '') } assert_equal expected, Twemoji.parse(Nokogiri::HTML::DocumentFragment.parse("

🍪🎂

"), img_attrs: {'aria-label'=> aria_label } ).to_html - end + end def test_parse_by_unicode_multiple_mix_codepoint_name_html expected = %(

🍪🎂

) @@ -230,5 +238,4 @@ def test_parse_multiple aria_label = ->(name) { 'emoji: ' + name.gsub(":", '') } assert_equal expected, Twemoji.parse(":cookie::birthday:", img_attrs: {'aria-label'=> aria_label } ) end - end From c20cf1f218621b1b79abd5453710c0cc678972d6 Mon Sep 17 00:00:00 2001 From: yantene Date: Mon, 9 Oct 2017 05:13:14 +0900 Subject: [PATCH 2/2] Ignore emoji or text presentation selector --- lib/twemoji.rb | 4 ++-- lib/twemoji/data/emoji-unicode.yml | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/twemoji.rb b/lib/twemoji.rb index 467ee31..0cd65a9 100644 --- a/lib/twemoji.rb +++ b/lib/twemoji.rb @@ -58,7 +58,7 @@ def self.find_by_text(text) # @param code [String] Emoji code to find text. # @return [String] Emoji Text. def self.find_by_code(code) - invert_codes[must_str(code)] + invert_codes[must_str(code).gsub(/(-fe0e|-fe0f)/, '')] end # Find emoji text by raw emoji unicode. @@ -70,7 +70,7 @@ def self.find_by_code(code) # @param raw [String] Emoji raw unicode to find text. # @return [String] Emoji Text. def self.find_by_unicode(raw) - invert_codes[unicode_to_str(raw)] + invert_codes[unicode_to_str(raw).gsub(/(-fe0e|-fe0f)/, '')] end # Render raw emoji unicode from emoji text or emoji code. diff --git a/lib/twemoji/data/emoji-unicode.yml b/lib/twemoji/data/emoji-unicode.yml index 2dfd1a4..b997166 100644 --- a/lib/twemoji/data/emoji-unicode.yml +++ b/lib/twemoji/data/emoji-unicode.yml @@ -791,8 +791,8 @@ ":man-woman-girl:": 1f468-200d-1f469-200d-1f467 ":man-woman-girl-boy:": 1f468-200d-1f469-200d-1f467-200d-1f466 ":man-woman-girl-girl:": 1f468-200d-1f469-200d-1f467-200d-1f467 -":man-heart-man:": 1f468-200d-2764-fe0f-200d-1f468 -":man-kiss-man:": 1f468-200d-2764-fe0f-200d-1f48b-200d-1f468 +":man-heart-man:": 1f468-200d-2764-200d-1f468 +":man-kiss-man:": 1f468-200d-2764-200d-1f48b-200d-1f468 ":woman::skin-tone-2:": 1f469-1f3fb ":woman::skin-tone-3:": 1f469-1f3fc ":woman::skin-tone-4:": 1f469-1f3fd @@ -804,10 +804,10 @@ ":woman-woman-girl:": 1f469-200d-1f469-200d-1f467 ":woman-woman-girl-boy:": 1f469-200d-1f469-200d-1f467-200d-1f466 ":woman-woman-girl-girl:": 1f469-200d-1f469-200d-1f467-200d-1f467 -":woman-heart-man:": 1f469-200d-2764-fe0f-200d-1f468 -":woman-heart-woman:": 1f469-200d-2764-fe0f-200d-1f469 -":woman-kiss-man:": 1f469-200d-2764-fe0f-200d-1f48b-200d-1f468 -":woman-kiss-woman:": 1f469-200d-2764-fe0f-200d-1f48b-200d-1f469 +":woman-heart-man:": 1f469-200d-2764-200d-1f468 +":woman-heart-woman:": 1f469-200d-2764-200d-1f469 +":woman-kiss-man:": 1f469-200d-2764-200d-1f48b-200d-1f468 +":woman-kiss-woman:": 1f469-200d-2764-200d-1f48b-200d-1f469 ":family:": 1f46a ":couple:": 1f46b ":two_men_holding_hands:": 1f46c