isodoc 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +2 -12
- data/.hound.yml +3 -1
- data/.rubocop.yml +3 -5
- data/isodoc.gemspec +1 -1
- data/lib/isodoc.rb +0 -2
- data/lib/isodoc/convert.rb +4 -0
- data/lib/isodoc/function/cleanup.rb +52 -43
- data/lib/isodoc/function/inline.rb +7 -7
- data/lib/isodoc/function/section.rb +29 -16
- data/lib/isodoc/function/to_word_html.rb +6 -3
- data/lib/isodoc/function/utils.rb +181 -163
- data/lib/isodoc/headlesshtml_convert.rb +8 -7
- data/lib/isodoc/html_function/comments.rb +2 -0
- data/lib/isodoc/html_function/footnotes.rb +14 -7
- data/lib/isodoc/html_function/html.rb +30 -26
- data/lib/isodoc/html_function/postprocess.rb +16 -13
- data/lib/isodoc/pdf_convert.rb +11 -13
- data/lib/isodoc/presentation_function/bibdata.rb +43 -22
- data/lib/isodoc/presentation_function/inline.rb +20 -15
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +50 -36
- data/lib/isodoc/xref/xref_gen_seq.rb +60 -35
- data/lib/isodoc/xref/xref_sect_gen.rb +4 -4
- data/spec/assets/scripts_override.html +3 -0
- data/spec/isodoc/blocks_spec.rb +196 -245
- data/spec/isodoc/inline_spec.rb +442 -289
- data/spec/isodoc/postproc_spec.rb +111 -50
- data/spec/isodoc/presentation_xml_spec.rb +354 -277
- data/spec/isodoc/terms_spec.rb +83 -83
- metadata +5 -4
data/spec/isodoc/inline_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe IsoDoc do
|
4
4
|
it "droplocs xrefs" do
|
5
|
-
|
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
|
47
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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
|
-
|
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
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
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><</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
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
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.   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.   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><</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><</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
|
-
|
379
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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({})
|
685
|
-
|
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
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
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> </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–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> </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'>  </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({})
|
941
|
-
|
942
|
-
expect(xmlpp(IsoDoc::
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|