cabal-club / commons

high level thoughts and issues for the future of cabal
14 stars 2 forks source link

emoji handling #2

Closed cinnamon-bun closed 5 years ago

cinnamon-bun commented 6 years ago

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:

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

cinnamon-bun commented 6 years ago

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 commented 5 years ago

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

EDIT: yes it does

fenwick67 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

LICENSE added 👍

fenwick67 commented 5 years ago

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

cblgh commented 5 years ago

@fenwick67 solved this super nicely!