Skip to content

Instantly share code, notes, and snippets.

@frankie-loves-jesus
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save frankie-loves-jesus/a06d2cec58cb2fd4e080 to your computer and use it in GitHub Desktop.
Save frankie-loves-jesus/a06d2cec58cb2fd4e080 to your computer and use it in GitHub Desktop.
def add_emojify_and_kramdown(text)
raw(Kramdown::Document.new(emojify(text)).to_html)
end
[...snip...]
def emojify(text)
h(text).to_str.gsub(/:([a-z0-9\+\-_]+):/) do |match|
if emoji = Emoji.find_by_alias($1)
'![' + $1 + '](' + asset_path("emoji/#{emoji.image_filename}") + ')'
else
match
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment