Sha256: 24c4e64b05055c1a97d8e84eacb92c0fb2881fde0ee697b75eab3cfe141cd031

Contents?: true

Size: 997 Bytes

Versions: 11

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

require 'asciidoctor' unless defined? Asciidoctor.load
require_relative 'preprocessor'
require_relative 'tree_processor'

module Asciidoctor::Reducer
  module Extensions
    module_function

    def group
      proc do
        next if document.options[:reduced]
        preprocessor Preprocessor
        tree_processor TreeProcessor
      end
    end

    def key
      :reducer
    end

    def prepare_registry registry = nil
      registry = ::Asciidoctor::Extensions.create(&registry) if ::Proc === registry
      return registry if ::Asciidoctor::Extensions.groups[key]
      if registry
        registry.groups[key] = group
        registry
      else
        ::Asciidoctor::Extensions.create key, &group
      end
    end

    def register
      ::Asciidoctor::Extensions.register key, &group
    end

    def unregister
      ::Asciidoctor::Extensions.groups.delete key # NOTE `Extensions.unregister key` fails if groups is not initialized
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
asciidoctor-reducer-1.0.6 lib/asciidoctor/reducer/extensions.rb
asciidoctor-reducer-1.0.5 lib/asciidoctor/reducer/extensions.rb
asciidoctor-reducer-1.0.4 lib/asciidoctor/reducer/extensions.rb
asciidoctor-reducer-1.0.3 lib/asciidoctor/reducer/extensions.rb
asciidoctor-reducer-1.0.2 lib/asciidoctor/reducer/extensions.rb
asciidoctor-reducer-1.0.1 lib/asciidoctor/reducer/extensions.rb
asciidoctor-reducer-1.0.0 lib/asciidoctor/reducer/extensions.rb
asciidoctor-reducer-1.0.0-rc.1 lib/asciidoctor/reducer/extensions.rb
asciidoctor-reducer-1.0.0-beta.1 lib/asciidoctor/reducer/extensions.rb
asciidoctor-reducer-1.0.0.alpha.10 lib/asciidoctor/reducer/extensions.rb
asciidoctor-reducer-1.0.0.alpha.9 lib/asciidoctor/reducer/extensions.rb