Closed cinnamon-bun closed 5 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
@cinnamon-bun does node-emoji work with :male-singer:
?
EDIT: yes it does
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.
I put neato-emoji-converter together yesterday/today to cover most emoji conversion use-cases, while being faster than most. It can borrow emoji-toolkit
s 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.
@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?
LICENSE added 👍
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)
@fenwick67 solved this super nicely!
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.