metanorma-iec 1.2.10 → 1.2.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 open blocks" 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}
@@ -12,7 +16,7 @@ RSpec.describe Asciidoctor::Iec do
12
16
  z
13
17
  --
14
18
  INPUT
15
- #{BLANK_HDR}
19
+ #{@blank_hdr}
16
20
  <sections><p id="_">x</p>
17
21
  <p id="_">y</p>
18
22
  <p id="_">z</p></sections>
@@ -34,7 +38,7 @@ RSpec.describe Asciidoctor::Iec do
34
38
  <mml:math><mml:msub xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"> <mml:mrow> <mml:mrow> <mml:mi mathvariant="bold-italic">F</mml:mi> </mml:mrow> </mml:mrow> <mml:mrow> <mml:mrow> <mml:mi mathvariant="bold-italic">&#x0391;</mml:mi> </mml:mrow> </mml:mrow> </mml:msub> </mml:math>
35
39
  ++++
36
40
  INPUT
37
- #{BLANK_HDR}
41
+ #{@blank_hdr}
38
42
  <sections>
39
43
  <formula id="_">
40
44
  <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi></math></stem>
@@ -62,7 +66,7 @@ RSpec.describe Asciidoctor::Iec do
62
66
  For further information on the Foreword, see *ISO/IEC Directives, Part 2, 2016, Clause 12.*
63
67
  ****
64
68
  INPUT
65
- #{BLANK_HDR}
69
+ #{@blank_hdr}
66
70
  <sections><p id="foreword">Foreword</p>
67
71
  </sections>
68
72
  </iec-standard>
@@ -107,7 +111,7 @@ RSpec.describe Asciidoctor::Iec do
107
111
 
108
112
  NOTE: This is a note
109
113
  INPUT
110
- #{BLANK_HDR}
114
+ #{@blank_hdr}
111
115
  <sections>
112
116
  <terms id="_" obligation="normative">
113
117
  <title>Terms and definitions</title>
@@ -130,7 +134,7 @@ RSpec.describe Asciidoctor::Iec do
130
134
  #{ASCIIDOC_BLANK_HDR}
131
135
  NOTE: This is a note
132
136
  INPUT
133
- #{BLANK_HDR}
137
+ #{@blank_hdr}
134
138
  <sections>
135
139
  <note id="_">
136
140
  <p id="_">This is a note</p>
@@ -148,7 +152,7 @@ RSpec.describe Asciidoctor::Iec do
148
152
  LITERAL
149
153
  ....
150
154
  INPUT
151
- #{BLANK_HDR}
155
+ #{@blank_hdr}
152
156
  <sections>
153
157
  <figure id="_">
154
158
  <pre id="_">LITERAL</pre>
@@ -163,7 +167,7 @@ RSpec.describe Asciidoctor::Iec do
163
167
  #{ASCIIDOC_BLANK_HDR}
164
168
  CAUTION: Only use paddy or parboiled rice for the determination of husked rice yield.
165
169
  INPUT
166
- #{BLANK_HDR}
170
+ #{@blank_hdr}
167
171
  <sections>
168
172
  <admonition id="_" type="caution">
169
173
  <p id="_">Only use paddy or parboiled rice for the determination of husked rice yield.</p>
@@ -188,7 +192,7 @@ RSpec.describe Asciidoctor::Iec do
188
192
  . Celery makes them sad.
189
193
  ====
190
194
  INPUT
191
- #{BLANK_HDR}
195
+ #{@blank_hdr}
192
196
  <sections>
193
197
  <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
198
  <ol id="_">
@@ -218,7 +222,7 @@ RSpec.describe Asciidoctor::Iec do
218
222
  [example]
219
223
  This is an example
220
224
  INPUT
221
- #{BLANK_HDR}
225
+ #{@blank_hdr}
222
226
  <sections>
223
227
  <terms id="_" obligation="normative">
224
228
  <title>Terms and definitions</title>
@@ -247,7 +251,7 @@ RSpec.describe Asciidoctor::Iec do
247
251
  Amen
248
252
  ====
249
253
  INPUT
250
- #{BLANK_HDR}
254
+ #{@blank_hdr}
251
255
  <sections>
252
256
  <example id="_"><p id="_">This is an example</p>
253
257
  <p id="_">Amen</p></example>
@@ -263,7 +267,7 @@ RSpec.describe Asciidoctor::Iec do
263
267
 
264
268
  == Section 1
265
269
  INPUT
266
- #{BLANK_HDR}
270
+ #{@blank_hdr}
267
271
  <preface><foreword id="_" obligation="informative">
268
272
  <title>FOREWORD</title>
269
273
  <p id="_">This is a preamble</p>
