metanorma-iec 1.2.5 → 1.2.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) 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 +32 -0
  5. data/lib/asciidoctor/iec/converter.rb +6 -1
  6. data/lib/asciidoctor/iec/front.rb +17 -3
  7. data/lib/asciidoctor/iec/iec.rng +52 -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 +29 -44
  11. data/lib/asciidoctor/iec/isostandard.rng +11 -0
  12. data/lib/isodoc/iec/html/htmlstyle.css +10 -6
  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 +782 -301
  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/fonts_manifest.yaml +5 -0
  26. data/lib/metanorma/iec/processor.rb +0 -8
  27. data/lib/metanorma/iec/version.rb +1 -1
  28. data/metanorma-iec.gemspec +1 -2
  29. data/spec/asciidoctor-iec/base_spec.rb +21 -0
  30. data/spec/asciidoctor-iec/blocks_spec.rb +1 -1
  31. data/spec/asciidoctor-iec/cleanup_spec.rb +0 -84
  32. data/spec/asciidoctor-iec/iev_spec.rb +3 -0
  33. data/spec/asciidoctor-iec/lists_spec.rb +6 -6
  34. data/spec/asciidoctor-iec/validate_spec.rb +36 -1
  35. data/spec/assets/xref_error.adoc +7 -0
  36. data/spec/isodoc/i18n_spec.rb +36 -16
  37. data/spec/isodoc/iev_spec.rb +9 -65
  38. data/spec/isodoc/iso_spec.rb +2 -2
  39. data/spec/isodoc/metadata_spec.rb +59 -24
  40. data/spec/isodoc/ref_spec.rb +4 -7
  41. data/spec/spec_helper.rb +8 -1
  42. metadata +7 -21
  43. data/.github/workflows/macos.yml +0 -38
  44. data/.github/workflows/ubuntu.yml +0 -56
  45. 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
 
@@ -0,0 +1,5 @@
1
+ ---
2
+ Arial:
3
+ Times New Roman:
4
+ Source Han Sans:
5
+ Courier New:
@@ -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
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Iec
3
- VERSION = "1.2.5"
3
+ VERSION = "1.2.10"
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.9"
31
+ spec.add_dependency "metanorma-iso", "~> 1.5.10"
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,8 @@ 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
90
96
  INPUT
91
97
  <?xml version="1.0" encoding="UTF-8"?>
92
98
  <iec-standard xmlns="https://www.metanorma.org/ns/iec" type="semantic" version="#{Metanorma::Iec::VERSION}">
@@ -138,6 +144,7 @@ RSpec.describe Asciidoctor::Iec do
138
144
  </copyright>
139
145
  <ext>
140
146
  <doctype>article</doctype>
147
+ <horizontal>false</horizontal>
141
148
  <editorialgroup>
142
149
  <technical-committee number="1" type="A">TC</technical-committee>
143
150
  <technical-committee number="11" type="A1">TC1</technical-committee>
@@ -160,6 +167,8 @@ RSpec.describe Asciidoctor::Iec do
160
167
  <project-number part="1">IEC 1000</project-number>
161
168
  </structuredidentifier>
162
169
  <stagename>New work item proposal</stagename>
170
+ <accessibility-color-inside>true</accessibility-color-inside>
171
+ <price-code>XC</price-code>
163
172
  </ext>
164
173
  </bibdata>
165
174
  #{UNPUBLISHED_BOILERPLATE}
@@ -186,6 +195,8 @@ RSpec.describe Asciidoctor::Iec do
186
195
  :copyright-year: 2001
187
196
  :docstage: A2CD
188
197
  :doctype: technical-specification
198
+ :function: emc
199
+ :horizontal: true
189
200
  INPUT
190
201
  <?xml version="1.0" encoding="UTF-8"?>
191
202
  <iec-standard xmlns="https://www.metanorma.org/ns/iec" type="semantic" version="#{Metanorma::Iec::VERSION}">
@@ -268,6 +279,8 @@ RSpec.describe Asciidoctor::Iec do
268
279
  </copyright>
269
280
  <ext>
270
281
  <doctype>technical-specification</doctype>
282
+ <horizontal>true</horizontal>
283
+ <function>emc</function>
271
284
  <editorialgroup>
272
285
  <technical-committee/>
273
286
  <subcommittee/>
@@ -372,6 +385,7 @@ RSpec.describe Asciidoctor::Iec do
372
385
  </copyright>
373
386
  <ext>
374
387
  <doctype>article</doctype>
388
+ <horizontal>false</horizontal>
375
389
  <editorialgroup>
