Sha256: 648f1e63fd6b2a6c948442c63cca84ecf91eb4786f0aa7ea50d08398b677cb25

Contents?: true

Size: 1.78 KB

Versions: 40

Compression:

Stored size: 1.78 KB

Contents

require "metanorma/processor"

module Metanorma
  module Gb
    class Processor < Metanorma::Processor

      def initialize
        @short = :gb
        @input_format = :asciidoc
        @asciidoctor_backend = :gb
      end

      def output_formats
        super.merge(
          html: "html",
          compliant_html: "compliant.html",
          doc: "doc"
        )
      end

      def version
        "Metanorma::Gb #{Metanorma::Gb::VERSION}"
      end

      def input_to_isodoc(file, filename)
        Metanorma::Input::Asciidoc.new.process(file, filename, @asciidoctor_backend)
      end

      def extract_options(file)
        head = file.sub(/\n\n.*$/m, "\n")
        /\n:standard-logo-img: (?<standardlogoimg>[^\n]+)\n/ =~ head
        /\n:standard-class-img: (?<standardclassimg>[^\n]+)\n/ =~ head
        /\n:standard-issuer-img: (?<standardissuerimg>[^\n]+)\n/ =~ head
        /\n:title-font: (?<titlefont>[^\n]+)\n/ =~ head
        new_options = {
          standardlogoimg: defined?(standardlogoimg) ? standardlogoimg : nil,
          standardclassimg: defined?(standardclassimg) ? standardclassimg : nil,
          standardissuerimg: defined?(standardissuerimg) ? standardissuerimg : nil,
          titlefont: defined?(titlefont) ? titlefont : nil,
        }.reject { |_, val| val.nil? }
        super.merge(new_options)
      end

      def output(isodoc_node, outname, format, options={})
        case format
        when :html
          IsoDoc::Gb::HtmlConvert.new(options).convert(outname, isodoc_node)
        when :compliant_html
          IsoDoc::Gb::HtmlConvert.new(options.merge(compliant: true)).convert(outname, isodoc_node)
        when :doc
          IsoDoc::Gb::WordConvert.new(options).convert(outname, isodoc_node)
        else
          super
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
metanorma-gb-1.3.23 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.22 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.21 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.20 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.19 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.18 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.17 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.16 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.15 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.14 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.13 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.12 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.11 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.9 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.8 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.7 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.6 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.5 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.4 lib/metanorma/gb/processor.rb
metanorma-gb-1.3.3 lib/metanorma/gb/processor.rb