lib/asciidoctor/csand/converter.rb in asciidoctor-csand-0.2.5 vs lib/asciidoctor/csand/converter.rb in asciidoctor-csand-0.2.6

- old
+ new

@@ -1,15 +1,15 @@ require "asciidoctor" require "asciidoctor/csand/version" -require "asciidoctor/csand/csandconvert" +require "isodoc/csand/csandconvert" require "asciidoctor/iso/converter" module Asciidoctor module Csand - CSAND_NAMESPACE = "https://open.ribose.com/standards/csand" + CSAND_NAMESPACE = "https://open.ribose.com/standards/csand" - # A {Converter} implementation that generates CSAND output, and a document + # A {Converter} implementation that generates CSD output, and a document # schema encapsulation of the document for validation class Converter < ISO::Converter register_for "csand" @@ -31,11 +31,11 @@ end end def metadata_committee(node, xml) xml.editorialgroup do |a| - a.technical_committee node.attr("technical-committee"), + a.committee node.attr("technical-committee"), **attr_code(type: node.attr("technical-committee-type")) end end def title(node, xml) @@ -81,18 +81,29 @@ validate(ret1) ret1.root.add_namespace(nil, CSAND_NAMESPACE) ret1 end + def doctype(node) + d = node.attr("doctype") + unless %w{guidance proposal standard report whitepaper charter policy glossary case-study}.include? d + warn "#{d} is not a legal document type: reverting to 'standard'" + d = "standard" + end + d + end + def document(node) init(node) ret1 = makexml(node) ret = ret1.to_xml(indent: 2) - filename = node.attr("docfile").gsub(/\.adoc/, ".xml"). - gsub(%r{^.*/}, "") - File.open(filename, "w") { |f| f.write(ret) } - html_converter(node).convert filename unless node.attr("nodoc") + unless node.attr("nodoc") || !node.attr("docfile") + filename = node.attr("docfile").gsub(/\.adoc/, ".xml"). + gsub(%r{^.*/}, "") + File.open(filename, "w") { |f| f.write(ret) } + html_converter(node).convert filename unless node.attr("nodoc") + end @files_to_delete.each { |f| system "rm #{f}" } ret end def validate(doc) @@ -123,28 +134,19 @@ def style(n, t) return end - def html_converter(_node) - CsandConvert.new( - htmlstylesheet: generate_css(html_doc_path("htmlstyle.scss"), true), - standardstylesheet: generate_css(html_doc_path("csand.scss"), true), - htmlcoverpage: html_doc_path("html_csand_titlepage.html"), - htmlintropage: html_doc_path("html_csand_intro.html"), - scripts: html_doc_path("scripts.html"), + def html_converter(node) + IsoDoc::Csand::Convert.new( + script: node.attr("script"), + bodyfont: node.attr("body-font"), + headerfont: node.attr("header-font"), + monospacefont: node.attr("monospace-font"), + titlefont: node.attr("title-font"), + i18nyaml: node.attr("i18nyaml"), + scope: node.attr("scope"), ) - end - - def default_fonts(node) - b = node.attr("body-font") || - (node.attr("script") == "Hans" ? '"SimSun",serif' : - '"Overpass",sans-serif') - h = node.attr("header-font") || - (node.attr("script") == "Hans" ? '"SimHei",sans-serif' : - '"Overpass",sans-serif') - m = node.attr("monospace-font") || '"Space Mono",monospace' - "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n" end def inline_quoted(node) noko do |xml| case node.type