@@ -282,7 +286,7 @@ RSpec.describe Asciidoctor::Iec do
282
286
  image::spec/examples/rice_images/rice_image1.png[]
283
287
 
284
288
  INPUT
285
- #{BLANK_HDR}
289
+ #{@blank_hdr}
286
290
  <sections>
287
291
  <figure id="_">
288
292
  <name>Split-it-right sample divider</name>
@@ -300,7 +304,7 @@ RSpec.describe Asciidoctor::Iec do
300
304
  image::spec/examples/rice_images/rice_image1.png[]
301
305
 
302
306
  INPUT
303
- #{BLANK_HDR}
307
+ #{@blank_hdr}
304
308
  <sections>
305
309
  <figure id="_">
306
310
  <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="4" width="3"/>
@@ -317,7 +321,7 @@ RSpec.describe Asciidoctor::Iec do
317
321
  image::spec/examples/rice_images/rice_image1.png[]
318
322
 
319
323
  INPUT
320
- #{BLANK_HDR}
324
+ #{@blank_hdr}
321
325
  <sections>
322
326
  <figure id="_">
323
327
  <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="4" width="auto"/>
@@ -333,7 +337,7 @@ RSpec.describe Asciidoctor::Iec do
333
337
  [align=right]
334
338
  This para is right-aligned.
335
339
  INPUT
336
- #{BLANK_HDR}
340
+ #{@blank_hdr}
337
341
  <sections>
338
342
  <p align="right" id="_">This para is right-aligned.</p>
339
343
  </sections>
@@ -349,7 +353,7 @@ RSpec.describe Asciidoctor::Iec do
349
353
  Block quotation
350
354
  ____
351
355
  INPUT
352
- #{BLANK_HDR}
356
+ #{@blank_hdr}
353
357
  <sections>
354
358
  <quote id="_">
355
359
  <source type="inline" bibitemid="ISO7301" citeas=""><localityStack><locality type="section"><referenceFrom>1</referenceFrom></locality></localityStack></source>
@@ -372,7 +376,7 @@ RSpec.describe Asciidoctor::Iec do
372
376
  end
373
377
  --
374
378
  INPUT
375
- #{BLANK_HDR}
379
+ #{@blank_hdr}
376
380
  <sections>
377
381
  <sourcecode lang="ruby" id="_">puts "Hello, world."
378
382
  %w{a b c}.each do |x|
@@ -396,7 +400,7 @@ RSpec.describe Asciidoctor::Iec do
396
400
  <1> This is one callout
397
401
  <2> This is another callout
398
402
  INPUT
399
- #{BLANK_HDR}
403
+ #{@blank_hdr}
400
404
  <sections><sourcecode lang="ruby" id="_">puts "Hello, world." <callout target="_">1</callout>
401
405
  %w{a b c}.each do |x|
402
406
  puts x <callout target="_">2</callout>
@@ -420,7 +424,7 @@ RSpec.describe Asciidoctor::Iec do
420
424
  [.source]
421
425
  <<ISO2191,section=1>>
422
426
  INPUT
423
- #{BLANK_HDR}
427
+ #{@blank_hdr}
424
428
  <sections>
425
429
  <terms id="_" obligation="normative">
426
430
  <title>Terms and definitions</title>
@@ -452,7 +456,7 @@ RSpec.describe Asciidoctor::Iec do
452
456
  [.source]
453
457
  <<ISO2191,section=1>>, with adjustments
454
458
  INPUT
455
- #{BLANK_HDR}
459
+ #{@blank_hdr}
456
460
  <sections>
457
461
  <terms id="_" obligation="normative">
458
462
  <title>Terms and definitions</title>
