teepark / elmoji

Easy Twemoji & EmojiOne substitution functions for Elm.
5 stars 3 forks source link

Convert shortnames to images #4

Open vjousse opened 7 years ago

vjousse commented 7 years ago

Emojis are often used with shortnames, for example the shortname of 😀 is : grinning :. I would like the shortnames to be converted to Emojis too.

Based on data from https://github.com/iamcal/emoji-data I suppose that just adding new pairs here https://github.com/teepark/elmoji/blob/2.0.2/Elmoji/Internal/Valid.elm#L48 with the shortname as the first entry of the tuple should be enough.

I'm ready to do the work and propose a PR if you want, just tell me if the approach seems reasonable to you or if you see a better way to do it.

Btw, thanks for the great work :)

teepark commented 7 years ago

:+1: I'd love to have a PR doing this!

My only question about the short names from the linked repo: is that standardized in any way? The main reason that I punted on them up to this point is that different vendors seem to have different short code sets, and I couldn't find anything about them in the unicode standard.

I'm on hipchat at work all day which is just about the only holdout from :colon: :style:, so that's part of it 😞

vjousse commented 7 years ago

Ahah I know the hipchat feeling 😉 As far as I know, there is no standard regarding emojis. The closest thing I found is the https://github.com/iamcal/emoji-data repo. It's listing the "standard" short_name for an emoji and all the known variations of the short name under the short_names key. Not sure if we can get something better than that.

teepark commented 7 years ago

OK tell you what then, let's structure the code to reflect that: create a separate list of (short_code, unicode) pairs (rather than butting into the existing data structure), and the functions powering short-code recognition should accept that data structure as their first argument.

This way we can easily partially apply just that first argument, but if down the line someone wants to provide an alternative mapping and use the original functions then that's fine.

Sound good?

Fenntasy commented 7 years ago

Another way would be to just provide another module to the package like a Github module that gives the github set of short name and after that, other modules for commonly used ones.

What do you think?

teepark commented 7 years ago

Yeah I think the important thing is that we support pluggable shortcode-to-unicode mapping data structures (whatever form that structure takes). Putting them in named modules sounds fine.

The only thing I'd change is calling one Github, since that seems to be the one just about everybody (except hipchat) uses. I don't have a better name off the top of my head, but maybe steer clear of naming a particular vendor when there are so many?