mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 07:38:01 +08:00
Merge pull request #4928 from jjaffeux/transform-native-emojis-to-names
Transforms native emojis to valid names
This commit is contained in:
commit
f77e6c8fc6
|
@ -117,12 +117,21 @@ class Emoji
|
|||
def self.unicode_replacements
|
||||
return @unicode_replacements if @unicode_replacements
|
||||
|
||||
|
||||
@unicode_replacements = {}
|
||||
|
||||
db['emojis'].each do |e|
|
||||
next if e['name'] == 'tm'
|
||||
|
||||
code = replacement_code(e['code'])
|
||||
@unicode_replacements[code] = e['name'] if code
|
||||
next unless code
|
||||
|
||||
@unicode_replacements[code] = e['name']
|
||||
if Emoji.tonable_emojis.include?(e['name'])
|
||||
FITZPATRICK_SCALE.each_with_index do |scale, index|
|
||||
toned_code = (code.codepoints.insert(1, scale.to_i(16))).pack("U*")
|
||||
@unicode_replacements[toned_code] = "#{e['name']}:t#{index+2}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@unicode_replacements["\u{2639}"] = 'frowning'
|
||||
|
|
|
@ -453,6 +453,10 @@ HTML
|
|||
SiteSetting.enable_emoji = false
|
||||
expect(PrettyText.cook("💣")).not_to match(/\:bomb\:/)
|
||||
end
|
||||
|
||||
it "replaces skin toned emoji" do
|
||||
expect(PrettyText.cook("hello 👱🏿♀️")).to eq("<p>hello <img src=\"/images/emoji/emoji_one/blonde_woman/6.png?v=5\" title=\":blonde_woman:t6:\" class=\"emoji\" alt=\":blonde_woman:t6:\"></p>")
|
||||
end
|
||||
end
|
||||
|
||||
describe "tag and category links" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user