Sha256: 3df4b9e3fad4677c465f53b141de31ca44326b4d685de1a38e3b03086b27cb81

Contents?: true

Size: 1.46 KB

Versions: 45

Compression:

Stored size: 1.46 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/asciidoctor-extensions/flag-icon-inline.rb
# Asciidoctor flag icon 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
# ------------------------------------------------------------------------------
# <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

45 entries across 45 versions & 1 rubygems

Version Path
j1-template-2023.9.2 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.9.1 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.9.0 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.8.2 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.8.1 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.8.0 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.7.0 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.6.0 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.5.2 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.4.5 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.4.4 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.4.3 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.4.2 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.4.1 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.4.0 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.3.3 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.3.2 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.3.1 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.3.0 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb
j1-template-2023.2.7 lib/starter_web/_plugins/asciidoctor/flag-icon-inline.rb