Open Sequoia opened 8 years ago
The names and images are publicly available on https://github.com/github/gemoji, but I'm not sure there's really demand for such a feature.
I think this might be more useful implemented as a JavaScript library, and then we can apply it at runtime, like what we do with math. I wonder if someone has already done this.
@uranusjr if it can be implemented in JS I can probably do it! Is there an example of attaching a JS plugin to macdown I could look at?
It’s not actually attaching JS into the MacDown parser. MacDown generates an HTML document for preview, so it should be enough to write a script that goes through the document, and replaces :emoji:
occurrences with appropriate emojis. It will need to skip math and code constructs, but this shouldn’t be hard with some selectors. The one thing I’m concerned about is some edge cases that are hard to get right (spaces/punctuations around the pattern, something like :foo:bar:
should not work, etc.), but I’m not very good at regex, so this might not actually be the case. And we can always play it safe in extremely rare situations anyway; nobody would expect us to be 100% compatible with GitHub. (At least I hope not.)
So the main work here would be to extract the emoji info from GitHub’s repository, and write a JavaScript lib that does the find/replace thing. After that we can just conditionally include it in the generated HTML document, which is relatively easy.
Please do give a shot if you’re interested! It would be even better if it can come as a standalone JavaScript project; I’d imagine it being very useful for online forum and chat projects.
It looks like someone has already gone through the hassle and created a GFM emoji library written in JS 🙌
Wow that is pretty cool. It seems to only handle pure text replace, so we’ll need to jump through some hoops. But it would still be very useful.
Note: http://james.padolsey.com/javascript/replacing-text-in-the-dom-solved/
What we want is a little less complicated (don’t need to normalise things).
I have some need for emoji support here. Would such a feature be welcome? If so, I'll work on it.
@Hoten Go ahead!
Is it possible to enable/achieve this?