@@ -1,12 +1,92 @@
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
+
8
+ it "moves note from TC/SC officers to metadata" do
9
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
10
+ #{ASCIIDOC_BLANK_HDR}
11
+ == {blank}
12
+
13
+ [NOTE]
14
+ .Note from TC/SC Officers
15
+ ====
16
+ This FDIS is the result of the discussion between the IEC SC21A experts WG 3 during the meeting held in
17
+ Chicago (USA) on April 9th
18
+
19
+ This document is also of interest for ISO/ TC114/ WG1 Requirements for Watch batteries
20
+ ====
21
+ INPUT
22
+ <iec-standard xmlns="https://www.metanorma.org/ns/iec" type="semantic" version="#{Metanorma::Iec::VERSION}">
23
+ <bibdata type="standard">
24
+ <contributor>
25
+ <role type="author"/>
26
+ <organization>
27
+ <name>International Electrotechnical Commission</name>
28
+ <abbreviation>IEC</abbreviation>
29
+ </organization>
30
+ </contributor>
31
+ <contributor>
32
+ <role type="publisher"/>
33
+ <organization>
34
+ <name>International Electrotechnical Commission</name>
35
+ <abbreviation>IEC</abbreviation>
36
+ </organization>
37
+ </contributor>
38
+ <language>en</language>
39
+ <script>Latn</script>
40
+ <status>
41
+ <stage abbreviation="PPUB">60</stage>
42
+ <substage abbreviation="PPUB">60</substage>
43
+ </status>
44
+ <copyright>
45
+ <from>#{Time.new.year}</from>
46
+ <owner>
47
+ <organization>
48
+ <name>International Electrotechnical Commission</name>
49
+ <abbreviation>IEC</abbreviation>
50
+ </organization>
51
+ </owner>
52
+ </copyright>
53
+ <ext>
54
+ <doctype>article</doctype>
55
+ <horizontal>false</horizontal>
56
+ <editorialgroup>
57
+ <technical-committee/>
58
+ <subcommittee/>
59
+ <workgroup/>
60
+ </editorialgroup>
61
+ <stagename>International standard</stagename>
62
+ <tc-sc-officers-note>
63
+ <p id='_'>
64
+ This FDIS is the result of the discussion between the IEC SC21A
65
+ experts WG 3 during the meeting held in Chicago (USA) on April 9th
66
+ </p>
67
+ <p id='_'>
68
+ This document is also of interest for ISO/ TC114/ WG1 Requirements for
69
+ Watch batteries
70
+ </p>
71
+ </tc-sc-officers-note>
72
+ </ext>
73
+ </bibdata>
74
+ #{boilerplate(Nokogiri::XML(BLANK_HDR + "</iec-standard>"))}
75
+ <sections>
76
+ <clause id="_" inline-header="false" obligation="normative">
77
+
78
+ </clause>
79
+ </sections>
80
+ </iec-standard>
81
+ OUTPUT
82
+ end
83
+
4
84
  it "removes empty text elements" do
5
85
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
6
86
  #{ASCIIDOC_BLANK_HDR}
7
87
  == {blank}
8
88
  INPUT
9
- #{BLANK_HDR}
89
+ #{@blank_hdr}
10
90
  <sections>
11
91
  <clause id="_" inline-header="false" obligation="normative">
12
92
 
@@ -27,7 +107,7 @@ RSpec.describe Asciidoctor::Iec do
27
107
 
28
108
  Time
29
109
  INPUT
30
- #{BLANK_HDR}
110
+ #{@blank_hdr}
31
111
  <sections>
32
112
  <terms id="_" obligation="normative">
33
113
  <title>Terms and definitions</title>
@@ -75,7 +155,7 @@ RSpec.describe Asciidoctor::Iec do
75
155
 
76
156
  This paragraph is extraneous
77
157
  INPUT
78
- #{BLANK_HDR}
158
+ #{@blank_hdr}
79
159
  <sections>
80
160
  <terms id="_" obligation="normative">
81
161
  <title>Terms and definitions</title>
@@ -104,7 +184,7 @@ RSpec.describe Asciidoctor::Iec do
104
184
  OUTPUT
105
185
  end
106
186
 
107
- it "strips any initial boilerplate from terms and definitions" do
187
+ it "keeps any initial boilerplate from terms and definitions" do
108
188
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
109
189
  #{ASCIIDOC_BLANK_HDR}
110
190
  == Terms and Definitions
@@ -117,13 +197,18 @@ RSpec.describe Asciidoctor::Iec do
117
197
 
118
198
  This paragraph is extraneous
119
199
  INPUT
120
- #{BLANK_HDR}
200
+ #{@blank_hdr}
121
201
  <sections>
122
202
  <terms id="_" obligation="normative"><title>Terms and definitions</title>
123
203
  <p id="_">For the purposes of this document,
124
204
  the following terms and definitions apply.</p>
125
205
  #{TERMS_BOILERPLATE}
126
-
206
+ <p id='_'>I am boilerplate</p>
207
+ <ul id='_'>
208
+ <li>
209
+ <p id='_'>So am I</p>
210
+ </li>
211
+ </ul>
127
212
  <term id="term-time">
128
213
  <preferred>Time</preferred>
129
214
  <definition><p id="_">This paragraph is extraneous</p></definition>
@@ -142,7 +227,7 @@ RSpec.describe Asciidoctor::Iec do
142
227
  == Clause
143
228
  * [[[iso216,ISO 216]]], _Reference_
144
229
  INPUT
145
- #{BLANK_HDR}
230
+ #{@blank_hdr}
146
231
  <preface>
