Sha256: a940000deda0257c2e534926d7073d843686323bc8c26255280ad1d252f7a24a

Contents?: true

Size: 1.46 KB

Versions: 31

Compression:

Stored size: 1.46 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/asciidoctor-extensions/flag-icon-inline.rb
# Asciidoctor flag icon extension for J1 Template
#
# Product/Info:
# https://jekyll.one
#
# Copyright (C) 2021 Juergen Adams
#
# J1 Template is licensed under the MIT License.
# See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE
# ------------------------------------------------------------------------------
# <i class="flag-icon flag-icon-gr rectangle size-xs"></i>
# <i class="flag-icon flag-icon-gr squared size-xs"></i>
# ------------------------------------------------------------------------------

require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
include Asciidoctor

Asciidoctor::Extensions.register do
  class FlagIconInlineMacro < Extensions::InlineMacroProcessor
    use_dsl
    named :flag
    name_positional_attributes 'style', 'size', 'modifier'
    default_attrs 'style' => 'rectangle', 'size' => '', 'modifier' => ''

    def process parent, target, attributes
      doc = parent.document
      style_class = (style = attributes['style']) ? %(#{style}) : nil
      size_class = (size = attributes['size']) ? %(size-#{size}) : nil
      modifier_class = (modifier = attributes['modifier']) ? %(#{modifier}) : nil
      country_name = target.tr '_', '-'
      %(<i class="flag-icon flag-icon-#{country_name} #{style_class} #{size_class} #{modifier}"></i>)
    end
  end
  inline_macro FlagIconInlineMacro
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
j1-template-2022.0.18 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.17 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.16 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.15 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.14 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.13 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.12 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.11 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.10 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.9 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.8 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.7 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.6 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.5 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.4 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.3 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.2 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.1 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2022.0.0 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb
j1-template-2021.3.2 lib/starter_web/_plugins/asciidoctor-extensions/flag-icon-inline.rb