docbrown/app/services/html/parse_emoji.rb
Alex 1bad9dc698
Move EmojiConverter to service (#12081)
* Move EmojiConverter to service

* Fix spec

* Rename EmojiCoverter to Html::ParseEmoji
2021-01-04 17:41:48 +01:00

13 lines
302 B
Ruby

module Html
class ParseEmoji
def self.call(html)
return unless html
html.gsub!(/:([\w+-]+):/) do |match|
emoji = Emoji.find_by_alias(Regexp.last_match(1)) # rubocop:disable Rails/DynamicFindBy
emoji.present? ? emoji.raw : match
end
html
end
end
end