mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 19:00:32 -06:00
FIX: All unicode replacements beside words. Omit some symbols.
This commit is contained in:
parent
566b0bbb75
commit
616006a9ce
@ -169,7 +169,15 @@ Discourse.Dialect.addPreProcessor(function(text) {
|
|||||||
|
|
||||||
var m;
|
var m;
|
||||||
while ((m = _unicodeRegexp.exec(text)) !== null) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,8 +131,8 @@ class Emoji
|
|||||||
@unicode_replacements = {}
|
@unicode_replacements = {}
|
||||||
db['emojis'].each do |e|
|
db['emojis'].each do |e|
|
||||||
hex = e['code'].hex
|
hex = e['code'].hex
|
||||||
# Don't replace digits or letters
|
# Don't replace digits, letters and some symbols
|
||||||
if hex > 128
|
if hex > 255 && e['name'] != 'tm'
|
||||||
@unicode_replacements[[hex].pack('U')] = e['name']
|
@unicode_replacements[[hex].pack('U')] = e['name']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user