Rendering of ® in post results in ®

AI-generated summary

A bug has been reported where the ® symbol is being replaced with :registered: in rendered posts. downey and codinghorror both expressed that they do not want HTML entities replaced with emojis, and that raw unicode should be displayed as is. downey suggested that the issue is due to the Twitter emoji set being used.

eviltrout acknowledged the issue and suggested removing the replacement if it’s not desired. sam proposed adding a zero-width space around emoji substitutions to fix the issue.

However, eviltrout ultimately fixed the issue by updating the code to no longer automatically replace “TM, Copyright or Registered” with emojis, and to support emoji replacements beside words. The fix can be found in this commit.

Reproduce:

  1. Reply to a topic and use ‘®’ in the body of the post.

Expected results:

  • The ‘®’ symbol appears in the post where desired.

Actual results - editor window:

Actual results - editor preview:

Actual results - rendered post:

3 curtidas

Seeing the rendering here, suggests that it’s trying to be replaced with an emoji for some reason. (Why?!)

That said, for additional detail, we’re using the Twitter emoji set.

Thanks. That’s informative, but unfortunately doesn’t resolve the problem of not rendering correctly if (apparently) you aren’t using the EmojiOne set.

I believe this was updated with the new emoji updates, as my table of unicode chars → emoji replacements grew. If people don’t like it we could remove it. What does everyone think?

@eviltrout I think the bug here is that we are not adding some space around things. So our replacer can leave you with broken markup, maybe add zero width space around emoji subs.

test:registered: :registered:

test:registered: :registered:

5 curtidas

I definitely do not want the HTML entities replaced, e.g.

™ → ™
© → ©
® → ®

The above should not be using Emoji.. nor should raw unicode, let’s try raw:

™ © ® → ™ © ®

Yeah that’s not desired. Replacing infinitely scaleable typographical font vectors with emoji images is Not Cool™

8 curtidas

The issue though was​:sweat_smile: common to emojis as well​:smiling_face:

as well​:smiling_face:

as well☺

5 curtidas

Okay, I’ve fixed both issues. Emoji replacements beside words will now work, and I no longer replace “TM, Copyright or Registered” automatically.

https://github.com/discourse/discourse/commit/616006a9ce40cbd6361e61db8ed5246863e65fba

4 curtidas

Can you get away with a zero width space ?

I’m not sure if our emoji code supports that but this approach seems to work well enough.