Sha256: a4597f4990bd4e1d25752ef03037bdf5ea605737a28dae38bf02c7da3d71d5aa

Contents?: true

Size: 1.21 KB

Versions: 18

Compression:

Stored size: 1.21 KB

Contents

# ------------------------------------------------------------------------------
# ~/_plugins/asciidoctor-extensions/gallery-block.rb
# Asciidoctor extension for J1 Galleries
#
# 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
# ------------------------------------------------------------------------------
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
include Asciidoctor

# A block macro that embeds a Gallery block into the output document
#
# Usage
#
#   gallery::gallery_id[role="additional classes"]
#
# Example:
#
#   .The gallery title
#   gallery::jg_live_demo[]
#
Asciidoctor::Extensions.register do

  class ImageBlockMacro < Extensions::BlockMacroProcessor
    use_dsl

    named :gallery
    name_positional_attributes 'role'

    def process parent, target, attrs
      title_html  = (attrs.has_key? 'title') ? %(<div class="gallery-title">#{attrs['title']}</div>\n) : nil
      html = %(#{title_html} <div id="#{target}" class="#{attrs['role']}"></div>)
      create_pass_block parent, html, attrs, subs: nil
    end
  end

  block_macro ImageBlockMacro

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
j1-template-2023.1.0 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.17 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.16 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.15 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.14 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.13 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.12 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.11 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.10 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.9 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.8 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.7 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.6 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.5 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.3 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.2 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.1 lib/starter_web/_plugins/asciidoctor/gallery-block.rb
j1-template-2023.0.0 lib/starter_web/_plugins/asciidoctor/gallery-block.rb