Wordpress emojis and Discourse

@Canapin Hey :slight_smile: Just an update on this one.

The issue here arises when

  1. You have enabled the “full post content” setting in wp-discourse
  2. You’ve created a post in wordpress with at least one line of content before the insertion of emojis.

Firstly, could you just confirm with me that that’s what you’ve done in this case (particularly the “full post content” setting)?

In these circumstances the wp-discourse plugin sends html over to Discourse, which is imported as a topic embed. A few different issues, including this one, can arise when Discourse attempts to process the html when creating a post. For example, another issue that arises is Fix broken images for posts created by the WP Discourse and RSS plugins - admins - Discourse Meta.

On the technical front (as I know you’re technical :wink: ), you can see the issue directly if you attempt to use the relevant Discourse ruby class to parse a html string with unicode emojis.

Technical detail of issue
rails c
PrettyText.cook("<p>This is the sentence before the emojis</p><div>🦊🦊🦊🦊</div>")
=> "<p>This is the sentence before the emojis</p><div>🦊🦊🦊🦊</div>"

versus

rails c
PrettyText.cook("🦊🦊🦊🦊")
=> "<p><img src=\"/images/emoji/twitter/fox_face.png?v=9\" title=\":fox_face:\" class=\"emoji\" alt=\":fox_face:\"><img src=\"/images/emoji/twitter/fox_face.png?v=9\" title=\":fox_face:\" class=\"emoji\" alt=\":fox_face:\"><img src=\"/images/emoji/twitter/fox_face.png?v=9\" title=\":fox_face:\" class=\"emoji\" alt=\":fox_face:\"><img src=\"/images/emoji/twitter/fox_face.png?v=9\" title=\":fox_face:\" class=\"emoji\" alt=\":fox_face:\"></p>"

So what are we doing about it?

Generally speaking, some issues in Wordpress full post html > Discourse post conversion are not unexpected. The record of the Wordpress post on Discourse is just that, a record of the post.

That said, @simon and I are actively looking at improving that process in both wp-discourse and Discourse itself, with an appropriate prioritization. We’re going to focus on a few other things in this respect (e.g. the broken images issue mentioned above), before we get to this one. So you’ll need to sit tight for an official fix on this one for a bit.

3 Likes