metanorma-standoc 2.0.2 → 2.0.5
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 +73 -23
- data/lib/metanorma/standoc/basicdoc.rng +5 -3
- data/lib/metanorma/standoc/biblio.rng +5 -3
- data/lib/metanorma/standoc/blocks.rb +4 -4
- data/lib/metanorma/standoc/cleanup_amend.rb +33 -30
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +29 -5
- 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 +25 -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 +39 -17
- data/lib/metanorma/standoc/cleanup_xref.rb +82 -13
- data/lib/metanorma/standoc/converter.rb +2 -1
- data/lib/metanorma/standoc/inline.rb +21 -12
- data/lib/metanorma/standoc/isodoc.rng +73 -3
- data/lib/metanorma/standoc/macros.rb +14 -2
- data/lib/metanorma/standoc/macros_embed.rb +35 -14
- data/lib/metanorma/standoc/macros_note.rb +4 -3
- data/lib/metanorma/standoc/processor.rb +6 -1
- data/lib/metanorma/standoc/ref.rb +20 -16
- data/lib/metanorma/standoc/ref_utility.rb +8 -6
- data/lib/metanorma/standoc/render.rb +7 -3
- data/lib/metanorma/standoc/table.rb +8 -10
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +16 -10
- data/lib/metanorma/standoc/terms.rb +10 -7
- data/lib/metanorma/standoc/utils.rb +3 -1
- data/lib/metanorma/standoc/validate.rb +81 -7
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +2 -2
- data/spec/assets/a2.adoc +4 -2
- data/spec/assets/a3.adoc +2 -2
- data/spec/assets/a3a.adoc +7 -0
- data/spec/metanorma/base_spec.rb +1 -1
- data/spec/metanorma/cleanup_blocks_spec.rb +136 -0
- data/spec/metanorma/cleanup_spec.rb +34 -23
- data/spec/metanorma/cleanup_terms_spec.rb +16 -4
- 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 +267 -4
- data/spec/metanorma/processor_spec.rb +17 -13
- data/spec/metanorma/refs_spec.rb +632 -460
- data/spec/metanorma/section_spec.rb +1 -1
- data/spec/metanorma/validate_spec.rb +108 -0
- 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 +10 -9
@@ -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>
|
@@ -1364,8 +1364,70 @@ RSpec.describe Metanorma::Standoc do
|
|
1364
1364
|
embed::spec/assets/a1.adoc[]
|
1365
1365
|
INPUT
|
1366
1366
|
output = <<~OUTPUT
|
1367
|
-
#{
|
1368
|
-
|
1367
|
+
<standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Standoc::VERSION}'>
|
1368
|
+
<bibdata type='standard'>
|
1369
|
+
<title language='en' format='text/plain'>Document title</title>
|
1370
|
+
<language>en</language>
|
1371
|
+
<script>Latn</script>
|
1372
|
+
<status>
|
1373
|
+
<stage>published</stage>
|
1374
|
+
</status>
|
1375
|
+
<copyright>
|
1376
|
+
<from>2022</from>
|
1377
|
+
</copyright>
|
1378
|
+
<ext>
|
1379
|
+
<doctype>article</doctype>
|
1380
|
+
</ext>
|
1381
|
+
<relation type='derivedFrom'>
|
1382
|
+
<bibitem>
|
1383
|
+
<title language='en' format='text/plain'>A2</title>
|
1384
|
+
<language>en</language>
|
1385
|
+
<script>Latn</script>
|
1386
|
+
<status>
|
1387
|
+
<stage>published</stage>
|
1388
|
+
</status>
|
1389
|
+
<copyright>
|
1390
|
+
<from>2022</from>
|
1391
|
+
</copyright>
|
1392
|
+
<ext>
|
1393
|
+
<doctype>article</doctype>
|
1394
|
+
</ext>
|
1395
|
+
<relation type='derivedFrom'>
|
1396
|
+
<bibitem>
|
1397
|
+
<title language='en' format='text/plain'>A3</title>
|
1398
|
+
<language>en</language>
|
1399
|
+
<script>Latn</script>
|
1400
|
+
<status>
|
1401
|
+
<stage>published</stage>
|
1402
|
+
</status>
|
1403
|
+
<copyright>
|
1404
|
+
<from>2022</from>
|
1405
|
+
</copyright>
|
1406
|
+
<ext>
|
1407
|
+
<doctype>article</doctype>
|
1408
|
+
</ext>
|
1409
|
+
</bibitem>
|
1410
|
+
</relation>
|
1411
|
+
<relation type='derivedFrom'>
|
1412
|
+
<bibitem>
|
1413
|
+
<title language='en' format='text/plain'>A3a</title>
|
1414
|
+
<language>en</language>
|
1415
|
+
<script>Latn</script>
|
1416
|
+
<status>
|
1417
|
+
<stage>published</stage>
|
1418
|
+
</status>
|
1419
|
+
<copyright>
|
1420
|
+
<from>2022</from>
|
1421
|
+
</copyright>
|
1422
|
+
<ext>
|
1423
|
+
<doctype>article</doctype>
|
1424
|
+
</ext>
|
1425
|
+
</bibitem>
|
1426
|
+
</relation>
|
1427
|
+
</bibitem>
|
1428
|
+
</relation>
|
1429
|
+
</bibdata>
|
1430
|
+
<sections>
|
1369
1431
|
<clause id='clause1' inline-header='false' obligation='normative'>
|
1370
1432
|
<title>Clause</title>
|
1371
1433
|
</clause>
|
@@ -1381,6 +1443,10 @@ RSpec.describe Metanorma::Standoc do
|
|
1381
1443
|
<title>Clause 3</title>
|
1382
1444
|
<p id='_'>X</p>
|
1383
1445
|
</clause>
|
1446
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
1447
|
+
<title>Clause 3a</title>
|
1448
|
+
<p id='_'>X</p>
|
1449
|
+
</clause>
|
1384
1450
|
<clause id='_' inline-header='false' obligation='normative'>
|
1385
1451
|
<title>Clause 4</title>
|
1386
1452
|
<p id='_'>X</p>
|
@@ -1392,6 +1458,142 @@ RSpec.describe Metanorma::Standoc do
|
|
1392
1458
|
.to be_equivalent_to xmlpp(output)
|
1393
1459
|
end
|
1394
1460
|
|
1461
|
+
it "processes std-link macro" do
|
1462
|
+
VCR.use_cassette "std-link" do
|
1463
|
+
input = <<~INPUT
|
1464
|
+
#{ISOBIB_BLANK_HDR}
|
1465
|
+
|
1466
|
+
[[clause1]]
|
1467
|
+
== Clause
|
1468
|
+
|
1469
|
+
std-link:[ISO 131]
|
1470
|
+
std-link:[iso:std:iso:13485:en,droploc%clause=4,text]
|
1471
|
+
INPUT
|
1472
|
+
output = <<~OUTPUT
|
1473
|
+
#{BLANK_HDR}
|
1474
|
+
<sections>
|
1475
|
+
<clause id='clause1' inline-header='false' obligation='normative'>
|
1476
|
+
<title>Clause</title>
|
1477
|
+
<p id='_'>
|
1478
|
+
<eref type='inline' bibitemid='_' citeas='ISO 131'/>
|
1479
|
+
<eref type='inline' droploc='true' bibitemid='_' citeas='iso:std:iso:13485:en'>
|
1480
|
+
<localityStack>
|
1481
|
+
<locality type='clause'>
|
1482
|
+
<referenceFrom>4</referenceFrom>
|
1483
|
+
</locality>
|
1484
|
+
</localityStack>
|
1485
|
+
text
|
1486
|
+
</eref>
|
1487
|
+
</p>
|
1488
|
+
</clause>
|
1489
|
+
</sections>
|
1490
|
+
<bibliography>
|
1491
|
+
<references hidden='true' normative='true'>
|
1492
|
+
<bibitem id='_' type='standard' hidden="true">
|
1493
|
+
<fetched/>
|
1494
|
+
<title type='title-intro' format='text/plain' language='en' script='Latn'>Acoustics</title>
|
1495
|
+
<title type='title-main' format='text/plain' language='en' script='Latn'>Expression of physical and subjective magnitudes of sound or noise in air</title>
|
1496
|
+
<title type='main' format='text/plain' language='en' script='Latn'>
|
1497
|
+
Acoustics — Expression of physical and subjective magnitudes of sound
|
1498
|
+
or noise in air
|
1499
|
+
</title>
|
1500
|
+
<uri type='src'>https://www.iso.org/standard/3944.html</uri>
|
1501
|
+
<uri type='rss'>https://www.iso.org/contents/data/standard/00/39/3944.detail.rss</uri>
|
1502
|
+
<docidentifier type='ISO' primary='true'>ISO 131</docidentifier>
|
1503
|
+
<docidentifier type='URN'>urn:iso:std:iso:131:stage-95.99:ed-1:en</docidentifier>
|
1504
|
+
<docnumber>131</docnumber>
|
1505
|
+
<contributor>
|
1506
|
+
<role type='publisher'/>
|
1507
|
+
<organization>
|
1508
|
+
<name>International Organization for Standardization</name>
|
1509
|
+
<abbreviation>ISO</abbreviation>
|
1510
|
+
<uri>www.iso.org</uri>
|
1511
|
+
</organization>
|
1512
|
+
</contributor>
|
1513
|
+
<edition>1</edition>
|
1514
|
+
<language>en</language>
|
1515
|
+
<script>Latn</script>
|
1516
|
+
<status>
|
1517
|
+
<stage>95</stage>
|
1518
|
+
<substage>99</substage>
|
1519
|
+
</status>
|
1520
|
+
<copyright>
|
1521
|
+
<from>1979</from>
|
1522
|
+
<owner>
|
1523
|
+
<organization>
|
1524
|
+
<name>ISO</name>
|
1525
|
+
</organization>
|
1526
|
+
</owner>
|
1527
|
+
</copyright>
|
1528
|
+
<relation type='obsoletes'>
|
1529
|
+
<bibitem type='standard'>
|
1530
|
+
<formattedref format='text/plain'>ISO/R 357:1963</formattedref>
|
1531
|
+
</bibitem>
|
1532
|
+
</relation>
|
1533
|
+
<relation type='instance'>
|
1534
|
+
<bibitem type='standard'>
|
1535
|
+
<fetched/>
|
1536
|
+
<title type='title-intro' format='text/plain' language='en' script='Latn'>Acoustics</title>
|
1537
|
+
<title type='title-main' format='text/plain' language='en' script='Latn'>Expression of physical and subjective magnitudes of sound or noise in air</title>
|
1538
|
+
<title type='main' format='text/plain' language='en' script='Latn'>
|
1539
|
+
Acoustics — Expression of physical and subjective magnitudes of
|
1540
|
+
sound or noise in air
|
1541
|
+
</title>
|
1542
|
+
<uri type='src'>https://www.iso.org/standard/3944.html</uri>
|
1543
|
+
<uri type='rss'>https://www.iso.org/contents/data/standard/00/39/3944.detail.rss</uri>
|
1544
|
+
<docidentifier type='ISO' primary='true'>ISO 131:1979</docidentifier>
|
1545
|
+
<docidentifier type='URN'>urn:iso:std:iso:131:stage-95.99:ed-1:en</docidentifier>
|
1546
|
+
<docnumber>131</docnumber>
|
1547
|
+
<date type='published'>
|
1548
|
+
<on>1979-11</on>
|
1549
|
+
</date>
|
1550
|
+
<contributor>
|
1551
|
+
<role type='publisher'/>
|
1552
|
+
<organization>
|
1553
|
+
<name>International Organization for Standardization</name>
|
1554
|
+
<abbreviation>ISO</abbreviation>
|
1555
|
+
<uri>www.iso.org</uri>
|
1556
|
+
</organization>
|
1557
|
+
</contributor>
|
1558
|
+
<edition>1</edition>
|
1559
|
+
<language>en</language>
|
1560
|
+
<script>Latn</script>
|
1561
|
+
<status>
|
1562
|
+
<stage>95</stage>
|
1563
|
+
<substage>99</substage>
|
1564
|
+
</status>
|
1565
|
+
<copyright>
|
1566
|
+
<from>1979</from>
|
1567
|
+
<owner>
|
1568
|
+
<organization>
|
1569
|
+
<name>ISO</name>
|
1570
|
+
</organization>
|
1571
|
+
</owner>
|
1572
|
+
</copyright>
|
1573
|
+
<relation type='obsoletes'>
|
1574
|
+
<bibitem type='standard'>
|
1575
|
+
<formattedref format='text/plain'>ISO/R 357:1963</formattedref>
|
1576
|
+
</bibitem>
|
1577
|
+
</relation>
|
1578
|
+
<place>Geneva</place>
|
1579
|
+
</bibitem>
|
1580
|
+
</relation>
|
1581
|
+
<place>Geneva</place>
|
1582
|
+
</bibitem>
|
1583
|
+
<bibitem id='_' hidden="true">
|
1584
|
+
<formattedref format='application/x-isodoc+xml'/>
|
1585
|
+
<docidentifier type='ISO'>iso:std:iso:13485:en</docidentifier>
|
1586
|
+
<docnumber>13485:en</docnumber>
|
1587
|
+
</bibitem>
|
1588
|
+
</references>
|
1589
|
+
</bibliography>
|
1590
|
+
</standard-document>
|
1591
|
+
OUTPUT
|
1592
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))
|
1593
|
+
.gsub(%r{ bibitemid="_[^"]+"}, ' bibitemid="_"')))
|
1594
|
+
.to be_equivalent_to xmlpp(output)
|
1595
|
+
end
|
1596
|
+
end
|
1395
1597
|
|
1396
1598
|
describe "term inline macros" do
|
1397
1599
|
subject(:convert) do
|
@@ -1522,6 +1724,67 @@ RSpec.describe Metanorma::Standoc do
|
|
1522
1724
|
end
|
1523
1725
|
end
|
1524
1726
|
|
1727
|
+
context "terms with index terms" do
|
1728
|
+
let(:input) do
|
1729
|
+
<<~XML
|
1730
|
+
#{ASCIIDOC_BLANK_HDR}
|
1731
|
+
|
1732
|
+
== Terms and Definitions
|
1733
|
+
|
1734
|
+
=== name(((name)))
|
1735
|
+
|
1736
|
+
== Main
|
1737
|
+
|
1738
|
+
term:[name] is a term
|
1739
|
+
|
1740
|
+
{{name}} is a term
|
1741
|
+
XML
|
1742
|
+
end
|
1743
|
+
let(:output) do
|
1744
|
+
<<~XML
|
1745
|
+
#{BLANK_HDR}
|
1746
|
+
<sections>
|
1747
|
+
<terms id='_' obligation='normative'>
|
1748
|
+
<title>Terms and definitions</title>
|
1749
|
+
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
1750
|
+
<term id='term-name'>
|
1751
|
+
<preferred><expression><name>name
|
1752
|
+
<index>
|
1753
|
+
<primary>name</primary>
|
1754
|
+
</index>
|
1755
|
+
</name>
|
1756
|
+
</expression></preferred>
|
1757
|
+
</term>
|
1758
|
+
</terms>
|
1759
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
1760
|
+
<title>Main</title>
|
1761
|
+
<p id='_'>
|
1762
|
+
<concept>
|
1763
|
+
<refterm>name</refterm>
|
1764
|
+
<renderterm>name</renderterm>
|
1765
|
+
<xref target='term-name'/>
|
1766
|
+
</concept>
|
1767
|
+
is a term
|
1768
|
+
</p>
|
1769
|
+
<p id='_'>
|
1770
|
+
<concept>
|
1771
|
+
<refterm>name</refterm>
|
1772
|
+
<renderterm>name</renderterm>
|
1773
|
+
<xref target='term-name'/>
|
1774
|
+
</concept>
|
1775
|
+
is a term
|
1776
|
+
</p>
|
1777
|
+
</clause>
|
1778
|
+
</sections>
|
1779
|
+
</standard-document>
|
1780
|
+
XML
|
1781
|
+
end
|
1782
|
+
|
1783
|
+
it "strips index terms in terms anchors" do
|
1784
|
+
expect(convert).to(be_equivalent_to(xmlpp(output)))
|
1785
|
+
end
|
1786
|
+
end
|
1787
|
+
|
1525
1788
|
context "multiply exising ids in document" do
|
1526
1789
|
let(:input) do
|
1527
1790
|
<<~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
|