Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emoji handling #2

Closed
cinnamon-bun opened this issue Oct 19, 2018 · 8 comments
Closed

emoji handling #2

cinnamon-bun opened this issue Oct 19, 2018 · 8 comments
Labels
enhancement New feature or request

Comments

@cinnamon-bun
Copy link
Member

cinnamon-bun commented Oct 19, 2018

Would we like clients to handle emojis as actual emoji characters or as :emoji_codes:?

Clients can convert to emoji characters, convert to :emoji_codes:, or leave it alone.

This could happen when posting a message and/or when displaying a message.

Complexities:

  • CLI clients can't always display actual emojis depending on the font they're using. Even if they can, they can be very small
  • Some people run system tools which convert :codes: to actual emojis as they type
  • Some emojis are actually a sequence of several characters such as skintone modifiers. For example [Male Singer]:(https://emojipedia.org/male-singer/)

The Man Singer emoji is a sequence of the 👨 Man and 🎤 Microphone emojis. These are combined using a zero width joiner between each character and display as a single emoji on supported platforms.

Composite emojis are only supported in some places. Android supports them but not always MacOS Desktop.

@cinnamon-bun
Copy link
Member Author

node-emoji can convert between actual emojis and :codes:. It doesn't understand Male Singer (:man_singer:)

emoijlib has Male Singer but no functions for autoconverting :codes:.

twemoji looked promising but converts emoji characters to <img> tags, not :codes:.

Anyway, if we find a good library this might be a useful thing to put into cabal-client

@fenwick67
Copy link

fenwick67 commented Sep 3, 2019

@cinnamon-bun does node-emoji work with :male-singer: ?

EDIT: yes it does

@fenwick67
Copy link

fenwick67 commented Sep 4, 2019

I had some more thoughts to add here.

I worked on (but abandoned and deleted) a branch on cabal-clone that would take unicode or :codes: and then look up custom emoji, then replace it with an <img>.

I couldn't find a library that satisfied me so I wrote my own parsing function. Largely because none of them let me provide my own map of characters for codes or vice-versa. One thing I stuggled with was finding emoji characters. A big "Eureka" was when I realized lodash.toArray('👩🏽‍🦰👴🏻') splits the string into display characters (['👩🏽‍🦰','👴🏻']) successfully, handling the messy unicode stuff for you, including skin tone modifiers and zero-width-joins, and it does it reasonably quickly.

I threw together a jsperf notebook here: https://jsperf.com/emoji-parsing/1 . Looks like converting is comparable performance-wise in either direction.

I did (just now) find https://github.com/joypixels/emoji-toolkit , which has a nice shortNameToUnicode and ToShort method. Does not appear to support custom emoji.

@fenwick67
Copy link

I put neato-emoji-converter together yesterday/today to cover most emoji conversion use-cases, while being faster than most. It can borrow emoji-toolkits very complete list of shortcodes and unicode sequences, so it can cover literally every official emoji sequence out of the box.

The emoji set and replacer functions are totally configurable, so it can be used for basically any emoji strategy I can think of.

It doesn't have any sort of picker integration.

@cblgh
Copy link
Member

cblgh commented Sep 7, 2019

@fenwick67 ohhhhhh wha this looks really cool, it could help make cabal-cli handle emoji way better than the hack i implemented!

would you mind adding a license to https://github.com/fenwick67/neato-emoji-converter?

@fenwick67
Copy link

LICENSE added 👍

@fenwick67
Copy link

fenwick67 commented Oct 10, 2019

Hey y'all, I made a PR into cabal-cli to replace unicode with shortcodes cabal-club/cabal-cli#132 . (And it was merged)

@cblgh
Copy link
Member

cblgh commented Nov 14, 2019

@fenwick67 solved this super nicely!

@cblgh cblgh closed this as completed Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants