class Gollum::Filter::Emoji
Render an emoji tag such as “:smile:”. In some rare situations, you have to escape emoji tags e.g. when your content contains something like “hh:mm:ss” or “rake app:shell:install”. Prefix the leading colon with a backslash to disable this emoji tag e.g. “hh:mm:ss”.
Constants
- EXTRACT_PATTERN
Public Instance Methods
extract(data)
click to toggle source
# File lib/gollum-lib/filter/emoji.rb, line 17 def extract(data) data.gsub! EXTRACT_PATTERN do case when $~[:escape] then $&[1..-1] when emoji_exists?($~[:name]) then "#{open_pattern}#{$~[:name]}#{close_pattern}" else $& end end data end
process(data)
click to toggle source
# File lib/gollum-lib/filter/emoji.rb, line 28 def process(data) src = ::File.join(@markup.wiki.base_path, '/gollum/emoji/\\k<name>') data.gsub! process_pattern, %Q(<img src="#{src}" alt="\\k<name>" class="emoji">) data end
Private Instance Methods
emoji_exists?(name)
click to toggle source
# File lib/gollum-lib/filter/emoji.rb, line 44 def emoji_exists?(name) @index ||= Gemojione::Index.new !!@index.find_by_name(name) end
process_pattern()
click to toggle source
# File lib/gollum-lib/filter/emoji.rb, line 36 def process_pattern %r{ #{open_pattern} (?<name>[\w-]+) #{close_pattern} }ix end