Emote

Small lib for converting emoticons and emoji names to emoji characters:

Works with emoji names:

iex> Emote.convert_text("my emoji game is :fire:")
"my emoji game is πŸ”₯"

And emoticons (see lib/emoticons.txt for the list of supported ones):

iex> Emote.convert_text("my emoji game is :P")
"my emoji game is 😜"

You can also provide a list of images that can be used as custom emoji:

iex> Emote.convert_text("I can use images as custom emoji :favicon:", custom_emoji: %{"favicon" => "/favicon.ico"}) 
"I can use images as custom emoji <img class=&#39;emoji favicon&#39; alt=&#39;favicon&#39; title=&#39;:favicon:&#39; src=&#39;/favicon.ico&#39; />"

Or your own function to handle custom emoji:

> Emote.convert_text("I can define my own function to handle custom emoji :fire:",
   custom_fn: fn word -> 
    case lookup_my_custom_emoji(word) do
      %{label: label, url: url} ->
          " <img alt=&#39;#{label || word}&#39; title=&#39;#{label}&#39; class=&#39;emoji&#39; data-emoji=&#39;#{word}&#39; src=&#39;#{url}&#39; /> "
          
      _nil_ ->
          word
      end
   end
  )

Known limitation:

License

WTFPL, as originally forked from https://github.com/danigulyas/smile