metanorma-iso 1.1.5 → 1.2.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.
@@ -1,3 +1,4 @@
1
+ require_relative "base_convert"
1
2
  require "isodoc"
2
3
  require_relative "metadata"
3
4
 
@@ -33,15 +34,6 @@ module IsoDoc
33
34
  }
34
35
  end
35
36
 
36
- def metadata_init(lang, script, labels)
37
- @meta = Metadata.new(lang, script, labels)
38
- end
39
-
40
- def implicit_reference(b)
41
- isocode = b.at(ns("./docidentifier")).text
42
- isocode == "IEV"
43
- end
44
-
45
37
  def make_body(xml, docxml)
46
38
  body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
47
39
  xml.body **body_attr do |body|
@@ -60,165 +52,6 @@ module IsoDoc
60
52
  end
61
53
  end
62
54
 
63
- def introduction(isoxml, out)
64
- f = isoxml.at(ns("//introduction")) || return
65
- num = f.at(ns(".//clause")) ? "0" : nil
66
- title_attr = { class: "IntroTitle" }
67
- page_break(out)
68
- out.div **{ class: "Section3", id: f["id"] } do |div|
69
- # div.h1 "Introduction", **attr_code(title_attr)
70
- clause_name(num, @introduction_lbl, div, title_attr)
71
- f.elements.each do |e|
72
- if e.name == "patent-notice"
73
- e.elements.each { |e1| parse(e1, div) }
74
- else
75
- parse(e, div) unless e.name == "title"
76
- end
77
- end
78
- end
79
- end
80
-
81
- def foreword(isoxml, out)
82
- f = isoxml.at(ns("//foreword")) || return
83
- page_break(out)
84
- out.div **attr_code(id: f["id"]) do |s|
85
- s.h1(**{ class: "ForewordTitle" }) { |h1| h1 << @foreword_lbl }
86
- f.elements.each { |e| parse(e, s) unless e.name == "title" }
87
- end
88
- end
89
-
90
- def initial_anchor_names(d)
91
- super
92
- introduction_names(d.at(ns("//introduction")))
93
- end
94
-
95
- # we can reference 0-number clauses in introduction
96
- def introduction_names(clause)
97
- return if clause.nil?
98
- clause.xpath(ns("./clause")).each_with_index do |c, i|
99
- section_names1(c, "0.#{i + 1}", 2)
100
- end
101
- end
102
-
103
- # terms not defined in standoc
104
- def error_parse(node, out)
105
- case node.name
106
- when "appendix" then clause_parse(node, out)
107
- else
108
- super
109
- end
110
- end
111
-
112
- def annex_names(clause, num)
113
- appendix_names(clause, num)
114
- super
115
- end
116
-
117
- def appendix_names(clause, num)
118
- clause.xpath(ns("./appendix")).each_with_index do |c, i|
119
- @anchors[c["id"]] = anchor_struct(i + 1, nil, @appendix_lbl, "clause")
120
- @anchors[c["id"]][:level] = 2
121
- @anchors[c["id"]][:container] = clause["id"]
122
- end
123
- end
124
-
125
- def section_names1(clause, num, level)
126
- @anchors[clause["id"]] =
127
- { label: num, level: level, xref: num }
128
- # subclauses are not prefixed with "Clause"
129
- clause.xpath(ns("./clause | ./terms | ./term | ./definitions")).
130
- each_with_index do |c, i|
131
- section_names1(c, "#{num}.#{i + 1}", level + 1)
132
- end
133
- end
134
-
135
- def annex_names1(clause, num, level)
136
- @anchors[clause["id"]] = { label: num, xref: num, level: level }
137
- clause.xpath(ns("./clause")).each_with_index do |c, i|
138
- annex_names1(c, "#{num}.#{i + 1}", level + 1)
139
- end
140
- end
141
-
142
- def eref_localities1_zh(target, type, from, to)
143
- subsection = from&.text&.match(/\./)
144
- ret = type == "list" ? "" : ","
145
- ret += " 第#{from.text}" if from
146
- ret += "&ndash;#{to}" if to
147
- loc = (@locality[type] || type.sub(/^locality:/, "").capitalize )
148
- ret += " #{loc}" unless subsection && type == "clause" ||
149
- type == "list" || target.match(/^IEV$|^IEC 60050-/)
150
- ret += ")" if type == "list"
151
- ret
152
- end
153
-
154
- def eref_localities1(target, type, from, to, lang = "en")
155
- subsection = from&.text&.match(/\./)
156
- type = type.downcase
157
- return l10n(eref_localities1_zh(target, type, from, to)) if lang == "zh"
158
- ret = type == "list" ? "" : ","
159
- loc = @locality[type] || type.sub(/^locality:/, "").capitalize
160
- ret += " #{loc}" unless subsection && type == "clause" ||
161
- type == "list" || target.match(/^IEV$|^IEC 60050-/)
162
- ret += " #{from.text}" if from
163
- ret += "&ndash;#{to.text}" if to
164
- ret += ")" if type == "list"
165
- l10n(ret)
166
- end
167
-
168
- def prefix_container(container, linkend, target)
169
- delim = get_anchors[target][:type] == "listitem" ? " " : ", "
170
- l10n(get_anchors[container][:xref] + delim + linkend)
171
- end
172
-
173
- def example_p_parse(node, div)
174
- div.p do |p|
175
- p.span **{ class: "example_label" } do |s|
176
- s << example_label(node)
177
- end
178
- insert_tab(p, 1)
179
- node.first_element_child.children.each { |n| parse(n, p) }
180
- end
181
- node.element_children[1..-1].each { |n| parse(n, div) }
182
- end
183
-
184
- def example_parse1(node, div)
185
- div.p do |p|
186
- p.span **{ class: "example_label" } do |s|
187
- s << example_label(node)
188
- end
189
- insert_tab(p, 1)
190
- end
191
- node.children.each { |n| parse(n, div) }
192
- end
193
-
194
- def example_parse(node, out)
195
- out.div **{ id: node["id"], class: "example" } do |div|
196
- if node.first_element_child.name == "p"
197
- example_p_parse(node, div)
198
- else
199
- example_parse1(node, div)
200
- end
201
- end
202
- end
203
-
204
- def termexamples_before_termnotes(node)
205
- return unless node.at(ns("./termnote")) && node.at(ns("./termexample"))
206
- return unless insert = node.at(ns("./definition"))
207
- insert = insertall_after_here(node, insert, "termexample")
208
- insert = insertall_after_here(node, insert, "termnote")
209
- end
210
-
211
- def term_parse(node, out)
212
- termexamples_before_termnotes(node)
213
- out.p **{ class: "Terms", style:"text-align:left;" } do |p|
214
- node.children.each { |c| parse(c, p) }
215
- end
216
- end
217
-
218
- def clausedelim
219
- ""
220
- end
221
-
222
55
  def figure_cleanup(docxml)
223
56
  super
224
57
  docxml.xpath("//div[@class = 'figure']//table[@class = 'dl']").each do |t|
@@ -243,6 +76,8 @@ module IsoDoc
243
76
  word_annex_cleanup1(docxml, 5)
244
77
  word_annex_cleanup1(docxml, 6)
245
78
  end
79
+
80
+ include BaseConvert
246
81
  end
247
82
  end
248
83
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "1.1.5".freeze
3
+ VERSION = "1.2.0".freeze
4
4
  end
5
5
  end
@@ -27,13 +27,12 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
  spec.files = `git ls-files`.split("\n")
29
29
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
30
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
30
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
31
31
 
32
32
  spec.add_dependency "asciidoctor", "~> 1.5.7"
33
33
  spec.add_dependency "ruby-jing"
34
- spec.add_dependency "isodoc", "~> 0.9.8"
35
- spec.add_dependency "iev", "~> 0.2.0"
36
- spec.add_dependency "metanorma-standoc", "~> 1.1.0"
34
+ spec.add_dependency "isodoc", "~> 0.10.0"
35
+ spec.add_dependency "metanorma-standoc", "~> 1.2.0"
37
36
 
38
37
  spec.add_development_dependency "bundler", "~> 2.0.1"
39
38
  spec.add_development_dependency "byebug"
@@ -46,4 +45,5 @@ Gem::Specification.new do |spec|
46
45
  spec.add_development_dependency "simplecov", "~> 0.15"
47
46
  spec.add_development_dependency "timecop", "~> 0.9"
48
47
  spec.add_development_dependency "metanorma", "~> 0.3.0"
48
+ spec.add_development_dependency "iev", "~> 0.2.0"
49
49
  end
@@ -90,21 +90,16 @@ RSpec.describe Asciidoctor::ISO do
90
90
  INPUT
91
91
  <?xml version="1.0" encoding="UTF-8"?>
92
92
  <iso-standard xmlns="http://riboseinc.com/isoxml">
