Sha256: 152e4da3652dfe0eef6e90a04c60eebe9b4f7fc6195d3338fee3efdb8c4adae6

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

Contents

# ------------------------------------------------------------------------------
#  ~/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
#  Asciidoctor extension for J1 Template
#
#  Product/Info:
#  https://jekyll-one.com
#
#  Copyright (C) 2019 Juergen Adams
#
#  J1 Template is licensed under the MIT License.
#  See: https://github.com/jekyll-one/j1_template_mde/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-black'

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
j1_template_mde-2018.4.36 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1_template_mde-2018.4.35 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1_template_mde-2018.4.34 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1_template_mde-2018.4.33 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1_template_mde-2018.4.32 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1_template_mde-2018.4.31 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1_template_mde-2018.4.30 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1_template_mde-2018.4.29 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb
j1_template_mde-2018.4.28 lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb