lib/metanorma/generic/converter.rb in metanorma-generic-2.4.2 vs lib/metanorma/generic/converter.rb in metanorma-generic-2.4.4
- old
+ new
@@ -37,15 +37,20 @@
(id.empty? and docid.remove) or docid.children = id
end
def doctype(node)
d = super
- configuration.doctypes or return d == "article" ? (configuration.default_doctype || "standard") : d
+ node.attr("doctype") == "article" and d = "article"
+ unless configuration.doctypes
+ d == "article" and return (configuration.default_doctype || "standard")
+ return d
+ end
type = configuration.default_doctype ||
- configuration.doctypes.keys.dig(0) || "standard"
- unless configuration.doctypes.keys.include? d
- @log.add("Document Attributes", nil,
- "#{d} is not a legal document type: reverting to '#{type}'")
+ configuration.doctypes.keys[0] || "standard"
+ if !configuration.doctypes.key?(d)
+ (node.attr("doctype") && node.attr("doctype") != "article") and # factory default
+ @log.add("Document Attributes", nil,
+ "#{d} is not a legal document type: reverting to '#{type}'")
d = type
end
d
end