require "metanorma/processor" module Metanorma module Generic def self.fonts_used { html: [ configuration.html_bodyfont || "Overpass", configuration.html_headerfont || "Overpass", configuration.html_monospacefont || "Space Mono" ].uniq, doc: [ configuration.word_bodyfont || "Overpass", configuration.word_headerfont || "Overpass", configuration.word_monospacefont || "Space Mono"].uniq, pdf: [ configuration.word_bodyfont || "Overpass", configuration.word_headerfont || "Overpass", configuration.word_monospacefont || "Space Mono"].uniq, } end class Processor < Metanorma::Processor def configuration Metanorma::Generic.configuration end def initialize @short = configuration&.metanorma_name&.to_sym || :generic @input_format = :asciidoc @asciidoctor_backend = configuration&.metanorma_name&.to_sym || :generic end def output_formats super.merge( html: "html", doc: "doc", pdf: "pdf" ) end def version "Metanorma::Generic #{Metanorma::Generic::VERSION}" end def extract_options(file) head = file.sub(/\n\n.*$/m, "\n") /\n:htmlstylesheet: (?[^\n]+)\n/ =~ head /\n:htmlcoverpage: (?[^\n]+)\n/ =~ head /\n:htmlintropage: (?[^\n]+)\n/ =~ head /\n:scripts: (?[^\n]+)\n/ =~ head /\n:wordstylesheet: (?[^\n]+)\n/ =~ head /\n:standardstylesheet: (?[^\n]+)\n/ =~ head /\n:header: (?
[^\n]+)\n/ =~ head /\n:wordcoverpage: (?[^\n]+)\n/ =~ head /\n:wordintropage: (?[^\n]+)\n/ =~ head /\n:ulstyle: (?[^\n]+)\n/ =~ head /\n:olstyle: (?[^\n]+)\n/ =~ head new_options = { htmlstylesheet: defined?(htmlstylesheet) ? htmlstylesheet : nil, htmlcoverpage: defined?(htmlcoverpage) ? htmlcoverpage : nil, htmlintropage: defined?(htmlintropage) ? htmlintropage : nil, scripts: defined?(scripts) ? scripts : nil, wordstylesheet: defined?(wordstylesheet) ? wordstylesheet : nil, standardstylesheet: defined?(standardstylesheet) ? standardstylesheet : nil, header: defined?(header) ? header : nil, wordcoverpage: defined?(wordcoverpage) ? wordcoverpage : nil, wordintropage: defined?(wordintropage) ? wordintropage : nil, ulstyle: defined?(ulstyle) ? ulstyle : nil, olstyle: defined?(olstyle) ? olstyle : nil, }.reject { |_, val| val.nil? } super.merge(new_options) end 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 :pdf IsoDoc::Generic::PdfConvert.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 end end end