Jamie's Blog

Quick Snippet: Slack Emoji Names to Unicode :smile:

Tags: Programming

While working on this blog, I wanted to add Slack-style named emoji.


Eventually, I realised Pandoc already has Slack emoji support 🎉, but only after I’d already made my own 🤦‍♀️. Then I found out Pandoc doesn’t seem to have :‌woman-facepalming:, so it’s a damn good thing I did 😳.

Luckily, Slack’s own emoji metadata is available on github, which means most of the work is done for us. emoji.json contains all the Slack names (called short names) along with a whole load of other data we don’t care about. The first step is to extract the good stuff – the unified_name, storing the unicode hex in plaintext, and the short_name, a single name for the emoji chosen by our Slack overlords. It turns out Slack’s canonical short_name for a few entries is a little surprising – we all know a good :poop‌: when we see it, but Slack refers to that particular character as :hankey‌: 😕. We’re going to need the full list of alternative short_names, too.

For my purposes, I decided to create two files:

Mapping from a single short-name to its Unicode representation.
Mapping from canonical short-name to aliases.

The code to generate these files is also available on GitHub, along with the code to make the replacements.

Finally, we want to display the Unicode characters as emoji, whether or not our user has an emoji font installed. There are a few nice plug-and-play options for this, including EmojiOne and Twemoji, which is the one I use. And then we’re done! 😄.