isodoc 1.6.3 → 1.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe IsoDoc do
4
4
  it "droplocs xrefs" do
5
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({ i18nyaml: "spec/assets/i18n.yaml" }).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
5
+ input = <<~INPUT
6
6
  <iso-standard xmlns="http://riboseinc.com/isoxml">
7
7
  <sections>
8
8
  <clause id="A">
@@ -16,6 +16,7 @@ RSpec.describe IsoDoc do
16
16
  </sections>
17
17
  </iso-standard>
18
18
  INPUT
19
+ output = <<~OUTPUT
19
20
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
20
21
  <sections>
21
22
  <clause id='A'>
@@ -41,10 +42,13 @@ RSpec.describe IsoDoc do
41
42
  </sections>
42
43
  </iso-standard>
43
44
  OUTPUT
45
+ expect(xmlpp(IsoDoc::PresentationXMLConvert
46
+ .new({ i18nyaml: "spec/assets/i18n.yaml" })
47
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
44
48
  end
45
49
 
46
- it "processes inline formatting (HTML)" do
47
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
50
+ it "processes inline formatting" do
51
+ input = <<~INPUT
48
52
  <iso-standard xmlns="http://riboseinc.com/isoxml">
49
53
  <preface><foreword>
50
54
  <p>
@@ -56,69 +60,55 @@ RSpec.describe IsoDoc do
56
60
  <sections>
57
61
  </iso-standard>
58
62
  INPUT
59
- #{HTML_HDR}
60
- <br/>
61
- <div>
62
- <h1 class="ForewordTitle">Foreword</h1>
63
- <p>
64
- <i>A</i> <b>B</b> <sup>C</sup> <sub>D</sub> <tt>E</tt>
65
- <s>F</s> <span style="font-variant:small-caps;">G</span> <span class="keyword">I</span> <br/> <hr/>
66
- <a id="H"/> <br/> <br/>
67
- <span style='text-decoration: underline;'>J</span>
68
- </p>
69
- </div>
70
- <p class="zzSTDTitle1"/>
71
- </div>
72
- </body>
73
- </html>
63
+ html = <<~OUTPUT
64
+ <div>
65
+ <h1 class="ForewordTitle">Foreword</h1>
66
+ <p>
67
+ <i>A</i> <b>B</b> <sup>C</sup> <sub>D</sub> <tt>E</tt>
68
+ <s>F</s> <span style="font-variant:small-caps;">G</span> <span class="keyword">I</span> <br/> <hr/>
69
+ <a id="H"/> <br/> <br/>
70
+ <span style='text-decoration: underline;'>J</span>
71
+ </p>
72
+ </div>
74
73
  OUTPUT
75
- end
76
74
 
77
- it "processes inline formatting (Word)" do
78
- expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
79
- <iso-standard xmlns="http://riboseinc.com/isoxml">
80
- <preface/><sections><clause>
81
- <p>
82
- <em>A</em> <strong>B</strong> <sup>C</sup> <sub>D</sub> <tt>E</tt>
83
- <strike>F</strike> <smallcap>G</smallcap> <keyword>I</keyword> <br/> <hr/>
84
- <bookmark id="H"/> <pagebreak/> <pagebreak orientation="landscape"/> <underline>J</underline>
85
- </p>
86
- </clause></sections>
87
- </iso-standard>
88
- INPUT
89
- #{WORD_HDR}
90
- <p class='zzSTDTitle1'/>
91
- <div>
92
- <h1/>
93
- <p>
94
- <i>A</i>
95
- <b>B</b>
96
- <sup>C</sup>
97
- <sub>D</sub>
98
- <tt>E</tt>
99
- <s>F</s>
100
- <span style='font-variant:small-caps;'>G</span>
101
- <span class='keyword'>I</span>
102
- <br/>
103
- <hr/>
104
- <a id='H'/>
105
- <p>
106
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
107
- </p>
108
- <p>
109
- <br clear='all' class='section' orientation='landscape'/>
110
- </p>
111
- <u>J</u>
112
- </p>
113
- </div>
114
- </div>
115
- </body>
116
- </html>
75
+ doc = <<~OUTPUT
76
+ <div>
77
+ <h1 class='ForewordTitle'>Foreword</h1>
78
+ <p>
79
+ <i>A</i>
80
+ <b>B</b>
81
+ <sup>C</sup>
82
+ <sub>D</sub>
83
+ <tt>E</tt>
84
+ <s>F</s>
85
+ <span style='font-variant:small-caps;'>G</span>
86
+ <span class='keyword'>I</span>
87
+ <br/>
88
+ <hr/>
89
+ <a id='H'/>
90
+ <p>
91
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
92
+ </p>
93
+ <p>
94
+ <br clear='all' class='section' orientation='landscape'/>
95
+ </p>
96
+ <u>J</u>
97
+ </p>
98
+ </div>
117
99
  OUTPUT
100
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
101
+ .convert("test", input, true))
102
+ .sub(/^.*<h1/m, "<div><h1").sub(%r{</div>.*$}m, "</div>"))
103
+ .to be_equivalent_to xmlpp(html)
104
+ expect(xmlpp(IsoDoc::WordConvert.new({})
105
+ .convert("test", input, true))
106
+ .sub(/^.*<h1/m, "<div><h1").sub(%r{</div>.*$}m, "</div>"))
107
+ .to be_equivalent_to xmlpp(doc)
118
108
  end
119
109
 
120
110
  it "ignores index entries" do
121
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
111
+ input = <<~INPUT
122
112
  <iso-standard xmlns="http://riboseinc.com/isoxml">
123
113
  <preface><foreword>
124
114
  <p><index primary="A" secondary="B" tertiary="C"/></p>
@@ -129,6 +119,7 @@ RSpec.describe IsoDoc do
129
119
  </indexsect>
130
120
  </iso-standard>
131
121
  INPUT
122
+ output = <<~OUTPUT
132
123
  <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
133
124
  <preface>
134
125
  <foreword>
@@ -138,6 +129,8 @@ RSpec.describe IsoDoc do
138
129
  <sections> </sections>
139
130
  </iso-standard>
140
131
  OUTPUT
132
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
133
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
141
134
  end
142
135
 
143
136
  it "processes concept markup" do
@@ -226,162 +219,243 @@ RSpec.describe IsoDoc do
226
219
  </iso-standard>
227
220
  INPUT
228
221
  presxml = <<~OUTPUT
229
- <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
230
- <preface>
231
- <foreword>
232
- <p>
233
- <ul>
234
- <li>
235
- <em>
236
- <xref target='clause1'>Clause 2</xref>
237
- </em>
238
- </li>
239
- <li>
240
- <em>
241
- <xref target='clause1'>w[o]rd</xref>
242
- </em>
243
- </li>
244
- <li>
245
- <em>
246
- <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>ISO 712</eref>
247
- </em>
248
- </li>
249
- <li>
250
- <em>
251
- <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>word</eref>
252
- </em>
253
- </li>
254
- <li>
255
- <em>
256
- <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>
257
- <locality type='clause'>
258
- <referenceFrom>3.1</referenceFrom>
259
- </locality>
260
- <locality type='figure'>
261
- <referenceFrom>a</referenceFrom>
262
- </locality>
263
- ISO 712, Clause 3.1, Figure a
264
- </eref>
265
- </em>
266
- </li>
267
- <li>
268
- <em>
269
- <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>
270
- <localityStack>
271
- <locality type='clause'>
272
- <referenceFrom>3.1</referenceFrom>
273
- </locality>
274
- </localityStack>
275
- <localityStack>
276
- <locality type='figure'>
277
- <referenceFrom>b</referenceFrom>
278
- </locality>
279
- </localityStack>
280
- ISO 712, Clause 3.1; Figure b
281
- </eref>
282
- </em>
283
- </li>
284
- <li>
285
- <em>
286
- <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>
287
- <localityStack>
288
- <locality type='clause'>
289
- <referenceFrom>3.1</referenceFrom>
290
- </locality>
291
- </localityStack>
292
- <localityStack>
293
- <locality type='figure'>
294
- <referenceFrom>b</referenceFrom>
295
- </locality>
296
- </localityStack>
297
- <em>word</em>
298
- </eref>
299
- </em>
300
- </li>
301
- <li>
302
- [term defined in
303
- <termref base='IEV' target='135-13-13'/>
304
- ]
305
- </li>
306
- <li>
307
- <em>
308
- <termref base='IEV' target='135-13-13'>
309
- <em>word</em>
310
- word
311
- </termref>
312
- </em>
313
- </li>
314
- </ul>
315
- </p>
316
- </foreword>
317
- </preface>
318
- <sections>
319
- <clause id='clause1'>
320
- <title depth='1'>
321
- 2.
322
- <tab/>
323
- Clause 1
324
- </title>
325
- </clause>
326
- </sections>
327
- <bibliography>
328
- <references id='_normative_references' obligation='informative' normative='true'>
329
- <title depth='1'>
330
- 1.
331
- <tab/>
332
- Normative References
333
- </title>
334
- <p>
335
- The following documents are referred to in the text in such a way that
336
- some or all of their content constitutes requirements of this document.
337
- For dated references, only the edition cited applies. For undated
338
- references, the latest edition of the referenced document (including any
339
- amendments) applies.
340
- </p>
341
- <bibitem id='ISO712' type='standard'>
342
- <title format='text/plain'>Cereals or cereal products</title>
343
- <title type='main' format='text/plain'>Cereals and cereal products</title>
344
- <docidentifier type='ISO'>ISO 712</docidentifier>
345
- <contributor>
346
- <role type='publisher'/>
347
- <organization>
348
- <name>International Organization for Standardization</name>
349
- </organization>
350
- </contributor>
351
- </bibitem>
352
- </references>
353
- </bibliography>
354
- </iso-standard>
355
- end
356
-
357
- it "processes embedded inline formatting" do
358
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
359
- <iso-standard xmlns="http://riboseinc.com/isoxml">
360
- <preface><foreword>
361
- <p>
362
- <em><strong>&lt;</strong></em> <tt><link target="B"/></tt> <xref target="_http_1_1">Requirement <tt>/req/core/http</tt></xref> <eref type="inline" bibitemid="ISO712" citeas="ISO 712">Requirement <tt>/req/core/http</tt></eref>
363
- </p>
364
- </foreword></preface>
365
- <sections>
222
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
223
+ <preface>
224
+ <foreword>
225
+ <p>
226
+ <ul>
227
+ <li>
228
+ <em>
229
+ <xref target='clause1'>Clause 2</xref>
230
+ </em>
231
+ </li>
232
+ <li>
233
+ <em>
234
+ <xref target='clause1'>w[o]rd</xref>
235
+ </em>
236
+ </li>
237
+ <li>
238
+ <em>
239
+ <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>ISO 712</eref>
240
+ </em>
241
+ </li>
242
+ <li>
243
+ <em>
244
+ <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>word</eref>
245
+ </em>
246
+ </li>
247
+ <li>
248
+ <em>
249
+ <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>
250
+ <locality type='clause'>
251
+ <referenceFrom>3.1</referenceFrom>
252
+ </locality>
253
+ <locality type='figure'>
254
+ <referenceFrom>a</referenceFrom>
255
+ </locality>
256
+ ISO 712, Clause 3.1, Figure a
257
+ </eref>
258
+ </em>
259
+ </li>
260
+ <li>
261
+ <em>
262
+ <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>
263
+ <localityStack>
264
+ <locality type='clause'>
265
+ <referenceFrom>3.1</referenceFrom>
266
+ </locality>
267
+ </localityStack>
268
+ <localityStack>
269
+ <locality type='figure'>
270
+ <referenceFrom>b</referenceFrom>
271
+ </locality>
272
+ </localityStack>
273
+ ISO 712, Clause 3.1; Figure b
274
+ </eref>
275
+ </em>
276
+ </li>
277
+ <li>
278
+ <em>
279
+ <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>
280
+ <localityStack>
281
+ <locality type='clause'>
282
+ <referenceFrom>3.1</referenceFrom>
283
+ </locality>
284
+ </localityStack>
285
+ <localityStack>
286
+ <locality type='figure'>
287
+ <referenceFrom>b</referenceFrom>
288
+ </locality>
289
+ </localityStack>
290
+ <em>word</em>
291
+ </eref>
292
+ </em>
293
+ </li>
294
+ <li>
295
+ [term defined in
296
+ <termref base='IEV' target='135-13-13'/>
297
+ ]
298
+ </li>
299
+ <li>
300
+ <em>
301
+ <termref base='IEV' target='135-13-13'>
302
+ <em>word</em>
303
+ word
304
+ </termref>
305
+ </em>
306
+ </li>
307
+ </ul>
308
+ </p>
309
+ </foreword>
310
+ </preface>
311
+ <sections>
312
+ <clause id='clause1'>
313
+ <title depth='1'>
314
+ 2.
315
+ <tab/>
316
+ Clause 1
317
+ </title>
318
+ </clause>
319
+ </sections>
320
+ <bibliography>
321
+ <references id='_normative_references' obligation='informative' normative='true'>
322
+ <title depth='1'>
323
+ 1.
324
+ <tab/>
325
+ Normative References
326
+ </title>
327
+ <p>
328
+ The following documents are referred to in the text in such a way that
329
+ some or all of their content constitutes requirements of this document.
330
+ For dated references, only the edition cited applies. For undated
331
+ references, the latest edition of the referenced document (including any
332
+ amendments) applies.
333
+ </p>
334
+ <bibitem id='ISO712' type='standard'>
335
+ <title format='text/plain'>Cereals or cereal products</title>
336
+ <title type='main' format='text/plain'>Cereals and cereal products</title>
337
+ <docidentifier type='ISO'>ISO 712</docidentifier>
338
+ <contributor>
339
+ <role type='publisher'/>
340
+ <organization>
341
+ <name>International Organization for Standardization</name>
342
+ </organization>
343
+ </contributor>
344
+ </bibitem>
345
+ </references>
346
+ </bibliography>
366
347
  </iso-standard>
367
- INPUT
368
- #{HTML_HDR}
369
- <br/>
370
- <div>
371
- <h1 class="ForewordTitle">Foreword</h1>
372
- <p>
373
- <i><b>&lt;</b></i> <tt><a href="B">B</a></tt> <a href="#_http_1_1">Requirement <tt>/req/core/http</tt></a> <a href="#ISO712">Requirement <tt>/req/core/http</tt></a>
374
- </p>
375
- </div>
376
- <p class="zzSTDTitle1"/>
348
+ OUTPUT
349
+ output = <<~OUTPUT
350
+ #{HTML_HDR}
351
+ <br/>
352
+ <div>
353
+ <h1 class='ForewordTitle'>Foreword</h1>
354
+ <p>
355
+ <ul>
356
+ <li>
357
+ <i>
358
+ <a href='#clause1'>Clause 2</a>
359
+ </i>
360
+ </li>
361
+ <li>
362
+ <i>
363
+ <a href='#clause1'>w[o]rd</a>
364
+ </i>
365
+ </li>
366
+ <li>
367
+ <i>
368
+ <a href='#ISO712'>ISO 712</a>
369
+ </i>
370
+ </li>
371
+ <li>
372
+ <i>
373
+ <a href='#ISO712'>word</a>
374
+ </i>
375
+ </li>
376
+ <li>
377
+ <i>
378
+ <a href='#ISO712'> ISO 712, Clause 3.1, Figure a </a>
379
+ </i>
380
+ </li>
381
+ <li>
382
+ <i>
383
+ <a href='#ISO712'> ISO 712, Clause 3.1; Figure b </a>
384
+ </i>
385
+ </li>
386
+ <li>
387
+ <i>
388
+ <a href='#ISO712'>
389
+ <i>word</i>
390
+ </a>
391
+ </i>
392
+ </li>
393
+ <li> [term defined in Termbase IEV, term ID 135-13-13 ] </li>
394
+ <li>
395
+ <i> Termbase IEV, term ID 135-13-13 </i>
396
+ </li>
397
+ </ul>
398
+ </p>
399
+ </div>
400
+ <p class='zzSTDTitle1'/>
401
+ <div>
402
+ <h1> 1. &#160; Normative References </h1>
403
+ <p>
404
+ The following documents are referred to in the text in such a way
405
+ that some or all of their content constitutes requirements of this
406
+ document. For dated references, only the edition cited applies. For
407
+ undated references, the latest edition of the referenced document
408
+ (including any amendments) applies.
409
+ </p>
410
+ <p id='ISO712' class='NormRef'>
411
+ ISO 712,
412
+ <i>Cereals and cereal products</i>
413
+ </p>
414
+ </div>
415
+ <div id='clause1'>
416
+ <h1> 2. &#160; Clause 1 </h1>
417
+ </div>
418
+ </div>
419
+ </body>
420
+ </html>
421
+ OUTPUT
422
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
423
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
424
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
425
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
426
+ end
427
+
428
+ it "processes embedded inline formatting" do
429
+ input = <<~INPUT
430
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
431
+ <preface><foreword>
432
+ <p>
433
+ <em><strong>&lt;</strong></em> <tt><link target="B"/></tt> <xref target="_http_1_1">Requirement <tt>/req/core/http</tt></xref> <eref type="inline" bibitemid="ISO712" citeas="ISO 712">Requirement <tt>/req/core/http</tt></eref>
434
+ </p>
435
+ </foreword></preface>
436
+ <sections>
437
+ </iso-standard>
438
+ INPUT
439
+ output = <<~OUTPUT
440
+ #{HTML_HDR}
441
+ <br/>
442
+ <div>
443
+ <h1 class="ForewordTitle">Foreword</h1>
444
+ <p>
445
+ <i><b>&lt;</b></i> <tt><a href="B">B</a></tt> <a href="#_http_1_1">Requirement <tt>/req/core/http</tt></a> <a href="#ISO712">Requirement <tt>/req/core/http</tt></a>
446
+ </p>
377
447
  </div>