93
- <bibdata type="article">
94
- <title>
95
- <title-intro language="en" format="text/plain">Introduction</title-intro>
96
- <title-main language="en" format="text/plain">Main Title — Title</title-main>
97
- <title-part language="en" format="text/plain">Title Part</title-part>
98
- </title>
99
- <title>
100
- <title-intro language="fr" format="text/plain">Introduction Française</title-intro>
101
- <title-main language="fr" format="text/plain">Titre Principal</title-main>
102
- <title-part language="fr" format="text/plain">Part du Titre</title-part>
103
- </title>
93
+ <bibdata type="standard">
94
+ <title language="en" format="text/plain" type="main">Introduction — Main Title — Title — Title Part</title>
95
+ <title language="en" format="text/plain" type="title-intro">Introduction</title>
96
+ <title language="en" format="text/plain" type="title-main">Main Title — Title</title>
97
+ <title language="en" format="text/plain" type="title-part">Title Part</title>
98
+ <title language="fr" format="text/plain" type="main">Introduction Française — Titre Principal — Part du Titre</title>
99
+ <title language="fr" format="text/plain" type="title-intro">Introduction Française</title>
100
+ <title language="fr" format="text/plain" type="title-main">Titre Principal</title>
101
+ <title language="fr" format="text/plain" type="title-part">Part du Titre</title>
104
102
  <docidentifier type="iso">ISO/PreNWIP3 1000-1</docidentifier>
105
- <docidentifier type="iso-structured">
106
- <project-number part="1">ISO 1000</project-number>
107
- </docidentifier>
108
103
  <docnumber>1000</docnumber>
109
104
  <edition>2</edition>
110
105
  <version>
@@ -141,6 +136,8 @@ RSpec.describe Asciidoctor::ISO do
141
136
  </organization>
142
137
  </owner>
143
138
  </copyright>
139
+ <ext>
140
+ <doctype>article</doctype>
144
141
  <editorialgroup>
145
142
  <technical-committee number="1" type="A">TC</technical-committee>
146
143
  <technical-committee number="11" type="A1">TC1</technical-committee>
@@ -159,6 +156,10 @@ RSpec.describe Asciidoctor::ISO do
159
156
  <ics>
160
157
  <code>3</code>
161
158
  </ics>
159
+ <structuredidentifier>
160
+ <project-number part="1">ISO 1000</project-number>
161
+ </structuredidentifier>
162
+ </ext>
162
163
  </bibdata>
163
164
  <sections/>
164
165
  </iso-standard>
@@ -184,17 +185,8 @@ RSpec.describe Asciidoctor::ISO do
184
185
  INPUT
185
186
  <?xml version="1.0" encoding="UTF-8"?>
186
187
  <iso-standard xmlns="http://riboseinc.com/isoxml">
187
- <bibdata type="article">
188
- <title>
189
-
190
- </title>
191
- <title>
192
-
193
- </title>
188
+ <bibdata type="standard">
194
189
  <docidentifier type="iso">ISO/IEC/IETF 1000-1-1:2001</docidentifier>
195
- <docidentifier type="iso-structured">
196
- <project-number part="1" subpart="1">ISO/IEC/IETF 1000</project-number>
197
- </docidentifier>
198
190
  <docidentifier type="iso-tc">2000</docidentifier>
199
191
  <docnumber>1000</docnumber>
200
192
  <contributor>
@@ -269,17 +261,211 @@ RSpec.describe Asciidoctor::ISO do
269
261
  </organization>
270
262
  </owner>
271
263
  </copyright>
264
+ <ext>
265
+ <doctype>article</doctype>
272
266
  <editorialgroup>
273
267
  <technical-committee/>
274
268
  <subcommittee/>
275
269
  <workgroup/>
276
270
  </editorialgroup>
271
+ <structuredidentifier>
272
+ <project-number part="1" subpart="1">ISO/IEC/IETF 1000</project-number>
273
+ </structuredidentifier>
274
+ </ext>
277
275
  </bibdata>
278
276
  <sections/>
279
277
  </iso-standard>
280
278
  OUTPUT
281
279
  end
282
280
 
281
+ it "defaults substage" do
282
+ expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
283
+ = Document title
284
+ Author
285
+ :docfile: test.adoc
286
+ :nodoc:
287
+ :novalid:
288
+ :no-isobib:
289
+ :docnumber: 1000
290
+ :docstage: 50
291
+ INPUT
292
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
293
+ <bibdata type="standard">
294
+ <docidentifier type="iso">ISO/FDIS 1000</docidentifier>
295
+ <docnumber>1000</docnumber>
296
+ <contributor>
297
+ <role type="author"/>
298
+ <organization>
299
+ <name>International Organization for Standardization</name>
300
+ <abbreviation>ISO</abbreviation>
301
+ </organization>
302
+ </contributor>
303
+ <contributor>
304
+ <role type="publisher"/>
305
+ <organization>
306
+ <name>International Organization for Standardization</name>
307
+ <abbreviation>ISO</abbreviation>
308
+ </organization>
309
+ </contributor>
310
+
311
+ <language>en</language>
312
+ <script>Latn</script>
313
+ <status>
314
+ <stage>50</stage>
315
+ <substage>00</substage>
316
+ </status>
317
+ <copyright>
318
+ <from>#{Date.today.year}</from>
319
+ <owner>
320
+ <organization>
321
+ <name>International Organization for Standardization</name>
322
+ <abbreviation>ISO</abbreviation>
323
+ </organization>
324
+ </owner>
325
+ </copyright>
326
+ <ext>
327
+ <doctype>article</doctype>
328
+ <editorialgroup>
329
+ <technical-committee/>
330
+ <subcommittee/>
331
+ <workgroup/>
332
+ </editorialgroup>
333
+ <structuredidentifier>
334
+ <project-number>ISO 1000</project-number>
335
+ </structuredidentifier>
336
+ </ext>
337
+ </bibdata>
338
+ <sections/>
339
+ </iso-standard>
340
+ OUTPUT
341
+ end
342
+
343
+ it "defaults substage for stage 60" do
344
+ expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
345
+ = Document title
346
+ Author
347
+ :docfile: test.adoc
348
+ :nodoc:
349
+ :novalid:
350
+ :no-isobib:
351
+ :docnumber: 1000
352
+ :docstage: 60
353
+ INPUT
354
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
355
+ <bibdata type="standard">
356
+ <docidentifier type="iso">ISO 1000</docidentifier>
357
+ <docnumber>1000</docnumber>
358
+ <contributor>
359
+ <role type="author"/>
360
+ <organization>
361
+ <name>International Organization for Standardization</name>
362
+ <abbreviation>ISO</abbreviation>
363
+ </organization>
364
+ </contributor>
365
+ <contributor>
366
+ <role type="publisher"/>
367
+ <organization>
368
+ <name>International Organization for Standardization</name>
369
+ <abbreviation>ISO</abbreviation>
370
+ </organization>
371
+ </contributor>
372
+
373
+ <language>en</language>
374
+ <script>Latn</script>
375
+ <status>
376
+ <stage>60</stage>
377
+ <substage>60</substage>
378
+ </status>
379
+ <copyright>
380
+ <from>#{Date.today.year}</from>
381
+ <owner>
382
+ <organization>
383
+ <name>International Organization for Standardization</name>
384
+ <abbreviation>ISO</abbreviation>
385
+ </organization>
386
+ </owner>
387
+ </copyright>
388
+ <ext>
389
+ <doctype>article</doctype>
390
+ <editorialgroup>
391
+ <technical-committee/>
392
+ <subcommittee/>
393
+ <workgroup/>
394
+ </editorialgroup>
395
+ <structuredidentifier>
396
+ <project-number>ISO 1000</project-number>
397
+ </structuredidentifier>
398
+ </ext>
399
+ </bibdata>
400
+ <sections/>
401
+ </iso-standard>
402
+ OUTPUT
403
+ end
404
+
405
+ it "populates metadata for PRF" do
406
+ expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
407
+ = Document title
408
+ Author
409
+ :docfile: test.adoc
410
+ :nodoc:
411
+ :novalid:
412
+ :no-isobib:
413
+ :docnumber: 1000
414
+ :docstage: 60
415
+ :docsubstage: 00
416
+ INPUT
417
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
418
+ <bibdata type="standard">
419
+ <docidentifier type="iso">ISO/PRF 1000</docidentifier>
420
+ <docnumber>1000</docnumber>
421
+ <contributor>
422
+ <role type="author"/>
423
+ <organization>
424
+ <name>International Organization for Standardization</name>
425
+ <abbreviation>ISO</abbreviation>
426
+ </organization>
427
+ </contributor>
428
+ <contributor>
429
+ <role type="publisher"/>
430
+ <organization>
431
+ <name>International Organization for Standardization</name>
432
+ <abbreviation>ISO</abbreviation>
433
+ </organization>
434
+ </contributor>
435
+
436
+ <language>en</language>
437
+ <script>Latn</script>
438
+ <status>
439
+ <stage>60</stage>
440
+ <substage>00</substage>
441
+ </status>
442
+ <copyright>
443
+ <from>#{Date.today.year}</from>
444
+ <owner>
445
+ <organization>
446
+ <name>International Organization for Standardization</name>
447
+ <abbreviation>ISO</abbreviation>
448
+ </organization>
449
+ </owner>
450
+ </copyright>
451
+ <ext>
452
+ <doctype>article</doctype>
453
+ <editorialgroup>
454
+ <technical-committee/>
455
+ <subcommittee/>
456
+ <workgroup/>
457
+ </editorialgroup>
458
+ <structuredidentifier>
459
+ <project-number>ISO 1000</project-number>
460
+ </structuredidentifier>
461
+ </ext>
462
+ </bibdata>
463
+ <sections/>
464
+ </iso-standard>
465
+ OUTPUT
466
+ end
467
+
468
+
283
469
  it "reads scripts into blank HTML document" do
284
470
  FileUtils.rm_f "test.html"
285
471
  Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)