# Auto-replace emoji like ☺ with Discourse codes

**URL:** https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155
**Category:** Feature
**Created:** [March 9, 2015, 9:23pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155 "2015-03-09T21:23:17Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![RaceProUK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raceprouk/32/115844_2.png) [@RaceProUK](https://meta.discourse.org/u/RaceProUK)
#### Post date: [March 9, 2015, 9:23pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/1 "2015-03-09T21:23:17Z")

</div>

Over on TDWTF, I’ve been using a bot to automatically replace Unicode emoji like ☺ with Discourse emoji codes like `:smile:`; it’s useful when posting from mobile. @codinghorror suggests it could be made a Discourse feature; it never occurred to me before, but it does sound like it’d be useful. That way it could also work in PMs, which is something I haven’t got working in my bot yet.

---

<div class="post-metadata">

### Author: ![purldator](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@purldator](https://meta.discourse.org/u/purldator)
#### Post date: [March 9, 2015, 9:28pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/2 "2015-03-09T21:28:59Z")

</div>

This is what happened with my first post on the Nexus @codinghorror sent me! I was thinking about that concept too. Glad I’m not the only one.

---

<div class="post-metadata">

### Author: ![LuaTenshi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/luatenshi/32/51081_2.png) [@LuaTenshi](https://meta.discourse.org/u/LuaTenshi)
#### Post date: [March 9, 2015, 9:42pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/3 "2015-03-09T21:42:40Z")

</div>

Would we not be able to do something like this already by using…

```
Discourse.Dialect.registerEmoji('☺', '/plugins/trout_emoji/images/trout-square.jpg');

```

Or something along those lines?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 9, 2015, 10:06pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/4 "2015-03-09T22:06:21Z")

</div>

Not that trivial to do efficiently, see:

> <https://github.com/joypixels/emojione/blob/master/lib/js/emojione.js>

In particular you need to map the unicode → code points → emoji image. This means that we need to scan through every char and check it to see if its an emoji.

We can not afford to cripple the editor here so whatever we do needs to be using lots of fancy tricks.

---

<div class="post-metadata">

### Author: ![RaceProUK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raceprouk/32/115844_2.png) [@RaceProUK](https://meta.discourse.org/u/RaceProUK)
#### Post date: [March 9, 2015, 10:08pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/5 "2015-03-09T22:08:23Z")

</div>

Does it need to be done in the editor though? On desktop, people will normally use the Discourse emoji code auto-complete instead of Unicode emoji; it’s only really those on mobile (which has no preview pane IIRC) that will be using Unicode emoji.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [March 9, 2015, 10:09pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/6 "2015-03-09T22:09:01Z")

</div>

No, this should only be done server side on post bake. No need to clutter the client with this.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 9, 2015, 10:31pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/7 "2015-03-09T22:31:19Z")

</div>

Server side this is much more practical, we already do a bunch of nokogiri passes.

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [March 10, 2015, 12:46am UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/8 "2015-03-10T00:46:33Z")

</div>

> [@RaceProUK](#):
>
> On desktop, people will normally use the Discourse emoji code auto-complete instead of Unicode emoji; it’s only really those on mobile (which has no preview pane IIRC) that will be using Unicode emoji.

Any particular benefit for this? Using Discourse™ and other programs under Linux© I usually ❤ typing emoji at least ¾ of the time inline using Compose - can make most of the really common ones even ← arrows →.

That’s right - I’m the ♔ of edge user cases. 😜

---

<div class="post-metadata">

### Author: ![Chili](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chili/32/40331_2.png) [@Chili](https://meta.discourse.org/u/Chili)
#### Post date: [March 10, 2015, 10:15am UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/9 "2015-03-10T10:15:59Z")

</div>

Isn’t Emoji One designed to do exactly this?

> **[JoyPixels | Stunning emoji for beautiful brands & agencies!](https://joypixels.com)**
>
> Simple emoji licensing for your creators and brands with the highest of standards. Offering bespoke emoji licenses for everything from apps, retail products, commercial advertising, and anything you can dream!

Although I guess that would only replace with Emoji One emojis rather than the forum’s customised emoji choices.

---

<div class="post-metadata">

### Author: ![RaceProUK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raceprouk/32/115844_2.png) [@RaceProUK](https://meta.discourse.org/u/RaceProUK)
#### Post date: [March 10, 2015, 10:27am UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/10 "2015-03-10T10:27:06Z")

</div>

> [@supermathie](#):
>
> Any particular benefit for this?

Mostly for those on Windows 7 and other older OS’s that don’t have extensive Unicode emoji support, so they don’t see loads of little squares 😉

---

<div class="post-metadata">

### Author: ![zzzzBov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zzzzbov/32/114874_2.png) [@zzzzBov](https://meta.discourse.org/u/zzzzBov)
#### Post date: [March 16, 2015, 1:43pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/11 "2015-03-16T13:43:36Z")

</div>

Just commenting to add that there is a [similar thread in the markdown community](http://talk.commonmark.org/t/emoji-support-like-in-jira/1055) considering adding emoji directly to markdown.

I’m of the opinion that it should be kept separate as a postprocessor, and that discourse could lead by example by creating/implementing a post-processor for emoji support. It wouldn’t be that difficult to scan through the DOM and replace patterns in text nodes with their emoji equivalents.

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [March 19, 2015, 8:23pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/12 "2015-03-19T20:23:23Z")

</div>

Pretty sure this topic is a duplicate of this one:

[https://meta.discourse.org/t/unicode-emoji-rendered-incorrectly-on-google-chrome/20458?u=deanmarktaylor](https://meta.discourse.org/t/unicode-emoji-rendered-incorrectly-on-google-chrome/20458)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [March 19, 2015, 10:55pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/13 "2015-03-19T22:55:17Z")

</div>

I disagree; the title of that topic alone rules it out from being a duplicate. Sorry. ☹

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 19, 2015, 11:26pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/14 "2015-03-19T23:26:50Z")

</div>

It is exactly the same issue as here, we should close one of them and if we prefer the title here then just keep this and close the old one as dupe.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [July 14, 2015, 11:18pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/15 "2015-07-14T23:18:22Z")

</div>

When I was at Red Dot Ruby conf, [Juanito](https://github.com/JuanitoFatas) said he may look at implementing this.

Will invite him here in case he is still up to it, Juanito loves Emoji 😋

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [July 14, 2015, 11:20pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/16 "2015-07-14T23:20:56Z")

</div>

What’s the impact going to be for those of us who embed Discourse content elsewhere, such as back into WordPress?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [July 14, 2015, 11:22pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/17 "2015-07-14T23:22:45Z")

</div>

It means when I post on iPhone and enter Emojis direct we would replace them with images, when cooking. It **improves** the embedding story AND ensures posts look consistent across all browsers. (and no one has ugly square blocks or monochrome emojis) 😱

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [July 14, 2015, 11:23pm UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/18 "2015-07-14T23:23:30Z")

</div>

That sounds so awesome I’m surprised it’s not already a thing.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 12, 2015, 8:19am UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/19 "2015-08-12T08:19:45Z")

</div>

This is planned, we want to do it just have not had time, PR totally welcome (but we will eventually get to it)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [December 11, 2015, 1:24am UTC](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155/20 "2015-12-11T01:24:40Z")

</div>

Is this something you want to take on when you’re back @eviltrout? Maybe you could scope the work.

[Next page](https://meta.discourse.org/t/auto-replace-emoji-like-with-discourse-codes/26155.md?page=2)
