metanorma-iec 1.2.8 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +4 -5
  3. data/lib/asciidoctor/iec/converter.rb +5 -1
  4. data/lib/asciidoctor/iec/front.rb +6 -0
  5. data/lib/asciidoctor/iec/iec.rng +36 -1
  6. data/lib/asciidoctor/iec/iec_intro_en.xml +82 -53
  7. data/lib/asciidoctor/iec/iec_intro_fr.xml +44 -20
  8. data/lib/asciidoctor/iec/isostandard.rng +8 -0
  9. data/lib/isodoc/iec/html/htmlstyle.css +5 -5
  10. data/lib/isodoc/iec/html/htmlstyle.scss +4 -4
  11. data/lib/isodoc/iec/html/isodoc.css +79 -79
  12. data/lib/isodoc/iec/html/isodoc.scss +79 -79
  13. data/lib/isodoc/iec/html/wordstyle.css +120 -120
  14. data/lib/isodoc/iec/html/wordstyle.scss +120 -120
  15. data/lib/isodoc/iec/html_convert.rb +8 -0
  16. data/lib/isodoc/iec/i18n-en.yaml +16 -0
  17. data/lib/isodoc/iec/i18n-fr.yaml +17 -0
  18. data/lib/isodoc/iec/iec.international-standard.xsl +313 -213
  19. data/lib/isodoc/iec/metadata.rb +33 -0
  20. data/lib/isodoc/iec/presentation_xml_convert.rb +12 -0
  21. data/lib/isodoc/iec/word_convert.rb +10 -0
  22. data/lib/metanorma/iec/fonts_manifest.yaml +5 -0
  23. data/lib/metanorma/iec/processor.rb +0 -8
  24. data/lib/metanorma/iec/version.rb +1 -1
  25. data/metanorma-iec.gemspec +0 -1
  26. data/spec/asciidoctor-iec/base_spec.rb +8 -0
  27. data/spec/asciidoctor-iec/blocks_spec.rb +1 -1
  28. data/spec/asciidoctor-iec/iev_spec.rb +3 -0
  29. data/spec/asciidoctor-iec/lists_spec.rb +6 -6
  30. data/spec/asciidoctor-iec/validate_spec.rb +15 -0
  31. data/spec/isodoc/i18n_spec.rb +30 -0
  32. data/spec/isodoc/iso_spec.rb +2 -2
  33. data/spec/isodoc/metadata_spec.rb +23 -1
  34. data/spec/spec_helper.rb +4 -1
  35. metadata +3 -16
@@ -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.8"
3
+ VERSION = "1.2.9"
4
4
  end
5
5
  end
6
6
 
@@ -28,7 +28,6 @@ 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
31
  spec.add_dependency "metanorma-iso", "~> 1.5.10"
33
32
 
34
33
  spec.add_development_dependency "byebug"
@@ -142,6 +142,7 @@ RSpec.describe Asciidoctor::Iec do
142
142
  </copyright>
143
143
  <ext>
144
144
  <doctype>article</doctype>
145
+ <horizontal>false</horizontal>
145
146
  <editorialgroup>
146
147
  <technical-committee number="1" type="A">TC</technical-committee>
147
148
  <technical-committee number="11" type="A1">TC1</technical-committee>
@@ -190,6 +191,8 @@ RSpec.describe Asciidoctor::Iec do
190
191
  :copyright-year: 2001
191
192
  :docstage: A2CD
192
193
  :doctype: technical-specification
194
+ :function: emc
195
+ :horizontal: true
193
196
  INPUT
194
197
  <?xml version="1.0" encoding="UTF-8"?>
195
198
  <iec-standard xmlns="https://www.metanorma.org/ns/iec" type="semantic" version="#{Metanorma::Iec::VERSION}">
@@ -272,6 +275,8 @@ RSpec.describe Asciidoctor::Iec do
272
275
  </copyright>
273
276
  <ext>
274
277
  <doctype>technical-specification</doctype>
278
+ <horizontal>true</horizontal>
279
+ <function>emc</function>
275
280
  <editorialgroup>
276
281
  <technical-committee/>
277
282
  <subcommittee/>
@@ -376,6 +381,7 @@ RSpec.describe Asciidoctor::Iec do
376
381
  </copyright>
377
382
  <ext>
378
383
  <doctype>article</doctype>
384
+ <horizontal>false</horizontal>
379
385
  <editorialgroup>
