Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Twemoji RubyGem

Twemoji RubyGem

Introduce Twemoji RubyGem @ Asakusa.rb
19 May 2015

Juanito Fatas

May 19, 2015
Tweet

More Decks by Juanito Fatas

Other Decks in Technology

Transcript

  1. 6YGOQLKRCTUGQRVKQPU Twemoji.configure do |config| config.asset_root = "https://twemoji.awesomecdn.com/" config.file_ext = ".svg"

    config.image_size = nil # only png need to set size config.class_name = "twemoji" config.img_attr = "style='height: 1.3em;'" end
  2. +PVGTITCVGYKVJ*6/.2KRGNKPG module HTML class Pipeline module Twitter class EmojiFilter <

    HTML::Pipeline::Filter def call Twemoji.parse(doc) end end end end end
  3. +PVGTITCVGYKVJ*6/.2KRGNKPG module MarkdownHelper def markdown_to_html(post, **options) pipeline = HTML::Pipeline.new [

    HTML::Pipeline::SanitizationFilter, HTML::Pipeline::Twitter::EmojiFilter, HTML::Pipeline::RougeFilter, ], { gfm: true, mentions: post.mentions, post: post, **options } pipeline.call(post.body)[:output].to_s.html_safe end end