metanorma-standoc 2.0.1 → 2.0.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/lib/metanorma/standoc/base.rb +61 -22
- data/lib/metanorma/standoc/basicdoc.rng +5 -3
- data/lib/metanorma/standoc/biblio.rng +7 -5
- data/lib/metanorma/standoc/blocks.rb +3 -3
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +3 -3
- data/lib/metanorma/standoc/cleanup_image.rb +117 -3
- data/lib/metanorma/standoc/cleanup_ref.rb +32 -3
- data/lib/metanorma/standoc/cleanup_ref_dl.rb +20 -16
- data/lib/metanorma/standoc/cleanup_section.rb +2 -2
- data/lib/metanorma/standoc/cleanup_terms_designations.rb +4 -2
- data/lib/metanorma/standoc/cleanup_text.rb +0 -22
- data/lib/metanorma/standoc/cleanup_xref.rb +82 -13
- data/lib/metanorma/standoc/converter.rb +2 -0
- data/lib/metanorma/standoc/inline.rb +21 -12
- data/lib/metanorma/standoc/isodoc.rng +142 -4
- data/lib/metanorma/standoc/macros.rb +14 -1
- data/lib/metanorma/standoc/macros_embed.rb +72 -0
- data/lib/metanorma/standoc/ref.rb +11 -7
- data/lib/metanorma/standoc/ref_utility.rb +2 -1
- data/lib/metanorma/standoc/render.rb +7 -3
- data/lib/metanorma/standoc/table.rb +8 -10
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +9 -6
- data/lib/metanorma/standoc/terms.rb +10 -7
- data/lib/metanorma/standoc/utils.rb +3 -1
- data/lib/metanorma/standoc/validate.rb +7 -2
- data/lib/metanorma/standoc/version.rb +1 -1
- data/spec/assets/a1.adoc +8 -0
- data/spec/assets/a2.adoc +8 -0
- data/spec/assets/a3.adoc +9 -0
- data/spec/assets/a4.adoc +4 -0
- data/spec/metanorma/base_spec.rb +1 -1
- data/spec/metanorma/cleanup_blocks_spec.rb +136 -0
- data/spec/metanorma/cleanup_spec.rb +13 -13
- data/spec/metanorma/cleanup_terms_spec.rb +1 -1
- data/spec/metanorma/inline_spec.rb +31 -0
- data/spec/metanorma/isobib_cache_spec.rb +2 -2
- data/spec/metanorma/macros_plantuml_spec.rb +41 -42
- data/spec/metanorma/macros_spec.rb +288 -2
- data/spec/metanorma/processor_spec.rb +17 -13
- data/spec/metanorma/refs_spec.rb +633 -461
- data/spec/metanorma/section_spec.rb +1 -1
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +48 -48
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +13 -13
- data/spec/vcr_cassettes/hide_refs.yml +100 -100
- data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_123_1.yml +25 -25
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +11 -11
- data/spec/vcr_cassettes/isobib_get_124.yml +13 -13
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +18 -18
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +86 -66
- metadata +7 -2
|
@@ -748,7 +748,7 @@ RSpec.describe Metanorma::Standoc do
|
|
|
748
748
|
<definitions id='clause1' obligation='normative'>
|
|
749
749
|
<title>Symbols and abbreviated terms</title>
|
|
750
750
|
<dl id='_'>
|
|
751
|
-
<dt id='symbol-
|
|
751
|
+
<dt id='symbol-__x230a_-x-__x230b_'>
|
|
752
752
|
<stem type='MathML'>
|
|
753
753
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
|
754
754
|
<mo>⌊</mo>
|
|
@@ -770,7 +770,7 @@ RSpec.describe Metanorma::Standoc do
|
|
|
770
770
|
function.
|
|
771
771
|
</p>
|
|
772
772
|
</dd>
|
|
773
|
-
<dt id='symbol-
|
|
773
|
+
<dt id='symbol-__x2308_-x-__x2309_'>
|
|
774
774
|
<stem type='MathML'>
|
|
775
775
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
|
776
776
|
<mo>⌈</mo>
|
|
@@ -1304,6 +1304,231 @@ RSpec.describe Metanorma::Standoc do
|
|
|
1304
1304
|
.to be_equivalent_to xmlpp(output)
|
|
1305
1305
|
end
|
|
1306
1306
|
|
|
1307
|
+
it "processes embed macro" do
|
|
1308
|
+
input = <<~INPUT
|
|
1309
|
+
#{ASCIIDOC_BLANK_HDR}
|
|
1310
|
+
|
|
1311
|
+
[[clause1]]
|
|
1312
|
+
== Clause 1
|
|
1313
|
+
|
|
1314
|
+
embed::spec/assets/xref_error.adoc[]
|
|
1315
|
+
INPUT
|
|
1316
|
+
output = <<~OUTPUT
|
|
1317
|
+
#{BLANK_HDR}
|
|
1318
|
+
<sections>
|
|
1319
|
+
<clause id='clause1' inline-header='false' obligation='normative'>
|
|
1320
|
+
<title>Clause 1</title>
|
|
1321
|
+
</clause>
|
|
1322
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
|
1323
|
+
<title>Clause</title>
|
|
1324
|
+
<p id='_'>
|
|
1325
|
+
<xref target='a'>b</xref>
|
|
1326
|
+
</p>
|
|
1327
|
+
</clause>
|
|
1328
|
+
</sections>
|
|
1329
|
+
</standard-document>
|
|
1330
|
+
OUTPUT
|
|
1331
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
|
1332
|
+
.to be_equivalent_to xmlpp(output)
|
|
1333
|
+
end
|
|
1334
|
+
|
|
1335
|
+
it "processes embed macro with overwriting" do
|
|
1336
|
+
input = <<~INPUT
|
|
1337
|
+
#{ASCIIDOC_BLANK_HDR}
|
|
1338
|
+
|
|
1339
|
+
[[clause1]]
|
|
1340
|
+
== Clause
|
|
1341
|
+
|
|
1342
|
+
embed::spec/assets/xref_error.adoc[]
|
|
1343
|
+
INPUT
|
|
1344
|
+
output = <<~OUTPUT
|
|
1345
|
+
#{BLANK_HDR}
|
|
1346
|
+
<sections>
|
|
1347
|
+
<clause id='clause1' inline-header='false' obligation='normative'>
|
|
1348
|
+
<title>Clause</title>
|
|
1349
|
+
</clause>
|
|
1350
|
+
</sections>
|
|
1351
|
+
</standard-document>
|
|
1352
|
+
OUTPUT
|
|
1353
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
|
1354
|
+
.to be_equivalent_to xmlpp(output)
|
|
1355
|
+
end
|
|
1356
|
+
|
|
1357
|
+
it "processes recursive embed macro with includes" do
|
|
1358
|
+
input = <<~INPUT
|
|
1359
|
+
#{ASCIIDOC_BLANK_HDR}
|
|
1360
|
+
|
|
1361
|
+
[[clause1]]
|
|
1362
|
+
== Clause
|
|
1363
|
+
|
|
1364
|
+
embed::spec/assets/a1.adoc[]
|
|
1365
|
+
INPUT
|
|
1366
|
+
output = <<~OUTPUT
|
|
1367
|
+
#{BLANK_HDR}
|
|
1368
|
+
<sections>
|
|
1369
|
+
<clause id='clause1' inline-header='false' obligation='normative'>
|
|
1370
|
+
<title>Clause</title>
|
|
1371
|
+
</clause>
|
|
1372
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
|
1373
|
+
<title>Clause 1</title>
|
|
1374
|
+
<p id='_'>X</p>
|
|
1375
|
+
</clause>
|
|
1376
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
|
1377
|
+
<title>Clause 2</title>
|
|
1378
|
+
<p id='_'>X</p>
|
|
1379
|
+
</clause>
|
|
1380
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
|
1381
|
+
<title>Clause 3</title>
|
|
1382
|
+
<p id='_'>X</p>
|
|
1383
|
+
</clause>
|
|
1384
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
|
1385
|
+
<title>Clause 4</title>
|
|
1386
|
+
<p id='_'>X</p>
|
|
1387
|
+
</clause>
|
|
1388
|
+
</sections>
|
|
1389
|
+
</standard-document>
|
|
1390
|
+
OUTPUT
|
|
1391
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
|
1392
|
+
.to be_equivalent_to xmlpp(output)
|
|
1393
|
+
end
|
|
1394
|
+
|
|
1395
|
+
it "processes std-link macro" do
|
|
1396
|
+
VCR.use_cassette "std-link" do
|
|
1397
|
+
input = <<~INPUT
|
|
1398
|
+
#{ISOBIB_BLANK_HDR}
|
|
1399
|
+
|
|
1400
|
+
[[clause1]]
|
|
1401
|
+
== Clause
|
|
1402
|
+
|
|
1403
|
+
std-link:[ISO 131]
|
|
1404
|
+
std-link:[iso:std:iso:13485:en,droploc%clause=4,text]
|
|
1405
|
+
INPUT
|
|
1406
|
+
output = <<~OUTPUT
|
|
1407
|
+
#{BLANK_HDR}
|
|
1408
|
+
<sections>
|
|
1409
|
+
<clause id='clause1' inline-header='false' obligation='normative'>
|
|
1410
|
+
<title>Clause</title>
|
|
1411
|
+
<p id='_'>
|
|
1412
|
+
<eref type='inline' bibitemid='_' citeas='ISO 131'/>
|
|
1413
|
+
<eref type='inline' droploc='true' bibitemid='_' citeas='iso:std:iso:13485:en'>
|
|
1414
|
+
<localityStack>
|
|
1415
|
+
<locality type='clause'>
|
|
1416
|
+
<referenceFrom>4</referenceFrom>
|
|
1417
|
+
</locality>
|
|
1418
|
+
</localityStack>
|
|
1419
|
+
text
|
|
1420
|
+
</eref>
|
|
1421
|
+
</p>
|
|
1422
|
+
</clause>
|
|
1423
|
+
</sections>
|
|
1424
|
+
<bibliography>
|
|
1425
|
+
<references hidden='true' normative='true'>
|
|
1426
|
+
<bibitem id='_' type='standard' hidden="true">
|
|
1427
|
+
<fetched/>
|
|
1428
|
+
<title type='title-intro' format='text/plain' language='en' script='Latn'>Acoustics</title>
|
|
1429
|
+
<title type='title-main' format='text/plain' language='en' script='Latn'>Expression of physical and subjective magnitudes of sound or noise in air</title>
|
|
1430
|
+
<title type='main' format='text/plain' language='en' script='Latn'>
|
|
1431
|
+
Acoustics — Expression of physical and subjective magnitudes of sound
|
|
1432
|
+
or noise in air
|
|
1433
|
+
</title>
|
|
1434
|
+
<uri type='src'>https://www.iso.org/standard/3944.html</uri>
|
|
1435
|
+
<uri type='rss'>https://www.iso.org/contents/data/standard/00/39/3944.detail.rss</uri>
|
|
1436
|
+
<docidentifier type='ISO' primary='true'>ISO 131</docidentifier>
|
|
1437
|
+
<docidentifier type='URN'>urn:iso:std:iso:131:stage-95.99:ed-1:en</docidentifier>
|
|
1438
|
+
<docnumber>131</docnumber>
|
|
1439
|
+
<contributor>
|
|
1440
|
+
<role type='publisher'/>
|
|
1441
|
+
<organization>
|
|
1442
|
+
<name>International Organization for Standardization</name>
|
|
1443
|
+
<abbreviation>ISO</abbreviation>
|
|
1444
|
+
<uri>www.iso.org</uri>
|
|
1445
|
+
</organization>
|
|
1446
|
+
</contributor>
|
|
1447
|
+
<edition>1</edition>
|
|
1448
|
+
<language>en</language>
|
|
1449
|
+
<script>Latn</script>
|
|
1450
|
+
<status>
|
|
1451
|
+
<stage>95</stage>
|
|
1452
|
+
<substage>99</substage>
|
|
1453
|
+
</status>
|
|
1454
|
+
<copyright>
|
|
1455
|
+
<from>1979</from>
|
|
1456
|
+
<owner>
|
|
1457
|
+
<organization>
|
|
1458
|
+
<name>ISO</name>
|
|
1459
|
+
</organization>
|
|
1460
|
+
</owner>
|
|
1461
|
+
</copyright>
|
|
1462
|
+
<relation type='obsoletes'>
|
|
1463
|
+
<bibitem type='standard'>
|
|
1464
|
+
<formattedref format='text/plain'>ISO/R 357:1963</formattedref>
|
|
1465
|
+
</bibitem>
|
|
1466
|
+
</relation>
|
|
1467
|
+
<relation type='instance'>
|
|
1468
|
+
<bibitem type='standard'>
|
|
1469
|
+
<fetched/>
|
|
1470
|
+
<title type='title-intro' format='text/plain' language='en' script='Latn'>Acoustics</title>
|
|
1471
|
+
<title type='title-main' format='text/plain' language='en' script='Latn'>Expression of physical and subjective magnitudes of sound or noise in air</title>
|
|
1472
|
+
<title type='main' format='text/plain' language='en' script='Latn'>
|
|
1473
|
+
Acoustics — Expression of physical and subjective magnitudes of
|
|
1474
|
+
sound or noise in air
|
|
1475
|
+
</title>
|
|
1476
|
+
<uri type='src'>https://www.iso.org/standard/3944.html</uri>
|
|
1477
|
+
<uri type='rss'>https://www.iso.org/contents/data/standard/00/39/3944.detail.rss</uri>
|
|
1478
|
+
<docidentifier type='ISO' primary='true'>ISO 131:1979</docidentifier>
|
|
1479
|
+
<docidentifier type='URN'>urn:iso:std:iso:131:stage-95.99:ed-1:en</docidentifier>
|
|
1480
|
+
<docnumber>131</docnumber>
|
|
1481
|
+
<date type='published'>
|
|
1482
|
+
<on>1979-11</on>
|
|
1483
|
+
</date>
|
|
1484
|
+
<contributor>
|
|
1485
|
+
<role type='publisher'/>
|
|
1486
|
+
<organization>
|
|
1487
|
+
<name>International Organization for Standardization</name>
|
|
1488
|
+
<abbreviation>ISO</abbreviation>
|
|
1489
|
+
<uri>www.iso.org</uri>
|
|
1490
|
+
</organization>
|
|
1491
|
+
</contributor>
|
|
1492
|
+
<edition>1</edition>
|
|
1493
|
+
<language>en</language>
|
|
1494
|
+
<script>Latn</script>
|
|
1495
|
+
<status>
|
|
1496
|
+
<stage>95</stage>
|
|
1497
|
+
<substage>99</substage>
|
|
1498
|
+
</status>
|
|
1499
|
+
<copyright>
|
|
1500
|
+
<from>1979</from>
|
|
1501
|
+
<owner>
|
|
1502
|
+
<organization>
|
|
1503
|
+
<name>ISO</name>
|
|
1504
|
+
</organization>
|
|
1505
|
+
</owner>
|
|
1506
|
+
</copyright>
|
|
1507
|
+
<relation type='obsoletes'>
|
|
1508
|
+
<bibitem type='standard'>
|
|
1509
|
+
<formattedref format='text/plain'>ISO/R 357:1963</formattedref>
|
|
1510
|
+
</bibitem>
|
|
1511
|
+
</relation>
|
|
1512
|
+
<place>Geneva</place>
|
|
1513
|
+
</bibitem>
|
|
1514
|
+
</relation>
|
|
1515
|
+
<place>Geneva</place>
|
|
1516
|
+
</bibitem>
|
|
1517
|
+
<bibitem id='_' hidden="true">
|
|
1518
|
+
<formattedref format='application/x-isodoc+xml'/>
|
|
1519
|
+
<docidentifier type='ISO'>iso:std:iso:13485:en</docidentifier>
|
|
1520
|
+
<docnumber>13485:en</docnumber>
|
|
1521
|
+
</bibitem>
|
|
1522
|
+
</references>
|
|
1523
|
+
</bibliography>
|
|
1524
|
+
</standard-document>
|
|
1525
|
+
OUTPUT
|
|
1526
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))
|
|
1527
|
+
.gsub(%r{ bibitemid="_[^"]+"}, ' bibitemid="_"')))
|
|
1528
|
+
.to be_equivalent_to xmlpp(output)
|
|
1529
|
+
end
|
|
1530
|
+
end
|
|
1531
|
+
|
|
1307
1532
|
describe "term inline macros" do
|
|
1308
1533
|
subject(:convert) do
|
|
1309
1534
|
xmlpp(
|
|
@@ -1433,6 +1658,67 @@ RSpec.describe Metanorma::Standoc do
|
|
|
1433
1658
|
end
|
|
1434
1659
|
end
|
|
1435
1660
|
|
|
1661
|
+
context "terms with index terms" do
|
|
1662
|
+
let(:input) do
|
|
1663
|
+
<<~XML
|
|
1664
|
+
#{ASCIIDOC_BLANK_HDR}
|
|
1665
|
+
|
|
1666
|
+
== Terms and Definitions
|
|
1667
|
+
|
|
1668
|
+
=== name(((name)))
|
|
1669
|
+
|
|
1670
|
+
== Main
|
|
1671
|
+
|
|
1672
|
+
term:[name] is a term
|
|
1673
|
+
|
|
1674
|
+
{{name}} is a term
|
|
1675
|
+
XML
|
|
1676
|
+
end
|
|
1677
|
+
let(:output) do
|
|
1678
|
+
<<~XML
|
|
1679
|
+
#{BLANK_HDR}
|
|
1680
|
+
<sections>
|
|
1681
|
+
<terms id='_' obligation='normative'>
|
|
1682
|
+
<title>Terms and definitions</title>
|
|
1683
|
+
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
|
1684
|
+
<term id='term-name'>
|
|
1685
|
+
<preferred><expression><name>name
|
|
1686
|
+
<index>
|
|
1687
|
+
<primary>name</primary>
|
|
1688
|
+
</index>
|
|
1689
|
+
</name>
|
|
1690
|
+
</expression></preferred>
|
|
1691
|
+
</term>
|
|
1692
|
+
</terms>
|
|
1693
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
|
1694
|
+
<title>Main</title>
|
|
1695
|
+
<p id='_'>
|
|
1696
|
+
<concept>
|
|
1697
|
+
<refterm>name</refterm>
|
|
1698
|
+
<renderterm>name</renderterm>
|
|
1699
|
+
<xref target='term-name'/>
|
|
1700
|
+
</concept>
|
|
1701
|
+
is a term
|
|
1702
|
+
</p>
|
|
1703
|
+
<p id='_'>
|
|
1704
|
+
<concept>
|
|
1705
|
+
<refterm>name</refterm>
|
|
1706
|
+
<renderterm>name</renderterm>
|
|
1707
|
+
<xref target='term-name'/>
|
|
1708
|
+
</concept>
|
|
1709
|
+
is a term
|
|
1710
|
+
</p>
|
|
1711
|
+
</clause>
|
|
1712
|
+
</sections>
|
|
1713
|
+
</standard-document>
|
|
1714
|
+
XML
|
|
1715
|
+
end
|
|
1716
|
+
|
|
1717
|
+
it "strips index terms in terms anchors" do
|
|
1718
|
+
expect(convert).to(be_equivalent_to(xmlpp(output)))
|
|
1719
|
+
end
|
|
1720
|
+
end
|
|
1721
|
+
|
|
1436
1722
|
context "multiply exising ids in document" do
|
|
1437
1723
|
let(:input) do
|
|
1438
1724
|
<<~XML
|
|
@@ -23,13 +23,16 @@ RSpec.describe Metanorma::Standoc::Processor do
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "generates IsoDoc XML from a blank document" do
|
|
26
|
-
|
|
26
|
+
input = <<~INPUT
|
|
27
27
|
#{ASCIIDOC_BLANK_HDR}
|
|
28
28
|
INPUT
|
|
29
|
+
output = <<~"OUTPUT"
|
|
29
30
|
#{BLANK_HDR}
|
|
30
31
|
<sections/>
|
|
31
32
|
</iso-standard>
|
|
32
33
|
OUTPUT
|
|
34
|
+
expect(processor.input_to_isodoc(input, "test"))
|
|
35
|
+
.to be_equivalent_to output
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
it "generates HTML from IsoDoc XML" do
|
|
@@ -45,16 +48,17 @@ RSpec.describe Metanorma::Standoc::Processor do
|
|
|
45
48
|
</sections>
|
|
46
49
|
</iso-standard>
|
|
47
50
|
INPUT
|
|
48
|
-
expect(File.read("test.html", encoding: "utf-8")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
expect(File.read("test.html", encoding: "utf-8")
|
|
52
|
+
.gsub(%r{^.*<main}m, "<main")
|
|
53
|
+
.gsub(%r{</main>.*}m, "</main>"))
|
|
54
|
+
.to be_equivalent_to <<~"OUTPUT"
|
|
55
|
+
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
|
56
|
+
<p class="zzSTDTitle1"></p>
|
|
57
|
+
<div id="H"><h1>Terms, Definitions, Symbols and Abbreviated Terms</h1><h2 class="TermNum" id="J"></h2>
|
|
58
|
+
<p class="Terms" style="text-align:left;">Term2</p>
|
|
59
|
+
</div>
|
|
60
|
+
</main>
|
|
61
|
+
OUTPUT
|
|
58
62
|
end
|
|
59
63
|
|
|
60
64
|
it "generates HTML from IsoDoc XML" do
|
|
@@ -70,8 +74,8 @@ RSpec.describe Metanorma::Standoc::Processor do
|
|
|
70
74
|
</sections>
|
|
71
75
|
</iso-standard>
|
|
72
76
|
INPUT
|
|
73
|
-
expect(File.read("test.doc",
|
|
74
|
-
|
|
77
|
+
expect(File.read("test.doc", encoding: "utf-8"))
|
|
78
|
+
.to match(/Terms, Definitions, Symbols and Abbreviated Terms/)
|
|
75
79
|
end
|
|
76
80
|
|
|
77
81
|
it "generates XML from IsoDoc XML" do
|