Sha256: c6d9f193582122551c2bbc6236134c5855bf4266e210ef220f0814820e46ee6a

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require "metanorma/processor"

module Metanorma
  module Csd
    class Processor < Metanorma::Processor

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

      def output_formats
        super.merge(
          html: "html",
          pdf: "pdf"
        )
      end

      def version
        "Asciidoctor::Csd #{Asciidoctor::Csd::VERSION}"
      end

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

      def output(isodoc_node, outname, format, options={})
        case format
        when :html
          IsoDoc::Csd::HtmlConvert.new(options).convert(outname, isodoc_node)
        when :pdf
          require 'tempfile'
          # Tempfile.open("#{outname}.html") do |tmp|
          outname_html = outname + ".html"
          IsoDoc::Csd::HtmlConvert.new(options).convert(outname_html, isodoc_node)
          puts outname_html
          system "cat #{outname_html}"
          Metanorma::Output::Pdf.new.convert(outname_html, outname)
        else
          super
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
asciidoctor-csd-0.4.4 lib/metanorma/csd/processor.rb
asciidoctor-csd-0.4.3 lib/metanorma/csd/processor.rb
asciidoctor-csd-0.4.2 lib/metanorma/csd/processor.rb