isodoc 0.5.5 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CODE_OF_CONDUCT.md +46 -0
  3. data/LICENSE +25 -0
  4. data/README.adoc +1 -1
  5. data/Rakefile +6 -0
  6. data/isodoc.gemspec +1 -0
  7. data/lib/isodoc.rb +4 -95
  8. data/lib/isodoc/cleanup.rb +14 -10
  9. data/lib/isodoc/{notes.rb → comments.rb} +0 -73
  10. data/lib/isodoc/convert.rb +97 -0
  11. data/lib/isodoc/footnotes.rb +74 -0
  12. data/lib/isodoc/html.rb +41 -4
  13. data/lib/isodoc/i18n-en.yaml +1 -0
  14. data/lib/isodoc/i18n-fr.yaml +1 -0
  15. data/lib/isodoc/i18n-zh-Hans.yaml +1 -0
  16. data/lib/isodoc/i18n.rb +1 -0
  17. data/lib/isodoc/inline.rb +4 -12
  18. data/lib/isodoc/iso2wordhtml.rb +26 -13
  19. data/lib/isodoc/metadata.rb +23 -10
  20. data/lib/isodoc/references.rb +20 -22
  21. data/lib/isodoc/section.rb +4 -3
  22. data/lib/isodoc/table.rb +0 -2
  23. data/lib/isodoc/terms.rb +2 -13
  24. data/lib/isodoc/utils.rb +24 -3
  25. data/lib/isodoc/version.rb +1 -1
  26. data/lib/isodoc/wordconvert/comments.rb +155 -0
  27. data/lib/isodoc/wordconvert/convert.rb +31 -0
  28. data/lib/isodoc/wordconvert/footnotes.rb +80 -0
  29. data/lib/isodoc/wordconvert/wordconvertmodule.rb +212 -0
  30. data/lib/isodoc/xref_gen.rb +50 -79
  31. data/lib/isodoc/xref_sect_gen.rb +82 -0
  32. data/spec/assets/header.html +7 -0
  33. data/spec/assets/html.css +2 -0
  34. data/spec/assets/htmlcover.html +4 -0
  35. data/spec/assets/htmlintro.html +5 -0
  36. data/spec/assets/i18n.yaml +2 -0
  37. data/spec/assets/iso.xml +8 -0
  38. data/spec/assets/rice_image1.png +0 -0
  39. data/spec/assets/std.css +2 -0
  40. data/spec/assets/word.css +2 -0
  41. data/spec/assets/wordcover.html +3 -0
  42. data/spec/assets/wordintro.html +4 -0
  43. data/spec/isodoc/blocks_spec.rb +130 -47
  44. data/spec/isodoc/cleanup_spec.rb +693 -0
  45. data/spec/isodoc/footnotes_spec.rb +282 -0
  46. data/spec/isodoc/i18n_spec.rb +662 -0
  47. data/spec/isodoc/inline_spec.rb +344 -0
  48. data/spec/isodoc/lists_spec.rb +81 -18
  49. data/spec/isodoc/metadata_spec.rb +141 -0
  50. data/spec/isodoc/postproc_spec.rb +444 -0
  51. data/spec/isodoc/ref_spec.rb +158 -0
  52. data/spec/isodoc/section_spec.rb +275 -112
  53. data/spec/isodoc/table_spec.rb +146 -8
  54. data/spec/isodoc/terms_spec.rb +118 -0
  55. data/spec/isodoc/xref_spec.rb +490 -114
  56. metadata +46 -4
  57. data/lib/isodoc/postprocessing.rb +0 -176
