hadley / emo

Easily insert emoji into R and RMarkdown
416 stars 53 forks source link

Add standard emoji codes #21

Open LucyMcGowan opened 7 years ago

LucyMcGowan commented 7 years ago

I think it'd be lovely if we could incorporate these emoji codes - used by Slack, GitHub, etc 🎉 👯

@romainfrancois: Here is their GitHub - I haven't poked around much, but can if you think this is worthwhile.

romainfrancois commented 7 years ago

Cool thanks for logging it here. I've had a quick look and I only found how to match the codes with pictures, but I need to :bowtie: this to their actual character representations, e.g.

capture d ecran 2017-08-13 a 19 16 55
> slice( emo::jis , 1:5  )
# A tibble: 5 x 17
     id        emoji                           name         category   subcategory  keywords skin_tone     runes
  <dbl>        <chr>                          <chr>            <chr>         <chr>    <list>     <chr>    <list>
1     1 "\U0001f600"                  grinning face Smileys & People face-positive <chr [2]>      <NA> <chr [1]>
2     2 "\U0001f601" beaming face with smiling eyes Smileys & People face-positive <chr [4]>      <NA> <chr [1]>
3     3 "\U0001f602"         face with tears of joy Smileys & People face-positive <chr [4]>      <NA> <chr [1]>
4     4 "\U0001f923"  rolling on the floor laughing Smileys & People face-positive <chr [4]>      <NA> <chr [1]>
5     5 "\U0001f603"    grinning face with big eyes Smileys & People face-positive <chr [4]>      <NA> <chr [1]>
# ... with 9 more variables: nrunes <int>, apple <lgl>, google <lgl>, twitter <lgl>, one <lgl>, facebook <lgl>,
#   messenger <lgl>, samsung <lgl>, windows <lgl>
LucyMcGowan commented 7 years ago

I think there are a couple of places that have mapped them (for example, here is python's and here is C's), so maybe we can use that?

romainfrancois commented 7 years ago

Perfect. Should be easy to use one of those. Not sure if this goes in a list column in jis or in a separate simple named chr vector.

The hesitation is bc some have multiple names, eg iirc :poop:

I like the tibble but it might be more practical

romainfrancois commented 7 years ago

Good news from looking at the python link above, they use this to transform some of the names from the unicode names (which we already have in pull( emo::jis, name )

> sample( dplyr::pull( emo::jis, name ), 10 )
 [1] "tear-off calendar"                      "woman juggling: medium-light skin tone" "purse"                                 
 [4] "information"                            "woman climbing: medium skin tone"       "baby angel"                            
 [7] "man cartwheeling: medium skin tone"     "poultry leg"                            "South Georgia & South Sandwich Islands"
[10] "input numbers"                         

so I guess to get started this will be a str_replace_all exercise in data-raw/jis.R

Then, they use the aliases, defined here

EMOJI_ALIAS_UNICODE = dict(EMOJI_UNICODE.items(), **{
    u':admission_tickets:': u'\U0001F39F',
    u':aerial_tramway:': u'\U0001F6A1',
    u':airplane:': u'\U00002708',
    u':airplane_arriving:': u'\U0001F6EC',
    u':airplane_departure:': u'\U0001F6EB',

I guess we can parse this somehow, but this also looks generated automatically ...

romainfrancois commented 7 years ago

ah, it looks like it all goes down to this repo: https://github.com/github/gemoji and particularly this file which as a bonus also has information about the version of unicode when the emoji was introduced:

... 
{
    "emoji": "😀"
  , "description": "grinning face"
  , "category": "People"
  , "aliases": [
      "grinning"
    ]
  , "tags": [
      "smile"
    , "happy"
    ]
  , "unicode_version": "6.1"
  , "ios_version": "6.0"
  } 
... 
romainfrancois commented 7 years ago

We now have emo::ji_alias vector (which might replace emo:::emoji_name ) so :

> cat( emo::ji_alias["grin"] )
😁

I'll simplify ji_glue to use this

romainfrancois commented 7 years ago

@LucyMcGowan For now I've put this in ji_replace but not 💍 with the name.

> ji_replace( ":ant: != :santa: " )
🐜 != 🎅 
romainfrancois commented 7 years ago

it probably should hint (did you mean ...) when it does not match

LucyMcGowan commented 7 years ago

Could it just be emo::ji_glue()? The other thing I was 🤔 is whether it is odd that ordinarily glue uses {parameter} but we use :parameter:, the latter I think makes sense because that's how all other places do (i.e.: Slack, GitHub, etc), but worth a thought.

romainfrancois commented 7 years ago

Makes sense for this to be ji_glue, btw it can't actually use glue i think as the begin and end are the same.

I kind of want to keem what i have now as i can do either :cat,face: or :face,cat: ... but i guess for most people, esp who know slack github ... it makes more sense to stick to exact matches.

To be truly great, we need rstudio to show emoji completion. @kevinushey shared some hints about where completion is implemented in rstudio, this might be my excuse to be curious about rstudio internals ...

I think my plan is: