metanorma-iso 2.3.2 → 2.3.4
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/iso/base_convert.rb +1 -0
- data/lib/isodoc/iso/html/html_iso_titlepage.html +1 -1
- data/lib/isodoc/iso/html/style-human.css +3 -0
- data/lib/isodoc/iso/html/style-human.scss +4 -0
- data/lib/isodoc/iso/html/style-iso.css +3 -0
- data/lib/isodoc/iso/html/style-iso.scss +4 -0
- data/lib/isodoc/iso/html/word_iso_titlepage-dis.html +1 -1
- data/lib/isodoc/iso/html/word_iso_titlepage-prf.html +1 -1
- data/lib/isodoc/iso/html/word_iso_titlepage.html +1 -1
- data/lib/isodoc/iso/html/wordstyle-dis.css +4 -4
- data/lib/isodoc/iso/html/wordstyle-dis.scss +4 -4
- data/lib/isodoc/iso/iso.amendment.xsl +42 -13
- data/lib/isodoc/iso/iso.international-standard.xsl +42 -13
- data/lib/isodoc/iso/metadata.rb +22 -25
- data/lib/isodoc/iso/presentation_bibdata.rb +9 -3
- data/lib/isodoc/iso/presentation_xml_convert.rb +14 -17
- data/lib/isodoc/iso/presentation_xref.rb +3 -3
- data/lib/isodoc/iso/word_dis_cleanup.rb +7 -34
- data/lib/isodoc/iso/word_dis_convert.rb +33 -6
- data/lib/metanorma/iso/basicdoc.rng +0 -1
- data/lib/metanorma/iso/biblio.rng +1 -1
- data/lib/metanorma/iso/cleanup.rb +18 -16
- data/lib/metanorma/iso/front.rb +21 -5
- data/lib/metanorma/iso/front_id.rb +114 -186
- data/lib/metanorma/iso/isodoc.rng +2 -1
- data/lib/metanorma/iso/processor.rb +1 -1
- data/lib/metanorma/iso/section.rb +6 -2
- data/lib/metanorma/iso/version.rb +1 -1
- data/lib/relaton/render/general.rb +1 -0
- data/metanorma-iso.gemspec +1 -1
- metadata +6 -6
@@ -34,153 +34,158 @@ module Metanorma
|
|
34
34
|
"95": "Withdrawal",
|
35
35
|
}.freeze
|
36
36
|
|
37
|
-
def stage_abbr(stage, substage,
|
37
|
+
def stage_abbr(stage, substage, _doctype)
|
38
38
|
return nil if stage.to_i > 60
|
39
39
|
|
40
40
|
ret = STAGE_ABBRS[stage.to_sym]
|
41
41
|
ret = "PRF" if stage == "60" && substage == "00"
|
42
|
+
ret = nil if stage == "60" && substage != "00"
|
42
43
|
ret = "AWI" if stage == "10" && substage == "99"
|
43
44
|
ret = "AWI" if stage == "20" && substage == "00"
|
44
|
-
if %w(amendment technical-corrigendum technical-report
|
45
|
-
technical-specification).include?(doctype)
|
46
|
-
ret = "D" if stage == "40" && doctype == "amendment"
|
47
|
-
ret = "FD" if stage == "50" && %w(amendment technical-corrigendum)
|
48
|
-
.include?(doctype)
|
49
|
-
end
|
50
|
-
ret
|
51
|
-
end
|
52
|
-
|
53
|
-
def stage_name(stage, substage, _doctype, iteration = nil)
|
54
|
-
return "Proof" if stage == "60" && substage == "00"
|
55
|
-
|
56
|
-
ret = STAGE_NAMES[stage.to_sym]
|
57
|
-
if iteration && %w(20 30).include?(stage)
|
58
|
-
prefix = iteration.to_i.localize(@lang.to_sym)
|
59
|
-
.to_rbnf_s("SpelloutRules", "spellout-ordinal")
|
60
|
-
ret = "#{prefix.capitalize} #{ret.downcase}"
|
61
|
-
end
|
62
45
|
ret
|
63
46
|
end
|
64
47
|
|
65
48
|
def metadata_id(node, xml)
|
66
49
|
iso_id(node, xml)
|
67
|
-
node
|
50
|
+
node.attr("tc-docnumber")&.split(/,\s*/)&.each do |n|
|
68
51
|
xml.docidentifier(n, **attr_code(type: "iso-tc"))
|
69
52
|
end
|
70
53
|
xml.docnumber node&.attr("docnumber")
|
71
54
|
end
|
72
55
|
|
56
|
+
# @param type [nil, :tr, :ts, :amd, :cor, :guide, :dir, :tc, Type]
|
57
|
+
# document's type, eg. :tr, :ts, :amd, :cor, Type.new(:tr)
|
58
|
+
def get_typeabbr(node, amd: false)
|
59
|
+
node.attr("amendment-number") and return :amd
|
60
|
+
node.attr("corrigendum-number") and return :cor
|
61
|
+
case doctype(node)
|
62
|
+
when "directive" then :dir
|
63
|
+
when "technical-report" then :tr
|
64
|
+
when "technical-specification" then :ts
|
65
|
+
when "guide" then :guide
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
73
69
|
def iso_id(node, xml)
|
74
70
|
(!@amd && node.attr("docnumber")) || (@amd && node.attr("updates")) or
|
75
71
|
return
|
76
|
-
|
77
|
-
|
78
|
-
id_year(dn, node, mode: :force),
|
79
|
-
id_year(dn, node, mode: :strip)]
|
80
|
-
iso_id_out(node, xml, dns)
|
72
|
+
params = iso_id_params(node)
|
73
|
+
iso_id_out(xml, params, true)
|
81
74
|
end
|
82
75
|
|
83
|
-
def
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
76
|
+
def iso_id_params(node)
|
77
|
+
params = iso_id_params_core(node)
|
78
|
+
params2 = iso_id_params_add(node)
|
79
|
+
if node.attr("updates")
|
80
|
+
orig_id = Pubid::Iso::Identifier::Base.parse(node.attr("updates"))
|
81
|
+
orig_id.edition ||= 1
|
82
|
+
end
|
83
|
+
iso_id_params_resolve(params, params2, node, orig_id)
|
84
|
+
end
|
85
|
+
|
86
|
+
# unpublished is for internal use
|
87
|
+
def iso_id_params_core(node)
|
88
|
+
pub = (node.attr("publisher") || "ISO").split(/[;,]/)
|
89
|
+
ret = { number: node.attr("docnumber"),
|
90
|
+
part: node.attr("partnumber"),
|
91
|
+
language: node.attr("language") || "en",
|
92
|
+
type: get_typeabbr(node),
|
93
|
+
publisher: pub[0],
|
94
|
+
unpublished: /^[0-5]/.match?(get_stage(node)),
|
95
|
+
copublisher: pub[1..-1] }.compact
|
96
|
+
ret[:copublisher].empty? and ret.delete(:copublisher)
|
97
|
+
ret
|
90
98
|
end
|
91
99
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
+
def iso_id_params_add(node)
|
101
|
+
stage = iso_id_stage(node)
|
102
|
+
|
103
|
+
ret = { number: node.attr("amendment-number") ||
|
104
|
+
node.attr("corrigendum-number"),
|
105
|
+
year: iso_id_year(node),
|
106
|
+
iteration: node.attr("iteration") }.compact
|
107
|
+
stage and ret[:stage] = stage
|
108
|
+
ret[:stage] == "60.00" and ret[:stage] = :PRF
|
109
|
+
ret
|
100
110
|
end
|
101
111
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
112
|
+
def iso_id_stage(node)
|
113
|
+
stage = stage_abbr(get_stage(node), get_substage(node),
|
114
|
+
doctype(node))
|
115
|
+
harmonised = "#{get_stage(node)}.#{get_substage(node)}"
|
116
|
+
harmonised = nil unless /^\d\d\.\d\d/.match?(harmonised)
|
117
|
+
{ abbr: stage&.to_sym, harmonized_code: harmonised }
|
118
|
+
harmonised || stage&.to_sym
|
119
|
+
end
|
120
|
+
|
121
|
+
def iso_id_year(node)
|
122
|
+
node.attr("copyright-year") || node.attr("updated-date")
|
123
|
+
&.sub(/-.*$/, "") || Date.today.year
|
124
|
+
end
|
125
|
+
|
126
|
+
def iso_id_params_resolve(params, params2, node, orig_id)
|
127
|
+
if orig_id && (node.attr("amendment-number") ||
|
128
|
+
node.attr("corrigendum-number"))
|
129
|
+
params.delete(:unpublished)
|
130
|
+
params.delete(:part)
|
131
|
+
params2[:base] = orig_id
|
109
132
|
end
|
133
|
+
params.merge!(params2)
|
134
|
+
params
|
110
135
|
end
|
111
136
|
|
112
|
-
def
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
}
|
128
|
-
if a = node.attr("amendment-number")
|
129
|
-
params[:amendments] = { number: a, stage: stage }
|
130
|
-
elsif a = node.attr("corrigendum-number")
|
131
|
-
params[:corrigendums] = { number: a, stage: stage }
|
132
|
-
else
|
133
|
-
params.merge!( { stage: stage, urn_stage: urn_stage }.compact )
|
134
|
-
end
|
135
|
-
iso_id_out(xml, params)
|
137
|
+
def iso_id_out(xml, params, with_prf)
|
138
|
+
xml.docidentifier iso_id_default(params).to_s(with_prf: with_prf),
|
139
|
+
**attr_code(type: "ISO")
|
140
|
+
xml.docidentifier iso_id_reference(params)
|
141
|
+
.to_s(format: :ref_num_long, with_prf: with_prf),
|
142
|
+
**attr_code(type: "iso-reference")
|
143
|
+
xml.docidentifier iso_id_reference(params).urn, **attr_code(type: "URN")
|
144
|
+
return if @amd
|
145
|
+
|
146
|
+
xml.docidentifier iso_id_undated(params).to_s(with_prf: with_prf),
|
147
|
+
**attr_code(type: "iso-undated")
|
148
|
+
xml.docidentifier iso_id_with_lang(params)
|
149
|
+
.to_s(format: :ref_num_short, with_prf: with_prf),
|
150
|
+
**attr_code(type: "iso-with-lang")
|
151
|
+
rescue StandardError => e
|
152
|
+
clean_abort("Document identifier: #{e}", xml)
|
136
153
|
end
|
137
154
|
|
138
|
-
def
|
155
|
+
def iso_id_default(params)
|
139
156
|
params_nolang = params.dup.tap { |hs| hs.delete(:language) }
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
warn params
|
149
|
-
warn "Generated: #{Pubid::Iso::Identifier.new(**params).to_s}"
|
150
|
-
xml.docidentifier(Pubid::Iso::Identifier.new(**params),
|
151
|
-
**attr_code(type: "iso-reference"))
|
157
|
+
params1 = if params[:unpublished]
|
158
|
+
params_nolang.dup.tap do |hs|
|
159
|
+
hs.delete(:year)
|
160
|
+
end
|
161
|
+
else params_nolang
|
162
|
+
end
|
163
|
+
params1.delete(:unpublished)
|
164
|
+
Pubid::Iso::Identifier.create(**params1)
|
152
165
|
end
|
153
|
-
=end
|
154
166
|
|
155
|
-
def
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
part, subpart = node&.attr("partnumber")&.split(/-/)
|
161
|
-
add_id_parts(node.attr("docnumber"), part, subpart)
|
167
|
+
def iso_id_undated(params)
|
168
|
+
params_nolang = params.dup.tap { |hs| hs.delete(:language) }
|
169
|
+
params2 = params_nolang.dup.tap do |hs|
|
170
|
+
hs.delete(:year)
|
171
|
+
hs.delete(:unpublished)
|
162
172
|
end
|
173
|
+
Pubid::Iso::Identifier.create(**params2)
|
163
174
|
end
|
164
175
|
|
165
|
-
def
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
176
|
+
def iso_id_with_lang(params)
|
177
|
+
params1 = if params[:unpublished]
|
178
|
+
params.dup.tap do |hs|
|
179
|
+
hs.delete(:year)
|
180
|
+
end
|
181
|
+
else params end
|
182
|
+
params1.delete(:unpublished)
|
183
|
+
Pubid::Iso::Identifier.create(**params1)
|
172
184
|
end
|
173
185
|
|
174
|
-
def
|
175
|
-
|
176
|
-
|
177
|
-
when "en" then "(E)"
|
178
|
-
when "fr" then "(F)"
|
179
|
-
when "ru" then "(R)"
|
180
|
-
else
|
181
|
-
"(X)"
|
182
|
-
end
|
183
|
-
"#{docnum}#{suffix}"
|
186
|
+
def iso_id_reference(params)
|
187
|
+
params1 = params.dup.tap { |hs| hs.delete(:unpublished) }
|
188
|
+
Pubid::Iso::Identifier.create(**params1)
|
184
189
|
end
|
185
190
|
|
186
191
|
def structured_id(node, xml)
|
@@ -197,83 +202,6 @@ pub = (node.attr("publisher") || "ISO").split(/[;,]/)
|
|
197
202
|
end
|
198
203
|
end
|
199
204
|
|
200
|
-
def add_id_parts(docnum, part, subpart)
|
201
|
-
docnum += "-#{part}" if part
|
202
|
-
docnum += "-#{subpart}" if subpart
|
203
|
-
docnum
|
204
|
-
end
|
205
|
-
|
206
|
-
def id_stage_abbr(stage, substage, node, bare = false)
|
207
|
-
ret = id_stage_abbr1(stage, substage, node, bare)
|
208
|
-
if %w(amendment technical-corrigendum technical-report
|
209
|
-
technical-specification).include?(doctype(node)) &&
|
210
|
-
!%w(D FD).include?(ret)
|
211
|
-
ret = "#{ret} "
|
212
|
-
end
|
213
|
-
ret
|
214
|
-
end
|
215
|
-
|
216
|
-
def id_stage_abbr1(stage, substage, node, bare)
|
217
|
-
if bare
|
218
|
-
IsoDoc::Iso::Metadata.new("en", "Latn", nil, @i18n)
|
219
|
-
.status_abbrev(stage_abbr(stage, substage, doctype(node)),
|
220
|
-
substage, nil, nil, doctype(node))
|
221
|
-
else
|
222
|
-
IsoDoc::Iso::Metadata.new("en", "Latn", nil, @i18n)
|
223
|
-
.status_abbrev(stage_abbr(stage, substage, doctype(node)),
|
224
|
-
substage, node.attr("iteration"),
|
225
|
-
node.attr("draft"), doctype(node))
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
def cover_stage_abbr(node)
|
230
|
-
stage = get_stage(node)
|
231
|
-
abbr = id_stage_abbr(get_stage(node), get_substage(node), node, true)
|
232
|
-
typeabbr = get_typeabbr(node, amd: true)
|
233
|
-
if stage.to_i > 50 || (stage.to_i == 60 && get_substage(node).to_i < 60)
|
234
|
-
typeabbr = ""
|
235
|
-
end
|
236
|
-
"#{abbr}#{typeabbr}".strip
|
237
|
-
end
|
238
|
-
|
239
|
-
def id_stage_prefix(docnum, node)
|
240
|
-
stage = get_stage(node)
|
241
|
-
typeabbr = get_typeabbr(node)
|
242
|
-
if stage && (stage.to_i < 60)
|
243
|
-
docnum = unpub_stage_prefix(docnum, stage, typeabbr, node)
|
244
|
-
elsif typeabbr == "DIR " then docnum = "#{typeabbr}#{docnum}"
|
245
|
-
elsif typeabbr && !@amd then docnum = "/#{typeabbr}#{docnum}"
|
246
|
-
end
|
247
|
-
docnum
|
248
|
-
end
|
249
|
-
|
250
|
-
def id_year(docnum, node, mode: :default)
|
251
|
-
case mode
|
252
|
-
when :strip then docnum.sub(/:(19|20)\d\d(?!\d)/, "")
|
253
|
-
when :force then id_add_year(docnum, node)
|
254
|
-
else
|
255
|
-
stage = get_stage(node)
|
256
|
-
if stage && (stage.to_i < 60)
|
257
|
-
docnum
|
258
|
-
else id_add_year(docnum, node)
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
def unpub_stage_prefix(docnum, stage, typeabbr, node)
|
264
|
-
abbr = id_stage_abbr(stage, get_substage(node), node)
|
265
|
-
%w(40 50).include?(stage) && i = node.attr("iteration") and
|
266
|
-
itersuffix = ".#{i}"
|
267
|
-
return docnum if abbr.nil? || abbr.empty? # prefixes added in cleanup
|
268
|
-
|
269
|
-
typeabbr = "" if %w(DTS FDTS).include?(abbr.sub(/\s+$/, ""))
|
270
|
-
return "/#{abbr}#{typeabbr} #{docnum}#{itersuffix}" unless @amd
|
271
|
-
|
272
|
-
a = docnum.split(%r{/})
|
273
|
-
a[-1] = "#{abbr}#{a[-1]}#{itersuffix}"
|
274
|
-
a.join("/")
|
275
|
-
end
|
276
|
-
|
277
205
|
def id_add_year(docnum, node)
|
278
206
|
year = node.attr("copyright-year")
|
279
207
|
@amd and year ||= node.attr("updated-date")&.sub(/-.*$/, "")
|
@@ -66,6 +66,7 @@
|
|
66
66
|
<value>caution</value>
|
67
67
|
<value>statement</value>
|
68
68
|
<value>editorial</value>
|
69
|
+
<value>box</value>
|
69
70
|
</choice>
|
70
71
|
</define>
|
71
72
|
<define name="index">
|
@@ -1580,7 +1581,7 @@
|
|
1580
1581
|
</element>
|
1581
1582
|
</define>
|
1582
1583
|
<define name="misccontainer">
|
1583
|
-
<element name="
|
1584
|
+
<element name="metanorma-extension">
|
1584
1585
|
<oneOrMore>
|
1585
1586
|
<ref name="AnyElement"/>
|
1586
1587
|
</oneOrMore>
|
@@ -45,9 +45,13 @@ module Metanorma
|
|
45
45
|
super
|
46
46
|
end
|
47
47
|
|
48
|
+
# in ISO, term has subterm, unless
|
49
|
+
# there is no definition to the term (subclauses start immediately),
|
50
|
+
# or it is labelled as "grouping"
|
48
51
|
def term_contains_subclauses(node)
|
49
|
-
|
50
|
-
|
52
|
+
!node.sections? and return false
|
53
|
+
node.level != node.blocks[0].level ||
|
54
|
+
node.role == "grouping"
|
51
55
|
end
|
52
56
|
end
|
53
57
|
end
|
data/metanorma-iso.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
|
35
35
|
spec.add_dependency "metanorma-standoc", "~> 2.3.0"
|
36
36
|
spec.add_dependency "mnconvert", "~> 1.14"
|
37
|
-
spec.add_dependency "pubid-iso"
|
37
|
+
spec.add_dependency "pubid-iso", "~> 0.4.0"
|
38
38
|
spec.add_dependency "ruby-jing"
|
39
39
|
spec.add_dependency "tokenizer", "~> 0.3.0"
|
40
40
|
spec.add_dependency "twitter_cldr"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-iso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metanorma-standoc
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: pubid-iso
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.4.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.4.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: ruby-jing
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|