metanorma-iho 0.5.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/isodoc/iho/base_convert.rb +1 -105
- data/lib/isodoc/iho/html/html_iho_titlepage.html +2 -0
- data/lib/isodoc/iho/html/word_iho_titlepage.html +1 -0
- data/lib/isodoc/iho/iho.specification.xsl +559 -184
- data/lib/isodoc/iho/iho.standard.xsl +559 -184
- data/lib/isodoc/iho/init.rb +1 -1
- data/lib/isodoc/iho/pdf_convert.rb +2 -3
- data/lib/isodoc/iho/presentation_xml_convert.rb +5 -1
- data/lib/isodoc/iho/xref.rb +16 -13
- data/lib/metanorma/iho/biblio.rng +62 -10
- data/lib/metanorma/iho/isodoc.rng +56 -0
- data/lib/metanorma/iho/version.rb +1 -1
- data/lib/relaton/render/config.yml +8 -0
- data/lib/relaton/render/fields.rb +23 -0
- data/lib/relaton/render/general.rb +25 -0
- data/lib/relaton/render/parse.rb +31 -0
- data/metanorma-iho.gemspec +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2cff547b03ecc70aec12998ad10bec0bf6ff613bfc9287d9a85301f13c3e653
|
4
|
+
data.tar.gz: b0fa1bd5bf299a0b01a821bdafcc6e89292b726bad76ad171b6f78f8ba25d289
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc68dc888841c38bbece4f4fb3efe17f9bec41b706cf886be668323b218b2b42a513cda400813f4c3b254f3a318fd70e91a247a1e013a1b1000ee13ac9b5797b
|
7
|
+
data.tar.gz: 00dbf67eeefb94f12293843e81b516a318a7e8db5f1f7ec8c497c4d9027db2a8cb8ccf866bb572dc0d3af933d536c4d05597bc10eb37883d9737ce8ac0c62335
|
@@ -18,119 +18,15 @@ module IsoDoc
|
|
18
18
|
def std_bibitem_entry(list, bib, ordinal, biblio)
|
19
19
|
list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
|
20
20
|
prefix_bracketed_ref(ref, "[#{ordinal}]")
|
21
|
-
|
21
|
+
reference_format(bib, ref)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def nodes_to_span(node)
|
26
|
-
noko do |xml|
|
27
|
-
xml.span do |s|
|
28
|
-
node&.children&.each { |x| parse(x, s) }
|
29
|
-
end
|
30
|
-
end.join
|
31
|
-
end
|
32
|
-
|
33
|
-
def multiplenames_and(names)
|
34
|
-
return "" if names.empty?
|
35
|
-
return names[0] if names.length == 1
|
36
|
-
return "#{names[0]} and #{names[1]}" if names.length == 2
|
37
|
-
|
38
|
-
names[0..-2].join(", ") + " and #{names[-1]}"
|
39
|
-
end
|
40
|
-
|
41
|
-
def extract_publisher(bib)
|
42
|
-
c = bib
|
43
|
-
.xpath(ns("./contributor[role/@type = 'publisher'][organization]"))
|
44
|
-
abbrs = []
|
45
|
-
names = []
|
46
|
-
c&.each do |c1|
|
47
|
-
n = c1.at(ns("./organization/name")) or next
|
48
|
-
abbrs << (c1.at(ns("./organization/abbreviation")) || n)
|
49
|
-
names << nodes_to_span(n)
|
50
|
-
end
|
51
|
-
return [nil, nil] if names.empty?
|
52
|
-
|
53
|
-
[multiplenames_and(names), abbrs.map(&:text).join("/")]
|
54
|
-
end
|
55
|
-
|
56
|
-
def inline_bibitem_ref_code(bib)
|
57
|
-
id = bib.at(ns("./docidentifier[not(@type = 'DOI' or "\
|
58
|
-
"@type = 'metanorma' or @type = 'ISSN' or "\
|
59
|
-
"@type = 'ISBN' or @type = 'rfc-anchor' or "\
|
60
|
-
"@type = 'metanorma-ordinal')]"))
|
61
|
-
id ||= bib.at(ns("./docidentifier[not(@type = 'metanorma' or "\
|
62
|
-
"@type = 'metanorma-ordinal')]"))
|
63
|
-
return [nil, id, nil, nil] if id
|
64
|
-
|
65
|
-
id = Nokogiri::XML::Node.new("docidentifier", bib.document)
|
66
|
-
id << "(NO ID)"
|
67
|
-
[nil, id, nil, nil]
|
68
|
-
end
|
69
|
-
|
70
|
-
def extract_edition(bib)
|
71
|
-
bib&.at(ns("./edition"))&.text
|
72
|
-
end
|
73
|
-
|
74
|
-
def extract_uri(bib)
|
75
|
-
bib.at(ns("./uri[@type = 'src']")) || bib.at(ns("./uri"))
|
76
|
-
end
|
77
|
-
|
78
25
|
def omit_docid_prefix(prefix)
|
79
26
|
return true if prefix == "IHO"
|
80
27
|
|
81
28
|
super
|
82
29
|
end
|
83
|
-
|
84
|
-
def render_identifier(id)
|
85
|
-
if !id[1].nil? && (id[1]["type"] == "IHO")
|
86
|
-
id[1].children = id[1].text.sub(/^IHO /, "")
|
87
|
-
end
|
88
|
-
super
|
89
|
-
end
|
90
|
-
|
91
|
-
def extract_author(bib)
|
92
|
-
c = bib.xpath(ns("./contributor[role/@type = 'author']"))
|
93
|
-
c = bib.xpath(ns("./contributor[role/@type = 'editor']")) if c.empty?
|
94
|
-
return extract_publisher(bib)[0] if c.empty?
|
95
|
-
|
96
|
-
c.map do |c1|
|
97
|
-
c1&.at(ns("./organization/name"))&.text || extract_person_name(c1)
|
98
|
-
end.reject { |e| e.nil? || e.empty? }.join(", ")
|
99
|
-
end
|
100
|
-
|
101
|
-
def extract_person_name(bib)
|
102
|
-
p = bib.at(ns("./person/name")) or return
|
103
|
-
c = p.at(ns("./completename")) and return c.text
|
104
|
-
s = p&.at(ns("./surname"))&.text or return
|
105
|
-
i = p.xpath(ns("./initial")) and
|
106
|
-
front = i.map { |e| e.text.gsub(/[^[:upper:]]/, "") }.join
|
107
|
-
i.empty? and f = p.xpath(ns("./forename")) and
|
108
|
-
front = f.map { |e| e.text[0].upcase }.join
|
109
|
-
front ? "#{s} #{front}" : s
|
110
|
-
end
|
111
|
-
|
112
|
-
def iho?(bib)
|
113
|
-
extract_publisher(bib)[1] == "IHO"
|
114
|
-
end
|
115
|
-
|
116
|
-
# [{number}] {docID} edition {edition}: {title}, {author/organization}
|
117
|
-
def standard_citation(out, bib)
|
118
|
-
if ftitle = bib.at(ns("./formattedref"))
|
119
|
-
ftitle&.children&.each { |n| parse(n, out) }
|
120
|
-
else
|
121
|
-
id = render_identifier(inline_bibitem_ref_code(bib))
|
122
|
-
out << id[:sdo] if id[:sdo]
|
123
|
-
ed = extract_edition(bib) if iho?(bib)
|
124
|
-
out << " edition #{ed}" if ed
|
125
|
-
out << ": " if id[:sdo] || ed
|
126
|
-
iso_title(bib)&.children&.each { |n| parse(n, out) }
|
127
|
-
out << ", "
|
128
|
-
author = extract_author(bib)
|
129
|
-
out << author
|
130
|
-
u = extract_uri(bib)
|
131
|
-
out << " (<a href='#{u.text}'>#{u.text}</a>)" if u
|
132
|
-
end
|
133
|
-
end
|
134
30
|
end
|
135
31
|
end
|
136
32
|
end
|