metanorma-standoc 1.10.5 → 1.10.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1018 @@
1
+ require "spec_helper"
2
+ require "fileutils"
3
+
4
+ RSpec.describe Asciidoctor::Standoc do
5
+ it "processes svgmap" do
6
+ FileUtils.cp "spec/fixtures/action_schemaexpg1.svg",
7
+ "action_schemaexpg1.svg"
8
+ FileUtils.cp "spec/fixtures/action_schemaexpg1.svg",
9
+ "action_schemaexpg2.svg"
10
+ input = <<~INPUT
11
+ #{ASCIIDOC_BLANK_HDR}
12
+
13
+ [svgmap%unnumbered,number=8,subsequence=A,keep-with-next=true,keep-lines-together=true]
14
+ ====
15
+ * <<ref1,Computer>>; http://www.example.com
16
+ ====
17
+
18
+ [[ref1]]
19
+ .SVG title
20
+ [.svgmap]
21
+ ====
22
+ image::action_schemaexpg1.svg[]
23
+
24
+ * <<ref1,Computer>>; mn://action_schema
25
+ * http://www.example.com[Phone]; http://www.example.com
26
+ ====
27
+
28
+ [[ref2]]
29
+ [svgmap%unnumbered,number=8,subsequence=A,keep-with-next=true,keep-lines-together=true]
30
+ ====
31
+ [alt=Workmap]
32
+ image::action_schemaexpg2.svg[]
33
+
34
+ * <<ref1,Computer>>; mn://action_schema
35
+ * http://www.example.com[Phone]; mn://basic_attribute_schema
36
+ * <<express:action_schema:action_schema.basic,Coffee>>; mn://support_resource_schema
37
+ ====
38
+ INPUT
39
+ output = <<~OUTPUT
40
+ #{BLANK_HDR}
41
+ <sections>
42
+ <svgmap unnumbered='true' number='8' subsequence='A' keep-with-next='true' keep-lines-together='true'>
43
+ <target href='http://www.example.com'>
44
+ <xref target='ref1'>Computer</xref>
45
+ </target>
46
+ </svgmap>
47
+ <figure id='ref1'>
48
+ <name>SVG title</name>
49
+ <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_000000001' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
50
+ <style/>
51
+ <image/>
52
+ <a xlink:href='#ref1'>
53
+ <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
54
+ </a>
55
+ <a xlink:href='mn://basic_attribute_schema'>
56
+ <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
57
+ </a>
58
+ <a xlink:href='mn://support_resource_schema'>
59
+ <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
60
+ </a>
61
+ </svg>
62
+ </figure>
63
+ <svgmap>
64
+ <figure id='ref2' unnumbered='true' number='8' subsequence='A' keep-with-next='true' keep-lines-together='true'>
65
+ <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_000000002' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
66
+ <style/>
67
+ <image/>
68
+ <a xlink:href='#ref1'>
69
+ <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
70
+ </a>
71
+ <a xlink:href='http://www.example.com'>
72
+ <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
73
+ </a>
74
+ <a xlink:href='mn://support_resource_schema'>
75
+ <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
76
+ </a>
77
+ </svg>
78
+ </figure>
79
+ <target href='mn://support_resource_schema'>
80
+ <eref bibitemid='express_action_schema' citeas=''>
81
+ <localityStack>
82
+ <locality type='anchor'>
83
+ <referenceFrom>action_schema.basic</referenceFrom>
84
+ </locality>
85
+ </localityStack>
86
+ Coffee
87
+ </eref>
88
+ </target>
89
+ </svgmap>
90
+ </sections>
91
+ <bibliography>
92
+ <references hidden='true' normative='false'>
93
+ <bibitem id='express_action_schema' type='internal'>
94
+ <docidentifier type='repository'>express/action_schema</docidentifier>
95
+ </bibitem>
96
+ </references>
97
+ </bibliography>
98
+ </standard-document>
99
+ OUTPUT
100
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))
101
+ .gsub(%r{<image.*?</image>}m, "<image/>")
102
+ .gsub(%r{<style.*?</style>}m, "<style/>"))
103
+ .to be_equivalent_to xmlpp(output)
104
+ end
105
+
106
+ it "processes markup in sourcecode" do
107
+ input = <<~INPUT
108
+ #{ASCIIDOC_BLANK_HDR}
109
+
110
+ [source]
111
+ ----
112
+ <tag/>
113
+ ----
114
+
115
+ [[A]]
116
+ [source]
117
+ ----
118
+ var {{{*x*}}} : {{{<<A,recursive>>}}} <tag/>
119
+ ----
120
+
121
+
122
+ INPUT
123
+ output = <<~OUTPUT
124
+ #{BLANK_HDR}
125
+ <sections>
126
+ <sourcecode id='_'>&lt;tag/&gt;</sourcecode>
127
+ <sourcecode id='A'>
128
+ var
129
+ <strong>x</strong>
130
+ :
131
+ <xref target='A'>recursive</xref>
132
+ &lt;tag/&gt;
133
+ </sourcecode>
134
+ </sections>
135
+ </standard-document>
136
+ OUTPUT
137
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
138
+ .to be_equivalent_to xmlpp(output)
139
+ end
140
+
141
+ it "processes markup in sourcecode with custom delimiters" do
142
+ input = <<~INPUT
143
+ = Document title
144
+ Author
145
+ :docfile: test.adoc
146
+ :nodoc:
147
+ :novalid:
148
+ :no-isobib:
149
+ :sourcecode-markup-start: [[[
150
+ :sourcecode-markup-end: ]]]
151
+
152
+ [[A]]
153
+ [source]
154
+ ----
155
+ var [[[*x*]]] : [[[<<A,recursive>>]]]
156
+ ----
157
+
158
+
159
+ INPUT
160
+ output = <<~OUTPUT
161
+ #{BLANK_HDR}
162
+ <sections>
163
+ <sourcecode id='A'>
164
+ var
165
+ <strong>x</strong>
166
+ :
167
+ <xref target='A'>recursive</xref>
168
+ </sourcecode>
169
+ </sections>
170
+ </standard-document>
171
+ OUTPUT
172
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
173
+ .to be_equivalent_to xmlpp(output)
174
+ end
175
+
176
+ it "moves notes inside preceding blocks, if they are not at clause end, and the blocks are not delimited" do
177
+ input = <<~INPUT
178
+ #{ASCIIDOC_BLANK_HDR}
179
+
180
+ [stem]
181
+ ++++
182
+ r = 1 %
183
+ r = 1 %
184
+ ++++
185
+
186
+ NOTE: That formula does not do much
187
+
188
+ Indeed.
189
+ INPUT
190
+ output = <<~OUTPUT
191
+ #{BLANK_HDR}
192
+ <sections><formula id="_">
193
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mo>%</mo><mi>r</mi><mo>=</mo><mn>1</mn><mo>%</mo></math></stem>
194
+ <note id="_">
195
+ <p id="_">That formula does not do much</p>
196
+ </note></formula>
197
+ <p id="_">Indeed.</p></sections>
198
+ </standard-document>
199
+ OUTPUT
200
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
201
+ .to be_equivalent_to xmlpp(output)
202
+ end
203
+
204
+ it "does not move notes inside preceding blocks, if they are marked as keep-separate" do
205
+ input = <<~INPUT
206
+ #{ASCIIDOC_BLANK_HDR}
207
+
208
+ [stem]
209
+ ++++
210
+ r = 1 %
211
+ r = 1 %
212
+ ++++
213
+
214
+ [NOTE,keep-separate=true]
215
+ ====
216
+ That formula does not do much
217
+ ====
218
+
219
+ Indeed.
220
+ INPUT
221
+ output = <<~OUTPUT
222
+ #{BLANK_HDR}
223
+ <sections><formula id="_">
224
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mo>%</mo><mi>r</mi><mo>=</mo><mn>1</mn><mo>%</mo></math></stem></formula>
225
+ <note id="_">
226
+ <p id="_">That formula does not do much</p>
227
+ </note>
228
+ <p id="_">Indeed.</p></sections>
229
+ </standard-document>
230
+ OUTPUT
231
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
232
+ .to be_equivalent_to xmlpp(output)
233
+ end
234
+
235
+ it "does not move notes inside preceding tables, if they are marked as keep-separate" do
236
+ input = <<~INPUT
237
+ #{ASCIIDOC_BLANK_HDR}
238
+
239
+ |===
240
+ |A |B
241
+
242
+ |C |D
243
+ |===
244
+
245
+ [NOTE,keep-separate=true]
246
+ ====
247
+ That formula does not do much
248
+ ====
249
+
250
+ |===
251
+ |A |B
252
+
253
+ |C |D
254
+ |===
255
+
256
+ [NOTE]
257
+ ====
258
+ That formula does not do much
259
+ ====
260
+
261
+ Indeed.
262
+ INPUT
263
+ output = <<~OUTPUT
264
+ #{BLANK_HDR}
265
+ <sections>
266
+ <table id='_'>
267
+ <thead>
268
+ <tr>
269
+ <th valign='top' align='left'>A</th>
270
+ <th valign='top' align='left'>B</th>
271
+ </tr>
272
+ </thead>
273
+ <tbody>
274
+ <tr>
275
+ <td valign='top' align='left'>C</td>
276
+ <td valign='top' align='left'>D</td>
277
+ </tr>
278
+ </tbody>
279
+ </table>
280
+ <note id='_'>
281
+ <p id='_'>That formula does not do much</p>
282
+ </note>
283
+ <table id='_'>
284
+ <thead>
285
+ <tr>
286
+ <th valign='top' align='left'>A</th>
287
+ <th valign='top' align='left'>B</th>
288
+ </tr>
289
+ </thead>
290
+ <tbody>
291
+ <tr>
292
+ <td valign='top' align='left'>C</td>
293
+ <td valign='top' align='left'>D</td>
294
+ </tr>
295
+ </tbody>
296
+ <note id='_'>
297
+ <p id='_'>That formula does not do much</p>
298
+ </note>
299
+ </table>
300
+ <p id='_'>Indeed.</p>
301
+ </sections>
302
+ </standard-document>
303
+ OUTPUT
304
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
305
+ .to be_equivalent_to xmlpp(output)
306
+ end
307
+
308
+ it "does not move notes inside preceding blocks, if they are at clause end" do
309
+ input = <<~INPUT
310
+ #{ASCIIDOC_BLANK_HDR}
311
+ [source,ruby]
312
+ [1...x].each do |y|
313
+ puts y
314
+ end
315
+
316
+ NOTE: That loop does not do much
317
+ INPUT
318
+ output = <<~OUTPUT
319
+ #{BLANK_HDR}
320
+ <sections><sourcecode id="_" lang="ruby">[1...x].each do |y|
321
+ puts y
322
+ end</sourcecode>
323
+ <note id="_">
324
+ <p id="_">That loop does not do much</p>
325
+ </note></sections>
326
+ </standard-document>
327
+ OUTPUT
328
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
329
+ .to be_equivalent_to xmlpp(output)
330
+ end
331
+
332
+ it "inserts IDs into paragraphs" do
333
+ input = <<~INPUT
334
+ #{ASCIIDOC_BLANK_HDR}
335
+ Paragraph
336
+ INPUT
337
+ output = <<~OUTPUT
338
+ #{BLANK_HDR}
339
+ <sections>
340
+ <p id="_">Paragraph</p>
341
+ </sections>
342
+ </standard-document>
343
+ OUTPUT
344
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
345
+ .to be_equivalent_to xmlpp(output)
346
+ end
347
+
348
+ it "inserts IDs into notes" do
349
+ input = <<~INPUT
350
+ #{ASCIIDOC_BLANK_HDR}
351
+ [example]
352
+ ====
353
+ NOTE: This note has no ID
354
+ ====
355
+ INPUT
356
+ output = <<~OUTPUT
357
+ #{BLANK_HDR}
358
+ <sections>
359
+ <example id="_">
360
+ <note id="_">
361
+ <p id="_">This note has no ID</p>
362
+ </note>
363
+ </example>
364
+ </sections>
365
+ </standard-document>
366
+ OUTPUT
367
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
368
+ .to be_equivalent_to xmlpp(output)
369
+ end
370
+
371
+ it "moves table key inside table" do
372
+ input = <<~INPUT
373
+ #{ASCIIDOC_BLANK_HDR}
374
+ |===
375
+ |a |b |c
376
+ |===
377
+
378
+ Key
379
+
380
+ a:: b
381
+
382
+ |===
383
+ |a |b |c
384
+ |===
385
+
386
+ [%key]
387
+ a:: b
388
+
389
+ |===
390
+ |a |b |c
391
+ |===
392
+
393
+ a:: b
394
+ INPUT
395
+ output = <<~OUTPUT
396
+ #{BLANK_HDR}
397
+ <sections>
398
+ <table id='_'>
399
+ <tbody>
400
+ <tr>
401
+ <td valign='top' align='left'>a</td>
402
+ <td valign='top' align='left'>b</td>
403
+ <td valign='top' align='left'>c</td>
404
+ </tr>
405
+ </tbody>
406
+ <dl id='_' key='true'>
407
+ <dt>a</dt>
408
+ <dd>
409
+ <p id='_'>b</p>
410
+ </dd>
411
+ </dl>
412
+ </table>
413
+ <table id='_'>
414
+ <tbody>
415
+ <tr>
416
+ <td valign='top' align='left'>a</td>
417
+ <td valign='top' align='left'>b</td>
418
+ <td valign='top' align='left'>c</td>
419
+ </tr>
420
+ </tbody>
421
+ <dl id='_' key='true'>
422
+ <dt>a</dt>
423
+ <dd>
424
+ <p id='_'>b</p>
425
+ </dd>
426
+ </dl>
427
+ </table>
428
+ <table id='_'>
429
+ <tbody>
430
+ <tr>
431
+ <td valign='top' align='left'>a</td>
432
+ <td valign='top' align='left'>b</td>
433
+ <td valign='top' align='left'>c</td>
434
+ </tr>
435
+ </tbody>
436
+ </table>
437
+ <dl id='_'>
438
+ <dt>a</dt>
439
+ <dd>
440
+ <p id='_'>b</p>
441
+ </dd>
442
+ </dl>
443
+ </sections>
444
+ </standard-document>
445
+ OUTPUT
446
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
447
+ .to be_equivalent_to xmlpp(output)
448
+ end
449
+
450
+ it "processes headerrows attribute for table without header rows" do
451
+ input = <<~INPUT
452
+ #{ASCIIDOC_BLANK_HDR}
453
+ [headerrows=3]
454
+ |===
455
+ |a |b |c
456
+ |a |b |c
457
+ |a |b |c
458
+ |a |b |c
459
+ |===
460
+ INPUT
461
+ output = <<~OUTPUT
462
+ #{BLANK_HDR}
463
+ <sections>
464
+ <table id="_"><thead><tr>
465
+ <th valign="top" align="left">a</th>
466
+ <th valign="top" align="left">b</th>
467
+ <th valign="top" align="left">c</th>
468
+ </tr><tr>
469
+ <th valign="top" align="left">a</th>
470
+ <th valign="top" align="left">b</th>
471
+ <th valign="top" align="left">c</th>
472
+ </tr><tr>
473
+ <th valign="top" align="left">a</th>
474
+ <th valign="top" align="left">b</th>
475
+ <th valign="top" align="left">c</th>
476
+ </tr></thead>
477
+ <tbody>
478
+ <tr>
479
+ <td valign="top" align="left">a</td>
480
+ <td valign="top" align="left">b</td>
481
+ <td valign="top" align="left">c</td>
482
+ </tr>
483
+ </tbody>
484
+ </table>
485
+ </sections>
486
+ </standard-document>
487
+ OUTPUT
488
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
489
+ .to be_equivalent_to xmlpp(output)
490
+ end
491
+
492
+ it "processes headerrows attribute for table with header rows" do
493
+ input = <<~INPUT
494
+ #{ASCIIDOC_BLANK_HDR}
495
+ [headerrows=3]
496
+ |===
497
+ |a |b |c
498
+
499
+ |a |b |c
500
+ |a |b |c
501
+ |a |b |c
502
+ |===
503
+ INPUT
504
+ output = <<~OUTPUT
505
+ #{BLANK_HDR}
506
+ <sections>
507
+ <table id="_">
508
+ <thead>
509
+ <tr>
510
+ <th valign="top" align="left">a</th>
511
+ <th valign="top" align="left">b</th>
512
+ <th valign="top" align="left">c</th>
513
+ </tr>
514
+ <tr>
515
+ <th valign="top" align="left">a</th>
516
+ <th valign="top" align="left">b</th>
517
+ <th valign="top" align="left">c</th>
518
+ </tr><tr>
519
+ <th valign="top" align="left">a</th>
520
+ <th valign="top" align="left">b</th>
521
+ <th valign="top" align="left">c</th>
522
+ </tr></thead>
523
+ <tbody>
524
+
525
+
526
+ <tr>
527
+ <td valign="top" align="left">a</td>
528
+ <td valign="top" align="left">b</td>
529
+ <td valign="top" align="left">c</td>
530
+ </tr>
531
+ </tbody>
532
+ </table>
533
+ </sections>
534
+ </standard-document>
535
+ OUTPUT
536
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
537
+ .to be_equivalent_to xmlpp(output)
538
+ end
539
+
540
+ it "moves table notes inside table" do
541
+ input = <<~INPUT
542
+ #{ASCIIDOC_BLANK_HDR}
543
+ |===
544
+ |a |b |c
545
+ |===
546
+
547
+ NOTE: Note 1
548
+
549
+ NOTE: Note 2
550
+ INPUT
551
+ output = <<~OUTPUT
552
+ #{BLANK_HDR}
553
+ <sections><table id="_">
554
+ <tbody>
555
+ <tr>
556
+ <td valign="top" align="left">a</td>
557
+ <td valign="top" align="left">b</td>
558
+ <td valign="top" align="left">c</td>
559
+ </tr>
560
+ </tbody>
561
+ <note id="_">
562
+ <p id="_">Note 1</p>
563
+ </note><note id="_">
564
+ <p id="_">Note 2</p>
565
+ </note></table>
566
+
567
+ </sections>
568
+ </standard-document>
569
+ OUTPUT
570
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
571
+ .to be_equivalent_to xmlpp(output)
572
+ end
573
+
574
+ it "moves formula key inside formula" do
575
+ input = <<~INPUT
576
+ #{ASCIIDOC_BLANK_HDR}
577
+ [stem]
578
+ ++++
579
+ Formula
580
+ ++++
581
+
582
+ Where,
583
+
584
+ a:: b
585
+
586
+ [stem]
587
+ ++++
588
+ Formula
589
+ ++++
590
+
591
+ [%key]
592
+ a:: b
593
+
594
+ [stem]
595
+ ++++
596
+ Formula
597
+ ++++
598
+
599
+ a:: b
600
+ INPUT
601
+ output = <<~OUTPUT
602
+ #{BLANK_HDR}
603
+ <sections>
604
+ <formula id='_'>
605
+ <stem type='MathML'>
606
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
607
+ <mi>F</mi>
608
+ <mi>or</mi>
609
+ <mi>μ</mi>
610
+ <mi>l</mi>
611
+ <mi>a</mi>
612
+ </math>
613
+ </stem>
614
+ <dl id='_' key='true'>
615
+ <dt>a</dt>
616
+ <dd>
617
+ <p id='_'>b</p>
618
+ </dd>
619
+ </dl>
620
+ </formula>
621
+ <formula id='_'>
622
+ <stem type='MathML'>
623
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
624
+ <mi>F</mi>
625
+ <mi>or</mi>
626
+ <mi>μ</mi>
627
+ <mi>l</mi>
628
+ <mi>a</mi>
629
+ </math>
630
+ </stem>
631
+ <dl id='_' key='true'>
632
+ <dt>a</dt>
633
+ <dd>
634
+ <p id='_'>b</p>
635
+ </dd>
636
+ </dl>
637
+ </formula>
638
+ <formula id='_'>
639
+ <stem type='MathML'>
640
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
641
+ <mi>F</mi>
642
+ <mi>or</mi>
643
+ <mi>μ</mi>
644
+ <mi>l</mi>
645
+ <mi>a</mi>
646
+ </math>
647
+ </stem>
648
+ </formula>
649
+ <dl id='_'>
650
+ <dt>a</dt>
651
+ <dd>
652
+ <p id='_'>b</p>
653
+ </dd>
654
+ </dl>
655
+ </sections>
656
+ </standard-document>
657
+ OUTPUT
658
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
659
+ .to be_equivalent_to xmlpp(output)
660
+ end
661
+
662
+ it "moves footnotes inside figures" do
663
+ input = <<~INPUT
664
+ #{ASCIIDOC_BLANK_HDR}
665
+ .Figuretitle.footnote:[xyz]
666
+ image::spec/examples/rice_images/rice_image1.png[]
667
+
668
+ footnote:[This is a footnote to a figure]
669
+
670
+ footnote:[This is another footnote to a figure]
671
+
672
+ A footnote:[This is a third footnote]
673
+ INPUT
674
+ output = <<~OUTPUT
675
+ #{BLANK_HDR}
676
+ <sections><figure id="_">
677
+ <name>
678
+ Figuretitle.
679
+ <fn reference='1'>
680
+ <p id='_'>xyz</p>
681
+ </fn>
682
+ </name>
683
+ <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="auto" width="auto"/>
684
+ <fn reference="a">
685
+ <p id="_">This is a footnote to a figure</p>
686
+ </fn><fn reference="b">
687
+ <p id="_">This is another footnote to a figure</p>
688
+ </fn></figure>
689
+ <p id='_'>
690
+ A
691
+ <fn reference='2'>
692
+ <p id='_'>This is a third footnote</p>
693
+ </fn>
694
+ </p>
695
+ </sections>
696
+ </standard-document>
697
+ OUTPUT
698
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
699
+ .to be_equivalent_to xmlpp(output)
700
+ end
701
+
702
+ it "moves figure key inside figure" do
703
+ input = <<~INPUT
704
+ #{ASCIIDOC_BLANK_HDR}
705
+ image::spec/examples/rice_images/rice_image1.png[]
706
+
707
+ key:
708
+
709
+ a:: b
710
+
711
+ image::spec/examples/rice_images/rice_image1.png[]
712
+
713
+ [%key]
714
+ a:: b
715
+
716
+ image::spec/examples/rice_images/rice_image1.png[]
717
+
718
+ a:: b
719
+ INPUT
720
+ output = <<~OUTPUT
721
+ #{BLANK_HDR}
722
+ <sections>
723
+ <figure id='_'>
724
+ <image src='spec/examples/rice_images/rice_image1.png' id='_' mimetype='image/png' height='auto' width='auto'/>
725
+ <dl id='_' key='true'>
726
+ <dt>a</dt>
727
+ <dd>
728
+ <p id='_'>b</p>
729
+ </dd>
730
+ </dl>
731
+ </figure>
732
+ <figure id='_'>
733
+ <image src='spec/examples/rice_images/rice_image1.png' id='_' mimetype='image/png' height='auto' width='auto'/>
734
+ <dl id='_' key='true'>
735
+ <dt>a</dt>
736
+ <dd>
737
+ <p id='_'>b</p>
738
+ </dd>
739
+ </dl>
740
+ </figure>
741
+ <figure id='_'>
742
+ <image src='spec/examples/rice_images/rice_image1.png' id='_' mimetype='image/png' height='auto' width='auto'/>
743
+ </figure>
744
+ <dl id='_'>
745
+ <dt>a</dt>
746
+ <dd>
747
+ <p id='_'>b</p>
748
+ </dd>
749
+ </dl>
750
+ </sections>
751
+ </standard-document>
752
+ OUTPUT
753
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
754
+ .to be_equivalent_to xmlpp(output)
755
+ end
756
+
757
+ it "processes subfigures" do
758
+ input = <<~INPUT
759
+ #{ASCIIDOC_BLANK_HDR}
760
+ [[figureC-2]]
761
+ .Stages of gelatinization
762
+ ====
763
+ .Initial stages: No grains are fully gelatinized (ungelatinized starch granules are visible inside the kernels)
764
+ image::spec/examples/rice_images/rice_image3_1.png[]
765
+
766
+ .Intermediate stages: Some fully gelatinized kernels are visible
767
+ image::spec/examples/rice_images/rice_image3_2.png[]
768
+
769
+ .Final stages: All kernels are fully gelatinized
770
+ image::spec/examples/rice_images/rice_image3_3.png[]
771
+ ====
772
+ INPUT
773
+ output = <<~OUTPUT
774
+ #{BLANK_HDR}
775
+ <sections>
776
+ <figure id="figureC-2"><name>Stages of gelatinization</name><figure id="_">
777
+ <name>Initial stages: No grains are fully gelatinized (ungelatinized starch granules are visible inside the kernels)</name>
778
+ <image src="spec/examples/rice_images/rice_image3_1.png" id="_" mimetype="image/png" height="auto" width="auto"/>
779
+ </figure>
780
+ <figure id="_">
781
+ <name>Intermediate stages: Some fully gelatinized kernels are visible</name>
782
+ <image src="spec/examples/rice_images/rice_image3_2.png" id="_" mimetype="image/png" height="auto" width="auto"/>
783
+ </figure>
784
+ <figure id="_">
785
+ <name>Final stages: All kernels are fully gelatinized</name>
786
+ <image src="spec/examples/rice_images/rice_image3_3.png" id="_" mimetype="image/png" height="auto" width="auto"/>
787
+ </figure></figure>
788
+ </sections>
789
+ </standard-document>
790
+ OUTPUT
791
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
792
+ .to be_equivalent_to xmlpp(output)
793
+ end
794
+
795
+ it "moves metadata deflist to correct location" do
796
+ input = <<~INPUT
797
+ #{ASCIIDOC_BLANK_HDR}
798
+
799
+ == Clause
800
+
801
+ [.requirement,subsequence="A",inherit="/ss/584/2015/level/1 &amp; /ss/584/2015/level/2"]
802
+ ====
803
+ [%metadata]
804
+ model:: ogc
805
+ type:: class
806
+ label:: http://www.opengis.net/spec/waterml/2.0/req/xsd-xml-rules[*req/core*]
807
+ subject:: Encoding of logical models
808
+ inherit:: urn:iso:dis:iso:19156:clause:7.2.2
809
+ inherit:: urn:iso:dis:iso:19156:clause:8
810
+ inherit:: http://www.opengis.net/doc/IS/GML/3.2/clause/2.4
811
+ inherit:: O&M Abstract model, OGC 10-004r3, clause D.3.4
812
+ inherit:: http://www.opengis.net/spec/SWE/2.0/req/core/core-concepts-used
813
+ inherit:: <<ref2>>
814
+ inherit:: <<ref3>>
815
+ classification:: priority:P0
816
+ classification:: domain:Hydrology,Groundwater
817
+ classification:: control-class:Technical
818
+ obligation:: recommendation,requirement
819
+
820
+ I recommend this
821
+ ====
822
+ INPUT
823
+ output = <<~OUTPUT
824
+ #{BLANK_HDR}
825
+ <sections>
826
+ <clause id='_' inline-header='false' obligation='normative'>
827
+ <title>Clause</title>
828
+ <requirement id='_' subsequence='A' obligation='recommendation,requirement' model='ogc' type='class'>
829
+ <label>
830
+ <link target='http://www.opengis.net/spec/waterml/2.0/req/xsd-xml-rules'>
831
+ <strong>req/core</strong>
832
+ </link>
833
+ </label>
834
+ <subject>Encoding of logical models</subject>
835
+ <inherit>/ss/584/2015/level/1 &amp; /ss/584/2015/level/2</inherit>
836
+ <inherit>urn:iso:dis:iso:19156:clause:7.2.2</inherit>
837
+ <inherit>urn:iso:dis:iso:19156:clause:8</inherit>
838
+ <inherit>
839
+ <link target='http://www.opengis.net/doc/IS/GML/3.2/clause/2.4'/>
840
+ </inherit>
841
+ <inherit>O&amp;M Abstract model, OGC 10-004r3, clause D.3.4</inherit>
842
+ <inherit>
843
+ <link target='http://www.opengis.net/spec/SWE/2.0/req/core/core-concepts-used'/>
844
+ </inherit>
845
+ <inherit>
846
+ <xref target='ref2'/>
847
+ </inherit>
848
+ <inherit>
849
+ <xref target='ref3'/>
850
+ </inherit>
851
+ <classification>
852
+ <tag>control-class</tag>
853
+ <value>Technical</value>
854
+ </classification>
855
+ <classification>
856
+ <tag>domain</tag>
857
+ <value>Groundwater</value>
858
+ </classification>
859
+ <classification>
860
+ <tag>domain</tag>
861
+ <value>Hydrology</value>
862
+ </classification>
863
+ <classification>
864
+ <tag>priority</tag>
865
+ <value>P0</value>
866
+ </classification>
867
+ <description>
868
+ <p id='_'>I recommend this</p>
869
+ </description>
870
+ </requirement>
871
+ </clause>
872
+ </sections>
873
+ </standard-document>
874
+ OUTPUT
875
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
876
+ .to be_equivalent_to xmlpp(output)
877
+ end
878
+
879
+ it "moves inherit macros to correct location" do
880
+ input = <<~INPUT
881
+ #{ASCIIDOC_BLANK_HDR}
882
+
883
+ == Clause
884
+
885
+ [.requirement,subsequence="A",inherit="/ss/584/2015/level/1 &amp; /ss/584/2015/level/2"]
886
+ .Title
887
+ ====
888
+ inherit:[A]
889
+ inherit:[B]
890
+ I recommend this
891
+ ====
892
+
893
+ [.requirement,subsequence="A",classification="X:Y"]
894
+ .Title
895
+ ====
896
+ inherit:[A]
897
+ I recommend this
898
+ ====
899
+
900
+ [.requirement,subsequence="A"]
901
+ .Title
902
+ ====
903
+ inherit:[A]
904
+ I recommend this
905
+ ====
906
+
907
+ [.requirement,subsequence="A"]
908
+ .Title
909
+ ====
910
+ inherit:[A]
911
+ ====
912
+
913
+ [.requirement,subsequence="A"]
914
+ ====
915
+ inherit:[A]
916
+ ====
917
+
918
+ INPUT
919
+ output = <<~OUTPUT
920
+ #{BLANK_HDR}
921
+ <sections>
922
+ <clause id='_' inline-header='false' obligation='normative'>
923
+ <title>Clause</title>
924
+ <requirement id='_' subsequence='A'>
925
+ <title>Title</title>
926
+ <inherit>A</inherit>
927
+ <inherit>B</inherit>
928
+ <inherit>/ss/584/2015/level/1 &amp; /ss/584/2015/level/2</inherit>
929
+ <description>
930
+ <p id='_'> I recommend this</p>
931
+ </description>
932
+ </requirement>
933
+ <requirement id='_' subsequence='A'>
934
+ <title>Title</title>
935
+ <inherit>A</inherit>
936
+ <classification>
937
+ <tag>X</tag>
938
+ <value>Y</value>
939
+ </classification>
940
+ <description>
941
+ <p id='_'> I recommend this</p>
942
+ </description>
943
+ </requirement>
944
+ <requirement id='_' subsequence='A'>
945
+ <title>Title</title>
946
+ <inherit>A</inherit>
947
+ <description>
948
+ <p id='_'> I recommend this</p>
949
+ </description>
950
+ </requirement>
951
+ <requirement id='_' subsequence='A'>
952
+ <title>Title</title>
953
+ <inherit>A</inherit>
954
+ </requirement>
955
+ <requirement id='_' subsequence='A'>
956
+ <inherit>A</inherit>
957
+ </requirement>
958
+ </clause>
959
+ </sections>
960
+ </standard-document>
961
+ OUTPUT
962
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
963
+ .to be_equivalent_to xmlpp(output)
964
+ end
965
+
966
+ it "moves %beforeclause admonitions to right position" do
967
+ input = <<~INPUT
968
+ #{ASCIIDOC_BLANK_HDR}
969
+
970
+ .Foreword
971
+ Foreword
972
+
973
+ [NOTE,beforeclauses=true]
974
+ ====
975
+ Note which is very important
976
+ ====
977
+
978
+ == Introduction
979
+ Introduction
980
+
981
+ == Scope
982
+ Scope statement
983
+
984
+ [IMPORTANT,beforeclauses=true]
985
+ ====
986
+ Notice which is very important
987
+ ====
988
+ INPUT
989
+ output = <<~OUTPUT
990
+ #{BLANK_HDR}
991
+ <preface>
992
+ <note id='_'>
993
+ <p id='_'>Note which is very important</p>
994
+ </note>
995
+ <foreword id='_' obligation='informative'>
996
+ <title>Foreword</title>
997
+ <p id='_'>Foreword</p>
998
+ </foreword>
999
+ <introduction id='_' obligation='informative'>
1000
+ <title>Introduction</title>
1001
+ <p id='_'>Introduction</p>
1002
+ </introduction>
1003
+ </preface>
1004
+ <sections>
1005
+ <admonition id='_' type='important'>
1006
+ <p id='_'>Notice which is very important</p>
1007
+ </admonition>
1008
+ <clause id='_' inline-header='false' obligation='normative' type="scope">
1009
+ <title>Scope</title>
1010
+ <p id='_'>Scope statement</p>
1011
+ </clause>
1012
+ </sections>
1013
+ </standard-document>
1014
+ OUTPUT
1015
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
1016
+ .to be_equivalent_to xmlpp(output)
1017
+ end
1018
+ end