metanorma-iec 1.2.7 → 1.2.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +29 -8
  3. data/README.adoc +3 -4
  4. data/lib/asciidoctor/iec/basicdoc.rng +50 -3
  5. data/lib/asciidoctor/iec/converter.rb +22 -1
  6. data/lib/asciidoctor/iec/front.rb +18 -7
  7. data/lib/asciidoctor/iec/iec.rng +81 -1
  8. data/lib/asciidoctor/iec/iec_intro_en.xml +110 -56
  9. data/lib/asciidoctor/iec/iec_intro_fr.xml +78 -22
  10. data/lib/asciidoctor/iec/isodoc.rng +61 -3
  11. data/lib/asciidoctor/iec/isostandard.rng +27 -10
  12. data/lib/isodoc/iec/base_convert.rb +2 -2
  13. data/lib/isodoc/iec/html/htmlstyle.css +5 -5
  14. data/lib/isodoc/iec/html/htmlstyle.scss +4 -4
  15. data/lib/isodoc/iec/html/isodoc.css +79 -79
  16. data/lib/isodoc/iec/html/isodoc.scss +79 -79
  17. data/lib/isodoc/iec/html/wordstyle.css +120 -120
  18. data/lib/isodoc/iec/html/wordstyle.scss +120 -120
  19. data/lib/isodoc/iec/html_convert.rb +8 -0
  20. data/lib/isodoc/iec/i18n-en.yaml +17 -0
  21. data/lib/isodoc/iec/i18n-fr.yaml +18 -0
  22. data/lib/isodoc/iec/iec.international-standard.xsl +817 -382
  23. data/lib/isodoc/iec/metadata.rb +33 -0
  24. data/lib/isodoc/iec/presentation_xml_convert.rb +12 -0
  25. data/lib/isodoc/iec/word_convert.rb +10 -0
  26. data/lib/metanorma/iec/processor.rb +11 -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 +429 -8
  30. data/spec/asciidoctor-iec/blocks_spec.rb +25 -21
  31. data/spec/asciidoctor-iec/cleanup_spec.rb +99 -98
  32. data/spec/asciidoctor-iec/iev_spec.rb +15 -6
  33. data/spec/asciidoctor-iec/inline_spec.rb +11 -7
  34. data/spec/asciidoctor-iec/lists_spec.rb +13 -9
  35. data/spec/asciidoctor-iec/section_spec.rb +9 -5
  36. data/spec/asciidoctor-iec/validate_spec.rb +15 -0
  37. data/spec/isodoc/i18n_spec.rb +30 -0
  38. data/spec/isodoc/iso_spec.rb +2 -2
  39. data/spec/isodoc/metadata_spec.rb +23 -1
  40. data/spec/isodoc/ref_spec.rb +2 -2
  41. data/spec/metanorma/processor_spec.rb +1 -1
  42. data/spec/spec_helper.rb +20 -31
  43. metadata +4 -18
@@ -2,6 +2,12 @@ require "spec_helper"
2
2
  require "fileutils"
3
3
 
4
4
  RSpec.describe Asciidoctor::Iec do
5
+ before(:all) do
6
+ @boilerplate = boilerplate(Nokogiri::XML(BLANK_HDR + "</iec-standard>"))
7
+ end
8
+
9
+
10
+
5
11
  it "generates reference boilerplate for IEV" do
6
12
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
7
13
  = Document title
@@ -43,7 +49,7 @@ RSpec.describe Asciidoctor::Iec do
43
49
  <substage abbreviation="PPUB">60</substage>
44
50
  </status>
45
51
  <copyright>
46
- <from>2020</from>
52
+ <from>#{Time.now.year}</from>
47
53
  <owner>
48
54
  <organization>
49
55
  <name>International Electrotechnical Commission</name>
@@ -53,6 +59,7 @@ RSpec.describe Asciidoctor::Iec do
53
59
  </copyright>
54
60
  <ext>
55
61
  <doctype>article</doctype>
62
+ <horizontal>false</horizontal>
56
63
  <editorialgroup>
57
64
  <technical-committee/>
58
65
  <subcommittee/>
