lib/asciidoctor/generic/converter.rb in metanorma-generic-1.6.3 vs lib/asciidoctor/generic/converter.rb in metanorma-generic-1.7.0
- old
+ new
@@ -30,10 +30,26 @@
def default_publisher
configuration.organization_name_long
end
+ def org_abbrev
+ if !configuration.organization_name_long.empty? &&
+ !configuration.organization_name_short.empty? &&
+ configuration.organization_name_long !=
+ configuration.organization_name_short
+ { configuration.organization_name_long =>
+ configuration.organization_name_short }
+ else
+ super
+ end
+ end
+
+ def relaton_relations
+ Array(configuration.relations) || []
+ end
+
def metadata_committee(node, xml)
return unless node.attr("committee")
xml.editorialgroup do |a|
a.committee node.attr("committee"),
**attr_code(type: node.attr("committee-type"))
@@ -115,14 +131,14 @@
super
end
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",
+ 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",
+ doc_converter(node)&.convert(@filename + ".presentation.xml",
nil, false, "#{@filename}.doc")
pdf_converter(node)&.convert(@filename + ".presentation.xml",
nil, false, "#{@filename}.pdf")
end
@@ -139,20 +155,30 @@
bibdata_validate(doc.root)
end
def bibdata_validate(doc)
stage_validate(doc)
+ committee_validate(doc)
end
def stage_validate(xmldoc)
stages = configuration&.stage_abbreviations&.keys || return
stages.empty? and return
stage = xmldoc&.at("//bibdata/status/stage")&.text
stages.include? stage or
@log.add("Document Attributes", nil, "#{stage} is not a recognised status")
end
+ def committee_validate(xmldoc)
+ committees = Array(configuration&.committees) || return
+ committees.empty? and return
+ xmldoc.xpath("//bibdata/ext/editorialgroup/committee").each do |c|
+ committees.include? c.text or
+ @log.add("Document Attributes", nil, "#{c.text} is not a recognised committee")
+ end
+ end
+
def sections_cleanup(x)
super
x.xpath("//*[@inline-header]").each do |h|
h.delete("inline-header")
end
@@ -184,9 +210,17 @@
conv = super
Metanorma::Generic::Configuration::CONFIG_ATTRS.each do |a|
conv.i18n.set(a, configuration.send(a))
end
conv
+ end
+
+ def boilerplate_file(xmldoc)
+ f = configuration.boilerplate
+ f.nil? and return super
+ f.is_a? String and return baselocation(f)
+ f.is_a? Hash and f[@lang] and return baselocation(f[@lang])
+ super
end
end
end
end