metanorma-iec 1.2.6 → 1.2.11

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +62 -0
  3. data/README.adoc +3 -4
  4. data/lib/asciidoctor/iec/basicdoc.rng +50 -3
  5. data/lib/asciidoctor/iec/converter.rb +6 -1
  6. data/lib/asciidoctor/iec/front.rb +13 -0
  7. data/lib/asciidoctor/iec/iec.rng +55 -1
  8. data/lib/asciidoctor/iec/iec_intro_en.xml +82 -53
  9. data/lib/asciidoctor/iec/iec_intro_fr.xml +44 -20
  10. data/lib/asciidoctor/iec/isodoc.rng +36 -43
  11. data/lib/asciidoctor/iec/isostandard.rng +11 -0
  12. data/lib/isodoc/iec/html/htmlstyle.css +9 -5
  13. data/lib/isodoc/iec/html/htmlstyle.scss +4 -4
  14. data/lib/isodoc/iec/html/isodoc.css +79 -79
  15. data/lib/isodoc/iec/html/isodoc.scss +79 -79
  16. data/lib/isodoc/iec/html/wordstyle.css +120 -120
  17. data/lib/isodoc/iec/html/wordstyle.scss +120 -120
  18. data/lib/isodoc/iec/html_convert.rb +8 -0
  19. data/lib/isodoc/iec/i18n-en.yaml +17 -0
  20. data/lib/isodoc/iec/i18n-fr.yaml +18 -0
  21. data/lib/isodoc/iec/iec.international-standard.xsl +827 -384
  22. data/lib/isodoc/iec/metadata.rb +33 -0
  23. data/lib/isodoc/iec/presentation_xml_convert.rb +12 -0
  24. data/lib/isodoc/iec/word_convert.rb +10 -0
  25. data/lib/metanorma/iec/processor.rb +11 -8
  26. data/lib/metanorma/iec/version.rb +1 -1
  27. data/metanorma-iec.gemspec +1 -2
  28. data/spec/asciidoctor-iec/base_spec.rb +24 -1
  29. data/spec/asciidoctor-iec/blocks_spec.rb +1 -1
  30. data/spec/asciidoctor-iec/cleanup_spec.rb +7 -86
  31. data/spec/asciidoctor-iec/iev_spec.rb +3 -0
  32. data/spec/asciidoctor-iec/lists_spec.rb +6 -6
  33. data/spec/asciidoctor-iec/validate_spec.rb +15 -0
  34. data/spec/isodoc/i18n_spec.rb +36 -16
  35. data/spec/isodoc/iev_spec.rb +9 -65
  36. data/spec/isodoc/iso_spec.rb +2 -2
  37. data/spec/isodoc/metadata_spec.rb +57 -3
  38. data/spec/isodoc/ref_spec.rb +4 -7
  39. data/spec/spec_helper.rb +4 -1
  40. metadata +5 -21
  41. data/.github/workflows/macos.yml +0 -38
  42. data/.github/workflows/ubuntu.yml +0 -56
  43. data/.github/workflows/windows.yml +0 -40
@@ -20,6 +20,39 @@ module IsoDoc
20
20
  set(:revdate, revdate&.text)
21
21
  end
22
22
 
23
+ def doctype(isoxml, _out)
24
+ super
25
+ b = isoxml&.at(ns("//bibdata/ext/doctype#{NOLANG}"))&.text
26
+ b1 = isoxml&.at(ns("//bibdata/ext/doctype[@language = 'en']"))&.text || b
27
+ b1 and set(:doctype_en, status_print(b1))
28
+ b1 = isoxml&.at(ns("//bibdata/ext/doctype[@language = 'fr']"))&.text || b
29
+ b1 and set(:doctype_fr, status_print(b1))
30
+ docfunction(isoxml)
31
+ dochorizontal(isoxml)
32
+ end
33
+
34
+ def docfunction(isoxml)
35
+ b = isoxml&.at(ns("//bibdata/ext/function#{NOLANG}"))&.text || return
36
+ b and set(:function, status_print(b))
37
+ b1 = isoxml&.at(ns("//bibdata/ext/function#{currlang}"))&.text || b
38
+ b1 and set(:function_display, status_print(b1))
39
+ b1 = isoxml&.at(ns("//bibdata/ext/function[@language = 'en']"))&.text || b
40
+ b1 and set(:function_en, status_print(b1))
41
+ b1 = isoxml&.at(ns("//bibdata/ext/function[@language = 'fr']"))&.text || b
42
+ b1 and set(:function_fr, status_print(b1))
43
+ end
44
+
45
+ def dochorizontal(isoxml)
46
+ b = isoxml&.at(ns("//bibdata/ext/horizontal#{NOLANG}"))&.text || return
47
+ b and set(:horizontal, status_print(b))
48
+ b1 = isoxml&.at(ns("//bibdata/ext/horizontal#{currlang}"))&.text
49
+ b1 and set(:horizontal_display, status_print(b1))
50
+ b1 = isoxml&.at(ns("//bibdata/ext/horizontal[@language = 'en']"))&.text
51
+ b1 and set(:horizontal_en, status_print(b1))
52
+ b1 = isoxml&.at(ns("//bibdata/ext/horizontal[@language = 'fr']"))&.text
53
+ b1 and set(:horizontal_fr, status_print(b1))
54
+ end
55
+
23
56
  def unpublished(status)
24
57
  status.to_i > 0 && status.to_i < 60
25
58
  end
@@ -28,6 +28,18 @@ module IsoDoc
28
28
  call(f)
29
29
  end
30
30
 
31
+ def bibdata_i18n(b)
32
+ fr = IsoDoc::Iec::I18n.new("fr", "Latn")
33
+ en = IsoDoc::Iec::I18n.new("en", "Latn")
34
+ [{ lang: "en", i18n: en }, { lang: "fr", i18n: fr }].each do |v|
35
+ hash_translate(b, v[:i18n].get["doctype_dict"], "./ext/doctype", v[:lang])
36
+ hash_translate(b, v[:i18n].get["stage_dict"], "./status/stage", v[:lang])
37
+ hash_translate(b, v[:i18n].get["substage_dict"], "./status/substage", v[:lang])
38
+ hash_translate(b, v[:i18n].get["function_dict"], "./ext/function", v[:lang])
39
+ hash_translate(b, v[:i18n].get["horizontal_dict"], "./ext/horizontal", v[:lang])
40
+ end
41
+ end
42
+
31
43
  include Init
32
44
  end
33
45
  end
@@ -16,6 +16,10 @@ module IsoDoc
16
16
  bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Arial",sans-serif'),
17
17
  headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Arial",sans-serif'),
18
18
  monospacefont: '"Courier New",monospace',
19
+ normalfontsize: "10.0pt",
20
+ footnotefontsize: "8.0pt",
21
+ smallerfontsize: "8.0pt",
22
+ monospacefontsize: "9.0pt",
19
23
  }
20
24
  end
21
25
 
@@ -161,6 +165,12 @@ module IsoDoc
161
165
  b.replace(b.children)
162
166
  end
163
167
 
168
+ def authority_cleanup(docxml)
169
+ auth = docxml.at("//div[@id = 'boilerplate-feedback' or @class = 'boilerplate-feedback']")
170
+ auth&.remove
171
+ super
172
+ end
173
+
164
174
  def make_body1(body, _docxml)
165
175
  end
166
176
 
@@ -2,14 +2,6 @@ require "metanorma/processor"
2
2
 
3
3
  module Metanorma
4
4
  module Iec
5
- def self.fonts_used
6
- {
7
- html: ["Arial", "Times New Roman", "HanSans", "Courier New"],
8
- doc: ["Arial", "Times New Roman", "HanSans", "Courier New"],
9
- pdf: ["Arial", "Times New Roman", "HanSans", "Courier New"],
10
- }
11
- end
12
-
13
5
  class Processor < Metanorma::Processor
14
6
 
15
7
  def initialize
@@ -26,6 +18,17 @@ module Metanorma
26
18
  )
27
19
  end
28
20
 
21
+ def fonts_manifest
22
+ {
23
+ "Arial" => nil,
24
+ "Times New Roman" => nil,
25
+ "STIX Two Math" => nil,
26
+ "Source Han Sans" => nil,
27
+ "Courier" => nil,
28
+ "Courier New" => nil,
29
+ }
30
+ end
31
+
29
32
  def version
30
33
  "Metanorma::Iec #{Metanorma::Iec::VERSION}"
31
34
  end
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Iec
3
- VERSION = "1.2.6"
3
+ VERSION = "1.2.11"
4
4
  end
5
5
  end
6
6
 
@@ -28,8 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
29
29
 
30
30
  spec.add_dependency "ruby-jing"
31
- spec.add_dependency "isodoc", "~> 1.2.0"
32
- spec.add_dependency "metanorma-iso", "~> 1.5.10"
31
+ spec.add_dependency "metanorma-iso", "~> 1.6.0"
33
32
 
34
33
  spec.add_development_dependency "byebug"
35
34
  spec.add_development_dependency "sassc", "2.4.0"
@@ -29,6 +29,8 @@ RSpec.describe Asciidoctor::Iec do
29
29
 
30
30
  it "converts a blank document" do
31
31
  FileUtils.rm_f "test.doc"
32
+ FileUtils.rm_f "test.html"
33
+ FileUtils.rm_f "test.pdf"
32
34
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
33
35
  = Document title
34
36
  Author
@@ -40,6 +42,8 @@ RSpec.describe Asciidoctor::Iec do
40
42
  <sections/>
41
43
  </iec-standard>
42
44
  OUTPUT
45
+ expect(File.exist?("test.pdf")).to be true
46
+ expect(File.exist?("test.html")).to be true
43
47
  expect(File.exist?("test.doc")).to be true
44
48
  expect(File.exist?("htmlstyle.css")).to be false
45
49
  end
@@ -87,6 +91,9 @@ RSpec.describe Asciidoctor::Iec do
87
91
  :title-main-fr: Titre Principal
88
92
  :title-part-fr: Part du Titre
89
93
  :library-ics: 1,2,3
94
+ :accessibility-color-inside: true
95
+ :price-code: XC
96
+ :cen-processing: true
90
97
  INPUT
91
98
  <?xml version="1.0" encoding="UTF-8"?>
92
99
  <iec-standard xmlns="https://www.metanorma.org/ns/iec" type="semantic" version="#{Metanorma::Iec::VERSION}">
@@ -138,6 +145,7 @@ RSpec.describe Asciidoctor::Iec do
138
145
  </copyright>
139
146
  <ext>
140
147
  <doctype>article</doctype>
148
+ <horizontal>false</horizontal>
141
149
  <editorialgroup>
142
150
  <technical-committee number="1" type="A">TC</technical-committee>
143
151
  <technical-committee number="11" type="A1">TC1</technical-committee>
@@ -160,6 +168,9 @@ RSpec.describe Asciidoctor::Iec do
160
168
  <project-number part="1">IEC 1000</project-number>
161
169
  </structuredidentifier>
162
170
  <stagename>New work item proposal</stagename>
171
+ <accessibility-color-inside>true</accessibility-color-inside>
172
+ <price-code>XC</price-code>
173
+ <cen-processing>true</cen-processing>
163
174
  </ext>
164
175
  </bibdata>
165
176
  #{UNPUBLISHED_BOILERPLATE}
@@ -182,10 +193,12 @@ RSpec.describe Asciidoctor::Iec do
182
193
  :tc-docnumber: 2000
183
194
  :language: el
184
195
  :script: Grek
185
- :publisher: IEC,IETF,ISO
196
+ :publisher: IEC;IETF;ISO
186
197
  :copyright-year: 2001
187
198
  :docstage: A2CD
188
199
  :doctype: technical-specification
200
+ :function: emc
201
+ :horizontal: true
189
202
  INPUT
190
203
  <?xml version="1.0" encoding="UTF-8"?>
191
204
  <iec-standard xmlns="https://www.metanorma.org/ns/iec" type="semantic" version="#{Metanorma::Iec::VERSION}">
@@ -268,6 +281,8 @@ RSpec.describe Asciidoctor::Iec do
268
281
  </copyright>
269
282
  <ext>
270
283
  <doctype>technical-specification</doctype>
284
+ <horizontal>true</horizontal>
285
+ <function>emc</function>
271
286
  <editorialgroup>
272
287
  <technical-committee/>
273
288
  <subcommittee/>
@@ -372,6 +387,7 @@ RSpec.describe Asciidoctor::Iec do
372
387
  </copyright>
373
388
  <ext>
374
389
  <doctype>article</doctype>
390
+ <horizontal>false</horizontal>
375
391
  <editorialgroup>
376
392
  <technical-committee/>
377
393
  <subcommittee/>
@@ -436,6 +452,7 @@ OUTPUT
436
452
  </copyright>
437
453
  <ext>
438
454
  <doctype>article</doctype>
455
+ <horizontal>false</horizontal>
439
456
  <editorialgroup>
440
457
  <technical-committee/>
441
458
  <subcommittee/>
@@ -501,6 +518,7 @@ OUTPUT
501
518
  </copyright>
502
519
  <ext>
503
520
  <doctype>article</doctype>
521
+ <horizontal>false</horizontal>
504
522
  <editorialgroup>
505
523
  <technical-committee/>
506
524
  <subcommittee/>
@@ -527,6 +545,7 @@ OUTPUT
527
545
  :docfile: test.adoc
528
546
  :novalid:
529
547
  :no-isobib:
548
+ :no-pdf:
530
549
  INPUT
531
550
  html = File.read("test.html", encoding: "utf-8")
532
551
  expect(html).to match(%r{<script>})
@@ -540,6 +559,7 @@ OUTPUT
540
559
  :docfile: test.adoc
541
560
  :novalid:
542
561
  :no-isobib:
562
+ :no-pdf:
543
563
  INPUT
544
564
  html = File.read("test.html", encoding: "utf-8")
545
565
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
@@ -556,6 +576,7 @@ OUTPUT
556
576
  :novalid:
557
577
  :no-isobib:
558
578
  :script: Hans
579
+ :no-pdf:
559
580
  INPUT
560
581
  html = File.read("test.html", encoding: "utf-8")
561
582
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
@@ -575,6 +596,7 @@ OUTPUT
575
596
  :body-font: Zapf Chancery
576
597
  :header-font: Comic Sans
577
598
  :monospace-font: Andale Mono
599
+ :no-pdf:
578
600
  INPUT
579
601
  html = File.read("test.html", encoding: "utf-8")
580
602
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: Andale Mono;]m)
@@ -591,6 +613,7 @@ OUTPUT
591
613
  :docfile: test.adoc
592
614
  :novalid:
593
615
  :no-isobib:
616
+ :no-pdf:
594
617
  INPUT
595
618
  word = File.read("test.doc", encoding: "utf-8")
596
619
  html = File.read("test.html", encoding: "utf-8")
@@ -191,7 +191,7 @@ RSpec.describe Asciidoctor::Iec do
191
191
  #{BLANK_HDR}
192
192
  <sections>
193
193
  <admonition id="_" type="safety precautions"><name>Safety Precautions</name><p id="_">While werewolves are hardy community members, keep in mind the following dietary concerns:</p>
194
- <ol id="_" type="arabic">
194
+ <ol id="_">
195
195
  <li>
196
196
  <p id="_">They are allergic to cinnamon.</p>
197
197
  </li>
@@ -104,7 +104,7 @@ RSpec.describe Asciidoctor::Iec do
104
104
  OUTPUT
105
105
  end
106
106
 
107
- it "strips any initial boilerplate from terms and definitions" do
107
+ it "keeps any initial boilerplate from terms and definitions" do
108
108
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
109
109
  #{ASCIIDOC_BLANK_HDR}
110
110
  == Terms and Definitions
@@ -123,7 +123,12 @@ RSpec.describe Asciidoctor::Iec do
123
123
  <p id="_">For the purposes of this document,
124
124
  the following terms and definitions apply.</p>
125
125
  #{TERMS_BOILERPLATE}
126
-
126
+ <p id='_'>I am boilerplate</p>
127
+ <ul id='_'>
128
+ <li>
129
+ <p id='_'>So am I</p>
130
+ </li>
131
+ </ul>
127
132
  <term id="term-time">
128
133
  <preferred>Time</preferred>
129
134
  <definition><p id="_">This paragraph is extraneous</p></definition>
@@ -266,65 +271,6 @@ RSpec.describe Asciidoctor::Iec do
266
271
  OUTPUT
267
272
  end
268
273
 
269
- it "moves table key inside table" do
270
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
271
- #{ASCIIDOC_BLANK_HDR}
272
- |===
273
- |a |b |c
274
- |===
275
-
276
- Key
277
-
278
- a:: b
279
- INPUT
280
- #{BLANK_HDR}
281
- <sections><table id="_">
282
- <tbody>
283
- <tr>
284
- <td valign="top" align="left">a</td>
285
- <td valign="top" align="left">b</td>
286
- <td valign="top" align="left">c</td>
287
- </tr>
288
- </tbody>
289
- <dl id="_">
290
- <dt>a</dt>
291
- <dd>
292
- <p id="_">b</p>
293
- </dd>
294
- </dl></table>
295
-
296
- </sections>
297
- </iec-standard>
298
- OUTPUT
299
- end
300
-
301
- it "moves formula key inside formula" do
302
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
303
- #{ASCIIDOC_BLANK_HDR}
304
- [stem]
305
- ++++
306
- Formula
307
- ++++
308
-
309
- where
310
-
311
- a:: b
312
- INPUT
313
- #{BLANK_HDR}
314
- <sections><formula id="_">
315
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>F</mi><mi>or</mi><mi>μ</mi><mi>l</mi><mi>a</mi></math></stem>
316
- <dl id="_">
317
- <dt>a</dt>
318
- <dd>
319
- <p id="_">b</p>
320
- </dd>
321
- </dl></formula>
322
-
323
- </sections>
324
- </iec-standard>
325
- OUTPUT
326
- end
327
-
328
274
  it "moves footnotes inside figures" do
329
275
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
330
276
  #{ASCIIDOC_BLANK_HDR}
@@ -349,31 +295,6 @@ RSpec.describe Asciidoctor::Iec do
349
295
  OUTPUT
350
296
  end
351
297
 
352
- it "moves figure key inside figure" do
353
- expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
354
- #{ASCIIDOC_BLANK_HDR}
355
- image::spec/examples/rice_images/rice_image1.png[]
356
-
357
- Key
358
-
359
- a:: b
360
- INPUT
361
- #{BLANK_HDR}
362
- <sections><figure id="_">
363
- <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="auto" width="auto"/>
364
- <dl id="_">
365
- <dt>a</dt>
366
- <dd>
367
- <p id="_">b</p>
368
- </dd>
369
- </dl></figure>
370
-
371
- </sections>
372
-
373
- </iec-standard>
374
- OUTPUT
375
- end
376
-
377
298
  it "defaults section obligations" do
378
299
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
379
300
  #{ASCIIDOC_BLANK_HDR}
@@ -53,6 +53,7 @@ RSpec.describe Asciidoctor::Iec do
53
53
  </copyright>
54
54
  <ext>
55
55
  <doctype>article</doctype>
56
+ <horizontal>false</horizontal>
56
57
  <editorialgroup>
57
58
  <technical-committee/>
58
59
  <subcommittee/>
@@ -131,6 +132,7 @@ INPUT
131
132
  </copyright>
132
133
  <ext>
133
134
  <doctype>article</doctype>
135
+ <horizontal>false</horizontal>
134
136
  <editorialgroup>
135
137
  <technical-committee/>
136
138
  <subcommittee/>
@@ -209,6 +211,7 @@ OUTPUT
209
211
  </copyright>
210
212
  <ext>
211
213
  <doctype>article</doctype>
214
+ <horizontal>false</horizontal>
212
215
  <editorialgroup>
213
216
  <technical-committee/>
214
217
  <subcommittee/>
@@ -28,7 +28,7 @@ RSpec.describe Asciidoctor::Iec do
28
28
  </li>
29
29
  <li>
30
30
  <p id="_">List 3</p>
31
- <ol id="_" type="arabic">
31
+ <ol id="_">
32
32
  <li>
33
33
  <p id="_">List A</p>
34
34
  </li>
@@ -107,13 +107,13 @@ RSpec.describe Asciidoctor::Iec do
107
107
  <li><p id="_">Second</p><p id="_">entry1</p>
108
108
  <p id="_">entry2</p></li>
109
109
  </ul>
110
- <ol id="id1" type="alphabet">
110
+ <ol id="id1">
111
111
  <li>
112
112
  <p id="_">First</p>
113
113
  </li>
114
114
  <li>
115
115
  <p id="_">Second</p>
116
- <ol id="_" type="alphabet_upper">
116
+ <ol id="_">
117
117
  <li>
118
118
  <p id="_">Third</p>
119
119
  </li>
@@ -129,19 +129,19 @@ RSpec.describe Asciidoctor::Iec do
129
129
  <p id="_">Sixth</p>
130
130
  </li>
131
131
  </ol>
132
- <ol id="_" type="roman">
132
+ <ol id="_">
133
133
  <li>
134
134
  <p id="_">A</p>
135
135
  </li>
136
136
  <li>
137
137
  <p id="_">B</p>
138
- <ol id="_" type="roman_upper">
138
+ <ol id="_">
139
139
  <li>
140
140
  <p id="_">C</p>
141
141
  </li>
142
142
  <li>
143
143
  <p id="_">D</p>
144
- <ol id="_" type="arabic">
144
+ <ol id="_">
145
145
  <li>
146
146
  <p id="_">E</p>
147
147
  </li>