isodoc 1.8.0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,71 +3,71 @@ require "spec_helper"
3
3
  RSpec.describe IsoDoc do
4
4
  it "processes IsoXML tables" do
5
5
  input = <<~INPUT
6
- <iso-standard xmlns="http://riboseinc.com/isoxml">
7
- <preface>
8
- <foreword>
9
- <table id="tableD-1" alt="tool tip" summary="long desc" width="70%" keep-with-next="true" keep-lines-together="true">
10
- <name>Repeatability and reproducibility of <em>husked</em> rice yield<fn reference="1"><p>X</p></fn></name>
11
- <colgroup>
12
- <col width="30%"/>
13
- <col width="20%"/>
14
- <col width="20%"/>
15
- <col width="20%"/>
16
- <col width="10%"/>
17
- </colgroup>
18
- <thead>
19
- <tr>
20
- <td rowspan="2" align="left">Description</td>
21
- <td colspan="4" align="center">Rice sample</td>
22
- </tr>
23
- <tr>
24
- <td valign="top" align="left">Arborio</td>
25
- <td valign="middle" align="center">Drago<fn reference="a">
26
- <p id="_0fe65e9a-5531-408e-8295-eeff35f41a55">Parboiled rice.</p>
27
- </fn></td>
28
- <td valign="bottom" align="center">Balilla<fn reference="a">
29
- <p id="_0fe65e9a-5531-408e-8295-eeff35f41a55">Parboiled rice.</p>
30
- </fn></td>
31
- <td align="center">Thaibonnet</td>
32
- </tr>
33
- </thead>
34
- <tbody>
35
- <tr>
36
- <th align="left">Number of laboratories retained after eliminating outliers</th>
37
- <td align="center">13</td>
38
- <td align="center">11</td>
39
- <td align="center">13</td>
40
- <td align="center">13</td>
41
- </tr>
42
- <tr>
43
- <td align="left">Mean value, g/100 g</td>
44
- <td align="center">81,2</td>
45
- <td align="center">82,0</td>
46
- <td align="center">81,8</td>
47
- <td align="center">77,7</td>
48
- </tr>
49
- </tbody>
50
- <tfoot>
51
- <tr>
52
- <td align="left">Reproducibility limit, <stem type="AsciiMath">R</stem> (= 2,83 <stem type="AsciiMath">s_R</stem>)</td>
53
- <td align="center">2,89</td>
54
- <td align="center">0,57</td>
55
- <td align="center">2,26</td>
56
- <td align="center">6,06</td>
57
- </tr>
58
- </tfoot>
59
- <dl>
60
- <dt>Drago</dt>
61
- <dd>A type of rice</dd>
62
- </dl>
63
- <note><p>This is a table about rice</p></note>
64
- </table>
65
- <table id="tableD-2" unnumbered="true">
66
- <tbody><tr><td>A</td></tr></tbody>
67
- </table>
68
- </foreword>
69
- </preface>
70
- </iso-standard>
6
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
7
+ <preface>
8
+ <foreword>
9
+ <table id="tableD-1" alt="tool tip" summary="long desc" width="70%" keep-with-next="true" keep-lines-together="true">
10
+ <name>Repeatability and reproducibility of <em>husked</em> rice yield<fn reference="1"><p>X</p></fn></name>
11
+ <colgroup>
12
+ <col width="30%"/>
13
+ <col width="20%"/>
14
+ <col width="20%"/>
15
+ <col width="20%"/>
16
+ <col width="10%"/>
17
+ </colgroup>
18
+ <thead>
19
+ <tr>
20
+ <td rowspan="2" align="left">Description</td>
21
+ <td colspan="4" align="center">Rice sample</td>
22
+ </tr>
23
+ <tr>
24
+ <td valign="top" align="left">Arborio</td>
25
+ <td valign="middle" align="center">Drago<fn reference="a">
26
+ <p id="_0fe65e9a-5531-408e-8295-eeff35f41a55">Parboiled rice.</p>
27
+ </fn></td>
28
+ <td valign="bottom" align="center">Balilla<fn reference="a">
29
+ <p id="_0fe65e9a-5531-408e-8295-eeff35f41a55">Parboiled rice.</p>
30
+ </fn></td>
31
+ <td align="center">Thaibonnet</td>
32
+ </tr>
33
+ </thead>
34
+ <tbody>
35
+ <tr>
36
+ <th align="left">Number of laboratories retained after eliminating outliers</th>
37
+ <td align="center">13</td>
38
+ <td align="center">11</td>
39
+ <td align="center">13</td>
40
+ <td align="center">13</td>
41
+ </tr>
42
+ <tr>
43
+ <td align="left">Mean value, g/100 g</td>
44
+ <td align="center">81,2</td>
45
+ <td align="center">82,0</td>
46
+ <td align="center">81,8</td>
47
+ <td align="center">77,7</td>
48
+ </tr>
49
+ </tbody>
50
+ <tfoot>
51
+ <tr>
52
+ <td align="left">Reproducibility limit, <stem type="AsciiMath">R</stem> (= 2,83 <stem type="AsciiMath">s_R</stem>)</td>
53
+ <td align="center">2,89</td>
54
+ <td align="center">0,57</td>
55
+ <td align="center">2,26</td>
56
+ <td align="center">6,06</td>
57
+ </tr>
58
+ </tfoot>
59
+ <dl>
60
+ <dt>Drago</dt>
61
+ <dd>A type of rice</dd>
62
+ </dl>
63
+ <note><p>This is a table about rice</p></note>
64
+ </table>
65
+ <table id="tableD-2" unnumbered="true">
66
+ <tbody><tr><td>A</td></tr></tbody>
67
+ </table>
68
+ </foreword>
69
+ </preface>
70
+ </iso-standard>
71
71
  INPUT
72
72
 
73
73
  presxml = <<~OUTPUT
@@ -344,14 +344,12 @@ RSpec.describe IsoDoc do
344
344
  <td align='center' style='border-top:solid windowtext 1.5pt;mso-border-top-alt:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;mso-border-bottom-alt:solid windowtext 1.5pt;'>6,06</td>
345
345
  </tr>
346
346
  </tfoot>
347
- <table class='dl'>
348
- <tr>
349
- <td valign='top' align='left'>
350
- <p align='left' style='margin-left:0pt;text-align:left;'>Drago</p>
351
- </td>
352
- <td valign='top'>A type of rice</td>
353
- </tr>
354
- </table>
347
+ <dl>
348
+ <dt>
349
+ <p align='left' style='margin-left:0pt;text-align:left;'>Drago</p>
350
+ </dt>
351
+ <dd>A type of rice</dd>
352
+ </dl>
355
353
  <div class='Note'>
356
354
  <p class='Note'>
357
355
  <span class='note_label'>NOTE</span>
@@ -0,0 +1,347 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe IsoDoc do
4
+ it "realises subsequences" do
5
+ input = <<~INPUT
6
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
7
+ <preface>
8
+ <foreword id="fwd">
9
+ <p>
10
+ <xref target="N1"/>
11
+ <xref target="N2"/>
12
+ <xref target="N3"/>
13
+ <xref target="N4"/>
14
+ <xref target="N5"/>
15
+ <xref target="N6"/>
16
+ <xref target="N7"/>
17
+ <xref target="N8"/>
18
+ </p>
19
+ </foreword>
20
+ <introduction id="intro">
21
+ <figure id="N1"> <name>Split-it-right sample divider</name>
22
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
23
+ </figure>
24
+ <figure id="N2" subsequence="A"> <name>Split-it-right sample divider</name>
25
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
26
+ </figure>
27
+ <figure id="N3" subsequence="A"> <name>Split-it-right sample divider</name>
28
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
29
+ </figure>
30
+ <figure id="N4" subsequence="B"> <name>Split-it-right sample divider</name>
31
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
32
+ </figure>
33
+ <figure id="N5" subsequence="B"> <name>Split-it-right sample divider</name>
34
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
35
+ </figure>
36
+ <figure id="N6" subsequence="B"> <name>Split-it-right sample divider</name>
37
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
38
+ </figure>
39
+ <figure id="N7"> <name>Split-it-right sample divider</name>
40
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
41
+ </figure>
42
+ <figure id="N8"> <name>Split-it-right sample divider</name>
43
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
44
+ </figure>
45
+ </introduction>
46
+ </iso-standard>
47
+ INPUT
48
+ output = <<~OUTPUT
49
+ <foreword id='fwd' displayorder="1">
50
+ <p>
51
+ <xref target='N1'>Figure 1</xref>
52
+ <xref target='N2'>Figure 2a</xref>
53
+ <xref target='N3'>Figure 2b</xref>
54
+ <xref target='N4'>Figure 3a</xref>
55
+ <xref target='N5'>Figure 3b</xref>
56
+ <xref target='N6'>Figure 3c</xref>
57
+ <xref target='N7'>Figure 4</xref>
58
+ <xref target='N8'>Figure 5</xref>
59
+ </p>
60
+ </foreword>
61
+ OUTPUT
62
+ expect(xmlpp(Nokogiri::XML(IsoDoc::PresentationXMLConvert.new({})
63
+ .convert("test", input, true))
64
+ .at("//xmlns:foreword").to_xml))
65
+ .to be_equivalent_to xmlpp(output)
66
+ end
67
+
68
+ it "realises numbering overrides" do
69
+ input = <<~INPUT
70
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
71
+ <preface>
72
+ <foreword id="fwd">
73
+ <p>
74
+ <xref target="N1"/>
75
+ <xref target="N2"/>
76
+ <xref target="N3"/>
77
+ <xref target="N4"/>
78
+ <xref target="N5"/>
79
+ <xref target="N6"/>
80
+ <xref target="N7"/>
81
+ <xref target="N8"/>
82
+ <xref target="N9"/>
83
+ <xref target="N10"/>
84
+ <xref target="N11"/>
85
+ <xref target="N12"/>
86
+ <xref target="N13"/>
87
+ </p>
88
+ <p>
89
+ <xref target="S1"/>
90
+ <xref target="S2"/>
91
+ <xref target="S3"/>
92
+ <xref target="S4"/>
93
+ <xref target="S12"/>
94
+ <xref target="S13"/>
95
+ <xref target="S14"/>
96
+ <xref target="S15"/>
97
+ <xref target="S16"/>
98
+ <xref target="S17"/>
99
+ <xref target="S18"/>
100
+ <xref target="S19"/>
101
+ <xref target="S20"/>
102
+ <xref target="S21"/>
103
+ <xref target="S22"/>
104
+ <xref target="S23"/>
105
+ <xref target="S24"/>
106
+ <xref target="S25"/>
107
+ <xref target="S26"/>
108
+ <xref target="S27"/>
109
+ <xref target="S28"/>
110
+ <xref target="S29"/>
111
+ <xref target="S30"/>
112
+ </p>
113
+ </foreword>
114
+ <introduction id="intro">
115
+ <figure id="N1"> <name>Split-it-right sample divider</name>
116
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
117
+ </figure>
118
+ <figure id="N2" number="A"> <name>Split-it-right sample divider</name>
119
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
120
+ </figure>
121
+ <figure id="N3"> <name>Split-it-right sample divider</name>
122
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
123
+ </figure>
124
+ <figure id="N4" number="7"> <name>Split-it-right sample divider</name>
125
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
126
+ </figure>
127
+ <figure id="N5"> <name>Split-it-right sample divider</name>
128
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
129
+ </figure>
130
+ <figure id="N6" subsequence="B"> <name>Split-it-right sample divider</name>
131
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
132
+ </figure>
133
+ <figure id="N7" subsequence="B" number="c"> <name>Split-it-right sample divider</name>
134
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
135
+ </figure>
136
+ <figure id="N8" subsequence="B"> <name>Split-it-right sample divider</name>
137
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
138
+ </figure>
139
+ <figure id="N9" subsequence="C" number="20f"> <name>Split-it-right sample divider</name>
140
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
141
+ </figure>
142
+ <figure id="N10" subsequence="C"> <name>Split-it-right sample divider</name>
143
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
144
+ </figure>
145
+ <figure id="N11" number="A.1"> <name>Split-it-right sample divider</name>
146
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
147
+ </figure>
148
+ <figure id="N12"> <name>Split-it-right sample divider</name>
149
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
150
+ </figure>
151
+ <figure id="N13" number="100"> <name>Split-it-right sample divider</name>
152
+ <image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
153
+ </figure>
154
+ </introduction>
155
+ </preface>
156
+ <sections>
157
+ <clause id='S1' number='1bis' type='scope' inline-header='false' obligation='normative'>
158
+ <title>Scope</title>
159
+ <p id='_'>Text</p>
160
+ </clause>
161
+ <terms id='S3' number='3bis' obligation='normative'>
162
+ <title>Terms and definitions</title>
163
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
164
+ <term id='S4' number='4bis'>
165
+ <preferred><expression><name>Term1</name></expression></preferred>
166
+ </term>
167
+ </terms>
168
+ <definitions id='S12' number='12bis' type='abbreviated_terms' obligation='normative'>
169
+ <title>Abbreviated terms</title>
170
+ </definitions>
171
+ <clause id='S13' number='13bis' inline-header='false' obligation='normative'>
172
+ <title>Clause 4</title>
173
+ <clause id='S14' number='14bis' inline-header='false' obligation='normative'>
174
+ <title>Introduction</title>
175
+ </clause>
176
+ <clause id='S15' inline-header='false' obligation='normative'>
177
+ <title>Clause A</title>
178
+ </clause>
179
+ <clause id='S16' inline-header='false' obligation='normative'>
180
+ <title>Clause B</title>
181
+ </clause>
182
+ <clause id='S17' number='0' inline-header='false' obligation='normative'>
183
+ <title>Clause C</title>
184
+ </clause>
185
+ <clause id='S18' inline-header='false' obligation='normative'>
186
+ <title>Clause D</title>
187
+ </clause>
188
+ <clause id='S19' inline-header='false' obligation='normative'>
189
+ <title>Clause E</title>
190
+ </clause>
191
+ <clause id='S20' number='a' inline-header='false' obligation='normative'>
192
+ <title>Clause F</title>
193
+ </clause>
194
+ <clause id='S21' inline-header='false' obligation='normative'>
195
+ <title>Clause G</title>
196
+ </clause>
197
+ <clause id='S22' number='B' inline-header='false' obligation='normative'>
198
+ <title>Clause H</title>
199
+ </clause>
200
+ <clause id='S23' inline-header='false' obligation='normative'>
201
+ <title>Clause I</title>
202
+ </clause>
203
+ </clause>
204
+ <clause id='S24' number='16bis' inline-header='false' obligation='normative'>
205
+ <title>Terms and Definitions</title>
206
+ </clause>
207
+ </sections>
208
+ <annex id='S25' obligation='normative'>
209
+ <title>First Annex</title>
210
+ </annex>
211
+ <annex id='S26' number='17bis' inline-header='false' obligation='normative'>
212
+ <title>Annex</title>
213
+ <clause id='S27' number='18bis' inline-header='false' obligation='normative'>
214
+ <title>Annex A.1</title>
215
+ </clause>
216
+ </annex>
217
+ <annex id='S28' inline-header='false' obligation='normative'>
218
+ <title>Another Annex</title>
219
+ </annex>
220
+ <bibliography>
221
+ <references id='S2' number='2bis' normative='true' obligation='informative'>
222
+ <title>Normative references</title>
223
+ <p id='_'>There are no normative references in this document.</p>
224
+ </references>
225
+ <clause id='S29' number='19bis' obligation='informative'>
226
+ <title>Bibliography</title>
227
+ <references id='S30' number='20bis' normative='false' obligation='informative'>
228
+ <title>Bibliography Subsection</title>
229
+ </references>
230
+ </clause>
231
+ </bibliography>
232
+ </iso-standard>
233
+ INPUT
234
+ output = <<~OUTPUT
235
+ <foreword id='fwd' displayorder='1'>
236
+ <p>
237
+ <xref target='N1'>Figure 1</xref>
238
+ <xref target='N2'>Figure A</xref>
239
+ <xref target='N3'>Figure B</xref>
240
+ <xref target='N4'>Figure 7</xref>
241
+ <xref target='N5'>Figure 8</xref>
242
+ <xref target='N6'>Figure 9a</xref>
243
+ <xref target='N7'>Figure 9c</xref>
244
+ <xref target='N8'>Figure 9d</xref>
245
+ <xref target='N9'>Figure 20f</xref>
246
+ <xref target='N10'>Figure 20g</xref>
247
+ <xref target='N11'>Figure A.1</xref>
248
+ <xref target='N12'>Figure A.2</xref>
249
+ <xref target='N13'>Figure 100</xref>
250
+ </p>
251
+ <p>
252
+ <xref target='S1'>Clause 1bis</xref>
253
+ <xref target='S2'>Clause 2bis</xref>
254
+ <xref target='S3'>Clause 3bis</xref>
255
+ <xref target='S4'>Clause 3bis.4bis</xref>
256
+ <xref target='S12'>Clause 12bis</xref>
257
+ <xref target='S13'>Clause 13bis</xref>
258
+ <xref target='S14'>Clause 13bis.14bis</xref>
259
+ <xref target='S15'>Clause 13bis.14bit</xref>
260
+ <xref target='S16'>Clause 13bis.14biu</xref>
261
+ <xref target='S17'>Clause 13bis.0</xref>
262
+ <xref target='S18'>Clause 13bis.1</xref>
263
+ <xref target='S19'>Clause 13bis.2</xref>
264
+ <xref target='S20'>Clause 13bis.a</xref>
265
+ <xref target='S21'>Clause 13bis.b</xref>
266
+ <xref target='S22'>Clause 13bis.B</xref>
267
+ <xref target='S23'>Clause 13bis.C</xref>
268
+ <xref target='S24'>Clause 16bis</xref>
269
+ <xref target='S25'>Annex A</xref>
270
+ <xref target='S26'>Annex 17bis</xref>
271
+ <xref target='S27'>Annex 17bis.18bis</xref>
272
+ <xref target='S28'>Annex 17bit</xref>
273
+ <xref target='S29'>Bibliography</xref>
274
+ <xref target='S30'>Bibliography Subsection</xref>
275
+ </p>
276
+ </foreword>
277
+ OUTPUT
278
+ expect(xmlpp(Nokogiri::XML(IsoDoc::PresentationXMLConvert.new({})
279
+ .convert("test", input, true))
280
+ .at("//xmlns:foreword").to_xml))
281
+ .to be_equivalent_to xmlpp(output)
282
+ end
283
+
284
+ it "realises roman counter for xrefs" do
285
+ a = IsoDoc::XrefGen::Counter.new(0, numerals: :roman)
286
+ a.increment({})
287
+ expect(a.print).to eq "I"
288
+ a.increment({})
289
+ expect(a.print).to eq "II"
290
+ a.increment({})
291
+ expect(a.print).to eq "III"
292
+ a.increment({})
293
+ expect(a.print).to eq "IV"
294
+ a.increment({})
295
+ expect(a.print).to eq "V"
296
+ end
297
+
298
+ it "skips I in counter for xrefs" do
299
+ a = IsoDoc::XrefGen::Counter.new("@", skip_i: true)
300
+ a.increment({})
301
+ a.increment({})
302
+ a.increment({})
303
+ a.increment({})
304
+ a.increment({})
305
+ a.increment({})
306
+ a.increment({})
307
+ a.increment({})
308
+ expect(a.print).to eq "H"
309
+ a.increment({})
310
+ expect(a.print).to eq "J"
311
+ a = IsoDoc::XrefGen::Counter.new("@")
312
+ a.increment({})
313
+ a.increment({})
314
+ a.increment({})
315
+ a.increment({})
316
+ a.increment({})
317
+ a.increment({})
318
+ a.increment({})
319
+ a.increment({})
320
+ expect(a.print).to eq "H"
321
+ a.increment({})
322
+ expect(a.print).to eq "I"
323
+ end
324
+
325
+ it "increments counter past Z for xrefs" do
326
+ a = IsoDoc::XrefGen::Counter.new("Z")
327
+ a.increment({})
328
+ expect(a.print).to eq "AA"
329
+ a.increment({})
330
+ expect(a.print).to eq "AB"
331
+ a = IsoDoc::XrefGen::Counter.new("BZ")
332
+ a.increment({})
333
+ expect(a.print).to eq "CA"
334
+ a.increment({})
335
+ expect(a.print).to eq "CB"
336
+ a = IsoDoc::XrefGen::Counter.new("z")
337
+ a.increment({})
338
+ expect(a.print).to eq "aa"
339
+ a.increment({})
340
+ expect(a.print).to eq "ab"
341
+ a = IsoDoc::XrefGen::Counter.new("Az")
342
+ a.increment({})
343
+ expect(a.print).to eq "Ba"
344
+ a.increment({})
345
+ expect(a.print).to eq "Bb"
346
+ end
347
+ end