gmac / gemoji-parser

The missing helper methods for GitHub's gemoji gem.
MIT License
72 stars 9 forks source link

Support for skin-colored emojis #1

Open joseramonc opened 9 years ago

joseramonc commented 9 years ago

Is there an appropiate way to parse apple colored emojis?

I'm getting:

EmojiParser.tokenize("Test 👍🏿")
# => "Test :+1:\u{1F3FF}"
# Expected: "Test :+1::skin-tone:" or something like that
rdlh commented 8 years ago

Just coded an ugly monkey patch to prevent database errors if that can help someone reading this issue.

require 'gemoji'

module EmojiParser
  def self.tokenize(text)
    text = text.gsub(color_emoji_regex, '')
    parse_unicode(text) { |emoji| ":#{emoji.name}:" }
  end

  def self.color_emoji_regex
    reg = /((?:\u{1f3fb}|\u{1f3fc}|\u{1f3fd}|\u{1f3fe}|\u{1f3ff}?))/
  end
end