Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Emojis #14

Closed
finnp opened this issue Apr 15, 2015 · 8 comments
Closed

Support Emojis #14

finnp opened this issue Apr 15, 2015 · 8 comments

Comments

@finnp
Copy link

finnp commented Apr 15, 2015

GitHub flavored markdown allows for emojis like this :poop: 💩. We should support them as well. Haven't found a good module yet for the conversion though.

@mikaelbr
Copy link
Owner

That would be cool. Mac Terminal supports them at least, I don't know about cross platform though. For instance what does

$ echo "\xF0\x9F\x98\x80"

show on Linux or Windows?

Github has a overview of all the emojis it support and it's unicode here: https://api.github.com/emojis

@mikaelbr
Copy link
Owner

I have a working example of this now, using something like:

function insertEmojis(text) {
  return text.replace(/:([A-Za-z0-9_\-\+]+?):/g, function (emojiString) {
    return emoji.get(emojiString) + ' ';
  });
}

But I need to add an option for using it, add some tests, and see how it works cross platform. Also probably need to extend the regex to not apply if inside code-block.

@finnp
Copy link
Author

finnp commented Apr 15, 2015

Looks good. Yeah exactly it should not be shown in code blocks. That's the only gotcha.

It's supported by Windows 7+ and Mac. Linux users usually need to change their terminal font. However I think it should be done per default on all systems - and then there should be an option to disable this. I don't think there is a good test if emojis are supported in a terminal.

Maybe you can use this for getting the emojis: https://www.npmjs.com/package/gemoji

@mikaelbr
Copy link
Owner

I used https://www.npmjs.com/package/node-emoji and it seemed to work as expected on the Mac Terminal.

@mikaelbr
Copy link
Owner

Pushed support for emojis now. Would be great if you could test it out and verify.

@finnp
Copy link
Author

finnp commented Apr 15, 2015

I just tried :pencil: and I got undefined. So 2 things:

  1. It didn't know :pencil:, which works here: 📝 (https://github.com/wooorm/gemoji seems to support this as well)
  2. Things like :thisisbullshit: should fallback to plain text like this: :thisisbullshit:

@mikaelbr
Copy link
Owner

Things like :thisisbullshit: should fallback to plain text like this: :thisisbullshit:

Good point. I completely forgot. Fixed now in 9196c03.

It didn't know 📝, which works here: 📝

There might be differences, I suspect, but until we find something better I think it'll do. As far as I see there's a pretty extensive list, so hopefully it works for the time being.

@finnp
Copy link
Author

finnp commented Apr 15, 2015

📝 is actually listed here, so might be a bug: https://github.com/omnidan/node-emoji/blob/master/lib/emojifile.js#L561 Will look into this, probably fine to use it.

Otherwise it works fine for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants