Sha256: 2654b2ac1aafcc498c77a6554d959540ca33d8faf50152528d01658390902cf4

Contents?: true

Size: 1.13 KB

Versions: 12

Compression:

Stored size: 1.13 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
# Asciidoctor extension for J1 Template
#
# Product/Info:
# https://jekyll.one
#
# Copyright (C) 2020 Juergen Adams
#
# J1 Template is licensed under the MIT License.
# See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE
#
# ------------------------------------------------------------------------------
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
include Asciidoctor

Asciidoctor::Extensions.register do
  class MdiIconInlineMacro < Extensions::InlineMacroProcessor
    use_dsl
    named :mdi
    name_positional_attributes 'size', 'modifier'
    default_attrs 'size' => '1x', 'modifier' => 'md-grey'

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
j1-template-2020.0.11 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1-template-2020.0.10 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1-template-2020.0.9 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1-template-2020.0.8 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1-template-2020.0.7 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1-template-2020.0.6 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1-template-2020.0.5 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1-template-2020.0.4 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1-template-2020.0.3 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1-template-2020.0.2 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1-template-2020.0.1 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1-template-2020.0.0 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb