Class: Metanorma::Csd::Processor

Inherits:
Processor
  • Object
show all
Defined in:
lib/metanorma/csd/processor.rb

Instance Method Summary collapse

Constructor Details

#initializeProcessor

Returns a new instance of Processor.



7
8
9
10
11
# File 'lib/metanorma/csd/processor.rb', line 7

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

Instance Method Details

#input_to_isodoc(file) ⇒ Object



24
25
26
# File 'lib/metanorma/csd/processor.rb', line 24

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

#output(isodoc_node, outname, format, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/metanorma/csd/processor.rb', line 28

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

#output_formatsObject



13
14
15
16
17
18
# File 'lib/metanorma/csd/processor.rb', line 13

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

#versionObject



20
21
22
# File 'lib/metanorma/csd/processor.rb', line 20

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