376
390
  <technical-committee/>
377
391
  <subcommittee/>
@@ -436,6 +450,7 @@ OUTPUT
436
450
  </copyright>
437
451
  <ext>
438
452
  <doctype>article</doctype>
453
+ <horizontal>false</horizontal>
439
454
  <editorialgroup>
440
455
  <technical-committee/>
441
456
  <subcommittee/>
@@ -501,6 +516,7 @@ OUTPUT
501
516
  </copyright>
502
517
  <ext>
503
518
  <doctype>article</doctype>
519
+ <horizontal>false</horizontal>
504
520
  <editorialgroup>
505
521
  <technical-committee/>
506
522
  <subcommittee/>
@@ -527,6 +543,7 @@ OUTPUT
527
543
  :docfile: test.adoc
528
544
  :novalid:
529
545
  :no-isobib:
546
+ :no-pdf:
530
547
  INPUT
531
548
  html = File.read("test.html", encoding: "utf-8")
532
549
  expect(html).to match(%r{<script>})
@@ -540,6 +557,7 @@ OUTPUT
540
557
  :docfile: test.adoc
541
558
  :novalid:
542
559
  :no-isobib:
560
+ :no-pdf:
543
561
  INPUT
544
562
  html = File.read("test.html", encoding: "utf-8")
545
563
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
@@ -556,6 +574,7 @@ OUTPUT
556
574
  :novalid:
557
575
  :no-isobib:
558
576
  :script: Hans
577
+ :no-pdf:
559
578
  INPUT
560
579
  html = File.read("test.html", encoding: "utf-8")
561
580
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
@@ -575,6 +594,7 @@ OUTPUT
575
594
  :body-font: Zapf Chancery
576
595
  :header-font: Comic Sans
577
596
  :monospace-font: Andale Mono
597
+ :no-pdf:
578
598
  INPUT
579
599
  html = File.read("test.html", encoding: "utf-8")
580
600
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: Andale Mono;]m)
@@ -591,6 +611,7 @@ OUTPUT
591
611
  :docfile: test.adoc
592
612
  :novalid:
593
613
  :no-isobib:
614
+ :no-pdf:
594
615
  INPUT
595
616
  word = File.read("test.doc", encoding: "utf-8")
596
617
  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>
@@ -266,65 +266,6 @@ RSpec.describe Asciidoctor::Iec do
266
266
  OUTPUT
267
267
  end
268
268
 
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
269
  it "moves footnotes inside figures" do
329
270
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
330
271
  #{ASCIIDOC_BLANK_HDR}
@@ -349,31 +290,6 @@ RSpec.describe Asciidoctor::Iec do
349
290
  OUTPUT
350
291
  end
351
292
 
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
293
  it "defaults section obligations" do
378
294
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
379
295
  #{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>
@@ -2,10 +2,30 @@ require "spec_helper"
2
2
  require "fileutils"
3
3
 
4
4
  RSpec.describe Asciidoctor::Iec do
5
+ context "when xref_error.adoc compilation" do
6
+ around do |example|
7
+ FileUtils.rm_f "spec/assets/xref_error.err"
8
+ example.run
9
+ Dir["spec/assets/xref_error*"].each do |file|
10
+ next if file.match?(/adoc$/)
11
+
12
+ FileUtils.rm_f(file)
13
+ end
14
+ end
15
+
16
+ it "generates error file" do
17
+ expect do
18
+ Metanorma::Compile
19
+ .new
20
+ .compile("spec/assets/xref_error.adoc", type: "iec")
21
+ end.to(change { File.exist?("spec/assets/xref_error.err") }
22
+ .from(false).to(true))
23
+ end
24
+ end
5
25
 
6
26
  it "Warns of illegal doctype" do
7
27
  FileUtils.rm_f "test.err"
8
- Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
28
+ Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
9
29
  = Document title
10
30
  Author
11
31
  :docfile: test.adoc
@@ -17,4 +37,19 @@ it "Warns of illegal doctype" do
17
37
  INPUT
18
38
  expect(File.read("test.err")).to include "pizza is not a recognised document type"
19
39
  end
40
+
41
+ it "Warns of illegal function" do
42
+ FileUtils.rm_f "test.err"
43
+ Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
44
+ = Document title
45
+ Author
46
+ :docfile: test.adoc
47
+ :nodoc:
48
+ :no-isobib:
49
+ :function: pizza
50
+
51
+ text
52
+ INPUT
53
+ expect(File.read("test.err")).to include "pizza is not a recognised document function"
54
+ end
20
55
  end