@@ -0,0 +1,693 @@
1
+ require "spec_helper"
2
+ require "nokogiri"
3
+
4
+ RSpec.describe IsoDoc do
5
+ it "cleans up admonitions" do
6
+ expect(IsoDoc::Convert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
7
+ <html>
8
+ <body>
9
+ <div class="Admonition">
10
+ <title>Warning</title>
11
+ <p>Text</p>
12
+ </div>
13
+ </body>
14
+ </html>
15
+ INPUT
16
+ <?xml version="1.0"?>
17
+ <html>
18
+ <body>
19
+ <div class="Admonition">
20
+
21
+ <p>Warning&#x2014;Text</p>
22
+ </div>
23
+ </body>
24
+ </html>
25
+ OUTPUT
26
+ end
27
+
28
+ it "cleans up figures" do
29
+ expect(IsoDoc::Convert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
30
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
31
+ <body>
32
+ <div class="figure">
33
+ <p>Warning</p>
34
+ <a href="#tableD-1a" class="TableFootnoteRef">a</a><aside><div id="ftntableD-1a"><a id="tableD-1a" class="TableFootnoteRef">a<span style="mso-tab-count:1">&#160; </span></a>
35
+ <p id="_0fe65e9a-5531-408e-8295-eeff35f41a55">Parboiled rice.</p>
36
+ </div></aside>
37
+ </div>
38
+ </body>
39
+ </html>
40
+ INPUT
41
+ <?xml version="1.0"?>
42
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
43
+ <body>
44
+ <div class="figure">
45
+ <p>Warning</p>
46
+ <aside><div id="ftntableD-1a">
47
+
48
+ </div></aside>
49
+ <p><b/></p><dl><dt><a id="tableD-1a" class="TableFootnoteRef">a<span style="mso-tab-count:1">&#xA0; </span></a></dt><dd><p id="_0fe65e9a-5531-408e-8295-eeff35f41a55">Parboiled rice.</p></dd></dl></div>
50
+ </body>
51
+ </html>
52
+ OUTPUT
53
+ end
54
+
55
+ it "cleans up inline headers" do
56
+ expect(IsoDoc::Convert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
57
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
58
+ <head>
59
+ <title>test</title>
60
+ <body lang="EN-US" link="blue" vlink="#954F72">
61
+ <div class="WordSection1">
62
+ <p>&#160;</p>
63
+ </div>
64
+ <br clear="all" class="section"/>
65
+ <div class="WordSection2">
66
+ <p>&#160;</p>
67
+ </div>
68
+ <br clear="all" class="section"/>
69
+ <div class="WordSection3">
70
+ <p class="zzSTDTitle1"/>
71
+ <div id="M">
72
+ <h1>4.<span style="mso-tab-count:1">&#160; </span>Clause 4</h1>
73
+ <div id="N">
74
+ <h2>4.1. Introduction</h2>
75
+ </div>
76
+ <div id="O">
77
+ <span class="zzMoveToFollowing"><b>4.2. Clause 4.2 </b></span>
78
+ </div>
79
+ <div id="P">
80
+ <span class="zzMoveToFollowing"><b>4.3. Clause 4.3 </b></span>
81
+ <p>text</p>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ </body>
86
+ </head>
87
+ </html>
88
+ INPUT
89
+ <?xml version="1.0"?>
90
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
91
+ <head>
92
+ <title>test</title>
93
+ <body lang="EN-US" link="blue" vlink="#954F72">
94
+ <div class="WordSection1">
95
+ <p>&#xA0;</p>
96
+ </div>
97
+ <br clear="all" class="section"/>
98
+ <div class="WordSection2">
99
+ <p>&#xA0;</p>
100
+ </div>
101
+ <br clear="all" class="section"/>
102
+ <div class="WordSection3">
103
+ <p class="zzSTDTitle1"/>
104
+ <div id="M">
105
+ <h1>4.<span style="mso-tab-count:1">&#xA0; </span>Clause 4</h1>
106
+ <div id="N">
107
+ <h2>4.1. Introduction</h2>
108
+ </div>
109
+ <div id="O">
110
+ <p><b>4.2. Clause 4.2 </b></p>
111
+ </div>
112
+ <div id="P">
113
+
114
+ <p><span><b>4.3. Clause 4.3 </b></span>text</p>
115
+ </div>
116
+ </div>
117
+ </div>
118
+ </body>
119
+ </head>
120
+ </html>
121
+ OUTPUT
122
+ end
123
+
124
+ it "cleans up footnotes" do
125
+ expect(IsoDoc::Convert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
126
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
127
+ <head>
128
+ <title>test</title>
129
+ <body lang="EN-US" link="blue" vlink="#954F72">
130
+ <div class="WordSection1">
131
+ <p>&#160;</p>
132
+ </div>
133
+ <br clear="all" class="section"/>
134
+ <div class="WordSection2">
135
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
136
+ <div>
137
+ <h1 class="ForewordTitle">Foreword</h1>
138
+ <p>A.<a href="#ftn2" epub:type="footnote"><sup>2</sup></a></p>
139
+ <p>B.<a href="#ftn2" epub:type="footnote"><sup>2</sup></a></p>
140
+ <p>C.<a href="#ftn1" epub:type="footnote"><sup>1</sup></a></p>
141
+ </div>
142
+ <p>&#160;</p>
143
+ </div>
144
+ <br clear="all" class="section"/>
145
+ <div class="WordSection3">
146
+ <p class="zzSTDTitle1"/>
147
+ <aside id="ftn2">
148
+ <p id="_1e228e29-baef-4f38-b048-b05a051747e4">Formerly denoted as 15 % (m/m).</p>
149
+ </aside>
150
+ <aside id="ftn1">
151
+ <p id="_1e228e29-baef-4f38-b048-b05a051747e4">Hello! denoted as 15 % (m/m).</p>
152
+ </aside>
153
+ </div>
154
+ </body>
155
+ </head>
156
+ </html>
157
+ INPUT
158
+ <?xml version="1.0"?>
159
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
160
+ <head>
161
+ <title>test</title>
162
+ <body lang="EN-US" link="blue" vlink="#954F72">
163
+ <div class="WordSection1">
164
+ <p>&#xA0;</p>
165
+ </div>
166
+ <br clear="all" class="section"/>
167
+ <div class="WordSection2">
168
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
169
+ <div>
170
+ <h1 class="ForewordTitle">Foreword</h1>
171
+ <p>A.<a href="#ftn2" epub:type="footnote"><sup>1</sup></a></p>
172
+ <p>B.<a href="#ftn2" epub:type="footnote"><sup>2</sup></a></p>
173
+ <p>C.<a href="#ftn1" epub:type="footnote"><sup>3</sup></a></p>
174
+ </div>
175
+ <p>&#xA0;</p>
176
+ </div>
177
+ <br clear="all" class="section"/>
178
+ <div class="WordSection3">
179
+ <p class="zzSTDTitle1"/>
180
+ <aside id="ftn2">
181
+ <p id="_1e228e29-baef-4f38-b048-b05a051747e4">Formerly denoted as 15 % (m/m).</p>
182
+ </aside>
183
+ <aside id="ftn1">
184
+ <p id="_1e228e29-baef-4f38-b048-b05a051747e4">Hello! denoted as 15 % (m/m).</p>
185
+ </aside>
186
+ </div>
187
+ </body>
188
+ </head>
189
+ </html>
190
+ OUTPUT
191
+ end
192
+
193
+ it "cleans up tables with tfoot" do
194
+ expect(IsoDoc::Convert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
195
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
196
+ <head>
197
+ <title>test</title>
198
+ <body lang="EN-US" link="blue" vlink="#954F72">
199
+ <div class="WordSection1">
200
+ <p>&#160;</p>
201
+ </div>
202
+ <br clear="all" class="section"/>
203
+ <div class="WordSection2">
204
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
205
+ <div>
206
+ <h1 class="ForewordTitle">Foreword</h1>
207
+ <p class="TableTitle" align="center">
208
+ <b>Table 1&#160;&#8212; Repeatability and reproducibility of husked rice yield</b>
209
+ </p>
210
+ <table id="tableD-1" class="MsoISOTable" border="1" cellspacing="0" cellpadding="0">
211
+ <thead>
212
+ <tr>
213
+ <td rowspan="2" align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">Description</td>
214
+ <td colspan="4" align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">Rice sample</td>
215
+ </tr>
216
+ <tr>
217
+ <td align="left" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Arborio</td>
218
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Drago<a href="#tableD-1a" class="TableFootnoteRef">a</a><aside><div id="ftntableD-1a"><a id="tableD-1a" class="TableFootnoteRef">a<span style="mso-tab-count:1">&#160; </span></a>
219
+ <p id="_0fe65e9a-5531-408e-8295-eeff35f41a55">Parboiled rice.</p>
220
+ </div></aside></td>
221
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Balilla<a href="#tableD-1a" class="TableFootnoteRef">a</a></td>
222
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Thaibonnet</td>
223
+ </tr>
224
+ </thead>
225
+ <tbody>
226
+ <tr>
227
+ <td align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">Number of laboratories retained after eliminating outliers</td>
228
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
229
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">11</td>
230
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
231
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
232
+ </tr>
233
+ <tr>
234
+ <td align="left" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Mean value, g/100 g</td>
235
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">81,2</td>
236
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">82,0</td>
237
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">81,8</td>
238
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">77,7</td>
239
+ </tr>
240
+ </tbody>
241
+ <tfoot>
242
+ <tr>
243
+ <td align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">Reproducibility limit, <span class="stem">(#(R)#)</span> (= 2,83 <span class="stem">(#(s_R)#)</span>)</td>
244
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">2,89</td>
245
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">0,57</td>
246
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">2,26</td>
247
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">6,06</td>
248
+ </tr>
249
+ </tfoot>
250
+ <dl>
251
+ <dt>
252
+ <p>Drago</p>
253
+ </dt>
254
+ <dd>A type of rice</dd>
255
+ </dl>
256
+ <div id="" class="Note">
257
+ <p class="Note">NOTE<span style="mso-tab-count:1">&#160; </span>This is a table about rice</p>
258
+ </div>
259
+ </table>
260
+ </div>
261
+ <p>&#160;</p>
262
+ </div>
263
+ <br clear="all" class="section"/>
264
+ <div class="WordSection3">
265
+ <p class="zzSTDTitle1"/>
266
+ </div>
267
+ </body>
268
+ </head>
269
+ </html>
270
+ INPUT
271
+ <?xml version="1.0"?>
272
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
273
+ <head>
274
+ <title>test</title>
275
+ <body lang="EN-US" link="blue" vlink="#954F72">
276
+ <div class="WordSection1">
277
+ <p>&#xA0;</p>
278
+ </div>
279
+ <br clear="all" class="section"/>
280
+ <div class="WordSection2">
281
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
282
+ <div>
283
+ <h1 class="ForewordTitle">Foreword</h1>
284
+ <p class="TableTitle" align="center">
285
+ <b>Table 1&#xA0;&#x2014; Repeatability and reproducibility of husked rice yield</b>
286
+ </p>
287
+ <table id="tableD-1" class="MsoISOTable" border="1" cellspacing="0" cellpadding="0">
288
+ <thead>
289
+ <tr>
290
+ <td rowspan="2" align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">Description</td>
291
+ <td colspan="4" align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">Rice sample</td>
292
+ </tr>
293
+ <tr>
294
+ <td align="left" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Arborio</td>
295
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Drago<a href="#tableD-1a" class="TableFootnoteRef">a</a></td>
296
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Balilla<a href="#tableD-1a" class="TableFootnoteRef">a</a></td>
297
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Thaibonnet</td>
298
+ </tr>
299
+ </thead>
300
+ <tbody>
301
+ <tr>
302
+ <td align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">Number of laboratories retained after eliminating outliers</td>
303
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
304
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">11</td>
305
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
306
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
307
+ </tr>
308
+ <tr>
309
+ <td align="left" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Mean value, g/100 g</td>
310
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">81,2</td>
311
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">82,0</td>
312
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">81,8</td>
313
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">77,7</td>
314
+ </tr>
315
+ </tbody>
316
+ <tfoot>
317
+ <tr>
318
+ <td align="left" style="border-top:solid windowtext 1.5pt;border-bottom:0pt;">Reproducibility limit, <span class="stem">(#(R)#)</span> (= 2,83 <span class="stem">(#(s_R)#)</span>)</td>
319
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:0pt;">2,89</td>
320
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:0pt;">0,57</td>
321
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:0pt;">2,26</td>
322
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:0pt;">6,06</td>
323
+ </tr>
324
+ <tr><td colspan="5" style="border-top:0pt;border-bottom:solid windowtext 1.5pt;"><div id="" class="Note">
325
+ <p class="Note">NOTE<span style="mso-tab-count:1">&#xA0; </span>This is a table about rice</p>
326
+ </div><div class="Note"><div id="ftntableD-1a">
327
+ <p id="_0fe65e9a-5531-408e-8295-eeff35f41a55" class="Note"><a id="tableD-1a" class="TableFootnoteRef">a<span style="mso-tab-count:1">&#xA0; </span></a>Parboiled rice.</p>
328
+ </div></div></td></tr></tfoot>
329
+ <dl>
330
+ <dt>
331
+ <p>Drago</p>
332
+ </dt>
333
+ <dd>A type of rice</dd>
334
+ </dl>
335
+
336
+ </table>
337
+ </div>
338
+ <p>&#xA0;</p>
339
+ </div>
340
+ <br clear="all" class="section"/>
341
+ <div class="WordSection3">
342
+ <p class="zzSTDTitle1"/>
343
+ </div>
344
+ </body>
345
+ </head>
346
+ </html>
347
+ OUTPUT
348
+ end
349
+
350
+ it "cleans up tables with tfoot (Word)" do
351
+ expect(IsoDoc::WordConvert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
352
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
353
+ <head>
354
+ <title>test</title>
355
+ <body lang="EN-US" link="blue" vlink="#954F72">
356
+ <div class="WordSection1">
357
+ <p>&#160;</p>
358
+ </div>
359
+ <br clear="all" class="section"/>
360
+ <div class="WordSection2">
361
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
362
+ <div>
363
+ <h1 class="ForewordTitle">Foreword</h1>
364
+ <p class="TableTitle" align="center">
365
+ <b>Table 1&#160;&#8212; Repeatability and reproducibility of husked rice yield</b>
366
+ </p>
367
+ <table id="tableD-1" class="MsoISOTable" border="1" cellspacing="0" cellpadding="0">
368
+ <thead>
369
+ <tr>
370
+ <td rowspan="2" align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">Description</td>
371
+ <td colspan="4" align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">Rice sample</td>
372
+ </tr>
373
+ <tr>
374
+ <td align="left" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Arborio</td>
375
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Drago<a href="#tableD-1a" class="TableFootnoteRef">a</a><aside><div id="ftntableD-1a"><a id="tableD-1a" class="TableFootnoteRef">a<span style="mso-tab-count:1">&#160; </span></a>
376
+ <p id="_0fe65e9a-5531-408e-8295-eeff35f41a55">Parboiled rice.</p>
377
+ </div></aside></td>
378
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Balilla<a href="#tableD-1a" class="TableFootnoteRef">a</a></td>
379
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Thaibonnet</td>
380
+ </tr>
381
+ </thead>
382
+ <tbody>
383
+ <tr>
384
+ <td align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">Number of laboratories retained after eliminating outliers</td>
385
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
386
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">11</td>
387
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
388
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
389
+ </tr>
390
+ <tr>
391
+ <td align="left" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Mean value, g/100 g</td>
392
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">81,2</td>
393
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">82,0</td>
394
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">81,8</td>
395
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">77,7</td>
396
+ </tr>
397
+ </tbody>
398
+ <tfoot>
399
+ <tr>
400
+ <td align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">Reproducibility limit, <span class="stem">(#(R)#)</span> (= 2,83 <span class="stem">(#(s_R)#)</span>)</td>
401
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">2,89</td>
402
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">0,57</td>
403
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">2,26</td>
404
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">6,06</td>
405
+ </tr>
406
+ </tfoot>
407
+ <dl>
408
+ <dt>
409
+ <p>Drago</p>
410
+ </dt>
411
+ <dd>A type of rice</dd>
412
+ </dl>
413
+ <div id="" class="Note">
414
+ <p class="Note">NOTE<span style="mso-tab-count:1">&#160; </span>This is a table about rice</p>
415
+ </div>
416
+ </table>
417
+ </div>
418
+ <p>&#160;</p>
419
+ </div>
420
+ <br clear="all" class="section"/>
421
+ <div class="WordSection3">
422
+ <p class="zzSTDTitle1"/>
423
+ </div>
424
+ </body>
425
+ </head>
426
+ </html>
427
+ INPUT
428
+ <?xml version="1.0"?>
429
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
430
+ <head>
431
+ <title>test</title>
432
+ <body lang="EN-US" link="blue" vlink="#954F72">
433
+ <div class="WordSection1">
434
+ <p>&#xA0;</p>
435
+ </div>
436
+ <br clear="all" class="section"/>
437
+ <div class="WordSection2">
438
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
439
+ <div>
440
+ <h1 class="ForewordTitle">Foreword</h1>
441
+ <p class="TableTitle" align="center">
442
+ <b>Table 1&#xA0;&#x2014; Repeatability and reproducibility of husked rice yield</b>
443
+ </p>
444
+ <table id="tableD-1" class="MsoISOTable" border="1" cellspacing="0" cellpadding="0">
445
+ <thead>
446
+ <tr>
447
+ <td rowspan="2" align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">Description</td>
448
+ <td colspan="4" align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">Rice sample</td>
449
+ </tr>
450
+ <tr>
451
+ <td align="left" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Arborio</td>
452
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Drago<a href="#tableD-1a" class="TableFootnoteRef">a</a></td>
453
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Balilla<a href="#tableD-1a" class="TableFootnoteRef">a</a></td>
454
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Thaibonnet</td>
455
+ </tr>
456
+ </thead>
457
+ <tbody>
458
+ <tr>
459
+ <td align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">Number of laboratories retained after eliminating outliers</td>
460
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
461
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">11</td>
462
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
463
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
464
+ </tr>
465
+ <tr>
466
+ <td align="left" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Mean value, g/100 g</td>
467
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">81,2</td>
468
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">82,0</td>
469
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">81,8</td>
470
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">77,7</td>
471
+ </tr>
472
+ </tbody>
473
+ <tfoot>
474
+ <tr>
475
+ <td align="left" style="border-top:solid windowtext 1.5pt;border-bottom:0pt;">Reproducibility limit, <span class="stem">(#(R)#)</span> (= 2,83 <span class="stem">(#(s_R)#)</span>)</td>
476
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:0pt;">2,89</td>
477
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:0pt;">0,57</td>
478
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:0pt;">2,26</td>
479
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:0pt;">6,06</td>
480
+ </tr>
481
+ <tr><td colspan="5" style="border-top:0pt;mso-border-top-alt:0pt; border-bottom:solid windowtext 1.5pt;mso-border-bottom-alt:solid windowtext 1.5pt;"><div id="" class="Note">
482
+ <p class="Note">NOTE<span style="mso-tab-count:1">&#xA0; </span>This is a table about rice</p>
483
+ </div><div class="Note"><div id="ftntableD-1a">
484
+ <p id="_0fe65e9a-5531-408e-8295-eeff35f41a55" class="Note"><a id="tableD-1a" class="TableFootnoteRef">a<span style="mso-tab-count:1">&#xA0; </span></a>Parboiled rice.</p>
485
+ </div></div></td></tr></tfoot>
486
+ <dl>
487
+ <dt>
488
+ <p>Drago</p>
489
+ </dt>
490
+ <dd>A type of rice</dd>
491
+ </dl>
492
+
493
+ </table>
494
+ </div>
495
+ <p>&#xA0;</p>
496
+ </div>
497
+ <br clear="all" class="section"/>
498
+ <div class="WordSection3">
499
+ <p class="zzSTDTitle1"/>
500
+ </div>
501
+ </body>
502
+ </head>
503
+ </html>
504
+ OUTPUT
505
+ end
506
+
507
+
508
+ it "cleans up tables without tfoot" do
509
+ expect(IsoDoc::Convert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
510
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
511
+ <head>
512
+ <title>test</title>
513
+ <body lang="EN-US" link="blue" vlink="#954F72">
514
+ <div class="WordSection1">
515
+ <p>&#160;</p>
516
+ </div>
517
+ <br clear="all" class="section"/>
518
+ <div class="WordSection2">
519
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
520
+ <div>
521
+ <h1 class="ForewordTitle">Foreword</h1>
522
+ <p class="TableTitle" align="center">
523
+ <b>Table 1&#160;&#8212; Repeatability and reproducibility of husked rice yield</b>
524
+ </p>
525
+ <table id="tableD-1" class="MsoISOTable" border="1" cellspacing="0" cellpadding="0">
526
+ <thead>
527
+ <tr>
528
+ <td rowspan="2" align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">Description</td>
529
+ <td colspan="4" align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">Rice sample</td>
530
+ </tr>
531
+ <tr>
532
+ <td align="left" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Arborio</td>
533
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Drago<a href="#tableD-1a" class="TableFootnoteRef">a</a><aside><div id="ftntableD-1a"><a id="tableD-1a" class="TableFootnoteRef">a<span style="mso-tab-count:1">&#160; </span></a>
534
+ <p id="_0fe65e9a-5531-408e-8295-eeff35f41a55">Parboiled rice.</p>
535
+ </div></aside></td>
536
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Balilla<a href="#tableD-1a" class="TableFootnoteRef">a</a></td>
537
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Thaibonnet</td>
538
+ </tr>
539
+ </thead>
540
+ <tbody>
541
+ <tr>
542
+ <td align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">Number of laboratories retained after eliminating outliers</td>
543
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
544
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">11</td>
545
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
546
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
547
+ </tr>
548
+ <tr>
549
+ <td align="left" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Mean value, g/100 g</td>
550
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">81,2</td>
551
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">82,0</td>
552
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">81,8</td>
553
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">77,7</td>
554
+ </tr>
555
+ </tbody>
556
+ <dl>
557
+ <dt>
558
+ <p>Drago</p>
559
+ </dt>
560
+ <dd>A type of rice</dd>
561
+ </dl>
562
+ <div id="" class="Note">
563
+ <p class="Note">NOTE<span style="mso-tab-count:1">&#160; </span>This is a table about rice</p>
564
+ </div>
565
+ </table>
566
+ </div>
567
+ <p>&#160;</p>
568
+ </div>
569
+ <br clear="all" class="section"/>
570
+ <div class="WordSection3">
571
+ <p class="zzSTDTitle1"/>
572
+ </div>
573
+ </body>
574
+ </head>
575
+ </html>
576
+ INPUT
577
+ <?xml version="1.0"?>
578
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
579
+ <head>
580
+ <title>test</title>
581
+ <body lang="EN-US" link="blue" vlink="#954F72">
582
+ <div class="WordSection1">
583
+ <p>&#xA0;</p>
584
+ </div>
585
+ <br clear="all" class="section"/>
586
+ <div class="WordSection2">
587
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
588
+ <div>
589
+ <h1 class="ForewordTitle">Foreword</h1>
590
+ <p class="TableTitle" align="center">
591
+ <b>Table 1&#xA0;&#x2014; Repeatability and reproducibility of husked rice yield</b>
592
+ </p>
593
+ <table id="tableD-1" class="MsoISOTable" border="1" cellspacing="0" cellpadding="0">
594
+ <thead>
595
+ <tr>
596
+ <td rowspan="2" align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;">Description</td>
597
+ <td colspan="4" align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">Rice sample</td>
598
+ </tr>
599
+ <tr>
600
+ <td align="left" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Arborio</td>
601
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Drago<a href="#tableD-1a" class="TableFootnoteRef">a</a></td>
602
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Balilla<a href="#tableD-1a" class="TableFootnoteRef">a</a></td>
603
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Thaibonnet</td>
604
+ </tr>
605
+ </thead>
606
+ <tbody>
607
+ <tr>
608
+ <td align="left" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">Number of laboratories retained after eliminating outliers</td>
609
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
610
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">11</td>
611
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
612
+ <td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:solid windowtext 1.0pt;">13</td>
613
+ </tr>
614
+ <tr>
615
+ <td align="left" style="border-top:none;border-bottom:solid windowtext 1.5pt;">Mean value, g/100 g</td>
616
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">81,2</td>
617
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">82,0</td>
618
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">81,8</td>
619
+ <td align="center" style="border-top:none;border-bottom:solid windowtext 1.5pt;">77,7</td>
620
+ </tr>
621
+ </tbody>
622
+ <dl>
623
+ <dt>
624
+ <p>Drago</p>
625
+ </dt>
626
+ <dd>A type of rice</dd>
627
+ </dl>
628
+
629
+ <tfoot><tr><td colspan="5" style="border-top:0pt;border-bottom:solid windowtext 1.5pt;"><div id="" class="Note">
630
+ <p class="Note">NOTE<span style="mso-tab-count:1">&#xA0; </span>This is a table about rice</p>
631
+ </div><div class="Note"><div id="ftntableD-1a">
632
+ <p id="_0fe65e9a-5531-408e-8295-eeff35f41a55" class="Note"><a id="tableD-1a" class="TableFootnoteRef">a<span style="mso-tab-count:1">&#xA0; </span></a>Parboiled rice.</p>
633
+ </div></div></td></tr></tfoot></table>
634
+ </div>
635
+ <p>&#xA0;</p>
636
+ </div>
637
+ <br clear="all" class="section"/>
638
+ <div class="WordSection3">
639
+ <p class="zzSTDTitle1"/>
640
+ </div>
641
+ </body>
642
+ </head>
643
+ </html>
644
+ OUTPUT
645
+ end
646
+
647
+ it "cleans up symbols lists" do
648
+ expect(IsoDoc::Convert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
649
+ <div id="L" class="Symbols">
650
+ <h1>4.<span style="mso-tab-count:1">&#160; </span>Symbols and Abbreviated Terms</h1>
651
+ <dl>
652
+ <dt><p><span class="stem">(#(&#x3b1;)#)</span></p></dt><dd>Definition 1</dd>
653
+ <dt><p><span class="stem">(#(xa)#)</span></p></dt><dd>Definition 2</dd>
654
+ <dt><p><span class="stem">(#(x_1)#)</span></p></dt><dd>Definition 3</dd>
655
+ <dt><p><span class="stem">(#(x_m)#)</span></p></dt><dd>Definition 4</dd>
656
+ <dt><p><span class="stem">(#(x)#)</span></p></dt><dd>Definition 5</dd>
657
+ </dl>
658
+ </div>
659
+ INPUT
660
+ <?xml version="1.0"?>
661
+ <div id="L" class="Symbols">
662
+ <h1>4.<span style="mso-tab-count:1">&#xA0; </span>Symbols and Abbreviated Terms</h1>
663
+ <dt>
664
+ <p>
665
+ <span class="stem">(#(x)#)</span>
666
+ </p>
667
+ </dt><dd>Definition 5</dd>
668
+ <dt>
669
+ <p>
670
+ <span class="stem">(#(x_m)#)</span>
671
+ </p>
672
+ </dt><dd>Definition 4</dd>
673
+ <dt>
674
+ <p>
675
+ <span class="stem">(#(x_1)#)</span>
676
+ </p>
677
+ </dt><dd>Definition 3</dd>
678
+ <dt>
679
+ <p>
680
+ <span class="stem">(#(xa)#)</span>
681
+ </p>
682
+ </dt><dd>Definition 2</dd>
683
+ <dt>
684
+ <p>
685
+ <span class="stem">(#(&#x3B1;)#)</span>
686
+ </p>
687
+ </dt><dd>Definition 1</dd>
688
+ </div>
689
+
690
+ OUTPUT
691
+ end
692
+
693
+ end