@@ -64,7 +71,7 @@ RSpec.describe Asciidoctor::Iec do
64
71
  <stagename>International standard</stagename>
65
72
  </ext>
66
73
  </bibdata>
67
- #{BOILERPLATE}
74
+ #{@boilerplate}
68
75
  <sections> </sections>
69
76
  <bibliography>
70
77
  <references id='_' obligation='informative' normative="true">
@@ -121,7 +128,7 @@ INPUT
121
128
  <substage abbreviation="PPUB">60</substage>
122
129
  </status>
123
130
  <copyright>
124
- <from>2020</from>
131
+ <from>#{Time.now.year}</from>
125
132
  <owner>
126
133
  <organization>
127
134
  <name>International Electrotechnical Commission</name>
@@ -131,6 +138,7 @@ INPUT
131
138
  </copyright>
132
139
  <ext>
133
140
  <doctype>article</doctype>
141
+ <horizontal>false</horizontal>
134
142
  <editorialgroup>
135
143
  <technical-committee/>
136
144
  <subcommittee/>
@@ -142,7 +150,7 @@ INPUT
142
150
  <stagename>International standard</stagename>
143
151
  </ext>
144
152
  </bibdata>
145
- #{BOILERPLATE}
153
+ #{@boilerplate}
146
154
  <sections>
147
155
  <clause id='_' obligation='normative'>
148
156
  <title>Terms and definitions</title>
@@ -199,7 +207,7 @@ OUTPUT
199
207
  <substage abbreviation='PPUB'>60</substage>
200
208
  </status>
201
209
  <copyright>
202
- <from>2020</from>
210
+ <from>#{Time.now.year}</from>
203
211
  <owner>
204
212
  <organization>
205
213
  <name>International Electrotechnical Commission</name>
@@ -209,6 +217,7 @@ OUTPUT
209
217
  </copyright>
210
218
  <ext>
211
219
  <doctype>article</doctype>
220
+ <horizontal>false</horizontal>
212
221
  <editorialgroup>
213
222
  <technical-committee/>
214
223
  <subcommittee/>
@@ -220,7 +229,7 @@ OUTPUT
220
229
  <stagename>International standard</stagename>
221
230
  </ext>
222
231
  </bibdata>
223
- #{BOILERPLATE}
232
+ #{@boilerplate}
224
233
  <preface>
225
234
  <introduction id='_' obligation='informative'>
226
235
  <title>INTRODUCTION&lt;br/&gt;Principles and rules followed</title>
@@ -1,6 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe Asciidoctor::Iec do
4
+ before(:all) do
5
+ @blank_hdr = blank_hdr_gen
6
+ end
7
+
4
8
  it "processes inline_quoted formatting" do
5
9
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
6
10
  #{ASCIIDOC_BLANK_HDR}
@@ -19,7 +23,7 @@ RSpec.describe Asciidoctor::Iec do
19
23
  [strike]#strike#
20
24
  [smallcap]#smallcap#
21
25
  INPUT
22
- #{BLANK_HDR}
26
+ #{@blank_hdr}
23
27
  <sections>
24
28
  <em>emphasis</em>
25
29
  <strong>strong</strong>
@@ -56,7 +60,7 @@ RSpec.describe Asciidoctor::Iec do
56
60
 
57
61
  <<<
58
62
  INPUT
59
- #{BLANK_HDR}
63
+ #{@blank_hdr}
60
64
  <sections><p id="_">Line break<br/>
61
65
  line break</p>
62
66
  <hr/>
@@ -72,7 +76,7 @@ RSpec.describe Asciidoctor::Iec do
72
76
  http://example.com[]
73
77
  http://example.com[Link]
74
78
  INPUT
75
- #{BLANK_HDR}
79
+ #{@blank_hdr}
76
80
  <sections>
77
81
  <p id="_">mailto:fred@example.com
78
82
  <link target="http://example.com"/>
@@ -87,7 +91,7 @@ RSpec.describe Asciidoctor::Iec do
87
91
  #{ASCIIDOC_BLANK_HDR}
88
92
  Text [[bookmark]] Text
89
93
  INPUT
90
- #{BLANK_HDR}
94
+ #{@blank_hdr}
91
95
  <sections>
92
96
  <p id="_">Text <bookmark id="bookmark"/> Text</p>
93
97
  </sections>
@@ -106,7 +110,7 @@ RSpec.describe Asciidoctor::Iec do
106
110
  Inline Reference with Text to <<reference,text>>
107
111
  Footnoted Reference with Text to <<reference,fn: text>>
108
112
  INPUT
109
- #{BLANK_HDR}
113
+ #{@blank_hdr}
110
114
  <sections>
111
115
  <clause id="reference" inline-header="false" obligation="normative">
112
116
  <title>Section</title>
@@ -130,7 +134,7 @@ RSpec.describe Asciidoctor::Iec do
130
134
  * [[[ISO713]]] Reference
131
135
 
132
136
  INPUT
133
- #{BLANK_HDR}
137
+ #{@blank_hdr}
134
138
  <sections>
135
139
 
136
140
  </sections><bibliography><references id="_" obligation="informative" normative="true">
@@ -156,7 +160,7 @@ RSpec.describe Asciidoctor::Iec do
156
160
  #{ASCIIDOC_BLANK_HDR}
157
161
  Hello!footnote:[Footnote text]
158
162
  INPUT
159
- #{BLANK_HDR}
163
+ #{@blank_hdr}
160
164
  <sections>
161
165
  <p id="_">Hello!<fn reference="1">
162
166
  <p id="_">Footnote text</p>
@@ -1,6 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe Asciidoctor::Iec do
4
+ before(:all) do
5
+ @blank_hdr = blank_hdr_gen
6
+ end
7
+
4
8
  it "processes simple lists" do
5
9
  output = Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
6
10
  #{ASCIIDOC_BLANK_HDR}
@@ -17,7 +21,7 @@ RSpec.describe Asciidoctor::Iec do
17
21
 
18
22
  INPUT
19
23
  expect(xmlpp(strip_guid(output))).to be_equivalent_to xmlpp(<<~"OUTPUT")
20
- #{BLANK_HDR}
24
+ #{@blank_hdr}
21
25
  <sections>
22
26
  <ul id="_">
23
27
  <li>
@@ -28,7 +32,7 @@ RSpec.describe Asciidoctor::Iec do
28
32
  </li>
29
33
  <li>
30
34
  <p id="_">List 3</p>
31
- <ol id="_" type="arabic">
35
+ <ol id="_">
32
36
  <li>
33
37
  <p id="_">List A</p>
34
38
  </li>
@@ -99,7 +103,7 @@ RSpec.describe Asciidoctor::Iec do
99
103
 
100
104
  INPUT
101
105
  expect(xmlpp(strip_guid(output))).to be_equivalent_to xmlpp(<<~"OUTPUT")
102
- #{BLANK_HDR}
106
+ #{@blank_hdr}
103
107
  <sections><ul id="id">
104
108
  <li>
105
109
  <p id="_">First</p>
@@ -107,13 +111,13 @@ RSpec.describe Asciidoctor::Iec do
107
111
  <li><p id="_">Second</p><p id="_">entry1</p>
108
112
  <p id="_">entry2</p></li>
109
113
  </ul>
110
- <ol id="id1" type="alphabet">
114
+ <ol id="id1">
111
115
  <li>
112
116
  <p id="_">First</p>
113
117
  </li>
114
118
  <li>
115
119
  <p id="_">Second</p>
116
- <ol id="_" type="alphabet_upper">
120
+ <ol id="_">
117
121
  <li>
118
122
  <p id="_">Third</p>
119
123
  </li>
@@ -129,19 +133,19 @@ RSpec.describe Asciidoctor::Iec do
129
133
  <p id="_">Sixth</p>
130
134
  </li>
131
135
  </ol>
132
- <ol id="_" type="roman">
136
+ <ol id="_">
133
137
  <li>
134
138
  <p id="_">A</p>
135
139
  </li>
136
140
  <li>
137
141
  <p id="_">B</p>
138
- <ol id="_" type="roman_upper">
142
+ <ol id="_">
139
143
  <li>
140
144
  <p id="_">C</p>
141
145
  </li>
142
146
  <li>
143
147
  <p id="_">D</p>
144
- <ol id="_" type="arabic">
148
+ <ol id="_">
145
149
  <li>
146
150
  <p id="_">E</p>
147
151
  </li>
@@ -172,7 +176,7 @@ RSpec.describe Asciidoctor::Iec do
172
176
  * Hello [[id3]] List item
173
177
 
174
178
  INPUT
175
- #{BLANK_HDR}
179
+ #{@blank_hdr}
176
180
  <sections>
177
181
  <ul id="id1">
178
182
  <li id="id2">
@@ -1,6 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe Asciidoctor::Iec do
4
+ before(:all) do
5
+ @blank_hdr = blank_hdr_gen
6
+ end
7
+
4
8
  it "processes sections" do
5
9
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
6
10
  #{ASCIIDOC_BLANK_HDR}
@@ -52,7 +56,7 @@ RSpec.describe Asciidoctor::Iec do
52
56
 
53
57
  === Bibliography Subsection
54
58
  INPUT
55
- #{BLANK_HDR}
59
+ #{@blank_hdr}
56
60
  <preface><foreword id="_" obligation="informative">
57
61
  <title>FOREWORD</title>
58
62
  <p id="_">Text</p>
@@ -189,7 +193,7 @@ RSpec.describe Asciidoctor::Iec do
189
193
 
190
194
  === Bibliography Subsection
191
195
  INPUT
192
- #{BLANK_HDR}
196
+ #{@blank_hdr}
193
197
  <preface>
194
198
  <foreword id="_" obligation="informative">
195
199
  <title>FOREWORD</title>
@@ -298,7 +302,7 @@ RSpec.describe Asciidoctor::Iec do
298
302
  [appendix,obligation=informative]
299
303
  == Annex
300
304
  INPUT
301
- #{BLANK_HDR}
305
+ #{@blank_hdr}
302
306
  <sections><clause id="_" inline-header="false" obligation="informative">
303
307
  <title>Clause 1</title>
304
308
  <clause id="_" inline-header="false" obligation="informative">
@@ -329,7 +333,7 @@ RSpec.describe Asciidoctor::Iec do
329
333
  [%inline-header]
330
334
  === Clause Aa
331
335
  INPUT
332
- #{BLANK_HDR}
336
+ #{@blank_hdr}
333
337
  <sections><clause id="_" inline-header="false" obligation="normative">
334
338
  <title>Clause 1</title>
335
339
  <clause id="_" inline-header="true" obligation="normative">
@@ -354,7 +358,7 @@ RSpec.describe Asciidoctor::Iec do
354
358
  === {blank}
355
359
 
356
360
  INPUT
357
- #{BLANK_HDR}
361
+ #{@blank_hdr}
358
362
  <sections>
359
363
  <clause id="_" inline-header="false" obligation="normative">
360
364
  <title>Clause 1</title>
@@ -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",
@@ -44,7 +44,7 @@ RSpec.describe IsoDoc::Iec do
44
44
  <abbreviation>ISO</abbreviation>
45
45
  </organization>
46
46
  </contributor>
47
- <note format="text/plain" reference="1" type="ISO DATE">Under preparation. (Stage at the time of publication ISO/DIS 16634)</note>
47
+ <note format="text/plain" reference="1" type="Unpublished-Status">Under preparation. (Stage at the time of publication ISO/DIS 16634)</note>
48
48
  <extent type="part">
49
49
  <referenceFrom>all</referenceFrom>
50
50
  </extent>
@@ -167,7 +167,7 @@ RSpec.describe IsoDoc::Iec do
167
167
  <abbreviation>ISO</abbreviation>
168
168
  </organization>
169
169
  </contributor>
170
- <note format="text/plain" reference="1" type="ISO DATE">Under preparation. (Stage at the time of publication ISO/DIS 16634)</note>
170
+ <note format="text/plain" reference="1" type="Unpublished-Status">Under preparation. (Stage at the time of publication ISO/DIS 16634)</note>
171
171
  <extent type="part">
172
172
  <referenceFrom>all</referenceFrom>
173
173
  </extent>