metanorma-iec 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/bin/rspec +18 -0
  4. data/lib/asciidoctor/iec/biblio.rng +949 -0
  5. data/lib/asciidoctor/iec/converter.rb +68 -0
  6. data/lib/asciidoctor/iec/iec_intro_en.xml +15 -0
  7. data/lib/asciidoctor/iec/iec_intro_fr.xml +15 -0
  8. data/lib/asciidoctor/iec/isodoc.rng +1132 -0
  9. data/lib/asciidoctor/iec/isostandard.rng +789 -0
  10. data/lib/asciidoctor/iec/reqt.rng +162 -0
  11. data/lib/isodoc/iec/base_convert.rb +69 -0
  12. data/lib/isodoc/iec/html/header.html +160 -0
  13. data/lib/isodoc/iec/html/html_iec_intro.html +34 -0
  14. data/lib/isodoc/iec/html/html_iec_titlepage.html +62 -0
  15. data/lib/isodoc/iec/html/htmlstyle.scss +840 -0
  16. data/lib/isodoc/iec/html/isodoc.scss +785 -0
  17. data/lib/isodoc/iec/html/scripts.html +176 -0
  18. data/lib/isodoc/iec/html/word_iec_intro.html +72 -0
  19. data/lib/isodoc/iec/html/word_iec_titlepage.html +92 -0
  20. data/lib/isodoc/iec/html/wordstyle.scss +1849 -0
  21. data/lib/isodoc/iec/html_convert.rb +33 -0
  22. data/lib/isodoc/iec/i18n-en.yaml +3 -0
  23. data/lib/isodoc/iec/i18n-fr.yaml +3 -0
  24. data/lib/isodoc/iec/i18n-zh-Hans.yaml +3 -0
  25. data/lib/isodoc/iec/metadata.rb +20 -0
  26. data/lib/isodoc/iec/word_convert.rb +165 -0
  27. data/lib/metanorma-iec.rb +12 -0
  28. data/lib/metanorma/iec.rb +8 -0
  29. data/lib/metanorma/iec/processor.rb +40 -0
  30. data/lib/metanorma/iec/version.rb +6 -0
  31. data/metanorma-iec.gemspec +47 -0
  32. data/spec/asciidoctor-iec/base_spec.rb +609 -0
  33. data/spec/asciidoctor-iec/blocks_spec.rb +467 -0
  34. data/spec/asciidoctor-iec/cleanup_spec.rb +766 -0
  35. data/spec/asciidoctor-iec/inline_spec.rb +162 -0
  36. data/spec/asciidoctor-iec/lists_spec.rb +190 -0
  37. data/spec/asciidoctor-iec/macros_spec.rb +21 -0
  38. data/spec/asciidoctor-iec/refs_spec.rb +268 -0
  39. data/spec/asciidoctor-iec/section_spec.rb +341 -0
  40. data/spec/asciidoctor-iec/table_spec.rb +307 -0
  41. data/spec/asciidoctor-iec/validate_spec.rb +132 -0
  42. data/spec/examples/rice.adoc +723 -0
  43. data/spec/examples/rice.doc +19162 -0
  44. data/spec/examples/rice.html +1787 -0
  45. data/spec/examples/rice.xml +1951 -0
  46. data/spec/isodoc/i18n_spec.rb +642 -0
  47. data/spec/isodoc/inline_spec.rb +265 -0
  48. data/spec/isodoc/iso_spec.rb +319 -0
  49. data/spec/isodoc/metadata_spec.rb +153 -0
  50. data/spec/isodoc/postproc_spec.rb +569 -0
  51. data/spec/isodoc/section_spec.rb +686 -0
  52. data/spec/isodoc/terms_spec.rb +206 -0
  53. data/spec/isodoc/xref_spec.rb +1323 -0
  54. data/spec/metanorma/processor_spec.rb +88 -0
  55. data/spec/spec_helper.rb +253 -0
  56. metadata +325 -0
@@ -0,0 +1,686 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe IsoDoc do
4
+ it "processes section names" do
5
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
6
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
7
+ <preface>
8
+ <foreword obligation="informative">
9
+ <title>Foreword</title>
10
+ <p id="A">This is a preamble</p>
11
+ </foreword>
12
+ <introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
13
+ <title>Introduction Subsection</title>
14
+ </clause>
15
+ <patent-notice>
16
+ <p>This is patent boilerplate</p>
17
+ </patent-notice>
18
+ </introduction></preface><sections>
19
+ <clause id="D" obligation="normative">
20
+ <title>Scope</title>
21
+ <p id="E">Text</p>
22
+ </clause>
23
+
24
+ <clause id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
25
+ <title>Normal Terms</title>
26
+ <term id="J">
27
+ <preferred>Term2</preferred>
28
+ </term>
29
+ </terms>
30
+ <definitions id="K">
31
+ <dl>
32
+ <dt>Symbol</dt>
33
+ <dd>Definition</dd>
34
+ </dl>
35
+ </definitions>
36
+ </clause>
37
+ <definitions id="L">
38
+ <dl>
39
+ <dt>Symbol</dt>
40
+ <dd>Definition</dd>
41
+ </dl>
42
+ </definitions>
43
+ <clause id="M" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
44
+ <title>Introduction</title>
45
+ </clause>
46
+ <clause id="O" inline-header="false" obligation="normative">
47
+ <title>Clause 4.2</title>
48
+ </clause></clause>
49
+
50
+ </sections><annex id="P" inline-header="false" obligation="normative">
51
+ <title>Annex</title>
52
+ <clause id="Q" inline-header="false" obligation="normative">
53
+ <title>Annex A.1</title>
54
+ <clause id="Q1" inline-header="false" obligation="normative">
55
+ <title>Annex A.1a</title>
56
+ </clause>
57
+ </clause>
58
+ <appendix id="Q2" inline-header="false" obligation="normative">
59
+ <title>An Appendix</title>
60
+ </appendix>
61
+ </annex><bibliography><references id="R" obligation="informative">
62
+ <title>Normative References</title>
63
+ </references><clause id="S" obligation="informative">
64
+ <title>Bibliography</title>
65
+ <references id="T" obligation="informative">
66
+ <title>Bibliography Subsection</title>
67
+ </references>
68
+ </clause>
69
+ </bibliography>
70
+ </iso-standard>
71
+ INPUT
72
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
73
+ <head/>
74
+ <body lang="EN-US" link="blue" vlink="#954F72">
75
+ <div class="title-section">
76
+ <p>&#160;</p>
77
+ </div>
78
+ <br/>
79
+ <div class="prefatory-section">
80
+ <p>&#160;</p>
81
+ </div>
82
+ <br/>
83
+ <div class="main-section">
84
+ <br/>
85
+ #{IEC_TITLE}
86
+ <div>
87
+ <h1 class="ForewordTitle">FOREWORD</h1>
88
+ <div class="boilerplate_legal"/>
89
+ <p id="A">This is a preamble</p>
90
+ </div>
91
+ <br/>
92
+ <div class="Section3" id="B">
93
+ <h1 class="IntroTitle">0&#160; INTRODUCTION</h1>
94
+ <div id="C">
95
+ <h2>0.1 Introduction Subsection</h2>
96
+ </div>
97
+ <p>This is patent boilerplate</p>
98
+ </div>
99
+ #{IEC_TITLE}
100
+ <div id="D">
101
+ <h1>1&#160; Scope</h1>
102
+ <p id="E">Text</p>
103
+ </div>
104
+ <div>
105
+ <h1>2&#160; Normative references</h1>
106
+ <p>There are no normative references in this document.</p>
107
+ </div>
108
+ <div id="H"><h1>3&#160; Terms, definitions, symbols and abbreviated terms</h1><p>For the purposes of this document,
109
+ the following terms and definitions apply.</p>
110
+ <p>ISO and IEC maintain terminological databases for use in
111
+ standardization at the following addresses:</p>
112
+
113
+ <ul>
114
+ <li> <p>ISO Online browsing platform: available at
115
+ <a href="http://www.iso.org/obp">http://www.iso.org/obp</a></p> </li>
116
+ <li> <p>IEC Electropedia: available at
117
+ <a href="http://www.electropedia.org">http://www.electropedia.org</a>
118
+ </p> </li> </ul>
119
+ <div id="I">
120
+ <h2>3.1 Normal Terms</h2>
121
+ <p class="TermNum" id="J">3.1.1</p>
122
+ <p class="Terms" style="text-align:left;">Term2</p>
123
+
124
+ </div><div id="K"><h2>3.2 Symbols and abbreviated terms</h2>
125
+ <dl><dt><p>Symbol</p></dt><dd>Definition</dd></dl>
126
+ </div></div>
127
+ <div id="L" class="Symbols">
128
+ <h1>4&#160; Symbols and abbreviated terms</h1>
129
+ <dl>
130
+ <dt>
131
+ <p>Symbol</p>
132
+ </dt>
133
+ <dd>Definition</dd>
134
+ </dl>
135
+ </div>
136
+ <div id="M">
137
+ <h1>5&#160; Clause 4</h1>
138
+ <div id="N">
139
+ <h2>5.1 Introduction</h2>
140
+ </div>
141
+ <div id="O">
142
+ <h2>5.2 Clause 4.2</h2>
143
+ </div>
144
+ </div>
145
+ <br/>
146
+ <div id="P" class="Section3">
147
+ <h1 class="Annex"><b>Annex A</b><br/><br/>(normative)<br/><br/><b>Annex</b></h1>
148
+ <div id="Q">
149
+ <h2>A.1 Annex A.1</h2>
150
+ <div id="Q1">
151
+ <h3>A.1.1 Annex A.1a</h3>
152
+ </div>
153
+ </div>
154
+ <div id="Q2">
155
+ <h2>Appendix 1 An Appendix</h2>
156
+ </div>
157
+
158
+ </div>
159
+ <br/>
160
+ <div>
161
+ <h1 class="Section3">Bibliography</h1>
162
+ <div>
163
+ <h2 class="Section3">Bibliography Subsection</h2>
164
+ </div>
165
+ </div>
166
+ </div>
167
+ </body>
168
+ </html>
169
+ OUTPUT
170
+ end
171
+
172
+ it "processes section names (Word)" do
173
+ expect(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body /m, "<body ")).to be_equivalent_to <<~"OUTPUT"
174
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
175
+ <preface>
176
+ <foreword obligation="informative">
177
+ <title>Foreword</title>
178
+ <p id="A">This is a preamble</p>
179
+ </foreword>
180
+ <introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
181
+ <title>Introduction Subsection</title>
182
+ </clause>
183
+ <patent-notice>
184
+ <p>This is patent boilerplate</p>
185
+ </patent-notice>
186
+ </introduction></preface><sections>
187
+ <clause id="D" obligation="normative">
188
+ <title>Scope</title>
189
+ <p id="E">Text</p>
190
+ </clause>
191
+
192
+ <clause id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
193
+ <title>Normal Terms</title>
194
+ <term id="J">
195
+ <preferred>Term2</preferred>
196
+ </term>
197
+ </terms>
198
+ <definitions id="K">
199
+ <dl>
200
+ <dt>Symbol</dt>
201
+ <dd>Definition</dd>
202
+ </dl>
203
+ </definitions>
204
+ </clause>
205
+ <definitions id="L">
206
+ <dl>
207
+ <dt>Symbol</dt>
208
+ <dd>Definition</dd>
209
+ </dl>
210
+ </definitions>
211
+ <clause id="M" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
212
+ <title>Introduction</title>
213
+ </clause>
214
+ <clause id="O" inline-header="false" obligation="normative">
215
+ <title>Clause 4.2</title>
216
+ </clause></clause>
217
+
218
+ </sections><annex id="P" inline-header="false" obligation="normative">
219
+ <title>Annex</title>
220
+ <clause id="Q" inline-header="false" obligation="normative">
221
+ <title>Annex A.1</title>
222
+ <clause id="Q1" inline-header="false" obligation="normative">
223
+ <title>Annex A.1a</title>
224
+ </clause>
225
+ </clause>
226
+ <appendix id="Q2" inline-header="false" obligation="normative">
227
+ <title>An Appendix</title>
228
+ </appendix>
229
+ </annex><bibliography><references id="R" obligation="informative">
230
+ <title>Normative References</title>
231
+ </references><clause id="S" obligation="informative">
232
+ <title>Bibliography</title>
233
+ <references id="T" obligation="informative">
234
+ <title>Bibliography Subsection</title>
235
+ </references>
236
+ </clause>
237
+ </bibliography>
238
+ </iso-standard>
239
+ INPUT
240
+ <body lang="EN-US" link="blue" vlink="#954F72">
241
+ <div class="WordSection1">
242
+ <p>&#160;</p>
243
+ </div>
244
+ <p><br clear="all" class="section"/></p>
245
+ <div class="WordSection2">
246
+ <p><br clear="all" style="mso-special-character:line-break;page-break-before:always"/></p>
247
+ #{IEC_TITLE}
248
+ <div>
249
+ <h1 class="ForewordTitle">FOREWORD</h1>
250
+ <div class="boilerplate_legal"/>
251
+ <p id="A">This is a preamble</p>
252
+ </div>
253
+ <p><br clear="all" style="mso-special-character:line-break;page-break-before:always"/></p>
254
+ <div class="Section3" id="B">
255
+ <h1 class="IntroTitle">0<span style="mso-tab-count:1">&#160; </span>INTRODUCTION</h1>
256
+ <div id="C">
257
+ <h2>0.1 Introduction Subsection</h2>
258
+ </div>
259
+ <p>This is patent boilerplate</p>
260
+ </div>
261
+ <p>&#160;</p>
262
+ </div>
263
+ <p><br clear="all" class="section"/></p>
264
+ <div class="WordSection3">
265
+ #{IEC_TITLE}
266
+ <div id="D">
267
+ <h1>1<span style="mso-tab-count:1">&#160; </span>Scope</h1>
268
+ <p id="E">Text</p>
269
+ </div>
270
+ <div>
271
+ <h1>2<span style="mso-tab-count:1">&#160; </span>Normative references</h1>
272
+ <p>There are no normative references in this document.</p>
273
+ </div>
274
+ <div id="H"><h1>3<span style="mso-tab-count:1">&#160; </span>Terms, definitions, symbols and abbreviated terms</h1><p>For the purposes of this document,
275
+ the following terms and definitions apply.</p>
276
+ <p>ISO and IEC maintain terminological databases for use in
277
+ standardization at the following addresses:</p>
278
+
279
+ <ul>
280
+ <li> <p>ISO Online browsing platform: available at
281
+ <a href="http://www.iso.org/obp">http://www.iso.org/obp</a></p> </li>
282
+ <li> <p>IEC Electropedia: available at
283
+ <a href="http://www.electropedia.org">http://www.electropedia.org</a>
284
+ </p> </li> </ul>
285
+ <div id="I">
286
+ <h2>3.1 Normal Terms</h2>
287
+ <p class="TermNum" id="J">3.1.1</p>
288
+ <p class="Terms" style="text-align:left;">Term2</p>
289
+
290
+ </div><div id="K"><h2>3.2 Symbols and abbreviated terms</h2>
291
+ <table class="dl"><tr><td valign="top" align="left"><p align="left" style="margin-left:0pt;text-align:left;">Symbol</p></td><td valign="top">Definition</td></tr></table>
292
+ </div></div>
293
+ <div id="L" class="Symbols">
294
+ <h1>4<span style="mso-tab-count:1">&#160; </span>Symbols and abbreviated terms</h1>
295
+ <table class="dl">
296
+ <tr>
297
+ <td valign="top" align="left">
298
+ <p align="left" style="margin-left:0pt;text-align:left;">Symbol</p>
299
+ </td>
300
+ <td valign="top">Definition</td>
301
+ </tr>
302
+ </table>
303
+ </div>
304
+ <div id="M">
305
+ <h1>5<span style="mso-tab-count:1">&#160; </span>Clause 4</h1>
306
+ <div id="N">
307
+ <h2>5.1 Introduction</h2>
308
+ </div>
309
+ <div id="O">
310
+ <h2>5.2 Clause 4.2</h2>
311
+ </div>
312
+ </div>
313
+ <p><br clear="all" style="mso-special-character:line-break;page-break-before:always"/></p>
314
+ <div id="P" class="Section3">
315
+ <h1 class="Annex"><b>Annex A</b><br/><br/>(normative)<br/><br/><b>Annex</b></h1>
316
+ <div id="Q">
317
+ <h2>A.1 Annex A.1</h2>
318
+ <div id="Q1">
319
+ <h3>A.1.1 Annex A.1a</h3>
320
+ </div>
321
+ </div>
322
+ <div id="Q2">
323
+ <h2>Appendix 1 An Appendix</h2>
324
+ </div>
325
+ </div>
326
+ <p><br clear="all" style="mso-special-character:line-break;page-break-before:always"/></p>
327
+ <div>
328
+ <h1 class="Section3">Bibliography</h1>
329
+ <div>
330
+ <h2 class="Section3">Bibliography Subsection</h2>
331
+ </div>
332
+ </div>
333
+ </div>
334
+ <br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
335
+ <div class="colophon"/>
336
+ </body>
337
+ </html>
338
+ OUTPUT
339
+ end
340
+
341
+ it "processes simple terms & definitions" do
342
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
343
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
344
+ <sections>
345
+ <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
346
+ <term id="J">
347
+ <preferred>Term2</preferred>
348
+ </term>
349
+ </terms>
350
+ </sections>
351
+ </iso-standard>
352
+ INPUT
353
+ #{HTML_HDR}
354
+ <div id="">
355
+ <h1 class="ForewordTitle">FOREWORD</h1>
356
+ <div class="boilerplate_legal"/>
357
+ </div>
358
+ #{IEC_TITLE}
359
+ <div id="H"><h1>1&#160; Terms and definitions</h1><p>For the purposes of this document,
360
+ the following terms and definitions apply.</p>
361
+ <p>ISO and IEC maintain terminological databases for use in
362
+ standardization at the following addresses:</p>
363
+
364
+ <ul>
365
+ <li> <p>ISO Online browsing platform: available at
366
+ <a href="http://www.iso.org/obp">http://www.iso.org/obp</a></p> </li>
367
+ <li> <p>IEC Electropedia: available at
368
+ <a href="http://www.electropedia.org">http://www.electropedia.org</a>
369
+ </p> </li> </ul>
370
+ <p class="TermNum" id="J">1.1</p>
371
+ <p class="Terms" style="text-align:left;">Term2</p>
372
+ </div>
373
+ </div>
374
+ </body>
375
+ </html>
376
+ OUTPUT
377
+ end
378
+
379
+ it "processes terms & definitions with external source" do
380
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
381
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
382
+ <termdocsource type="inline" bibitemid="ISO712"/>
383
+ <sections>
384
+ <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
385
+ <term id="J">
386
+ <preferred>Term2</preferred>
387
+ </term>
388
+ </terms>
389
+ </sections>
390
+ <bibliography>
391
+ <references id="_normative_references" obligation="informative"><title>Normative References</title>
392
+ <bibitem id="ISO712" type="standard">
393
+ <title format="text/plain">Cereals and cereal products?~@~I?~@~T?~@~IDetermination of moisture content?~@~I?~@~T?~@~IReference method</title>
394
+ <docidentifier>ISO 712</docidentifier>
395
+ <contributor>
396
+ <role type="publisher"/>
397
+ <organization>
398
+ <name>International Organization for Standardization</name>
399
+ </organization>
400
+ </contributor>
401
+ </bibitem></references>
402
+ </bibliography>
403
+ </iso-standard>
404
+ INPUT
405
+ #{HTML_HDR}
406
+ <div id="">
407
+ <h1 class="ForewordTitle">FOREWORD</h1>
408
+ <div class="boilerplate_legal"/>
409
+ </div>
410
+ #{IEC_TITLE}
411
+ <div>
412
+ <h1>1&#160; Normative references</h1>
413
+ <p>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>
414
+ <p id="ISO712" class="NormRef">ISO 712, <i> Cereals and cereal products?~@~I?~@~T?~@~IDetermination of moisture content?~@~I?~@~T?~@~IReference method</i></p>
415
+ </div>
416
+ <div id="H"><h1>2&#160; Terms and definitions</h1><p>For the purposes of this document, the terms and definitions
417
+ given in <a href="#ISO712">ISO 712</a> and the following apply.</p>
418
+ <p>ISO and IEC maintain terminological databases for use in
419
+ standardization at the following addresses:</p>
420
+
421
+ <ul>
422
+ <li> <p>ISO Online browsing platform: available at
423
+ <a href="http://www.iso.org/obp">http://www.iso.org/obp</a></p> </li>
424
+ <li> <p>IEC Electropedia: available at
425
+ <a href="http://www.electropedia.org">http://www.electropedia.org</a>
426
+ </p> </li> </ul>
427
+ <p class="TermNum" id="J">2.1</p>
428
+ <p class="Terms" style="text-align:left;">Term2</p>
429
+ </div>
430
+ </div>
431
+ </body>
432
+ </html>
433
+ OUTPUT
434
+ end
435
+
436
+ it "processes empty terms & definitions with external source" do
437
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
438
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
439
+ <termdocsource type="inline" bibitemid="ISO712"/>
440
+ <termdocsource type="inline" bibitemid="ISO712"/>
441
+ <termdocsource type="inline" bibitemid="ISO712"/>
442
+ <sections>
443
+ <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
444
+ </terms>
445
+ </sections>
446
+ <bibliography>
447
+ <references id="_normative_references" obligation="informative"><title>Normative References</title>
448
+ <bibitem id="ISO712" type="standard">
449
+ <title format="text/plain">Cereals and cereal products?~@~I?~@~T?~@~IDetermination of moisture content?~@~I?~@~T?~@~IReference method</title>
450
+ <docidentifier>ISO 712</docidentifier>
451
+ <contributor>
452
+ <role type="publisher"/>
453
+ <organization>
454
+ <abbreviation>ISO</abbreviation>
455
+ </organization>
456
+ </contributor>
457
+ </bibitem></references>
458
+ </bibliography>
459
+ </iso-standard>
460
+ INPUT
461
+ #{HTML_HDR}
462
+ <div id="">
463
+ <h1 class="ForewordTitle">FOREWORD</h1>
464
+ <div class="boilerplate_legal"/>
465
+ </div>
466
+ #{IEC_TITLE}
467
+ <div>
468
+ <h1>1&#160; Normative references</h1>
469
+ <p>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>
470
+ <p id="ISO712" class="NormRef">ISO 712, <i> Cereals and cereal products?~@~I?~@~T?~@~IDetermination of moisture content?~@~I?~@~T?~@~IReference method</i></p>
471
+ </div>
472
+ <div id="H"><h1>2&#160; Terms and definitions</h1><p>For the purposes of this document,
473
+ the terms and definitions given in <a href="#ISO712">ISO 712</a>, <a href="#ISO712">ISO 712</a> and <a href="#ISO712">ISO 712</a> apply.</p>
474
+ <p>ISO and IEC maintain terminological databases for use in
475
+ standardization at the following addresses:</p>
476
+
477
+ <ul>
478
+ <li> <p>ISO Online browsing platform: available at
479
+ <a href="http://www.iso.org/obp">http://www.iso.org/obp</a></p> </li>
480
+ <li> <p>IEC Electropedia: available at
481
+ <a href="http://www.electropedia.org">http://www.electropedia.org</a>
482
+ </p> </li> </ul>
483
+ </div>
484
+ </div>
485
+ </body>
486
+ </html>
487
+ OUTPUT
488
+ end
489
+
490
+ it "processes empty terms & definitions" do
491
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
492
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
493
+ <sections>
494
+ <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
495
+ </terms>
496
+ </sections>
497
+ </iso-standard>
498
+ INPUT
499
+ #{HTML_HDR}
500
+ <div id="">
501
+ <h1 class="ForewordTitle">FOREWORD</h1>
502
+ <div class="boilerplate_legal"/>
503
+ </div>
504
+ #{IEC_TITLE}
505
+ <div id="H"><h1>1&#160; Terms and definitions</h1><p>No terms and definitions are listed in this document.</p>
506
+ <p>ISO and IEC maintain terminological databases for use in
507
+ standardization at the following addresses:</p>
508
+
509
+ <ul>
510
+ <li> <p>ISO Online browsing platform: available at
511
+ <a href="http://www.iso.org/obp">http://www.iso.org/obp</a></p> </li>
512
+ <li> <p>IEC Electropedia: available at
513
+ <a href="http://www.electropedia.org">http://www.electropedia.org</a>
514
+ </p> </li> </ul>
515
+ </div>
516
+ </div>
517
+ </body>
518
+ </html>
519
+ OUTPUT
520
+ end
521
+
522
+ it "processes inline section headers" do
523
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
524
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
525
+ <sections>
526
+ <clause id="M" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
527
+ <title>Introduction</title>
528
+ </clause>
529
+ <clause id="O" inline-header="true" obligation="normative">
530
+ <title>Clause 4.2</title>
531
+ </clause></clause>
532
+
533
+ </sections>
534
+ </iso-standard>
535
+ INPUT
536
+ #{HTML_HDR}
537
+ <div id="">
538
+ <h1 class="ForewordTitle">FOREWORD</h1>
539
+ <div class="boilerplate_legal"/>
540
+ </div>
541
+ #{IEC_TITLE}
542
+ <div id="M">
543
+ <h1>1&#160; Clause 4</h1>
544
+ <div id="N">
545
+ <h2>1.1 Introduction</h2>
546
+ </div>
547
+ <div id="O">
548
+ <span class="zzMoveToFollowing"><b>1.2 Clause 4.2 </b></span>
549
+ </div>
550
+ </div>
551
+ </div>
552
+ </body>
553
+ </html>
554
+ OUTPUT
555
+ end
556
+
557
+ it "adds colophon to published standard (Word)" do
558
+ expect(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body /m, "<body ")).to be_equivalent_to <<~"OUTPUT"
559
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
560
+ <bibdata>
561
+ <status>
562
+ <stage>60</stage>
563
+ </status>
564
+ </bibdata>
565
+ <sections>
566
+ </sections>
567
+ </iso-standard>
568
+ INPUT
569
+ <body lang="EN-US" link="blue" vlink="#954F72">
570
+ <div class="WordSection1">
571
+ <p>&#160;</p>
572
+ </div>
573
+ <p><br clear="all" class="section"/></p>
574
+ <div class="WordSection2">
575
+ <p>
576
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
577
+ </p>
578
+ #{IEC_TITLE}
579
+ <div id="">
580
+ <h1 class="ForewordTitle">FOREWORD</h1>
581
+ <div class="boilerplate_legal"/>
582
+ </div>
583
+ <p>&#160;</p>
584
+ </div>
585
+ <p><br clear="all" class="section"/></p>
586
+ <div class="WordSection3">
587
+ #{IEC_TITLE}
588
+ </div>
589
+ <br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
590
+ <div class="colophon"/>
591
+ </body>
592
+ </html>
593
+ OUTPUT
594
+ end
595
+
596
+ it "does not add colophon to draft standard (Word)" do
597
+ expect(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body /m, "<body ")).to be_equivalent_to <<~"OUTPUT"
598
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
599
+ <bibdata>
600
+ <status>
601
+ <stage>30</stage>
602
+ </status>
603
+ </bibdata>
604
+ <sections>
605
+ </sections>
606
+ </iso-standard>
607
+ INPUT
608
+ <body lang="EN-US" link="blue" vlink="#954F72">
609
+ <div class="WordSection1">
610
+ <p>&#160;</p>
611
+ </div>
612
+ <p><br clear="all" class="section"/></p>
613
+ <div class="WordSection2">
614
+ <p>
615
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
616
+ </p>
617
+ #{IEC_TITLE}
618
+ <div id="">
619
+ <h1 class="ForewordTitle">FOREWORD</h1>
620
+ <div class="boilerplate_legal"/>
621
+ </div>
622
+ <p>&#160;</p>
623
+ </div>
624
+ <p><br clear="all" class="section"/></p>
625
+ <div class="WordSection3">
626
+ #{IEC_TITLE}
627
+ </div>
628
+ </body>
629
+ </html>
630
+ OUTPUT
631
+ end
632
+
633
+ it "adds boilerplate to foreword" do
634
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
635
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
636
+ <bibdata>
637
+ <ext><doctype>International Standard</doctype></ext>
638
+ </bibdata>
639
+ <boilerplate>
640
+ <legal-statement>
641
+ <p>Boilerplate</p>
642
+ </legal-statement>
643
+ </boilerplate>
644
+ <sections/>
645
+ </iso-standard>
646
+ INPUT
647
+ #{HTML_HDR}
648
+ <div id="">
649
+ <h1 class="ForewordTitle">FOREWORD</h1>
650
+ <div class="boilerplate_legal">
651
+ <p>Boilerplate</p>
652
+ </div>
653
+ </div>
654
+ #{IEC_TITLE}
655
+ </div>
656
+ </body>
657
+ </html>
658
+ OUTPUT
659
+ end
660
+
661
+ it "does not add boilerplate to foreword in amendments" do
662
+ expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
663
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
664
+ <bibdata>
665
+ <ext><doctype>Amendment</doctype></ext>
666
+ </bibdata>
667
+ <boilerplate>
668
+ <legal-statement>
669
+ <p>Boilerplate</p>
670
+ </legal-statement>
671
+ </boilerplate>
672
+ <sections/>
673
+ </iso-standard>
674
+ INPUT
675
+ #{HTML_HDR}
676
+ <div id="">
677
+ <h1 class="ForewordTitle">FOREWORD</h1>
678
+ </div>
679
+ #{IEC_TITLE}
680
+ </div>
681
+ </body>
682
+ </html>
683
+ OUTPUT
684
+ end
685
+
686
+ end