147
232
  <foreword id="_" obligation="informative">
148
233
  <title>FOREWORD</title>
@@ -179,7 +264,7 @@ RSpec.describe Asciidoctor::Iec do
179
264
  [.source]
180
265
  <<ISO2191,section=1>>
181
266
  INPUT
182
- #{BLANK_HDR}
267
+ #{@blank_hdr}
183
268
  <sections>
184
269
  <terms id="_" obligation="normative">
185
270
  <title>Terms and definitions</title>
@@ -211,7 +296,7 @@ RSpec.describe Asciidoctor::Iec do
211
296
 
212
297
  * [[[iso216,ISO 216]]], _Reference_
213
298
  INPUT
214
- #{BLANK_HDR}
299
+ #{@blank_hdr}
215
300
  <sections></sections>
216
301
  <bibliography><references id="_" obligation="informative" normative="true"><title>Normative references</title>
217
302
  <p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
@@ -238,7 +323,7 @@ RSpec.describe Asciidoctor::Iec do
238
323
  #{ASCIIDOC_BLANK_HDR}
239
324
  Paragraph
240
325
  INPUT
241
- #{BLANK_HDR}
326
+ #{@blank_hdr}
242
327
  <sections>
243
328
  <p id="_">Paragraph</p>
244
329
  </sections>
@@ -254,7 +339,7 @@ RSpec.describe Asciidoctor::Iec do
254
339
  NOTE: This note has no ID
255
340
  ====
256
341
  INPUT
257
- #{BLANK_HDR}
342
+ #{@blank_hdr}
258
343
  <sections>
259
344
  <example id="_">
260
345
  <note id="_">
@@ -275,7 +360,7 @@ RSpec.describe Asciidoctor::Iec do
275
360
 
276
361
  footnote:[This is another footnote to a figure]
277
362
  INPUT
278
- #{BLANK_HDR}
363
+ #{@blank_hdr}
279
364
  <sections><figure id="_">
280
365
  <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="auto" width="auto"/>
281
366
  <fn reference="a">
@@ -302,7 +387,7 @@ RSpec.describe Asciidoctor::Iec do
302
387
 
303
388
  Text
304
389
  INPUT
305
- #{BLANK_HDR}
390
+ #{@blank_hdr}
306
391
  <sections><clause id="_" inline-header="false" obligation="normative">
307
392
  <title>Clause</title>
308
393
  <p id="_">Text</p>
@@ -344,7 +429,7 @@ RSpec.describe Asciidoctor::Iec do
344
429
  ====== Clause 5B
345
430
 
346
431
  INPUT
347
- #{BLANK_HDR}
432
+ #{@blank_hdr}
348
433
  <sections>
349
434
  <clause id="_" inline-header="false" obligation="normative">
350
435
  <title>Clause1</title>
@@ -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>
@@ -65,7 +71,7 @@ RSpec.describe Asciidoctor::Iec do
65
71
  <stagename>International standard</stagename>
66
72
  </ext>
67
73
  </bibdata>
68
- #{BOILERPLATE}
74
+ #{@boilerplate}
69
75
  <sections> </sections>
70
76
  <bibliography>
71
77
  <references id='_' obligation='informative' normative="true">
@@ -122,7 +128,7 @@ INPUT
122
128
  <substage abbreviation="PPUB">60</substage>
123
129
  </status>
124
130
  <copyright>
125
- <from>2020</from>
131
+ <from>#{Time.now.year}</from>
126
132
  <owner>
127
133
  <organization>
128
134
  <name>International Electrotechnical Commission</name>
@@ -144,7 +150,7 @@ INPUT
144
150
  <stagename>International standard</stagename>
145
151
  </ext>
146
152
  </bibdata>
147
- #{BOILERPLATE}
153
+ #{@boilerplate}
148
154
  <sections>
149
155
  <clause id='_' obligation='normative'>
150
156
  <title>Terms and definitions</title>
@@ -201,7 +207,7 @@ OUTPUT
201
207
  <substage abbreviation='PPUB'>60</substage>
202
208
  </status>
203
209
  <copyright>
204
- <from>2020</from>
210
+ <from>#{Time.now.year}</from>
205
211
  <owner>
206
212
  <organization>
207
213
  <name>International Electrotechnical Commission</name>
@@ -223,7 +229,7 @@ OUTPUT
223
229
  <stagename>International standard</stagename>
224
230
  </ext>
225
231
  </bibdata>
226
- #{BOILERPLATE}
232
+ #{@boilerplate}
227
233
  <preface>
228
234
  <introduction id='_' obligation='informative'>
229
235
  <title>INTRODUCTION&lt;br/&gt;Principles and rules followed</title>