metanorma-iec 2.0.7 → 2.1.1

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.
@@ -1,219 +1,163 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe IsoDoc::Iec do
4
-
5
- it "processes admonitions" do
6
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
7
- <iso-standard xmlns="http://riboseinc.com/isoxml">
8
- <preface><foreword>
9
- <admonition id="_70234f78-64e5-4dfc-8b6f-f3f037348b6a" type="caution">
10
- <p id="_e94663cc-2473-4ccc-9a72-983a74d989f2">Only use paddy or parboiled rice for the determination of husked rice yield.</p>
11
- <p id="_e94663cc-2473-4ccc-9a72-983a74d989f3">Para 2.</p>
12
- </admonition>
13
- </foreword></preface>
14
- </iso-standard>
15
- INPUT
16
- #{HTML_HDR}
17
- <div>
18
- <h1 class='ForewordTitle'>FOREWORD</h1>
19
- <div class='boilerplate_legal'/>
20
- <div id='_70234f78-64e5-4dfc-8b6f-f3f037348b6a' class='Admonition'>
21
- <p>
22
- CAUTION &#8212; Only use paddy or parboiled rice for the
23
- determination of husked rice yield.
24
- </p>
25
- <p id='_e94663cc-2473-4ccc-9a72-983a74d989f3'>Para 2.</p>
26
- </div>
27
- </div>
28
- #{IEC_TITLE1}
29
- </div>
30
- </body>
31
- </html>
32
- OUTPUT
33
- end
34
-
35
- it "processes admonitions with titles" do
36
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
37
- <iso-standard xmlns="http://riboseinc.com/isoxml">
38
- <preface><foreword>
39
- <admonition id="_70234f78-64e5-4dfc-8b6f-f3f037348b6a" type="caution">
40
- <name>Title</name>
41
- <ul>
42
- <li>List</li>
43
- </ul>
44
- <p id="_e94663cc-2473-4ccc-9a72-983a74d989f2">Only use paddy or parboiled rice for the determination of husked rice yield.</p>
45
- </admonition>
46
- </foreword></preface>
47
- </iso-standard>
48
- INPUT
49
- #{HTML_HDR}
50
- <div>
51
- <h1 class='ForewordTitle'>FOREWORD</h1>
52
- <div class='boilerplate_legal'/>
53
- <div id='_70234f78-64e5-4dfc-8b6f-f3f037348b6a' class='Admonition'>
54
- <p>Title &#8212; </p>
55
- <ul>
56
- <li>List</li>
57
- </ul>
58
- <p id='_e94663cc-2473-4ccc-9a72-983a74d989f2'>Only use paddy or parboiled rice for the determination of husked rice yield.</p>
59
- </div>
60
- </div>
61
- #{IEC_TITLE1}
62
- </div>
63
- </body>
64
- </html>
65
- OUTPUT
66
- end
67
-
68
4
  it "processes formulae (Word)" do
69
- expect(xmlpp(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
70
- <iso-standard xmlns="http://riboseinc.com/isoxml">
71
- <preface><foreword>
72
- <formula id="_be9158af-7e93-4ee2-90c5-26d31c181934" unnumbered="true">
73
- <stem type="AsciiMath">r = 1 %</stem>
74
- <dl id="_e4fe94fe-1cde-49d9-b1ad-743293b7e21d">
75
- <dt>
76
- <stem type="AsciiMath">r</stem>
77
- </dt>
78
- <dd>
79
- <p id="_1b99995d-ff03-40f5-8f2e-ab9665a69b77">is the repeatability limit.</p>
80
- </dd>
81
- </dl>
82
- <note id="_83083c7a-6c85-43db-a9fa-4d8edd0c9fc0">
83
- <name>NOTE</name>
84
- <p id="_511aaa98-4116-42af-8e5b-c87cdf5bfdc8">[durationUnits] is essentially a duration statement without the "P" prefix. "P" is unnecessary because between "G" and "U" duration is always expressed.</p>
85
- </note>
86
- </formula>
87
- <formula id="_be9158af-7e93-4ee2-90c5-26d31c181935"><name>1</name>
88
- <stem type="AsciiMath">r = 1 %</stem>
89
- </formula>
90
- </foreword></preface>
91
- </iso-standard>
5
+ input = <<~INPUT
6
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
7
+ <preface><foreword>
8
+ <formula id="_be9158af-7e93-4ee2-90c5-26d31c181934" unnumbered="true">
9
+ <stem type="AsciiMath">r = 1 %</stem>
10
+ <dl id="_e4fe94fe-1cde-49d9-b1ad-743293b7e21d">
11
+ <dt>
12
+ <stem type="AsciiMath">r</stem>
13
+ </dt>
14
+ <dd>
15
+ <p id="_1b99995d-ff03-40f5-8f2e-ab9665a69b77">is the repeatability limit.</p>
16
+ </dd>
17
+ </dl>
18
+ <note id="_83083c7a-6c85-43db-a9fa-4d8edd0c9fc0">
19
+ <name>NOTE</name>
20
+ <p id="_511aaa98-4116-42af-8e5b-c87cdf5bfdc8">[durationUnits] is essentially a duration statement without the "P" prefix. "P" is unnecessary because between "G" and "U" duration is always expressed.</p>
21
+ </note>
22
+ </formula>
23
+ <formula id="_be9158af-7e93-4ee2-90c5-26d31c181935"><name>1</name>
24
+ <stem type="AsciiMath">r = 1 %</stem>
25
+ </formula>
26
+ </foreword></preface>
27
+ </iso-standard>
92
28
  INPUT
93
- <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
94
- <head>
95
- <style>
96
- </style>
97
- <style>
98
- </style>
99
- </head>
100
- <body lang='EN-US' link='blue' vlink='#954F72'>
101
- <div class='WordSection2'>
102
- <p>
103
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
104
- </p>
105
- #{IEC_TITLE}
106
- <div>
107
- <h1 class='ForewordTitle'>FOREWORD</h1>
108
- <div class='boilerplate_legal'/>
109
- <div id='_be9158af-7e93-4ee2-90c5-26d31c181934'><div class='formula'>
110
- <p class='formula'>
111
- <span style='mso-tab-count:1'>&#160; </span>
112
- <span class='stem'>(#(r = 1 %)#)</span>
113
- </p>
114
- </div>
115
- <span class='zzMoveToFollowing'>
116
- where
117
- <span class='stem'>(#(r)#)</span>
118
- </span>
119
- <p id='_1b99995d-ff03-40f5-8f2e-ab9665a69b77'>is the repeatability limit.</p>
120
- <div id='_83083c7a-6c85-43db-a9fa-4d8edd0c9fc0' class='Note'>
121
- <p class='Note'>
122
- <span class='note_label'>NOTE</span>
123
- <span style='mso-tab-count:1'>&#160; </span>
124
- [durationUnits] is essentially a duration statement without the "P"
125
- prefix. "P" is unnecessary because between "G" and "U" duration is
126
- always expressed.
127
- </p>
128
- </div>
129
- </div>
130
- <div id='_be9158af-7e93-4ee2-90c5-26d31c181935'><div class='formula'>
131
- <p class='formula'>
132
- <span style='mso-tab-count:1'>&#160; </span>
133
- <span class='stem'>(#(r = 1 %)#)</span>
134
- <span style='mso-tab-count:1'>&#160; </span>
135
- (1)
29
+ output = <<~OUTPUT
30
+ <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
31
+ <head>
32
+ <style>
33
+ </style>
34
+ <style>
35
+ </style>
36
+ </head>
37
+ <body lang='EN-US' link='blue' vlink='#954F72'>
38
+ <div class='WordSection2'>
39
+ <p>
40
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
41
+ </p>
42
+ #{IEC_TITLE}
43
+ <div>
44
+ <h1 class='ForewordTitle'>FOREWORD</h1>
45
+ <div class='boilerplate_legal'/>
46
+ <div id='_be9158af-7e93-4ee2-90c5-26d31c181934'><div class='formula'>
47
+ <p class='formula'>
48
+ <span style='mso-tab-count:1'>&#160; </span>
49
+ <span class='stem'>(#(r = 1 %)#)</span>
50
+ </p>
51
+ </div>
52
+ <span class='zzMoveToFollowing'>
53
+ where#{' '}
54
+ <span class='stem'>(#(r)#)</span>
55
+ </span>
56
+ <p id='_1b99995d-ff03-40f5-8f2e-ab9665a69b77'>is the repeatability limit.</p>
57
+ <div id='_83083c7a-6c85-43db-a9fa-4d8edd0c9fc0' class='Note'>
58
+ <p class='Note'>
59
+ <span class='note_label'>NOTE</span>
60
+ <span style='mso-tab-count:1'>&#160; </span>
61
+ [durationUnits] is essentially a duration statement without the "P"
62
+ prefix. "P" is unnecessary because between "G" and "U" duration is
63
+ always expressed.
64
+ </p>
65
+ </div>
66
+ </div>
67
+ <div id='_be9158af-7e93-4ee2-90c5-26d31c181935'><div class='formula'>
68
+ <p class='formula'>
69
+ <span style='mso-tab-count:1'>&#160; </span>
70
+ <span class='stem'>(#(r = 1 %)#)</span>
71
+ <span style='mso-tab-count:1'>&#160; </span>
72
+ (1)
73
+ </p>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ <p>&#160;</p>
78
+ </div>
79
+ <p>
80
+ <br clear='all' class='section'/>
136
81
  </p>
137
- </div>
138
- </div>
139
- </div>
140
- <p>&#160;</p>
141
- </div>
142
- <p>
143
- <br clear='all' class='section'/>
144
- </p>
145
- <div class='WordSection3'>
146
- #{IEC_TITLE1}
147
- </div>
148
- <br clear='all' style='page-break-before:left;mso-break-type:section-break'/>
149
- <div class='colophon'/>
150
- </body>
151
- </html>
82
+ <div class='WordSection3'>
83
+ #{IEC_TITLE1}
84
+ </div>
85
+ <br clear='all' style='page-break-before:left;mso-break-type:section-break'/>
86
+ <div class='colophon'/>
87
+ </body>
88
+ </html>
152
89
  OUTPUT
90
+ expect(xmlpp(IsoDoc::Iec::WordConvert.new({})
91
+ .convert("test", input, true)))
92
+ .to be_equivalent_to xmlpp(output)
153
93
  end
154
94
 
155
- it "cross-references formulae" do
156
- expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true).gsub(%r{^.*<body}m, "<body").gsub(%r{</body>.*}m, "</body>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
157
- <iso-standard xmlns="http://riboseinc.com/isoxml">
158
- <preface>
159
- <foreword>
160
- <p>
161
- <xref target="N1"/>
162
- <xref target="N2"/>
163
- </p>
164
- </foreword>
165
- </preface>
166
- <sections>
167
- <clause id="intro"><title>First</title>
168
- <formula id="N1">
169
- <stem type="AsciiMath">r = 1 %</stem>
170
- </formula>
171
- <clause id="xyz"><title>Preparatory</title>
172
- <formula id="N2" inequality="true">
173
- <stem type="AsciiMath">r = 1 %</stem>
174
- </formula>
175
- <xref target="N2"/>
176
- </clause>
177
- </sections>
178
- </iso-standard>
95
+ it "cross-references formulae" do
96
+ input = <<~INPUT
97
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
98
+ <preface>
99
+ <foreword>
100
+ <p>
101
+ <xref target="N1"/>
102
+ <xref target="N2"/>
103
+ </p>
104
+ </foreword>
105
+ </preface>
106
+ <sections>
107
+ <clause id="intro"><title>First</title>
108
+ <formula id="N1">
109
+ <stem type="AsciiMath">r = 1 %</stem>
110
+ </formula>
111
+ <clause id="xyz"><title>Preparatory</title>
112
+ <formula id="N2" inequality="true">
113
+ <stem type="AsciiMath">r = 1 %</stem>
114
+ </formula>
115
+ <xref target="N2"/>
116
+ </clause>
117
+ </sections>
118
+ </iso-standard>
179
119
  INPUT
180
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
181
- <preface>
182
- <foreword displayorder="1">
183
- <p>
184
- <xref target='N1'>Clause 1, Equation (1)</xref>
185
- <xref target='N2'>1.1, Inequality (2)</xref>
186
- </p>
187
- </foreword>
188
- </preface>
189
- <sections>
190
- <clause id='intro' displayorder="2">
191
- <title depth='1'>
192
- 1
193
- <tab/>
194
- First
195
- </title>
196
- <formula id='N1'>
197
- <name>1</name>
198
- <stem type='AsciiMath'>r = 1 %</stem>
199
- </formula>
200
- <clause id='xyz'>
201
- <title depth='2'>
202
- 1.1
120
+ output = <<~OUTPUT
121
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
122
+ <preface>
123
+ <foreword displayorder="1">
124
+ <p>
125
+ <xref target='N1'>Clause 1, Equation (1)</xref>
126
+ <xref target='N2'>1.1, Inequality (2)</xref>
127
+ </p>
128
+ </foreword>
129
+ </preface>
130
+ <sections>
131
+ <clause id='intro' displayorder="2">
132
+ <title depth='1'>
133
+ 1
203
134
  <tab/>
204
- Preparatory
135
+ First
205
136
  </title>
206
- <formula id='N2' inequality='true'>
207
- <name>2</name>
137
+ <formula id='N1'>
138
+ <name>1</name>
208
139
  <stem type='AsciiMath'>r = 1 %</stem>
209
140
  </formula>
210
- <xref target='N2'>Inequality (2)</xref>
141
+ <clause id='xyz'>
142
+ <title depth='2'>
143
+ 1.1
144
+ <tab/>
145
+ Preparatory
146
+ </title>
147
+ <formula id='N2' inequality='true'>
148
+ <name>2</name>
149
+ <stem type='AsciiMath'>r = 1 %</stem>
150
+ </formula>
151
+ <xref target='N2'>Inequality (2)</xref>
152
+ </clause>
211
153
  </clause>
212
- </clause>
213
- </sections>
214
- </iso-standard>
154
+ </sections>
155
+ </iso-standard>
215
156
  OUTPUT
216
- end
217
-
218
-
157
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({})
158
+ .convert("test", input, true)
159
+ .gsub(%r{^.*<body}m, "<body")
160
+ .gsub(%r{</body>.*}m, "</body>")))
161
+ .to be_equivalent_to xmlpp(output)
162
+ end
219
163
  end
@@ -84,7 +84,7 @@ RSpec.describe IsoDoc do
84
84
  <language current="true">en</language>
85
85
  <ext>
86
86
  <doctype language="">international-standard</doctype><doctype language="fr">Norme internationale</doctype><doctype language="en">International Standard</doctype>
87
- <horizontal language="">true</horizontal><horizontal language="fr">Norme horizontale</horizontal><horizontal language="en">Horizontal Standard</horizontal>
87
+ <horizontal language=''>true</horizontal><horizontal language="fr">Norme horizontale</horizontal><horizontal language="en">Horizontal Standard</horizontal>
88
88
  <function language="">emc</function><function language="fr">Publication fondamentale en CEM</function><function language="en">Basic EMC Publication</function>
89
89
  </ext>
90
90
  </bibdata>
@@ -224,12 +224,17 @@ RSpec.describe IsoDoc do
224
224
  </body>
225
225
  </html>
226
226
  OUTPUT
227
- expect((IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
228
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
227
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({})
228
+ .convert("test", input, true)
229
+ .sub(%r{<localized-strings>.*</localized-strings>}m, "")))
230
+ .to be_equivalent_to xmlpp(presxml)
231
+ expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
232
+ .convert("test", presxml, true)))
233
+ .to be_equivalent_to xmlpp(html)
229
234
  end
230
235
 
231
236
  it "defaults to English" do
232
- expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
237
+ input = <<~INPUT
233
238
  <iso-standard xmlns="http://riboseinc.com/isoxml">
234
239
  <bibdata>
235
240
  <language>tlh</language>
@@ -297,6 +302,7 @@ RSpec.describe IsoDoc do
297
302
  </bibliography>
298
303
  </iso-standard>
299
304
  INPUT
305
+ output = <<~OUTPUT
300
306
  <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
301
307
  <bibdata>
302
308
  <language current="true">tlh</language>
@@ -362,6 +368,10 @@ RSpec.describe IsoDoc do
362
368
  </bibliography>
363
369
  </iso-standard>
364
370
  OUTPUT
371
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({})
372
+ .convert("test", input, true)
373
+ .sub(%r{<localized-strings>.*</localized-strings>}m, "")))
374
+ .to be_equivalent_to xmlpp(output)
365
375
  end
366
376
 
367
377
  it "processes French" do
@@ -445,7 +455,7 @@ RSpec.describe IsoDoc do
445
455
  <language current="true">fr</language>
446
456
  <ext>
447
457
  <doctype language="">international-standard</doctype><doctype language="fr">Norme internationale</doctype><doctype language="en">International Standard</doctype>
448
- <horizontal language="">false</horizontal>
458
+ <horizontal>false</horizontal>
449
459
  <function language="">emc</function><function language="fr">Publication fondamentale en CEM</function><function language="en">Basic EMC Publication</function>
450
460
  </ext>
451
461
  </bibdata>
@@ -586,7 +596,12 @@ RSpec.describe IsoDoc do
586
596
  </body>
587
597
  </html>
588
598
  OUTPUT
589
- expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", input, true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(presxml)
590
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
599
+ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({})
600
+ .convert("test", input, true)
601
+ .sub(%r{<localized-strings>.*</localized-strings>}m, "")))
602
+ .to be_equivalent_to xmlpp(presxml)
603
+ expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
604
+ .convert("test", presxml, true)))
605
+ .to be_equivalent_to xmlpp(html)
591
606
  end
592
607
  end
@@ -171,7 +171,7 @@ RSpec.describe IsoDoc do
171
171
  <stage language="">60</stage>
172
172
  <stage language='fr'>Norme internationale</stage>
173
173
  <stage language='en'>International standard</stage>
174
- <substage language="">60</substage>
174
+ <substage>60</substage>
175
175
  </status>
176
176
  <copyright>
177
177
  <from>2020</from>
@@ -183,7 +183,7 @@ RSpec.describe IsoDoc do
183
183
  </owner>
184
184
  </copyright>
185
185
  <ext>
186
- <doctype language="">article</doctype>
186
+ <doctype>article</doctype>
187
187
  <editorialgroup>
188
188
  <technical-committee/>
189
189
  <subcommittee/>
@@ -598,7 +598,7 @@ RSpec.describe IsoDoc do
598
598
  <doctype language=''>international-standard</doctype>
599
599
  <doctype language='fr'>Norme internationale</doctype>
600
600
  <doctype language='en'>International Standard</doctype>
601
- <horizontal language=''>false</horizontal>
601
+ <horizontal>false</horizontal>
602
602
  <structuredidentifier>
603
603
  <project-number part='192'>IEC 60050</project-number>
604
604
  </structuredidentifier>
@@ -621,7 +621,7 @@ RSpec.describe IsoDoc do
621
621
  <termnote id='_5f49cfad-e57e-5029-78cf-5b7e3e10a3b3'>
622
622
  <name>Note 1 to entry</name>
623
623
  <p id='_8c830e60-8f09-73a2-6393-2a27d9c5b1ce'>Dependability includes availability (<em>192-01-02</em>
624
- (<xref target='term-sub-item'>192-01-02</xref>),
624
+ (<xref target='term-sub-item'><span class='citesec'>192-01-02</span></xref>),
625
625
  <em>191-01-02</em>
626
626
  [term defined in
627
627
  <termref base='IEV' target='191-01-02'/>])</p>
@@ -740,7 +740,7 @@ RSpec.describe IsoDoc do
740
740
  CONTRAST:
741
741
  <strong>Fifth Designation</strong>
742
742
  (
743
- <xref target='paddy1'>192-01-02</xref>
743
+ <xref target='paddy1'><span class='citesec'>192-01-02</span></xref>
744
744
  )
745
745
  </p>
746
746
  <termexample id='_671a1994-4783-40d0-bc81-987d06ffb740'>
@@ -786,14 +786,14 @@ RSpec.describe IsoDoc do
786
786
  CONTRASTEZ:
787
787
  <strong>Designation cinqui&#xE8;me</strong>
788
788
  (
789
- <xref target='paddy1'>192-01-02</xref>
789
+ <xref target='paddy1'><span class='citesec'>192-01-02</span></xref>
790
790
  )
791
791
  </p>
792
792
  <p>
793
793
  VOIR:
794
794
  <strong>Designation sixi&#xE8;me</strong>
795
795
  (
796
- <xref target='paddy1'>192-01-02</xref>
796
+ <xref target='paddy1'><span class='citesec'>192-01-02</span></xref>
797
797
  )
798
798
  </p>
799
799
  <termexample id='_671a1994-4783-40d0-bc81-987d06ffb741'>
@@ -859,7 +859,7 @@ RSpec.describe IsoDoc do
859
859
  <dd language='zh' script='Hans'>
860
860
  <preferred>
861
861
  <strong>&#x4EA7;&#x54C1;</strong>
862
- &#x3001;&#x3c;&#x5728;&#x53EF;&#x9760;&#x6027;&#x65B9;&#x9762;&#x3e;
862
+ , &#x3c;&#x5728;&#x53EF;&#x9760;&#x6027;&#x65B9;&#x9762;&#x3e;
863
863
  </preferred>
864
864
  </dd>
865
865
  </dl>