class Asciidoctor::Csa::Converter

Constants

XML_NAMESPACE
XML_ROOT_TAG

Public Instance Methods

bibdata_validate(doc) click to toggle source
Calls superclass method
# File lib/asciidoctor/csa/converter.rb, line 68
def bibdata_validate(doc)
  super
  role_validate(doc)
end
configuration() click to toggle source
# File lib/asciidoctor/csa/converter.rb, line 20
def configuration
  Metanorma::Csa.configuration
end
doc_converter(node) click to toggle source
# File lib/asciidoctor/csa/converter.rb, line 97
def doc_converter(node)
  IsoDoc::Csa::WordConvert.new(doc_extract_attributes(node))
end
html_converter(node) click to toggle source
# File lib/asciidoctor/csa/converter.rb, line 87
def html_converter(node)
  IsoDoc::Csa::HtmlConvert.new(html_extract_attributes(node))
end
metadata_committee(node, xml) click to toggle source
# File lib/asciidoctor/csa/converter.rb, line 31
def metadata_committee(node, xml)
  return unless node.attr("technical-committee")

  xml.editorialgroup do |a|
    a.committee node.attr("technical-committee"),
                **attr_code(type: node.attr("technical-committee-type"))
    i = 2
    while node.attr("technical-committee_#{i}")
      a.committee node.attr("technical-committee_#{i}"),
                  **attr_code(type: node.attr("technical-committee-type_#{i}"))
      i += 1
    end
  end
end
outputs(node, ret) click to toggle source
# File lib/asciidoctor/csa/converter.rb, line 50
def outputs(node, ret)
  File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
  presentation_xml_converter(node).convert("#{@filename}.xml")
  html_converter(node).convert("#{@filename}.presentation.xml",
                               nil, false, "#{@filename}.html")
  doc_converter(node).convert("#{@filename}.presentation.xml",
                              nil, false, "#{@filename}.doc")
  pdf_converter(node)&.convert("#{@filename}.presentation.xml",
                               nil, false, "#{@filename}.pdf")
end
pdf_converter(node) click to toggle source
# File lib/asciidoctor/csa/converter.rb, line 91
def pdf_converter(node)
  return if node.attr("no-pdf")

  IsoDoc::Csa::PdfConvert.new(html_extract_attributes(node))
end
personal_role(node, contrib, suffix) click to toggle source
# File lib/asciidoctor/csa/converter.rb, line 24
def personal_role(node, contrib, suffix)
  role = node.attr("role#{suffix}")&.downcase || "full author"
  contrib.role **{ type: role == "editor" ? "editor" : "author" } do |r|
    r.description role.strip.gsub(/\s/, "-")
  end
end
presentation_xml_converter(node) click to toggle source
# File lib/asciidoctor/csa/converter.rb, line 101
def presentation_xml_converter(node)
  IsoDoc::Csa::PresentationXMLConvert.new(doc_extract_attributes(node))
end
role_validate(doc) click to toggle source
# File lib/asciidoctor/csa/converter.rb, line 73
def role_validate(doc)
  doc&.xpath("//bibdata/contributor/role[description]")&.each do |r|
    r["type"] == "author" or next
    role = r.at("./description").text
    %w{full-author contributor staff reviewer}.include?(role) or
      @log.add("Document Attributes", nil,
               "#{role} is not a recognised role")
  end
end
sections_cleanup(xml) click to toggle source
Calls superclass method
# File lib/asciidoctor/csa/converter.rb, line 61
def sections_cleanup(xml)
  super
  xml.xpath("//*[@inline-header]").each do |h|
    h.delete("inline-header")
  end
end
style(_node, _text) click to toggle source
# File lib/asciidoctor/csa/converter.rb, line 83
def style(_node, _text)
  nil
end
title_validate(_root) click to toggle source
# File lib/asciidoctor/csa/converter.rb, line 46
def title_validate(_root)
  nil
end