Sha256: 432b00c4a7e0960a1c7df44dc50301d3d6b38cd5db6cbe44809ec1f3f40458db

Contents?: true

Size: 1.3 KB

Versions: 12

Compression:

Stored size: 1.3 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/asciidoctor-extensions/mdib-icon-inline.rb
# Asciidoctor extension for J1 Theme
#
# Product/Info:
# https://jekyll.one
#
# Copyright (C) 2023, 2024 Juergen Adams
#
# J1 Template 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

# A inline macro that places an MDIB icon into the output document
#
# Usage
#
#   mdib:<name>[<size>, <modifier>]
#
# Example:
#
#   mdib:account[mdib-48px, <modifier>]
#
Asciidoctor::Extensions.register do
  class MdibIconInlineMacro < Extensions::InlineMacroProcessor
    use_dsl
    named :mdib
    name_positional_attributes 'size', 'modifier'
    default_attrs 'size' => '1x', 'modifier' => ''

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

  inline_macro MdibIconInlineMacro
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
j1-template-2024.2.1 lib/starter_web/_plugins/asciidoctor/mdib-icon-inline.rb
j1-template-2024.2.0 lib/starter_web/_plugins/asciidoctor/mdib-icon-inline.rb
j1-template-2024.1.5 lib/starter_web/_plugins/asciidoctor/mdib-icon-inline.rb
j1-template-2024.1.4 lib/starter_web/_plugins/asciidoctor/mdib-icon-inline.rb
j1-template-2024.1.3 lib/starter_web/_plugins/asciidoctor/mdib-icon-inline.rb
j1-template-2024.1.2 lib/starter_web/_plugins/asciidoctor/mdib-icon-inline.rb
j1-template-2024.1.1 lib/starter_web/_plugins/asciidoctor/mdib-icon-inline.rb
j1-template-2024.1.0 lib/starter_web/_plugins/asciidoctor/mdib-icon-inline.rb
j1-template-2024.0.3 lib/starter_web/_plugins/asciidoctor/mdib-icon-inline.rb
j1-template-2024.0.2 lib/starter_web/_plugins/asciidoctor/mdib-icon-inline.rb
j1-template-2024.0.1 lib/starter_web/_plugins/asciidoctor/mdib-icon-inline.rb
j1-template-2024.0.0 lib/starter_web/_plugins/asciidoctor/mdib-icon-inline.rb