lib/isodoc/iho/base_convert.rb in metanorma-iho-0.4.5 vs lib/isodoc/iho/base_convert.rb in metanorma-iho-0.5.0
- old
+ new
@@ -25,11 +25,11 @@
def nodes_to_span(node)
noko do |xml|
xml.span do |s|
node&.children&.each { |x| parse(x, s) }
end
- end.join("")
+ end.join
end
def multiplenames_and(names)
return "" if names.empty?
return names[0] if names.length == 1
@@ -54,17 +54,19 @@
end
def inline_bibitem_ref_code(bib)
id = bib.at(ns("./docidentifier[not(@type = 'DOI' or "\
"@type = 'metanorma' or @type = 'ISSN' or "\
- "@type = 'ISBN' or @type = 'rfc-anchor')]"))
- id ||= bib.at(ns("./docidentifier[not(@type = 'metanorma')]"))
- return [nil, id, nil] if id
+ "@type = 'ISBN' or @type = 'rfc-anchor' or "\
+ "@type = 'metanorma-ordinal')]"))
+ id ||= bib.at(ns("./docidentifier[not(@type = 'metanorma' or "\
+ "@type = 'metanorma-ordinal')]"))
+ return [nil, id, nil, nil] if id
id = Nokogiri::XML::Node.new("docidentifier", bib.document)
id << "(NO ID)"
- [nil, id, nil]
+ [nil, id, nil, nil]
end
def extract_edition(bib)
bib&.at(ns("./edition"))&.text
end
@@ -99,13 +101,13 @@
def extract_person_name(bib)
p = bib.at(ns("./person/name")) or return
c = p.at(ns("./completename")) and return c.text
s = p&.at(ns("./surname"))&.text or return
i = p.xpath(ns("./initial")) and
- front = i.map { |e| e.text.gsub(/[^[:upper:]]/, "") }.join("")
+ front = i.map { |e| e.text.gsub(/[^[:upper:]]/, "") }.join
i.empty? and f = p.xpath(ns("./forename")) and
- front = f.map { |e| e.text[0].upcase }.join("")
+ front = f.map { |e| e.text[0].upcase }.join
front ? "#{s} #{front}" : s
end
def iho?(bib)
extract_publisher(bib)[1] == "IHO"
@@ -115,13 +117,13 @@
def standard_citation(out, bib)
if ftitle = bib.at(ns("./formattedref"))
ftitle&.children&.each { |n| parse(n, out) }
else
id = render_identifier(inline_bibitem_ref_code(bib))
- out << id[1] if id[1]
+ out << id[:sdo] if id[:sdo]
ed = extract_edition(bib) if iho?(bib)
out << " edition #{ed}" if ed
- out << ": " if id[1] || ed
+ out << ": " if id[:sdo] || ed
iso_title(bib)&.children&.each { |n| parse(n, out) }
out << ", "
author = extract_author(bib)
out << author
u = extract_uri(bib)