378
- </body>
379
- </html>
448
+ <p class="zzSTDTitle1"/>
449
+ </div>
450
+ </body>
451
+ </html>
380
452
  OUTPUT
453
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
454
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
381
455
  end
382
456
 
383
457
  it "processes inline images" do
384
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
458
+ input = <<~INPUT
385
459
  <iso-standard xmlns="http://riboseinc.com/isoxml">
386
460
  <preface><foreword>
387
461
  <p>
@@ -390,6 +464,7 @@ RSpec.describe IsoDoc do
390
464
  </foreword></preface>
391
465
  </iso-standard>
392
466
  INPUT
467
+ output = <<~OUTPUT
393
468
  #{HTML_HDR}
394
469
  <br/>
395
470
  <div>
@@ -403,10 +478,12 @@ RSpec.describe IsoDoc do
403
478
  </body>
404
479
  </html>
405
480
  OUTPUT
481
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
482
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
406
483
  end
407
484
 
408
485
  it "processes links" do
409
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
486
+ input = <<~INPUT
410
487
  <iso-standard xmlns="http://riboseinc.com/isoxml">
411
488
  <preface><foreword>
412
489
  <p>
@@ -420,6 +497,7 @@ RSpec.describe IsoDoc do
420
497
  <sections>
421
498
  </iso-standard>
422
499
  INPUT
500
+ output = <<~OUTPUT
423
501
  #{HTML_HDR}
424
502
  <br/>
425
503
  <div>
@@ -437,10 +515,55 @@ RSpec.describe IsoDoc do
437
515
  </body>
438
516
  </html>
439
517
  OUTPUT
518
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
519
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
520
+ end
521
+
522
+ it "processes updatetype links" do
523
+ input = <<~INPUT
524
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
525
+ <preface><foreword>
526
+ <p>
527
+ <link updatetype="true" target="http://example.com"/>
528
+ <link updatetype="true" target="list.adoc">example</link>
529
+ <link updatetype="true" target="list" alt="tip">example</link>
530
+ </p>
531
+ </foreword></preface>
532
+ <sections>
533
+ </iso-standard>
534
+ INPUT
535
+ html = <<~OUTPUT
536
+ <div>
537
+ <h1 class="ForewordTitle">Foreword</h1>
538
+ <p>
539
+ <a href="http://example.com">http://example.com</a>
540
+ <a href='list.adoc'>example</a>
541
+ <a href='list.html' title='tip'>example</a>
542
+ </p>
543
+ </div>
544
+ OUTPUT
545
+ doc = <<~OUTPUT
546
+ <div>
547
+ <h1 class="ForewordTitle">Foreword</h1>
548
+ <p>
549
+ <a href="http://example.com">http://example.com</a>
550
+ <a href='list.adoc'>example</a>
551
+ <a href='list.doc' title='tip'>example</a>
552
+ </p>
553
+ </div>
554
+ OUTPUT
555
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
556
+ .convert("test", input, true))
557
+ .sub(/^.*<h1/m, "<div><h1").sub(%r{</div>.*$}m, "</div>"))
558
+ .to be_equivalent_to xmlpp(html)
559
+ expect(xmlpp(IsoDoc::WordConvert.new({})
560
+ .convert("test", input, true))
561
+ .sub(/^.*<h1/m, "<div><h1").sub(%r{</div>.*$}m, "</div>"))
562
+ .to be_equivalent_to xmlpp(doc)
440
563
  end
441
564
 
442
565
  it "processes unrecognised markup" do
443
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
566
+ input = <<~INPUT
444
567
  <iso-standard xmlns="http://riboseinc.com/isoxml">
445
568
  <preface><foreword>
446
569
  <p>
@@ -450,6 +573,7 @@ RSpec.describe IsoDoc do
450
573
  <sections>
451
574
  </iso-standard>
452
575
  INPUT
576
+ output = <<~OUTPUT
453
577
  #{HTML_HDR}
454
578
  <br/>
455
579
  <div>
@@ -463,10 +587,12 @@ RSpec.describe IsoDoc do
463
587
  </body>
464
588
  </html>
465
589
  OUTPUT
590
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
591
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
466
592
  end
467
593
 
468
594
  it "processes AsciiMath and MathML" do
469
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true).sub(/<html/, "<html xmlns:m='m'"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
595
+ input = <<~INPUT
470
596
  <iso-standard xmlns="http://riboseinc.com/isoxml">
471
597
  <preface><foreword>
472
598
  <p>
@@ -478,6 +604,7 @@ RSpec.describe IsoDoc do
478
604
  <sections>
479
605
  </iso-standard>
480
606
  INPUT
607
+ output = <<~OUTPUT
481
608
  #{HTML_HDR.sub(/<html/, "<html xmlns:m='m'")}
482
609
  <br/>
483
610
  <div>
@@ -495,10 +622,13 @@ RSpec.describe IsoDoc do
495
622
  </body>
496
623
  </html>
497
624
  OUTPUT
625
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
626
+ .convert("test", input, true).sub(/<html/, "<html xmlns:m='m'")))
627
+ .to be_equivalent_to xmlpp(output)
498
628
  end
499
629
 
500
630
  it "overrides AsciiMath delimiters" do
501
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
631
+ input = <<~INPUT
502
632
  <iso-standard xmlns="http://riboseinc.com/isoxml">
503
633
  <preface><foreword>
504
634
  <p>
@@ -509,6 +639,7 @@ RSpec.describe IsoDoc do
509
639
  <sections>
510
640
  </iso-standard>
511
641
  INPUT
642
+ output = <<~OUTPUT
512
643
  #{HTML_HDR}
513
644
  <br/>
514
645
  <div>
@@ -523,10 +654,12 @@ RSpec.describe IsoDoc do
523
654
  </body>
524
655
  </html>
525
656
  OUTPUT
657
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
658
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
526
659
  end
527
660
 
528
661
  it "processes eref types" do
529
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
662
+ input = <<~INPUT
530
663
  <iso-standard xmlns="http://riboseinc.com/isoxml">
531
664
  <preface><foreword>
532
665
  <p>
@@ -549,6 +682,7 @@ RSpec.describe IsoDoc do
549
682
  </bibliography>
550
683
  </iso-standard>
551
684
  INPUT
685
+ output = <<~OUTPUT
552
686
  #{HTML_HDR}
553
687
  <br/>
554
688
  <div>
@@ -567,6 +701,8 @@ RSpec.describe IsoDoc do
567
701
  </body>
568
702
  </html>
569
703
  OUTPUT
704
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
705
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
570
706
  end
571
707
 
572
708
  it "processes eref content" do
@@ -681,8 +817,10 @@ RSpec.describe IsoDoc do
681
817
  </body>
682
818
  </html>
683
819
  OUTPUT
684
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
685
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
820
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
821
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
822
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
823
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
686
824
  end
687
825
 
688
826
  it "processes eref content pointing to reference with citation URL" do
@@ -870,80 +1008,83 @@ RSpec.describe IsoDoc do
870
1008
  OUTPUT
871
1009
 
872
1010
  word = <<~OUTPUT
