lib/asciidoctor/generic/converter.rb in metanorma-generic-1.10.3 vs lib/asciidoctor/generic/converter.rb in metanorma-generic-1.10.4
- old
+ new
@@ -17,15 +17,17 @@
def xml_namespace
configuration.document_namespace || XML_NAMESPACE
end
- def baselocation(loc)
+ def baselocation(loc)
return nil if loc.nil?
+
return loc
File.expand_path(File.join(File.dirname(
- self.class::_file || __FILE__), "..", "..", "..", loc))
+ self.class::_file || __FILE__,
+ ), "..", "..", "..", loc))
end
def docidentifier_cleanup(xmldoc)
template = configuration.docid_template ||
"{{ organization_name_short }} {{ docnumeric }}"
@@ -34,11 +36,11 @@
id.empty? and docid.remove or docid.children = id
end
def doctype(node)
d = super
- configuration.doctypes or return d == "article" ?
+ configuration.doctypes or return d == "article" ?
(configuration.default_doctype || "standard") : d
type = configuration.default_doctype ||
configuration.doctypes.keys.dig(0) || "standard"
unless configuration.doctypes.keys.include? d
@log.add("Document Attributes", nil,
@@ -47,22 +49,22 @@
end
d
end
def read_config_file(path_to_config_file)
- Metanorma::Generic.configuration.
- set_default_values_from_yaml_file(path_to_config_file)
+ Metanorma::Generic.configuration
+ .set_default_values_from_yaml_file(path_to_config_file)
end
def sectiontype_streamline(ret)
- if configuration&.termsdefs_titles&.map(&:downcase)&.include? (ret)
+ if configuration&.termsdefs_titles&.map(&:downcase)&.include? ret
"terms and definitions"
- elsif configuration&.symbols_titles&.map(&:downcase)&.include? (ret)
+ elsif configuration&.symbols_titles&.map(&:downcase)&.include? ret
"symbols and abbreviated terms"
- elsif configuration&.normref_titles&.map(&:downcase)&.include? (ret)
+ elsif configuration&.normref_titles&.map(&:downcase)&.include? ret
"normative references"
- elsif configuration&.bibliography_titles&.map(&:downcase)&.include? (ret)
+ elsif configuration&.bibliography_titles&.map(&:downcase)&.include? ret
"bibliography"
else
ret
end
end
@@ -71,19 +73,18 @@
read_config_file(node.attr("customize")) if node.attr("customize")
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",
+ 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",
+ doc_converter(node)&.convert("#{@filename}.presentation.xml",
nil, false, "#{@filename}.doc")
- pdf_converter(node)&.convert(@filename + ".presentation.xml",
+ pdf_converter(node)&.convert("#{@filename}.presentation.xml",
nil, false, "#{@filename}.pdf")
-
end
def validate(doc)
content_validate(doc)
schema_validate(formattedstr_strip(doc.dup),
@@ -104,25 +105,27 @@
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")
+ @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")
+ @log.add("Document Attributes", nil,
+ "#{c.text} is not a recognised committee")
end
end
- def sections_cleanup(x)
+ def sections_cleanup(xml)
super
- x.xpath("//*[@inline-header]").each do |h|
+ xml.xpath("//*[@inline-header]").each do |h|
h.delete("inline-header")
end
end
def blank_method(*args); end
@@ -130,10 +133,11 @@
def html_converter(node)
IsoDoc::Generic::HtmlConvert.new(html_extract_attributes(node))
end
def presentation_xml_converter(node)
- IsoDoc::Generic::PresentationXMLConvert.new(html_extract_attributes(node))
+ IsoDoc::Generic::PresentationXMLConvert
+ .new(html_extract_attributes(node))
end
alias_method :pdf_converter, :html_converter
alias_method :style, :blank_method
alias_method :title_validate, :blank_method