Class: Metanorma::Generic::Processor

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

Instance Method Summary collapse

Constructor Details

#initializeProcessor

Returns a new instance of Processor.


10
11
12
13
14
# File 'lib/metanorma/generic/processor.rb', line 10

def initialize
  @short = configuration&.metanorma_name&.to_sym || :generic
  @input_format = :asciidoc
  @asciidoctor_backend = configuration&.metanorma_name&.to_sym || :generic
end

Instance Method Details

#configurationObject


6
7
8
# File 'lib/metanorma/generic/processor.rb', line 6

def configuration
  Metanorma::Generic.configuration
end

#extract_options(file) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/metanorma/generic/processor.rb', line 27

def extract_options(file)
  head = file.sub(/\n\n.*$/m, "\n")
  ret = %w(htmlstylesheet htmlcoverpage htmlintropage scripts scripts-pdf
           wordstylesheet standardstylesheet header wordcoverpage
           wordintropage datauriimage htmltoclevels doctoclevels
           ulstyle olstyle htmlstylesheet-override sectionsplit
           wordstylesheet-override).each_with_object({}) do |w, acc|
    m = /\n:#{w}: ([^\n]+)\n/.match(head) or next
    acc[w.sub(/-/, "_").to_sym] = m[1]
  end
  super.merge(ret)
end

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


40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/metanorma/generic/processor.rb', line 40

def output(isodoc_node, inname, outname, format, options={})
  case format
  when :html
    IsoDoc::Generic::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
  when :doc
    IsoDoc::Generic::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
  when :presentation
    IsoDoc::Generic::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
  else
    super
  end
end

#output_formatsObject


16
17
18
19
20
21
# File 'lib/metanorma/generic/processor.rb', line 16

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

#versionObject


23
24
25
# File 'lib/metanorma/generic/processor.rb', line 23

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