873
- <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
874
- <head>
875
- <style>
876
- </style>
877
- </head>
878
- <body lang='EN-US' link='blue' vlink='#954F72'>
879
- <div class='WordSection1'>
880
- <p>&#160;</p>
881
- </div>
882
- <p>
883
- <br clear='all' class='section'/>
884
- </p>
885
- <div class='WordSection2'>
886
- <p>
887
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
888
- </p>
889
- <div>
890
- <h1 class='ForewordTitle'>Foreword</h1>
891
- <p>
892
- <a href='http://www.example.com'>ISO 712</a>
893
- <a href='http://www.example.com'>ISO 712</a>
894
- <a href='spec/assets/iso713.doc'>ISO 713, Table 1</a>
895
- <a href='spec/assets/iso713.doc'>ISO 713, Table 1</a>
896
- <a href='spec/assets/iso713.doc'>ISO 713, Table 1; Clause 1</a>
897
- <a href='spec/assets/iso713.doc'>ISO 713, Table 1&#8211;1</a>
898
- <a href='spec/assets/iso713.doc'>ISO 713, Clause 1, Table 1</a>
899
- <a href='spec/assets/iso713.doc'>ISO 713, Clause 1</a>
900
- <a href='spec/assets/iso713.doc'>ISO 713, Clause 1.5</a>
901
- <a href='spec/assets/iso713.doc'>A</a>
902
- <a href='spec/assets/iso713.doc'>ISO 713, Whole of text</a>
903
- <a href='spec/assets/iso713.doc'>ISO 713, Prelude 7</a>
904
- <a href='spec/assets/iso713.doc'>A</a>
905
- <a href='spec/assets/iso713.doc#xyz'>ISO 713</a>
906
- <a href='spec/assets/iso713.doc#xyz'>ISO 713, Clause 1</a>
907
- <a href='spec/assets/iso714.svg'>ISO 714</a>
908
- </p>
909
- </div>
910
- <p>&#160;</p>
911
- </div>
912
- <p>
913
- <br clear='all' class='section'/>
914
- </p>
915
- <div class='WordSection3'>
916
- <p class='zzSTDTitle1'/>
917
- <div>
918
- <h1>
919
- 1.
920
- <span style='mso-tab-count:1'>&#160; </span>
921
- Normative References
922
- </h1>
923
- <p id='ISO712' class='NormRef'>
924
- ISO 712,
925
- <i>Cereals and cereal products</i>
926
- </p>
927
- <p id='ISO713' class='NormRef'>
928
- ISO 713,
929
- <i>Cereals and cereal products</i>
930
- </p>
931
- <p id='ISO714' class='NormRef'>
932
- ISO 714,
933
- <i>Cereals and cereal products</i>
934
- </p>
935
- </div>
936
- </div>
937
- </body>
938
- </html>
1011
+ <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
1012
+ <head>
1013
+ <style>
1014
+ </style>
1015
+ </head>
1016
+ <body lang='EN-US' link='blue' vlink='#954F72'>
1017
+ <div class='WordSection1'>
1018
+ <p>&#160;</p>
1019
+ </div>
1020
+ <p>
1021
+ <br clear='all' class='section'/>
1022
+ </p>
1023
+ <div class='WordSection2'>
1024
+ <p>
1025
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
1026
+ </p>
1027
+ <div>
1028
+ <h1 class='ForewordTitle'>Foreword</h1>
1029
+ <p>
1030
+ <a href='http://www.example.com'>ISO 712</a>
1031
+ <a href='http://www.example.com'>ISO 712</a>
1032
+ <a href='spec/assets/iso713.doc'>ISO 713, Table 1</a>
1033
+ <a href='spec/assets/iso713.doc'>ISO 713, Table 1</a>
1034
+ <a href='spec/assets/iso713.doc'>ISO 713, Table 1; Clause 1</a>
1035
+ <a href='spec/assets/iso713.doc'>ISO 713, Table 1&#8211;1</a>
1036
+ <a href='spec/assets/iso713.doc'>ISO 713, Clause 1, Table 1</a>
1037
+ <a href='spec/assets/iso713.doc'>ISO 713, Clause 1</a>
1038
+ <a href='spec/assets/iso713.doc'>ISO 713, Clause 1.5</a>
1039
+ <a href='spec/assets/iso713.doc'>A</a>
1040
+ <a href='spec/assets/iso713.doc'>ISO 713, Whole of text</a>
1041
+ <a href='spec/assets/iso713.doc'>ISO 713, Prelude 7</a>
1042
+ <a href='spec/assets/iso713.doc'>A</a>
1043
+ <a href='spec/assets/iso713.doc#xyz'>ISO 713</a>
1044
+ <a href='spec/assets/iso713.doc#xyz'>ISO 713, Clause 1</a>
1045
+ <a href='spec/assets/iso714.svg'>ISO 714</a>
1046
+ </p>
1047
+ </div>
1048
+ <p>&#160;</p>
1049
+ </div>
1050
+ <p>
1051
+ <br clear='all' class='section'/>
1052
+ </p>
1053
+ <div class='WordSection3'>
1054
+ <p class='zzSTDTitle1'/>
1055
+ <div>
1056
+ <h1>
1057
+ 1.
1058
+ <span style='mso-tab-count:1'>&#160; </span>
1059
+ Normative References
1060
+ </h1>
1061
+ <p id='ISO712' class='NormRef'>
1062
+ ISO 712,
1063
+ <i>Cereals and cereal products</i>
1064
+ </p>
1065
+ <p id='ISO713' class='NormRef'>
1066
+ ISO 713,
1067
+ <i>Cereals and cereal products</i>
1068
+ </p>
1069
+ <p id='ISO714' class='NormRef'>
1070
+ ISO 714,
1071
+ <i>Cereals and cereal products</i>
1072
+ </p>
1073
+ </div>
1074
+ </div>
1075
+ </body>
1076
+ </html>
939
1077
  OUTPUT
