lib/metanorma/iso/cleanup_biblio.rb in metanorma-iso-2.8.7 vs lib/metanorma/iso/cleanup_biblio.rb in metanorma-iso-2.8.8

- old
+ new

@@ -1,11 +1,11 @@ module Metanorma - module ISO + module Iso class Converter < Standoc::Converter - def id_prefix(prefix, id) + def id_prefix(prefix, id, amd: false) # we're just inheriting the prefixes from parent doc - @amd and return id.text + amd and return id.text prefix.join("/") + (id.text.match?(%{^/}) ? "" : " ") + id.text end def get_id_prefix(xmldoc) xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']" \ @@ -14,13 +14,15 @@ prefix << x1 end end # ISO as a prefix goes first - def docidentifier_cleanup(xmldoc) - prefix = get_id_prefix(xmldoc) - id = xmldoc.at("//bibdata/ext/structuredidentifier/project-number") and - id.content = id_prefix(prefix, id) + def docidentifier_cleanup(xml) + prefix = get_id_prefix(xml) + amd = @amd || xml.at("//bibdata/ext/doctype")&.text == "addendum" + id = xml.at("//bibdata/ext/structuredidentifier/project-number") and + id.content = + id_prefix(prefix, id, amd:) end def format_ref(ref, type) ref = ref.sub(/ \(All Parts\)/i, "") super