Sha256: e4129092724f7ea7d940b540a0e318356dc482ca5e77fb1e6d82ca1cf8fe361f

Contents?: true

Size: 1.26 KB

Versions: 45

Compression:

Stored size: 1.26 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/asciidoctor-extensions/twitter-emoji-inline.rb
# Asciidoctor extension for J1 Theme
#
# Product/Info:
# https://jekyll.one
#
# Copyright (C) 2023 Juergen Adams
#
# J1 Theme is licensed under the MIT License.
# See: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE.md
#
# ------------------------------------------------------------------------------
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
include Asciidoctor

SIZE_MAP = {'1x' => 18, 'lg' => 24, '2x' => 34, '3x' => 50, '4x' => 68, '5x' => 85}
SIZE_MAP.default = 24

Asciidoctor::Extensions.register do
  class EmojiInlineMacro < Extensions::InlineMacroProcessor
    use_dsl
    named :emoji
    name_positional_attributes 'size', 'modifier'
    default_attrs 'size' => '1x', 'modifier' => ''

    def process parent, target, attributes
      doc = parent.document
      # Use twemoji only
      size_class = (size = attributes['size']) ? %(twa-#{size}) : nil
      modifier_class = (modifier = attributes['modifier']) ? %(twa-#{modifier}) : nil
      emoji_name = target.tr '_', '-'
      %(<i class="twa #{size_class} twa-#{emoji_name} twa-#{modifier}"></i>)
    end
  end
  inline_macro EmojiInlineMacro
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
j1-template-2023.2.6 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.2.5 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.2.4 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.2.3 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.2.2 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.2.1 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.2.0 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.1.0 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.0.17 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.0.16 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.0.15 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.0.14 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.0.13 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.0.12 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.0.11 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.0.10 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.0.9 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.0.8 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.0.7 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb
j1-template-2023.0.6 lib/starter_web/_plugins/asciidoctor/twitter-emoji-inline.rb