markdown-it-emoji icon indicating copy to clipboard operation
markdown-it-emoji copied to clipboard

Gemoji lacks behind

Open Crissov opened this issue 6 years ago • 8 comments

Gemoji is rarely updated and still does not support Unicode 10.0, released in June 2017. github/gemoji#139 Consider to switch to Emojione or Emojidata instead. Twemoji and Noto Emoji do not provide an emoji.json with short codes, but there may be others that are kept up to date.

Crissov avatar Oct 07 '18 23:10 Crissov

I recently had to update this, to be compatible with twemoji. A bunch of new ones were missing, and a bunch of old ones had wrong short codes. Might be good to list the steps I did here.

goto here: https://unicode.org/emoji/charts/full-emoji-list.html

Open console, do

(function () {
  const script = document.createElement('script');
  script.onload = () => {
    const emoji = {};
    for (const code of document.querySelectorAll('td.code')) {
      const desc = underscored(code.parentElement.lastElementChild.textContent);
      let key = '';
      code.textContent.trim().split(' ').forEach(unicode => {
        key += twemoji.convert.fromCodePoint(unicode.replace('U+', ''));
      });
      emoji[desc] = key;
    }
    window.emoji = emoji;
  };
  document.head.appendChild(script).src =
    'https://twemoji.maxcdn.com/v/latest/twemoji.min.js';
  function underscored(desc) {
    return desc.trim().replace(/[ :]+/g, '_');
  }
}());

This gets you an object that looks like:

{
  "grinning_face": "😀",
  "grinning_face_with_big_eyes": "😃",
  ...
}

Now do

.use(markdownitEmoji, {
  defs: twemojis_from_above
});

I got this also working nicely in a zurb/tribute autocomplete dropdown if anyones interested, I can post the code here if anyone wants.

@puzrin it might be good to either add some of these instructions to the twemoji section, or to use the instructions above to update the emoji list so we don't have to rewrite the defs.

dessalines avatar Sep 02 '19 23:09 dessalines

Such kind of issues should be limited somehow. This package was done to demonstrate general approach in parser, and provide some minimal smiles set. But i certainly don't wish to maintain growing list of all possible emojies.

puzrin avatar Sep 02 '19 23:09 puzrin

@WebReflection just made a package for this, so now you could just rely on this as a dependency: https://github.com/WebReflection/emoji-short-name

dessalines avatar Sep 04 '19 21:09 dessalines

FYI current module offers {"😀": "grinning face"} as code => CLRD Short Name, if you need to have other way around map simply do the following:

const esn = require('emoji-short-name');
const solved = Object.keys(esn).reduce(
  (p, k) => {
    p[esn[k].replace(/[ :]+/g, '_')] = k;
    return p;
  },
  {}
);

That's pretty much it, the solved object now has your flavor mapped.

i certainly don't wish to maintain growing list of all possible emojies.

neither do I, which is why emoji-short-name is generated automatically via electron so that whenever unicode releases new emoji (I'm member/subscribed there) I build new version and publish.

In this way nobody needs to bother their heavy page and, if I forget to update every 6 months, just ping me to run the build and publish.

WebReflection avatar Sep 04 '19 21:09 WebReflection

I think, it would be enougth if someone add to readme example of emoji-short-name use.

puzrin avatar Sep 04 '19 21:09 puzrin

just FYI since emoji-short-name was crawling the whole unicode full emoji list page but not collecting enough info, I've also created emoji-essential, now used by emoji-short-name itself, which has all the info such as groups and sub-groups of all emoji.

WebReflection avatar Sep 05 '19 15:09 WebReflection

In 2.0.0:

  • has clean bare.js, to populate from scrach
  • updated to latest gemoji DB

Is this issue still actual? As i said, this package is not intended to collect all possible emojis. But i could add examples to readme, how to use foreign db packages.

puzrin avatar Oct 14 '20 22:10 puzrin

That would be nice, as even the demo page of markdown-it shows some missing emojis: image

sovushka-utrom avatar Jan 07 '21 10:01 sovushka-utrom