Sha256: 22ecd939f72e26549f3950a916b7bb4323afb6676c2577718c38e43dcc708551

Contents?: true

Size: 630 Bytes

Versions: 44

Compression:

Stored size: 630 Bytes

Contents

module Metanorma::AsciidoctorExtensions

  class GlobIncludeProcessor < ::Asciidoctor::Extensions::IncludeProcessor
    def process doc, reader, target_glob, attributes
      Dir[File.join reader.dir, target_glob].sort.reverse_each do |target|
        content = IO.readlines target
        content.unshift '' unless attributes['adjoin-option']
        reader.push_include content, target, target, 1, attributes
      end
      reader
    end

    def handles? target
      target.include? '*'
    end
  end

end

Asciidoctor::Extensions.register do
  include_processor ::Metanorma::AsciidoctorExtensions::GlobIncludeProcessor
end

Version data entries

44 entries across 44 versions & 2 rubygems

Version Path
metanorma-0.3.7 lib/metanorma/asciidoctor_extensions/glob_include_processor.rb
metanorma-0.3.6 lib/metanorma/asciidoctor_extensions/glob_include_processor.rb
metanorma-0.3.5 lib/metanorma/asciidoctor_extensions/glob_include_processor.rb
metanorma-0.3.4 lib/metanorma/asciidoctor_extensions/glob_include_processor.rb