metanorma-standoc 1.3.24 → 1.3.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +10 -1
- data/.github/workflows/ubuntu.yml +13 -3
- data/.github/workflows/windows.yml +8 -1
- data/lib/asciidoctor/standoc/base.rb +29 -11
- data/lib/asciidoctor/standoc/biblio.rng +75 -28
- data/lib/asciidoctor/standoc/blocks.rb +12 -5
- data/lib/asciidoctor/standoc/cleanup.rb +17 -8
- data/lib/asciidoctor/standoc/cleanup_block.rb +3 -0
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +1 -3
- data/lib/asciidoctor/standoc/cleanup_inline.rb +3 -0
- data/lib/asciidoctor/standoc/cleanup_ref.rb +15 -6
- data/lib/asciidoctor/standoc/cleanup_section.rb +36 -8
- data/lib/asciidoctor/standoc/front.rb +5 -3
- data/lib/asciidoctor/standoc/inline.rb +43 -18
- data/lib/asciidoctor/standoc/isodoc.rng +31 -1
- data/lib/asciidoctor/standoc/macros.rb +2 -1
- data/lib/asciidoctor/standoc/macros_yaml2text.rb +142 -0
- data/lib/asciidoctor/standoc/ref.rb +6 -4
- data/lib/asciidoctor/standoc/section.rb +41 -9
- data/lib/asciidoctor/standoc/utils.rb +2 -11
- data/lib/asciidoctor/standoc/validate.rb +8 -2
- data/lib/asciidoctor/standoc/validate_section.rb +1 -3
- data/lib/metanorma/standoc/latexml_requirement.rb +14 -12
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +2 -2
- data/spec/asciidoctor-standoc/base_spec.rb +8 -0
- data/spec/asciidoctor-standoc/blocks_spec.rb +74 -2
- data/spec/asciidoctor-standoc/cleanup_spec.rb +75 -28
- data/spec/asciidoctor-standoc/inline_spec.rb +4 -3
- data/spec/asciidoctor-standoc/macros_spec.rb +9 -8
- data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +564 -0
- data/spec/asciidoctor-standoc/refs_dl_spec.rb +91 -3
- data/spec/asciidoctor-standoc/refs_spec.rb +272 -166
- data/spec/asciidoctor-standoc/section_spec.rb +197 -6
- data/spec/asciidoctor-standoc/validate_spec.rb +67 -2
- data/spec/assets/codes.yml +695 -0
- data/spec/assets/xref_error.adoc +7 -0
- data/spec/examples/codes_table.html +3174 -0
- data/spec/metanorma/processor_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +77 -271
- data/spec/vcr_cassettes/isobib_get_123.yml +36 -82
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +17 -40
- data/spec/vcr_cassettes/isobib_get_124.yml +19 -101
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +34 -34
- metadata +11 -6
@@ -293,6 +293,35 @@ RSpec.describe Asciidoctor::Standoc do
|
|
293
293
|
OUTPUT
|
294
294
|
end
|
295
295
|
|
296
|
+
it "does not move notes inside preceding blocks, if they are marked as keep-separate" do
|
297
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
298
|
+
#{ASCIIDOC_BLANK_HDR}
|
299
|
+
|
300
|
+
[stem]
|
301
|
+
++++
|
302
|
+
r = 1 %
|
303
|
+
r = 1 %
|
304
|
+
++++
|
305
|
+
|
306
|
+
[NOTE,keep-separate=true]
|
307
|
+
====
|
308
|
+
That formula does not do much
|
309
|
+
====
|
310
|
+
|
311
|
+
Indeed.
|
312
|
+
INPUT
|
313
|
+
#{BLANK_HDR}
|
314
|
+
<sections><formula id="_">
|
315
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi></math></stem></formula>
|
316
|
+
<note id="_">
|
317
|
+
<p id="_">That formula does not do much</p>
|
318
|
+
</note>
|
319
|
+
|
320
|
+
<p id="_">Indeed.</p></sections>
|
321
|
+
</standard-document>
|
322
|
+
OUTPUT
|
323
|
+
end
|
324
|
+
|
296
325
|
it "does not move notes inside preceding blocks, if they are at clause end" do
|
297
326
|
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
298
327
|
#{ASCIIDOC_BLANK_HDR}
|
@@ -330,12 +359,13 @@ RSpec.describe Asciidoctor::Standoc do
|
|
330
359
|
<eref type="inline" bibitemid="iso216" citeas="ISO 216:2001"/>
|
331
360
|
</p>
|
332
361
|
</foreword></preface><sections>
|
333
|
-
</sections><bibliography><references id="_" obligation="informative">
|
362
|
+
</sections><bibliography><references id="_" obligation="informative" normative="true">
|
334
363
|
<title>Normative References</title>
|
335
364
|
#{NORM_REF_BOILERPLATE}
|
336
365
|
<bibitem id="iso216" type="standard">
|
337
366
|
<title format="text/plain">Reference</title>
|
338
367
|
<docidentifier>ISO 216:2001</docidentifier>
|
368
|
+
<docnumber>216</docnumber>
|
339
369
|
<date type="published">
|
340
370
|
<on>2001</on>
|
341
371
|
</date>
|
@@ -407,12 +437,13 @@ RSpec.describe Asciidoctor::Standoc do
|
|
407
437
|
|
408
438
|
</p>
|
409
439
|
</foreword></preface><sections>
|
410
|
-
</sections><bibliography><references id="_" obligation="informative">
|
440
|
+
</sections><bibliography><references id="_" obligation="informative" normative="true">
|
411
441
|
<title>Normative References</title>
|
412
442
|
#{NORM_REF_BOILERPLATE}
|
413
443
|
<bibitem id="iso216" type="standard">
|
414
444
|
<title format="text/plain">Reference</title>
|
415
445
|
<docidentifier>ISO 216</docidentifier>
|
446
|
+
<docnumber>216</docnumber>
|
416
447
|
<contributor>
|
417
448
|
<role type="publisher"/>
|
418
449
|
<organization>
|
@@ -444,11 +475,12 @@ RSpec.describe Asciidoctor::Standoc do
|
|
444
475
|
<eref type="inline" bibitemid="iso216" citeas="ISO 216"/>
|
445
476
|
</p>
|
446
477
|
</foreword></preface><sections>
|
447
|
-
</sections><bibliography><references id="_" obligation="informative">
|
478
|
+
</sections><bibliography><references id="_" obligation="informative" normative="false">
|
448
479
|
<title>Bibliography</title>
|
449
480
|
<bibitem id="iso216" type="standard">
|
450
481
|
<title format="text/plain">Reference</title>
|
451
482
|
<docidentifier>ISO 216</docidentifier>
|
483
|
+
<docnumber>216</docnumber>
|
452
484
|
<contributor>
|
453
485
|
<role type="publisher"/>
|
454
486
|
<organization>
|
@@ -506,11 +538,12 @@ RSpec.describe Asciidoctor::Standoc do
|
|
506
538
|
INPUT
|
507
539
|
#{BLANK_HDR}
|
508
540
|
<sections></sections>
|
509
|
-
<bibliography><references id="_" obligation="informative"><title>Normative References</title>
|
541
|
+
<bibliography><references id="_" obligation="informative" normative="true"><title>Normative References</title>
|
510
542
|
#{NORM_REF_BOILERPLATE}
|
511
543
|
<bibitem id="iso216" type="standard">
|
512
544
|
<title format="text/plain">Reference</title>
|
513
545
|
<docidentifier>ISO 216</docidentifier>
|
546
|
+
<docnumber>216</docnumber>
|
514
547
|
<contributor>
|
515
548
|
<role type="publisher"/>
|
516
549
|
<organization>
|
@@ -552,12 +585,13 @@ RSpec.describe Asciidoctor::Standoc do
|
|
552
585
|
#{BLANK_HDR}
|
553
586
|
<sections> </sections>
|
554
587
|
<bibliography>
|
555
|
-
<references id='_' obligation='informative'>
|
588
|
+
<references id='_' obligation='informative' normative="false">
|
556
589
|
<title>Bibliography</title>
|
557
590
|
<p id='_'>This is extraneous information</p>
|
558
591
|
<bibitem id='iso216' type='standard'>
|
559
592
|
<title format='text/plain'>Reference</title>
|
560
593
|
<docidentifier>ISO 216</docidentifier>
|
594
|
+
<docnumber>216</docnumber>
|
561
595
|
<contributor>
|
562
596
|
<role type='publisher'/>
|
563
597
|
<organization>
|
@@ -574,6 +608,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
574
608
|
<bibitem id='iso216' type='standard'>
|
575
609
|
<title format='text/plain'>Reference</title>
|
576
610
|
<docidentifier>ISO 215</docidentifier>
|
611
|
+
<docnumber>215</docnumber>
|
577
612
|
<contributor>
|
578
613
|
<role type='publisher'/>
|
579
614
|
<organization>
|
@@ -931,12 +966,13 @@ end
|
|
931
966
|
<p id="_">Footnote2</p>
|
932
967
|
</fn>
|
933
968
|
</p>
|
934
|
-
</clause></sections><bibliography><references id="_" obligation="informative">
|
969
|
+
</clause></sections><bibliography><references id="_" obligation="informative" normative="true">
|
935
970
|
<title>Normative References</title>
|
936
971
|
#{NORM_REF_BOILERPLATE}
|
937
972
|
<bibitem id="iso123" type="standard">
|
938
973
|
<title format="text/plain">Standard</title>
|
939
974
|
<docidentifier>ISO 123:—</docidentifier>
|
975
|
+
<docnumber>123</docnumber>
|
940
976
|
<date type="published">
|
941
977
|
<on>–</on>
|
942
978
|
</date>
|
@@ -1161,7 +1197,7 @@ end
|
|
1161
1197
|
</localityStack>
|
1162
1198
|
</origin>
|
1163
1199
|
</termsource>
|
1164
|
-
</term></terms></sections><bibliography><references id="_" obligation="informative">
|
1200
|
+
</term></terms></sections><bibliography><references id="_" obligation="informative" normative="true">
|
1165
1201
|
<title>Normative References</title>
|
1166
1202
|
#{NORM_REF_BOILERPLATE}
|
1167
1203
|
<bibitem type="standard" id="IEC60050-102">
|
@@ -1331,21 +1367,16 @@ end
|
|
1331
1367
|
end
|
1332
1368
|
|
1333
1369
|
it "cleans up text MathML" do
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
:docfile: test.adoc
|
1338
|
-
:nodoc:
|
1339
|
-
:novalid:
|
1340
|
-
:no-isobib:
|
1341
|
-
|
1342
|
-
++++
|
1370
|
+
expect(Asciidoctor::Standoc::Converter.new(nil, backend: :standoc, header_footer: true).cleanup(Nokogiri::XML(<<~"INPUT")).to_xml).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
1371
|
+
#{BLANK_HDR}
|
1372
|
+
<sections>
|
1343
1373
|
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mn>1</mn><mi>r</mi></mfrac></math></stem>
|
1344
|
-
|
1374
|
+
</sections>
|
1375
|
+
</standard-document>
|
1345
1376
|
INPUT
|
1346
1377
|
#{BLANK_HDR}
|
1347
1378
|
<sections>
|
1348
|
-
<stem type="MathML"><math><mfrac><mn>1</mn><mi>r</mi></mfrac></math></stem>
|
1379
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mn>1</mn><mi>r</mi></mfrac></math></stem>
|
1349
1380
|
</sections>
|
1350
1381
|
|
1351
1382
|
|
@@ -1373,11 +1404,12 @@ end
|
|
1373
1404
|
<p id="_"><eref type="inline" bibitemid="iso123" citeas="[2]"/>
|
1374
1405
|
<eref type="inline" bibitemid="iso124" citeas="ISO 124"/></p>
|
1375
1406
|
</clause>
|
1376
|
-
</sections><bibliography><references id="_" obligation="informative">
|
1407
|
+
</sections><bibliography><references id="_" obligation="informative" normative="false">
|
1377
1408
|
<title>Bibliography</title>
|
1378
1409
|
<bibitem id="iso124" type="standard">
|
1379
1410
|
<title format="text/plain">Standard 124</title>
|
1380
1411
|
<docidentifier>ISO 124</docidentifier>
|
1412
|
+
<docnumber>124</docnumber>
|
1381
1413
|
<contributor>
|
1382
1414
|
<role type="publisher"/>
|
1383
1415
|
<organization>
|
@@ -1428,11 +1460,12 @@ OUTPUT
|
|
1428
1460
|
<eref type="inline" bibitemid="iso125" citeas="ISO 125"/>
|
1429
1461
|
<eref type="inline" bibitemid="iso126" citeas="[4]"/></p>
|
1430
1462
|
</clause>
|
1431
|
-
</sections><bibliography><clause id="_" obligation="informative"><title>Bibliography</title><references id="_" obligation="informative">
|
1463
|
+
</sections><bibliography><clause id="_" obligation="informative"><title>Bibliography</title><references id="_" obligation="informative" normative="false">
|
1432
1464
|
<title>Clause 1</title>
|
1433
1465
|
<bibitem id="iso124" type="standard">
|
1434
1466
|
<title format="text/plain">Standard 124</title>
|
1435
1467
|
<docidentifier>ISO 124</docidentifier>
|
1468
|
+
<docnumber>124</docnumber>
|
1436
1469
|
<contributor>
|
1437
1470
|
<role type="publisher"/>
|
1438
1471
|
<organization>
|
@@ -1447,11 +1480,11 @@ OUTPUT
|
|
1447
1480
|
<docidentifier type="metanorma">[2]</docidentifier>
|
1448
1481
|
</bibitem>
|
1449
1482
|
</references>
|
1450
|
-
<references id="_" obligation="informative">
|
1451
|
-
|
1483
|
+
<references id="_" obligation="informative" normative="false">
|
1452
1484
|
<bibitem id="iso125" type="standard">
|
1453
1485
|
<title format="text/plain">Standard 124</title>
|
1454
1486
|
<docidentifier>ISO 125</docidentifier>
|
1487
|
+
<docnumber>125</docnumber>
|
1455
1488
|
<contributor>
|
1456
1489
|
<role type="publisher"/>
|
1457
1490
|
<organization>
|
@@ -1481,7 +1514,7 @@ OUTPUT
|
|
1481
1514
|
#{BLANK_HDR}
|
1482
1515
|
<sections>
|
1483
1516
|
|
1484
|
-
</sections><bibliography><references id="_" obligation="informative">
|
1517
|
+
</sections><bibliography><references id="_" obligation="informative" normative="true">
|
1485
1518
|
<title>Normative References</title><p id="_">There are no normative references in this document.</p>
|
1486
1519
|
</references></bibliography>
|
1487
1520
|
</standard-document>
|
@@ -1500,7 +1533,7 @@ OUTPUT
|
|
1500
1533
|
#{BLANK_HDR}
|
1501
1534
|
<sections>
|
1502
1535
|
|
1503
|
-
</sections><bibliography><references id="_" obligation="informative">
|
1536
|
+
</sections><bibliography><references id="_" obligation="informative" normative="true">
|
1504
1537
|
<title>Normative References</title><p id="_">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>
|
1505
1538
|
<bibitem id="a">
|
1506
1539
|
<formattedref format="application/x-isodoc+xml">A</formattedref>
|
@@ -1529,7 +1562,7 @@ it "inserts boilerplate before empty Normative References in French" do
|
|
1529
1562
|
#{BLANK_HDR.sub(/<language>en/, "<language>fr")}
|
1530
1563
|
<sections>
|
1531
1564
|
|
1532
|
-
</sections><bibliography><references id="_" obligation="informative">
|
1565
|
+
</sections><bibliography><references id="_" obligation="informative" normative="true">
|
1533
1566
|
<title>Normative References</title><p id="_">Le présent document ne contient aucune référence normative.</p>
|
1534
1567
|
</references></bibliography>
|
1535
1568
|
</standard-document>
|
@@ -1574,7 +1607,7 @@ it "removes bibdata bibitem IDs" do
|
|
1574
1607
|
</bibdata>
|
1575
1608
|
<sections> </sections>
|
1576
1609
|
<bibliography>
|
1577
|
-
<references id='_' obligation='informative'>
|
1610
|
+
<references id='_' obligation='informative' normative="true">
|
1578
1611
|
<title>Normative References</title>
|
1579
1612
|
<p id="_">There are no normative references in this document.</p>
|
1580
1613
|
</references>
|
@@ -1691,11 +1724,25 @@ it "sorts symbols lists" do
|
|
1691
1724
|
<dd>
|
1692
1725
|
<p id='_'>Definition 5</p>
|
1693
1726
|
</dd>
|
1694
|
-
<dt><stem type='MathML'>
|
1727
|
+
<dt><stem type='MathML'>
|
1728
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1729
|
+
<msub>
|
1730
|
+
<mi>x</mi>
|
1731
|
+
<mi>m</mi>
|
1732
|
+
</msub>
|
1733
|
+
</math>
|
1734
|
+
</stem></dt>
|
1695
1735
|
<dd>
|
1696
1736
|
<p id='_'>Definition 4</p>
|
1697
1737
|
</dd>
|
1698
|
-
<dt><stem type='MathML'>
|
1738
|
+
<dt><stem type='MathML'>
|
1739
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1740
|
+
<msub>
|
1741
|
+
<mi>x</mi>
|
1742
|
+
<mn>1</mn>
|
1743
|
+
</msub>
|
1744
|
+
</math>
|
1745
|
+
</stem></dt>
|
1699
1746
|
<dd>
|
1700
1747
|
<p id='_'>Definition 3</p>
|
1701
1748
|
</dd>
|
@@ -88,7 +88,7 @@ text, including nested markup.
|
|
88
88
|
<sections>
|
89
89
|
<p id="_">
|
90
90
|
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>n</mi><mo><</mo><mn>1</mn></math></stem><br/>
|
91
|
-
<stem type="MathML"> <math xmlns="http://www.w3.org/1998/Math/MathML"
|
91
|
+
<stem type="MathML"> <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> <mrow> <mi>n</mi> <mo><</mo> <mn>1</mn> </mrow> </math></stem>
|
92
92
|
</p>
|
93
93
|
</sections>
|
94
94
|
</standard-document>
|
@@ -106,7 +106,7 @@ text, including nested markup.
|
|
106
106
|
<sections>
|
107
107
|
<p id="_">
|
108
108
|
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>n</mi><mo><</mo><mn>1</mn></math></stem>
|
109
|
-
<stem type="MathML"> <math xmlns="http://www.w3.org/1998/Math/MathML"
|
109
|
+
<stem type="MathML"> <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> <mrow> <mi>n</mi> <mo><</mo> <mn>1</mn> </mrow> </math></stem>
|
110
110
|
</p>
|
111
111
|
</sections>
|
112
112
|
</standard-document>
|
@@ -227,7 +227,7 @@ text, including nested markup.
|
|
227
227
|
#{BLANK_HDR}
|
228
228
|
<sections>
|
229
229
|
|
230
|
-
</sections><bibliography><references id="_" obligation="informative">
|
230
|
+
</sections><bibliography><references id="_" obligation="informative" normative="true">
|
231
231
|
<title>Normative References</title>
|
232
232
|
<p id="_">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>
|
233
233
|
<bibitem id="ISO712">
|
@@ -237,6 +237,7 @@ text, including nested markup.
|
|
237
237
|
<bibitem id="ISO713">
|
238
238
|
<formattedref format="application/x-isodoc+xml">Reference</formattedref>
|
239
239
|
<docidentifier>ISO713</docidentifier>
|
240
|
+
<docnumber>713</docnumber>
|
240
241
|
</bibitem>
|
241
242
|
</references>
|
242
243
|
</bibliography>
|
@@ -27,13 +27,14 @@ RSpec.describe Asciidoctor::Standoc do
|
|
27
27
|
</preface>
|
28
28
|
<sections> </sections>
|
29
29
|
<bibliography>
|
30
|
-
<references id='_' obligation='informative'>
|
30
|
+
<references id='_' obligation='informative' normative="false">
|
31
31
|
<title>Bibliography</title>
|
32
32
|
<bibitem id='ref1'>
|
33
33
|
<formattedref format='application/x-isodoc+xml'>
|
34
34
|
<em>Title</em>
|
35
35
|
</formattedref>
|
36
36
|
<docidentifier>XYZ 123</docidentifier>
|
37
|
+
<docnumber>123</docnumber>
|
37
38
|
</bibitem>
|
38
39
|
</references>
|
39
40
|
</bibliography>
|
@@ -177,7 +178,7 @@ INPUT
|
|
177
178
|
</clause>
|
178
179
|
</sections>
|
179
180
|
<bibliography>
|
180
|
-
<references id='_' obligation='informative'>
|
181
|
+
<references id='_' obligation='informative' normative="false">
|
181
182
|
<title>Bibliography</title>
|
182
183
|
<bibitem id='blah'>
|
183
184
|
<formattedref format='application/x-isodoc+xml'>
|
@@ -222,7 +223,8 @@ OUTPUT
|
|
222
223
|
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
223
224
|
#{ASCIIDOC_BLANK_HDR}
|
224
225
|
|
225
|
-
[pseudocode]
|
226
|
+
[pseudocode,subsequence="A"]
|
227
|
+
[%unnumbered]
|
226
228
|
====
|
227
229
|
*A* +
|
228
230
|
[smallcap]#B#
|
@@ -232,7 +234,7 @@ OUTPUT
|
|
232
234
|
INPUT
|
233
235
|
#{BLANK_HDR}
|
234
236
|
<sections>
|
235
|
-
<figure id="_" class="pseudocode"><p id="_"> <strong>A</strong><br/>
|
237
|
+
<figure id="_" subsequence='A' class="pseudocode" unnumbered="true"><p id="_"> <strong>A</strong><br/>
|
236
238
|
<smallcap>B</smallcap></p>
|
237
239
|
<p id="_"> <em>C</em></p></figure>
|
238
240
|
</sections>
|
@@ -287,7 +289,7 @@ OUTPUT
|
|
287
289
|
</standard-document>
|
288
290
|
OUTPUT
|
289
291
|
end
|
290
|
-
|
292
|
+
|
291
293
|
it "processes the PlantUML macro" do
|
292
294
|
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)).gsub(%r{plantuml/plantuml[^./]+\.}, "plantuml/_."))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
293
295
|
#{ASCIIDOC_BLANK_HDR}
|
@@ -462,7 +464,6 @@ Alice <-- Bob: another authentication Response
|
|
462
464
|
OUTPUT
|
463
465
|
end
|
464
466
|
|
465
|
-
|
466
467
|
private
|
467
468
|
|
468
469
|
def mock_plantuml_disabled
|
@@ -471,13 +472,13 @@ Alice <-- Bob: another authentication Response
|
|
471
472
|
false
|
472
473
|
end
|
473
474
|
end
|
474
|
-
|
475
|
+
|
475
476
|
def mock_localdir_unwritable
|
476
477
|
expect(Asciidoctor::Standoc::Utils).to receive(:localdir) do
|
477
478
|
"/"
|
478
479
|
end.exactly(2).times
|
479
480
|
end
|
480
|
-
|
481
|
+
|
481
482
|
def mock_localdir_unwritable
|
482
483
|
expect(File).to receive(:writable?) do
|
483
484
|
false
|
@@ -0,0 +1,564 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Asciidoctor::Standoc::Yaml2TextPreprocessor do
|
4
|
+
describe '#process' do
|
5
|
+
let(:example_file) { 'example.yml' }
|
6
|
+
|
7
|
+
before do
|
8
|
+
if defined?(example_yaml_content)
|
9
|
+
File.open(example_file, 'w') { |n| n.puts(example_yaml_content) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
FileUtils.rm_rf(example_file)
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'Array of hashes' do
|
18
|
+
let(:example_yaml_content) do
|
19
|
+
<<~TEXT
|
20
|
+
---
|
21
|
+
- name: spaghetti
|
22
|
+
desc: wheat noodles of 9mm diameter
|
23
|
+
symbol: SPAG
|
24
|
+
symbol_def: the situation is message like spaghetti at a kid's meal
|
25
|
+
TEXT
|
26
|
+
end
|
27
|
+
let(:input) do
|
28
|
+
<<~TEXT
|
29
|
+
= Document title
|
30
|
+
Author
|
31
|
+
:docfile: test.adoc
|
32
|
+
:nodoc:
|
33
|
+
:novalid:
|
34
|
+
:no-isobib:
|
35
|
+
:imagesdir: spec/assets
|
36
|
+
|
37
|
+
[yaml2text,#{example_file},my_context]
|
38
|
+
----
|
39
|
+
{my_context.*,item,EOF}
|
40
|
+
{item.name}:: {item.desc}
|
41
|
+
{EOF}
|
42
|
+
----
|
43
|
+
TEXT
|
44
|
+
end
|
45
|
+
let(:output) do
|
46
|
+
<<~TEXT
|
47
|
+
#{BLANK_HDR}
|
48
|
+
<sections>
|
49
|
+
<dl id='_'>
|
50
|
+
<dt>spaghetti</dt>
|
51
|
+
<dd>
|
52
|
+
<p id='_'>wheat noodles of 9mm diameter</p>
|
53
|
+
</dd>
|
54
|
+
</dl>
|
55
|
+
</sections>
|
56
|
+
</standard-document>
|
57
|
+
TEXT
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'correctly renders input yaml' do
|
61
|
+
expect(
|
62
|
+
xmlpp(
|
63
|
+
strip_guid(
|
64
|
+
Asciidoctor.convert(input,
|
65
|
+
backend: :standoc,
|
66
|
+
header_footer: true),
|
67
|
+
),
|
68
|
+
),
|
69
|
+
).to(be_equivalent_to(xmlpp(output)))
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'An array of strings' do
|
74
|
+
let(:example_yaml_content) do
|
75
|
+
<<~TEXT
|
76
|
+
---
|
77
|
+
- lorem
|
78
|
+
- ipsum
|
79
|
+
- dolor
|
80
|
+
TEXT
|
81
|
+
end
|
82
|
+
let(:input) do
|
83
|
+
<<~TEXT
|
84
|
+
= Document title
|
85
|
+
Author
|
86
|
+
:docfile: test.adoc
|
87
|
+
:nodoc:
|
88
|
+
:novalid:
|
89
|
+
:no-isobib:
|
90
|
+
:imagesdir: spec/assets
|
91
|
+
|
92
|
+
[yaml2text,#{example_file},ar]
|
93
|
+
----
|
94
|
+
{ar.*,s,EOS}
|
95
|
+
=== {s.#} {s}
|
96
|
+
|
97
|
+
This section is about {s}.
|
98
|
+
|
99
|
+
{EOS}
|
100
|
+
----
|
101
|
+
TEXT
|
102
|
+
end
|
103
|
+
let(:output) do
|
104
|
+
<<~TEXT
|
105
|
+
#{BLANK_HDR}
|
106
|
+
<sections>
|
107
|
+
<clause id="_" inline-header="false" obligation="normative">
|
108
|
+
<title>0 lorem</title>
|
109
|
+
<p id='_'>This section is about lorem.</p>
|
110
|
+
</clause>
|
111
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
112
|
+
<title>1 ipsum</title>
|
113
|
+
<p id='_'>This section is about ipsum.</p>
|
114
|
+
</clause>
|
115
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
116
|
+
<title>2 dolor</title>
|
117
|
+
<p id='_'>This section is about dolor.</p>
|
118
|
+
</clause>
|
119
|
+
</sections>
|
120
|
+
</standard-document>
|
121
|
+
TEXT
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'correctly renders input yaml' do
|
125
|
+
expect(
|
126
|
+
xmlpp(
|
127
|
+
strip_guid(
|
128
|
+
Asciidoctor.convert(input,
|
129
|
+
backend: :standoc,
|
130
|
+
header_footer: true),
|
131
|
+
),
|
132
|
+
),
|
133
|
+
).to(be_equivalent_to(xmlpp(output)))
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context 'A simple hash' do
|
138
|
+
let(:example_yaml_content) do
|
139
|
+
<<~TEXT
|
140
|
+
---
|
141
|
+
name: Lorem ipsum
|
142
|
+
desc: dolor sit amet
|
143
|
+
TEXT
|
144
|
+
end
|
145
|
+
let(:input) do
|
146
|
+
<<~TEXT
|
147
|
+
= Document title
|
148
|
+
Author
|
149
|
+
:docfile: test.adoc
|
150
|
+
:nodoc:
|
151
|
+
:novalid:
|
152
|
+
:no-isobib:
|
153
|
+
:imagesdir: spec/assets
|
154
|
+
|
155
|
+
[yaml2text,#{example_file},my_item]
|
156
|
+
----
|
157
|
+
=== {my_item.name}
|
158
|
+
|
159
|
+
{my_item.desc}
|
160
|
+
----
|
161
|
+
TEXT
|
162
|
+
end
|
163
|
+
let(:output) do
|
164
|
+
<<~TEXT
|
165
|
+
#{BLANK_HDR}
|
166
|
+
<sections>
|
167
|
+
<clause id="_" inline-header="false" obligation="normative">
|
168
|
+
<title>Lorem ipsum</title>
|
169
|
+
<p id='_'>dolor sit amet</p>
|
170
|
+
</clause>
|
171
|
+
</sections>
|
172
|
+
</standard-document>
|
173
|
+
TEXT
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'correctly renders input yaml' do
|
177
|
+
expect(
|
178
|
+
xmlpp(
|
179
|
+
strip_guid(
|
180
|
+
Asciidoctor.convert(input,
|
181
|
+
backend: :standoc,
|
182
|
+
header_footer: true),
|
183
|
+
),
|
184
|
+
),
|
185
|
+
).to(be_equivalent_to(xmlpp(output)))
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
context 'A simple hash with free keys' do
|
190
|
+
let(:example_yaml_content) do
|
191
|
+
<<~TEXT
|
192
|
+
---
|
193
|
+
name: Lorem ipsum
|
194
|
+
desc: dolor sit amet
|
195
|
+
TEXT
|
196
|
+
end
|
197
|
+
let(:input) do
|
198
|
+
<<~TEXT
|
199
|
+
= Document title
|
200
|
+
Author
|
201
|
+
:docfile: test.adoc
|
202
|
+
:nodoc:
|
203
|
+
:novalid:
|
204
|
+
:no-isobib:
|
205
|
+
:imagesdir: spec/assets
|
206
|
+
|
207
|
+
[yaml2text,#{example_file},my_item]
|
208
|
+
----
|
209
|
+
{my_item.*,key,EOI}
|
210
|
+
=== {key}
|
211
|
+
|
212
|
+
{my_item[key]}
|
213
|
+
|
214
|
+
{EOI}
|
215
|
+
----
|
216
|
+
TEXT
|
217
|
+
end
|
218
|
+
let(:output) do
|
219
|
+
<<~TEXT
|
220
|
+
#{BLANK_HDR}
|
221
|
+
<sections>
|
222
|
+
<clause id="_" inline-header="false" obligation="normative">
|
223
|
+
<title>name</title>
|
224
|
+
<p id='_'>Lorem ipsum</p>
|
225
|
+
</clause>
|
226
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
227
|
+
<title>desc</title>
|
228
|
+
<p id='_'>dolor sit amet</p>
|
229
|
+
</clause>
|
230
|
+
</sections>
|
231
|
+
</standard-document>
|
232
|
+
TEXT
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'correctly renders input yaml' do
|
236
|
+
expect(
|
237
|
+
xmlpp(
|
238
|
+
strip_guid(
|
239
|
+
Asciidoctor.convert(input,
|
240
|
+
backend: :standoc,
|
241
|
+
header_footer: true),
|
242
|
+
),
|
243
|
+
),
|
244
|
+
).to(be_equivalent_to(xmlpp(output)))
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
context 'An array of hashes' do
|
249
|
+
let(:example_yaml_content) do
|
250
|
+
<<~TEXT
|
251
|
+
---
|
252
|
+
- name: Lorem
|
253
|
+
desc: ipsum
|
254
|
+
nums: [2]
|
255
|
+
- name: dolor
|
256
|
+
desc: sit
|
257
|
+
nums: []
|
258
|
+
- name: amet
|
259
|
+
desc: lorem
|
260
|
+
nums: [2, 4, 6]
|
261
|
+
TEXT
|
262
|
+
end
|
263
|
+
let(:input) do
|
264
|
+
<<~TEXT
|
265
|
+
= Document title
|
266
|
+
Author
|
267
|
+
:docfile: test.adoc
|
268
|
+
:nodoc:
|
269
|
+
:novalid:
|
270
|
+
:no-isobib:
|
271
|
+
:imagesdir: spec/assets
|
272
|
+
|
273
|
+
[yaml2text,#{example_file},ar]
|
274
|
+
----
|
275
|
+
{ar.*,item,EOF}
|
276
|
+
|
277
|
+
{item.name}:: {item.desc}
|
278
|
+
|
279
|
+
{item.nums.*,num,EON}
|
280
|
+
- {item.name}: {num}
|
281
|
+
{EON}
|
282
|
+
|
283
|
+
{EOF}
|
284
|
+
----
|
285
|
+
TEXT
|
286
|
+
end
|
287
|
+
let(:output) do
|
288
|
+
<<~TEXT
|
289
|
+
#{BLANK_HDR}
|
290
|
+
<sections>
|
291
|
+
<dl id='_'>
|
292
|
+
<dt>Lorem</dt>
|
293
|
+
<dd>
|
294
|
+
<p id='_'>ipsum</p>
|
295
|
+
<ul id='_'>
|
296
|
+
<li>
|
297
|
+
<p id='_'>Lorem: 2</p>
|
298
|
+
</li>
|
299
|
+
</ul>
|
300
|
+
</dd>
|
301
|
+
<dt>dolor</dt>
|
302
|
+
<dd>
|
303
|
+
<p id='_'>sit</p>
|
304
|
+
</dd>
|
305
|
+
<dt>amet</dt>
|
306
|
+
<dd>
|
307
|
+
<p id='_'>lorem</p>
|
308
|
+
<ul id='_'>
|
309
|
+
<li>
|
310
|
+
<p id='_'>amet: 2</p>
|
311
|
+
</li>
|
312
|
+
<li>
|
313
|
+
<p id='_'>amet: 4</p>
|
314
|
+
</li>
|
315
|
+
<li>
|
316
|
+
<p id='_'>amet: 6</p>
|
317
|
+
</li>
|
318
|
+
</ul>
|
319
|
+
</dd>
|
320
|
+
</dl>
|
321
|
+
</sections>
|
322
|
+
</standard-document>
|
323
|
+
TEXT
|
324
|
+
end
|
325
|
+
|
326
|
+
it 'correctly renders input yaml' do
|
327
|
+
expect(
|
328
|
+
xmlpp(
|
329
|
+
strip_guid(
|
330
|
+
Asciidoctor.convert(input,
|
331
|
+
backend: :standoc,
|
332
|
+
header_footer: true),
|
333
|
+
),
|
334
|
+
),
|
335
|
+
).to(be_equivalent_to(xmlpp(output)))
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
context "An array with interpolated file names, etc. \
|
340
|
+
for Asciidoc's consumption" do
|
341
|
+
let(:example_yaml_content) do
|
342
|
+
<<~TEXT
|
343
|
+
---
|
344
|
+
prefix: doc-
|
345
|
+
items:
|
346
|
+
- lorem
|
347
|
+
- ipsum
|
348
|
+
- dolor
|
349
|
+
TEXT
|
350
|
+
end
|
351
|
+
let(:input) do
|
352
|
+
<<~TEXT
|
353
|
+
= Document title
|
354
|
+
Author
|
355
|
+
:docfile: test.adoc
|
356
|
+
:nodoc:
|
357
|
+
:novalid:
|
358
|
+
:no-isobib:
|
359
|
+
:imagesdir: spec/assets
|
360
|
+
|
361
|
+
[yaml2text,#{example_file},yaml]
|
362
|
+
------
|
363
|
+
First item is {yaml.items[0]}.
|
364
|
+
Last item is {yaml.items[-1]}.
|
365
|
+
|
366
|
+
{yaml.items.*,s,EOS}
|
367
|
+
=== {s.#} -> {s.# + 1} {s} == {yaml.items[s.#]}
|
368
|
+
|
369
|
+
[source,ruby]
|
370
|
+
----
|
371
|
+
include::{yaml.prefix}{s.#}.rb[]
|
372
|
+
----
|
373
|
+
|
374
|
+
{EOS}
|
375
|
+
------
|
376
|
+
TEXT
|
377
|
+
end
|
378
|
+
let(:output) do
|
379
|
+
<<~TEXT
|
380
|
+
#{BLANK_HDR}
|
381
|
+
<preface>
|
382
|
+
<foreword id='_' obligation='informative'>
|
383
|
+
<title>Foreword</title>
|
384
|
+
<p id='_'>First item is lorem. Last item is dolor.</p>
|
385
|
+
</foreword>
|
386
|
+
</preface>
|
387
|
+
<sections>
|
388
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
389
|
+
<title>0 → 1 lorem == lorem</title>
|
390
|
+
<sourcecode lang='ruby' id='_'>link:doc-0.rb[]</sourcecode>
|
391
|
+
</clause>
|
392
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
393
|
+
<title>1 → 2 ipsum == ipsum</title>
|
394
|
+
<sourcecode lang='ruby' id='_'>link:doc-1.rb[]</sourcecode>
|
395
|
+
</clause>
|
396
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
397
|
+
<title>2 → 3 dolor == dolor</title>
|
398
|
+
<sourcecode lang='ruby' id='_'>link:doc-2.rb[]</sourcecode>
|
399
|
+
</clause>
|
400
|
+
</sections>
|
401
|
+
</standard-document>
|
402
|
+
TEXT
|
403
|
+
end
|
404
|
+
|
405
|
+
it 'correctly renders input yaml' do
|
406
|
+
expect(
|
407
|
+
xmlpp(
|
408
|
+
strip_guid(
|
409
|
+
Asciidoctor.convert(input,
|
410
|
+
backend: :standoc,
|
411
|
+
header_footer: true),
|
412
|
+
),
|
413
|
+
),
|
414
|
+
).to(be_equivalent_to(xmlpp(output)))
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
context "Array of language codes" do
|
419
|
+
let(:input) do
|
420
|
+
<<~TEXT
|
421
|
+
= Document title
|
422
|
+
Author
|
423
|
+
:docfile: test.adoc
|
424
|
+
:nodoc:
|
425
|
+
:novalid:
|
426
|
+
:no-isobib:
|
427
|
+
:imagesdir: spec/assets
|
428
|
+
|
429
|
+
[yaml2text,#{File.expand_path('../assets/codes.yml', __dir__)},ar]
|
430
|
+
----
|
431
|
+
{ar.*,item,EOF}
|
432
|
+
.{item.values[1]}
|
433
|
+
[%noheader,cols="h,1"]
|
434
|
+
|===
|
435
|
+
{item.*,key,EOK}
|
436
|
+
| {key} | {item[key]}
|
437
|
+
|
438
|
+
{EOK}
|
439
|
+
|===
|
440
|
+
{EOF}
|
441
|
+
----
|
442
|
+
TEXT
|
443
|
+
end
|
444
|
+
let(:output) do
|
445
|
+
<<~TEXT
|
446
|
+
#{BLANK_HDR}
|
447
|
+
<sections>
|
448
|
+
#{File.read(File.expand_path('../examples/codes_table.html', __dir__))}
|
449
|
+
</sections>
|
450
|
+
</standard-document>
|
451
|
+
TEXT
|
452
|
+
end
|
453
|
+
|
454
|
+
it 'correctly renders input yaml' do
|
455
|
+
expect(
|
456
|
+
xmlpp(
|
457
|
+
strip_guid(
|
458
|
+
Asciidoctor.convert(input,
|
459
|
+
backend: :standoc,
|
460
|
+
header_footer: true),
|
461
|
+
),
|
462
|
+
),
|
463
|
+
).to(be_equivalent_to(xmlpp(output)))
|
464
|
+
end
|
465
|
+
end
|
466
|
+
|
467
|
+
context "Nested hash dot notation" do
|
468
|
+
let(:example_yaml_content) do
|
469
|
+
<<~TEXT
|
470
|
+
data:
|
471
|
+
acadsin-zho-hani-latn-2002:
|
472
|
+
code: acadsin-zho-hani-latn-2002
|
473
|
+
name:
|
474
|
+
en: Academica Sinica -- Chinese Tongyong Pinyin (2002)
|
475
|
+
authority: acadsin
|
476
|
+
lang:
|
477
|
+
system: iso-639-2
|
478
|
+
code: zho
|
479
|
+
source_script: Hani
|
480
|
+
target_script: Latn
|
481
|
+
system:
|
482
|
+
id: '2002'
|
483
|
+
specification: Academica Sinica -- Chinese Tongyong Pinyin (2002)
|
484
|
+
notes: 'NOTE: OGC 11-122r1 code `zho_Hani2Latn_AcadSin_2002`'
|
485
|
+
TEXT
|
486
|
+
end
|
487
|
+
let(:input) do
|
488
|
+
<<~TEXT
|
489
|
+
= Document title
|
490
|
+
Author
|
491
|
+
:docfile: test.adoc
|
492
|
+
:nodoc:
|
493
|
+
:novalid:
|
494
|
+
:no-isobib:
|
495
|
+
:imagesdir: spec/assets
|
496
|
+
|
497
|
+
[yaml2text,#{example_file},authorities]
|
498
|
+
----
|
499
|
+
[cols="a,a,a,a",options="header"]
|
500
|
+
|===
|
501
|
+
| Script conversion system authority code | Name in English | Notes | Name en
|
502
|
+
|
503
|
+
{authorities.data.*,key,EOI}
|
504
|
+
| {key} | {authorities.data[key]['code']} | {authorities.data[key]['notes']} | {authorities.data[key].name.en}
|
505
|
+
{EOI}
|
506
|
+
|
507
|
+
|===
|
508
|
+
----
|
509
|
+
TEXT
|
510
|
+
end
|
511
|
+
let(:output) do
|
512
|
+
<<~TEXT
|
513
|
+
#{BLANK_HDR}
|
514
|
+
<sections>
|
515
|
+
<table id='_'>
|
516
|
+
<thead>
|
517
|
+
<tr>
|
518
|
+
<th align='left'>Script conversion system authority code</th>
|
519
|
+
<th align='left'>Name in English</th>
|
520
|
+
<th align='left'>Notes</th>
|
521
|
+
<th align='left'>Name en</th>
|
522
|
+
</tr>
|
523
|
+
</thead>
|
524
|
+
<tbody>
|
525
|
+
<tr>
|
526
|
+
<td align='left'>
|
527
|
+
<p id='_'>acadsin-zho-hani-latn-2002</p>
|
528
|
+
</td>
|
529
|
+
<td align='left'>
|
530
|
+
<p id='_'>acadsin-zho-hani-latn-2002</p>
|
531
|
+
</td>
|
532
|
+
<td align='left'>
|
533
|
+
<note id='_'>
|
534
|
+
<p id='_'>
|
535
|
+
OGC 11-122r1 code
|
536
|
+
<tt>zho_Hani2Latn_AcadSin_2002</tt>
|
537
|
+
</p>
|
538
|
+
</note>
|
539
|
+
</td>
|
540
|
+
<td align='left'>
|
541
|
+
<p id='_'>Academica Sinica — Chinese Tongyong Pinyin (2002)</p>
|
542
|
+
</td>
|
543
|
+
</tr>
|
544
|
+
</tbody>
|
545
|
+
</table>
|
546
|
+
</sections>
|
547
|
+
</standard-document>
|
548
|
+
TEXT
|
549
|
+
end
|
550
|
+
|
551
|
+
it 'correctly renders input yaml' do
|
552
|
+
expect(
|
553
|
+
xmlpp(
|
554
|
+
strip_guid(
|
555
|
+
Asciidoctor.convert(input,
|
556
|
+
backend: :standoc,
|
557
|
+
header_footer: true),
|
558
|
+
),
|
559
|
+
),
|
560
|
+
).to(be_equivalent_to(xmlpp(output)))
|
561
|
+
end
|
562
|
+
end
|
563
|
+
end
|
564
|
+
end
|