lib/asciidoctor/gb/converter.rb in metanorma-gb-1.0.7 vs lib/asciidoctor/gb/converter.rb in metanorma-gb-1.0.8
- old
+ new
@@ -176,11 +176,12 @@
matched3 = ISO_REF_ALL_PARTS.match item
[matched, matched2, matched3]
end
def fetch_ref(xml, code, year, **opts)
- code = "CN(#{code})" if !/^CN\(/.match(code) && /^#{GBCODE}[^A-Za-z]/.match(code)
+ code = "CN(#{code})" if !/^CN\(/.match(code) &&
+ /^#{GBCODE}[^A-Za-z]/.match(code)
hit = @bibdb&.fetch(code, year, opts)
return nil if hit.nil?
xml.parent.add_child(Asciidoctor::Standoc::Utils::smart_render_xml(hit))
xml
rescue Algolia::AlgoliaProtocolError
@@ -194,16 +195,19 @@
contributor_cleanup(xmldoc)
xmldoc
end
def docidentifier_cleanup(xmldoc)
- id = xmldoc.at("//bibdata/docidentifier/project-number") or return
+ id = xmldoc.at("//bibdata/docidentifier[@type = 'gb']") or return
scope = xmldoc.at("//gbscope")&.text
prefix = xmldoc.at("//gbprefix")&.text
- mandate = xmldoc.at("//gbmandate")&.text || "mandatory"
- idtext = @agencyclass.docidentifier(scope, prefix, mandate,
- nil, id.text) || return
- id.content = idtext.gsub(/\ /, " ")
+ mand = xmldoc.at("//gbmandate")&.text || "mandatory"
+ idtext = @agencyclass.docidentifier(scope, prefix, mand, nil, id.text)
+ id.content = idtext&.gsub(/\ /, " ")
+ id = xmldoc.at("//bibdata/docidentifier[@type = 'gb-structured']/"\
+ "project-number") or return
+ idtext = @agencyclass.docidentifier(scope, prefix, mand, nil, id.text)
+ id.content = idtext&.gsub(/\ /, " ")
end
def committee_cleanup(xmldoc)
xmldoc.xpath("//gbcommittee").each do |c|
xmldoc.at("//bibdata/contributor").next =