# ------------------------------------------------------------------------------ # ~/_plugins/asciidoctor-extensions/image-block.rb # Asciidoctor extension for J1 Theme # # Product/Info: # https://jekyll.one # # Copyright (C) 2023 Juergen Adams # # J1 Theme is licensed under the MIT License. # For details, see: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE.md # # ------------------------------------------------------------------------------ # A block macro that embeds an Image Block into the output document # # Usage # # .block_title # lightbox::block_id[images_width, images_data] # # Example: # # .The image block title # lightbox::lightbox-example[300, "pages/roundtrip/100_present_images/image-1.jpg, description 1, pages/roundtrip/100_present_images/image-2.jpg, description 2" ] # # ------------------------------------------------------------------------------ include Asciidoctor require 'builder' require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal' Asciidoctor::Extensions.register do class LightboxBlockMacro < Extensions::BlockMacroProcessor use_dsl named :lightbox name_positional_attributes 'size', 'image_data', 'group' default_attrs 'size' => 800 def process parent, target, attrs html_block = Builder::XmlMarkup.new(:indent => 2) imagesdir = parent.attr 'imagesdir' images_hash = Hash[*attrs['image_data'].split(',')] title_html = (attrs.has_key? 'title') ? %(