diff --git a/app/assets/javascripts/discourse/lib/emoji/emoji.js.erb b/app/assets/javascripts/discourse/lib/emoji/emoji.js.erb index 777983ea9be..425f79538de 100644 --- a/app/assets/javascripts/discourse/lib/emoji/emoji.js.erb +++ b/app/assets/javascripts/discourse/lib/emoji/emoji.js.erb @@ -169,7 +169,15 @@ Discourse.Dialect.addPreProcessor(function(text) { var m; while ((m = _unicodeRegexp.exec(text)) !== null) { - text = text.replace(m[0], ":" + _unicodeReplacements[m[0]] + ":"); + + var replacement = ":" + _unicodeReplacements[m[0]] + ":"; + + var before = text.charAt(m.index-1); + if (!/\B/.test(before)) { + replacement = " " + replacement; + } + + text = text.replace(m[0], replacement); } } diff --git a/app/models/emoji.rb b/app/models/emoji.rb index 10755173b77..f6cc04b2774 100644 --- a/app/models/emoji.rb +++ b/app/models/emoji.rb @@ -131,8 +131,8 @@ class Emoji @unicode_replacements = {} db['emojis'].each do |e| hex = e['code'].hex - # Don't replace digits or letters - if hex > 128 + # Don't replace digits, letters and some symbols + if hex > 255 && e['name'] != 'tm' @unicode_replacements[[hex].pack('U')] = e['name'] end end