940
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
941
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
942
- expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(word)
1078
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1079
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
1080
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1081
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
1082
+ expect(xmlpp(IsoDoc::WordConvert.new({})
1083
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(word)
943
1084
  end
944
1085
 
945
1086
  it "processes variant" do
946
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1087
+ input = <<~INPUT
947
1088
  <iso-standard xmlns="http://riboseinc.com/isoxml">
948
1089
  <bibdata>
949
1090
  <language>en</language>
@@ -961,6 +1102,7 @@ RSpec.describe IsoDoc do
961
1102
  </preface>
962
1103
  </iso-standard>
963
1104
  INPUT
1105
+ output = <<~OUTPUT
964
1106
  <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
965
1107
  <bibdata>
966
1108
  <language current='true'>en</language>
@@ -992,10 +1134,14 @@ RSpec.describe IsoDoc do
992
1134
  </preface>
993
1135
  </iso-standard>
994
1136
  OUTPUT
1137
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1138
+ .convert("test", input, true)
1139
+ .sub(%r{<localized-strings>.*</localized-strings>}m, "")))
1140
+ .to be_equivalent_to xmlpp(output)
995
1141
  end
996
1142
 
997
1143
  it "cases xrefs" do
998
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({ i18nyaml: "spec/assets/i18n.yaml" }).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1144
+ input = <<~INPUT
999
1145
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1000
1146
  <sections>
1001
1147
  <clause id="A">
@@ -1013,6 +1159,7 @@ RSpec.describe IsoDoc do
1013
1159
  </sections>
1014
1160
  </iso-standard>
1015
1161
  INPUT
1162
+ output = <<~OUTPUT
1016
1163
  <?xml version='1.0'?>
1017
1164
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1018
1165
  <sections>
@@ -1053,16 +1200,20 @@ RSpec.describe IsoDoc do
1053
1200
  </sections>
1054
1201
  </iso-standard>
1055
1202
  OUTPUT
1203
+ expect(xmlpp(IsoDoc::PresentationXMLConvert
1204
+ .new({ i18nyaml: "spec/assets/i18n.yaml" })
1205
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1056
1206
  end
1057
1207
 
1058
1208
  it "processes add, del" do
1059
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1209
+ input = <<~INPUT
1060
1210
  <itu-standard xmlns="https://www.calconnect.org/standards/itu">
1061
1211
  <preface><foreword id="A">
1062
1212
  <add>ABC <xref target="A"></add> <del><strong>B</strong></del>
1063
1213
  </foreword></preface>
1064
1214
  </itu-standard>
1065
1215
  INPUT
1216
+ output = <<~OUTPUT
1066
1217
  #{HTML_HDR}
1067
1218
  <br/>
1068
1219
  <div id='A'>
@@ -1080,5 +1231,7 @@ RSpec.describe IsoDoc do
1080
1231
  </body>
1081
1232
  </html>
1082
1233
  OUTPUT
1234
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1235
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1083
1236
  end
1084
1237
  end