380
386
  <technical-committee/>
381
387
  <subcommittee/>
@@ -440,6 +446,7 @@ OUTPUT
440
446
  </copyright>
441
447
  <ext>
442
448
  <doctype>article</doctype>
449
+ <horizontal>false</horizontal>
443
450
  <editorialgroup>
444
451
  <technical-committee/>
445
452
  <subcommittee/>
@@ -505,6 +512,7 @@ OUTPUT
505
512
  </copyright>
506
513
  <ext>
507
514
  <doctype>article</doctype>
515
+ <horizontal>false</horizontal>
508
516
  <editorialgroup>
509
517
  <technical-committee/>
510
518
  <subcommittee/>
@@ -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>
@@ -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>
@@ -37,4 +37,19 @@ it "Warns of illegal doctype" do
37
37
  INPUT
38
38
  expect(File.read("test.err")).to include "pizza is not a recognised document type"
39
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
40
55
  end
@@ -7,6 +7,11 @@ RSpec.describe IsoDoc do
7
7
  <bibdata>
8
8
  <docnumber>1</docnumber>
9
9
  <language>en</language>
10
+ <ext>
11
+ <doctype>international-standard</doctype>
12
+ <horizontal>true</horizontal>
13
+ <function>emc</function>
14
+ </ext>
10
15
  </bibdata>
11
16
  <preface>
12
17
  <foreword obligation="informative">
@@ -77,6 +82,17 @@ RSpec.describe IsoDoc do
77
82
  <bibdata>
78
83
  <docnumber>1</docnumber>
79
84
  <language current="true">en</language>
85
+ <ext>
86
+ <doctype language=''>international-standard</doctype>
87
+ <doctype language='fr'>Norme international</doctype>
88
+ <doctype language='en'>International Standard</doctype>
89
+ <horizontal language=''>true</horizontal>
90
+ <horizontal language='fr'>Norme horizontale</horizontal>
91
+ <horizontal language='en'>Horizontal Standard</horizontal>
92
+ <function language=''>emc</function>
93
+ <function language='fr'>Publication fondamentale en CEM</function>
94
+ <function language='en'>Basic EMC Publication</function>
95
+ </ext>
80
96
  </bibdata>
81
97
  <preface>
82
98
  <foreword obligation="informative">
@@ -432,6 +448,11 @@ RSpec.describe IsoDoc do
432
448
  <iso-standard xmlns="http://riboseinc.com/isoxml">
433
449
  <bibdata>
434
450
  <language>fr</language>
451
+ <ext>
452
+ <doctype>international-standard</doctype>
453
+ <horizontal>false</horizontal>
454
+ <function>emc</function>
455
+ </ext>
435
456
  </bibdata>
436
457
  <preface>
437
458
  <foreword obligation="informative">
@@ -501,6 +522,15 @@ RSpec.describe IsoDoc do
501
522
  <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
502
523
  <bibdata>
503
524
  <language current="true">fr</language>
525
+ <ext>
526
+ <doctype language=''>international-standard</doctype>
527
+ <doctype language='fr'>Norme international</doctype>
528
+ <doctype language='en'>International Standard</doctype>
529
+ <horizontal language=''>false</horizontal>
530
+ <function language=''>emc</function>
531
+ <function language='fr'>Publication fondamentale en CEM</function>
532
+ <function language='en'>Basic EMC Publication</function>
533
+ </ext>
504
534
  </bibdata>
505
535
  <preface>
506
536
  <foreword obligation="informative">
@@ -65,9 +65,9 @@ RSpec.describe IsoDoc::Iec do
65
65
  </iso-standard>
66
66
  INPUT
67
67
  html = File.read("test.doc", encoding: "utf-8")
68
- expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New",monospace;]m)
68
+ expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
69
69
  expect(html).to match(%r[Quote[^{]+\{[^{]+font-family: "Arial", sans-serif;]m)
70
- expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Arial",sans-serif;]m)
70
+ expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Arial", sans-serif;]m)
71
71
  end
72
72
 
73
73
  it "processes examples" do
@@ -59,7 +59,15 @@ RSpec.describe IsoDoc::Iec::Metadata do
59
59
  </owner>
60
60
  </copyright>
61
61
  <ext>
62
- <doctype>international-standard</doctype>
62
+ <doctype language=''>international-standard</doctype>
63
+ <doctype language='fr'>Norme international</doctype>
64
+ <doctype language='en'>International Standard</doctype>
65
+ <horizontal language=''>true</horizontal>
66
+ <horizontal language='fr'>Norme horizontale</horizontal>
67
+ <horizontal language='en'>Horizontal Standard</horizontal>
68
+ <function language=''>emc</function>
69
+ <function language='fr'>Publication fondamentale en CEM</function>
70
+ <function language='en'>Basic EMC Publication</function>
63
71
  <editorialgroup>
64
72
  <technical-committee number="34">Food products</technical-committee>
65
73
  <subcommittee number="4">Cereals and pulses</subcommittee>
@@ -94,11 +102,21 @@ INPUT
94
102
  :doctitlepartlabel=>"Part&nbsp;1",
95
103
  :doctype=>"International Standard",
96
104
  :doctype_display=>"International Standard",
105
+ :doctype_en=>"International Standard",
106
+ :doctype_fr=>"Norme International",
97
107
  :docyear=>"2016",
98
108
  :draft=>"0.4",
99
109
  :draftinfo=>" (draft 0.4, 2016-05-01)",
100
110
  :edition=>"2",
101
111
  :editorialgroup=>["TC 34", "SC 4", "WG 3"],
112
+ :function=>"Emc",
113
+ :function_display=>"Basic Emc Publication",
114
+ :function_en=>"Basic Emc Publication",
115
+ :function_fr=>"Publication Fondamentale En Cem",
116
+ :horizontal=>"True",
117
+ :horizontal_display=>"Horizontal Standard",
118
+ :horizontal_en=>"Horizontal Standard",
119
+ :horizontal_fr=>"Norme Horizontale",
102
120
  :implementeddate=>"XXX",
103
121
  :issueddate=>"XXX",
104
122
  :lang=>"en",
@@ -188,6 +206,7 @@ OUTPUT
188
206
  </relation>
189
207
  <ext>
190
208
  <doctype>technical-report</doctype>
209
+ <horizontal>false</horizontal>
191
210
  <editorialgroup>
192
211
  <technical-committee number="34" type="ABC">Food products</technical-committee>
193
212
  <subcommittee number="4" type="DEF">Cereals and pulses</subcommittee>
@@ -221,8 +240,11 @@ INPUT
221
240
  :doctitlepartlabel=>"Part&nbsp;1&ndash;3",
222
241
  :doctype=>"Technical Report",
223
242
  :doctype_display=>"Technical Report",
243
+ :doctype_en=>"Technical Report",
244
+ :doctype_fr=>"Technical Report",
224
245
  :docyear=>"2016",
225
246
  :editorialgroup=>["ABC 34", "DEF 4", "GHI 3"],
247
+ :horizontal=>"False",
226
248
  :ics=>"1.2.3, 1.2.3",
227
249
  :implementeddate=>"XXX",
228
250
  :issueddate=>"XXX",
@@ -119,7 +119,9 @@ BOILERPLATE =
119
119
  gsub(/\{% if unpublished %\}.*\{% endif %\}/m, "").
120
120
  gsub(/(?<=\p{Alnum})'(?=\p{Alpha})/, "’").
121
121
  gsub(/<p>/, "<p id='_'>").
122
- gsub(/<ol>/, "<ol id='_'>")
122
+ gsub(/<ol>/, "<ol id='_'>").
123
+ gsub(/ - /, " — ").
124
+ gsub(/\.\.\./, "…")
123
125
  )
124
126
 
125
127
  BOILERPLATE_LICENSE = <<~END
@@ -178,6 +180,7 @@ BLANK_HDR = <<~"HDR"
178
180
  </copyright>
179
181
  <ext>
180
182
  <doctype>article</doctype>
183
+ <horizontal>false</horizontal>
181
184
  <editorialgroup>
182
185
  <technical-committee/>
183
186
  <subcommittee/>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-09 00:00:00.000000000 Z
11
+ date: 2020-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-jing
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: isodoc
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 1.2.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 1.2.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: metanorma-iso
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -263,6 +249,7 @@ files:
263
249
  - lib/isodoc/iec/xref.rb
264
250
  - lib/metanorma-iec.rb
265
251
  - lib/metanorma/iec.rb
252
+ - lib/metanorma/iec/fonts_manifest.yaml
266
253
  - lib/metanorma/iec/processor.rb
267
254
  - lib/metanorma/iec/version.rb
268
255
  - metanorma-iec.gemspec