metanorma-standoc 1.4.4 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +4 -9
  3. data/.github/workflows/ubuntu.yml +1 -5
  4. data/.github/workflows/windows.yml +2 -12
  5. data/.rubocop.yml +1 -1
  6. data/lib/asciidoctor/standoc/base.rb +11 -5
  7. data/lib/asciidoctor/standoc/base_structured_text_preprocessor.rb +123 -0
  8. data/lib/asciidoctor/standoc/basicdoc.rng +23 -0
  9. data/lib/asciidoctor/standoc/cleanup.rb +32 -12
  10. data/lib/asciidoctor/standoc/cleanup_amend.rb +54 -0
  11. data/lib/asciidoctor/standoc/cleanup_block.rb +0 -2
  12. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +11 -24
  13. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +0 -3
  14. data/lib/asciidoctor/standoc/cleanup_inline.rb +62 -1
  15. data/lib/asciidoctor/standoc/cleanup_ref.rb +10 -7
  16. data/lib/asciidoctor/standoc/cleanup_section.rb +91 -8
  17. data/lib/asciidoctor/standoc/cleanup_terms.rb +12 -2
  18. data/lib/asciidoctor/standoc/converter.rb +3 -3
  19. data/lib/asciidoctor/standoc/front.rb +0 -12
  20. data/lib/asciidoctor/standoc/front_contributor.rb +51 -10
  21. data/lib/asciidoctor/standoc/inline.rb +21 -31
  22. data/lib/asciidoctor/standoc/isodoc.rng +137 -21
  23. data/lib/asciidoctor/standoc/json2_text_preprocessor.rb +44 -0
  24. data/lib/asciidoctor/standoc/log.rb +10 -1
  25. data/lib/asciidoctor/standoc/macros.rb +45 -33
  26. data/lib/asciidoctor/standoc/ref.rb +45 -45
  27. data/lib/asciidoctor/standoc/section.rb +39 -30
  28. data/lib/asciidoctor/standoc/table.rb +3 -2
  29. data/lib/asciidoctor/standoc/utils.rb +18 -1
  30. data/lib/asciidoctor/standoc/validate.rb +30 -18
  31. data/lib/asciidoctor/standoc/validate_section.rb +1 -1
  32. data/lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb +10 -10
  33. data/lib/asciidoctor/standoc/yaml2_text_preprocessor.rb +46 -0
  34. data/lib/liquid/custom_blocks/key_iterator.rb +21 -0
  35. data/lib/liquid/custom_filters/values.rb +7 -0
  36. data/lib/metanorma/standoc.rb +0 -5
  37. data/lib/metanorma/standoc/version.rb +20 -1
  38. data/metanorma-standoc.gemspec +4 -5
  39. data/spec/asciidoctor-standoc/base_spec.rb +140 -7
  40. data/spec/asciidoctor-standoc/blocks_spec.rb +275 -149
  41. data/spec/asciidoctor-standoc/cleanup_spec.rb +1372 -56
  42. data/spec/asciidoctor-standoc/inline_spec.rb +133 -6
  43. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +9 -7
  44. data/spec/asciidoctor-standoc/macros_json2text_spec.rb +10 -0
  45. data/spec/asciidoctor-standoc/macros_spec.rb +43 -23
  46. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +5 -560
  47. data/spec/asciidoctor-standoc/refs_dl_spec.rb +9 -7
  48. data/spec/asciidoctor-standoc/refs_spec.rb +43 -34
  49. data/spec/asciidoctor-standoc/section_spec.rb +42 -39
  50. data/spec/asciidoctor-standoc/table_spec.rb +119 -113
  51. data/spec/asciidoctor-standoc/validate_spec.rb +45 -1
  52. data/spec/assets/i18n.yaml +17 -2
  53. data/spec/examples/codes_table.html +1365 -1365
  54. data/spec/fixtures/macros_datamodel/address_class_profile.xml +46 -46
  55. data/spec/fixtures/macros_datamodel/address_component_profile.xml +21 -21
  56. data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +21 -21
  57. data/spec/metanorma/processor_spec.rb +1 -2
  58. data/spec/spec_helper.rb +110 -109
  59. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +629 -0
  60. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +71 -71
  61. data/spec/vcr_cassettes/isobib_get_123.yml +16 -16
  62. data/spec/vcr_cassettes/isobib_get_123_1.yml +36 -36
  63. data/spec/vcr_cassettes/isobib_get_123_2001.yml +16 -16
  64. data/spec/vcr_cassettes/isobib_get_124.yml +17 -17
  65. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  66. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +39 -37
  67. metadata +29 -14
  68. data/lib/asciidoctor-yaml/i18n-en.yaml +0 -20
  69. data/lib/asciidoctor-yaml/i18n-fr.yaml +0 -13
  70. data/lib/asciidoctor-yaml/i18n-zh-Hans.yaml +0 -15
  71. data/lib/asciidoctor/standoc/i18n.rb +0 -39
  72. data/lib/asciidoctor/standoc/macros_yaml2text.rb +0 -165
  73. data/lib/metanorma/standoc/latexml_requirement.rb +0 -62
  74. data/lib/metanorma/standoc/requirement.rb +0 -13
@@ -158,7 +158,21 @@ RSpec.describe Asciidoctor::Standoc do
158
158
  <terms id="_" obligation="normative">
159
159
  <title>Terms and definitions</title>
160
160
  <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
161
- <term id="_"><preferred><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>t</mi><mn>90</mn></msub></math></stem></preferred><admitted><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>t</mi><mn>91</mn></msub></math></stem></admitted>
161
+ <term id="_"><preferred><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub>
162
+ <mrow>
163
+ <mi>t</mi>
164
+ </mrow>
165
+ <mrow>
166
+ <mn>90</mn>
167
+ </mrow>
168
+ </msub></math></stem></preferred><admitted><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub>
169
+ <mrow>
170
+ <mi>t</mi>
171
+ </mrow>
172
+ <mrow>
173
+ <mn>91</mn>
174
+ </mrow>
175
+ </msub></math></stem></admitted>
162
176
  <definition><p id="_">Time</p></definition></term>
163
177
  </terms>
164
178
  </sections>
@@ -229,8 +243,22 @@ RSpec.describe Asciidoctor::Standoc do
229
243
  <terms id="_" obligation="normative">
230
244
  <title>Terms and definitions</title>
231
245
  <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
232
- <term id="_"><preferred><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>t</mi><mn>90</mn></msub></math></stem></preferred><definition><formula id="_">
233
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>t</mi><mi>A</mi></msub></math></stem>
246
+ <term id="_"><preferred><stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub>
247
+ <mrow>
248
+ <mi>t</mi>
249
+ </mrow>
250
+ <mrow>
251
+ <mn>90</mn>
252
+ </mrow>
253
+ </msub></math></stem></preferred><definition><formula id="_">
254
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub>
255
+ <mrow>
256
+ <mi>t</mi>
257
+ </mrow>
258
+ <mrow>
259
+ <mi>A</mi>
260
+ </mrow>
261
+ </msub></math></stem>
234
262
  </formula>
235
263
  <p id="_">This paragraph is extraneous</p></definition>
236
264
  </term>
@@ -360,7 +388,7 @@ RSpec.describe Asciidoctor::Standoc do
360
388
  </p>
361
389
  </foreword></preface><sections>
362
390
  </sections><bibliography><references id="_" obligation="informative" normative="true">
363
- <title>Normative References</title>
391
+ <title>Normative references</title>
364
392
  #{NORM_REF_BOILERPLATE}
365
393
  <bibitem id="iso216" type="standard">
366
394
  <title format="text/plain">Reference</title>
@@ -438,7 +466,7 @@ RSpec.describe Asciidoctor::Standoc do
438
466
  </p>
439
467
  </foreword></preface><sections>
440
468
  </sections><bibliography><references id="_" obligation="informative" normative="true">
441
- <title>Normative References</title>
469
+ <title>Normative references</title>
442
470
  #{NORM_REF_BOILERPLATE}
443
471
  <bibitem id="iso216" type="standard">
444
472
  <title format="text/plain">Reference</title>
@@ -538,7 +566,7 @@ RSpec.describe Asciidoctor::Standoc do
538
566
  INPUT
539
567
  #{BLANK_HDR}
540
568
  <sections></sections>
541
- <bibliography><references id="_" obligation="informative" normative="true"><title>Normative References</title>
569
+ <bibliography><references id="_" obligation="informative" normative="true"><title>Normative references</title>
542
570
  #{NORM_REF_BOILERPLATE}
543
571
  <bibitem id="iso216" type="standard">
544
572
  <title format="text/plain">Reference</title>
@@ -680,9 +708,9 @@ end
680
708
  <sections><table id="_">
681
709
  <tbody>
682
710
  <tr>
683
- <td align="left">a</td>
684
- <td align="left">b</td>
685
- <td align="left">c</td>
711
+ <td valign="top" align="left">a</td>
712
+ <td valign="top" align="left">b</td>
713
+ <td valign="top" align="left">c</td>
686
714
  </tr>
687
715
  </tbody>
688
716
  <dl id="_">
@@ -711,23 +739,23 @@ end
711
739
  #{BLANK_HDR}
712
740
  <sections>
713
741
  <table id="_"><thead><tr>
714
- <th align="left">a</th>
715
- <th align="left">b</th>
716
- <th align="left">c</th>
742
+ <th valign="top" align="left">a</th>
743
+ <th valign="top" align="left">b</th>
744
+ <th valign="top" align="left">c</th>
717
745
  </tr><tr>
718
- <th align="left">a</th>
719
- <th align="left">b</th>
720
- <th align="left">c</th>
746
+ <th valign="top" align="left">a</th>
747
+ <th valign="top" align="left">b</th>
748
+ <th valign="top" align="left">c</th>
721
749
  </tr><tr>
722
- <th align="left">a</th>
723
- <th align="left">b</th>
724
- <th align="left">c</th>
750
+ <th valign="top" align="left">a</th>
751
+ <th valign="top" align="left">b</th>
752
+ <th valign="top" align="left">c</th>
725
753
  </tr></thead>
726
754
  <tbody>
727
755
  <tr>
728
- <td align="left">a</td>
729
- <td align="left">b</td>
730
- <td align="left">c</td>
756
+ <td valign="top" align="left">a</td>
757
+ <td valign="top" align="left">b</td>
758
+ <td valign="top" align="left">c</td>
731
759
  </tr>
732
760
  </tbody>
733
761
  </table>
@@ -753,26 +781,26 @@ end
753
781
  <table id="_">
754
782
  <thead>
755
783
  <tr>
756
- <th align="left">a</th>
757
- <th align="left">b</th>
758
- <th align="left">c</th>
784
+ <th valign="top" align="left">a</th>
785
+ <th valign="top" align="left">b</th>
786
+ <th valign="top" align="left">c</th>
759
787
  </tr>
760
788
  <tr>
761
- <th align="left">a</th>
762
- <th align="left">b</th>
763
- <th align="left">c</th>
789
+ <th valign="top" align="left">a</th>
790
+ <th valign="top" align="left">b</th>
791
+ <th valign="top" align="left">c</th>
764
792
  </tr><tr>
765
- <th align="left">a</th>
766
- <th align="left">b</th>
767
- <th align="left">c</th>
793
+ <th valign="top" align="left">a</th>
794
+ <th valign="top" align="left">b</th>
795
+ <th valign="top" align="left">c</th>
768
796
  </tr></thead>
769
797
  <tbody>
770
798
 
771
799
 
772
800
  <tr>
773
- <td align="left">a</td>
774
- <td align="left">b</td>
775
- <td align="left">c</td>
801
+ <td valign="top" align="left">a</td>
802
+ <td valign="top" align="left">b</td>
803
+ <td valign="top" align="left">c</td>
776
804
  </tr>
777
805
  </tbody>
778
806
  </table>
@@ -796,9 +824,9 @@ end
796
824
  <sections><table id="_">
797
825
  <tbody>
798
826
  <tr>
799
- <td align="left">a</td>
800
- <td align="left">b</td>
801
- <td align="left">c</td>
827
+ <td valign="top" align="left">a</td>
828
+ <td valign="top" align="left">b</td>
829
+ <td valign="top" align="left">c</td>
802
830
  </tr>
803
831
  </tbody>
804
832
  <note id="_">
@@ -967,7 +995,7 @@ end
967
995
  </fn>
968
996
  </p>
969
997
  </clause></sections><bibliography><references id="_" obligation="informative" normative="true">
970
- <title>Normative References</title>
998
+ <title>Normative references</title>
971
999
  #{NORM_REF_BOILERPLATE}
972
1000
  <bibitem id="iso123" type="standard">
973
1001
  <title format="text/plain">Standard</title>
@@ -1139,7 +1167,7 @@ end
1139
1167
  # mock_iecbib_get_iec60050_102_01
1140
1168
  # mock_iecbib_get_iec60050_103_01
1141
1169
  # mock_iev
1142
- VCR.use_cassette "separates_iev_citations_by_top_level_clause" do
1170
+ VCR.use_cassette "separates_iev_citations_by_top_level_clause", :re_record_interval => 25200 do
1143
1171
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1144
1172
  #{CACHED_ISOBIB_BLANK_HDR}
1145
1173
 
@@ -1198,7 +1226,7 @@ end
1198
1226
  </origin>
1199
1227
  </termsource>
1200
1228
  </term></terms></sections><bibliography><references id="_" obligation="informative" normative="true">
1201
- <title>Normative References</title>
1229
+ <title>Normative references</title>
1202
1230
  #{NORM_REF_BOILERPLATE}
1203
1231
  <bibitem type="standard" id="IEC60050-102">
1204
1232
  <fetched>#{Date.today}</fetched>
@@ -1208,6 +1236,7 @@ end
1208
1236
  <uri type="src">https://webstore.iec.ch/publication/160</uri>
1209
1237
  <uri type="obp">/preview/info_iec60050-102%7Bed1.0%7Db.pdf</uri>
1210
1238
  <docidentifier type="IEC">IEC 60050-102:2007</docidentifier>
1239
+ <docidentifier type='URN'>urn:iec:std:iec:60050-102:2007:::en</docidentifier>
1211
1240
  <date type="published">
1212
1241
  <on>2007</on>
1213
1242
  </date>
@@ -1246,6 +1275,7 @@ end
1246
1275
  <uri type="src">https://webstore.iec.ch/publication/161</uri>
1247
1276
  <uri type="obp">/preview/info_iec60050-103%7Bed1.0%7Db.pdf</uri>
1248
1277
  <docidentifier type="IEC">IEC 60050-103:2009</docidentifier>
1278
+ <docidentifier type='URN'>urn:iec:std:iec:60050-103:2009:::en</docidentifier>
1249
1279
  <date type="published">
1250
1280
  <on>2009</on>
1251
1281
  </date>
@@ -1359,7 +1389,14 @@ end
1359
1389
  #{BLANK_HDR}
1360
1390
  <sections>
1361
1391
  <p id="_">
1362
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mn>1</mn><mi>r</mi></mfrac></math></stem>
1392
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac>
1393
+ <mrow>
1394
+ <mn>1</mn>
1395
+ </mrow>
1396
+ <mrow>
1397
+ <mi>r</mi>
1398
+ </mrow>
1399
+ </mfrac></math></stem>
1363
1400
  </p>
1364
1401
  </sections>
1365
1402
  </standard-document>
@@ -1515,7 +1552,7 @@ OUTPUT
1515
1552
  <sections>
1516
1553
 
1517
1554
  </sections><bibliography><references id="_" obligation="informative" normative="true">
1518
- <title>Normative References</title><p id="_">There are no normative references in this document.</p>
1555
+ <title>Normative references</title><p id="_">There are no normative references in this document.</p>
1519
1556
  </references></bibliography>
1520
1557
  </standard-document>
1521
1558
  OUTPUT
@@ -1534,7 +1571,7 @@ OUTPUT
1534
1571
  <sections>
1535
1572
 
1536
1573
  </sections><bibliography><references id="_" obligation="informative" normative="true">
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>
1574
+ <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>
1538
1575
  <bibitem id="a">
1539
1576
  <formattedref format="application/x-isodoc+xml">A</formattedref>
1540
1577
  <docidentifier>b</docidentifier>
@@ -1563,7 +1600,7 @@ it "inserts boilerplate before empty Normative References in French" do
1563
1600
  <sections>
1564
1601
 
1565
1602
  </sections><bibliography><references id="_" obligation="informative" normative="true">
1566
- <title>Normative References</title><p id="_">Le présent document ne contient aucune référence normative.</p>
1603
+ <title>Références normatives</title><p id="_">Le présent document ne contient aucune référence normative.</p>
1567
1604
  </references></bibliography>
1568
1605
  </standard-document>
1569
1606
  OUTPUT
@@ -1584,7 +1621,7 @@ it "removes bibdata bibitem IDs" do
1584
1621
 
1585
1622
  INPUT
1586
1623
  <?xml version='1.0' encoding='UTF-8'?>
1587
- <standard-document xmlns='https://www.metanorma.org/ns/standoc'>
1624
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
1588
1625
  <bibdata type='standard'>
1589
1626
  <title language='en' format='text/plain'>Document title</title>
1590
1627
  <language>en</language>
@@ -1608,7 +1645,7 @@ it "removes bibdata bibitem IDs" do
1608
1645
  <sections> </sections>
1609
1646
  <bibliography>
1610
1647
  <references id='_' obligation='informative' normative="true">
1611
- <title>Normative References</title>
1648
+ <title>Normative references</title>
1612
1649
  <p id="_">There are no normative references in this document.</p>
1613
1650
  </references>
1614
1651
  </bibliography>
@@ -1630,7 +1667,7 @@ it "imports boilerplate file" do
1630
1667
  == Clause 1
1631
1668
 
1632
1669
  INPUT
1633
- <standard-document xmlns='https://www.metanorma.org/ns/standoc'>
1670
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
1634
1671
  <bibdata type='standard'>
1635
1672
  <title language='en' format='text/plain'>Document title</title>
1636
1673
  <language>en</language>
@@ -1669,12 +1706,28 @@ it "sorts symbols lists" do
1669
1706
  x_1_:: Definition 3
1670
1707
  x_m_:: Definition 4
1671
1708
  x:: Definition 5
1709
+ stem:[n]:: Definition 6
1710
+ m:: Definition 7
1672
1711
  INPUT
1673
1712
  #{BLANK_HDR}
1674
1713
  <sections>
1675
- <definitions id='L'>
1714
+ <definitions id='L' obligation="normative">
1676
1715
  <title>Symbols and abbreviated terms</title>
1677
1716
  <dl id='_'>
1717
+ <dt>m</dt>
1718
+ <dd>
1719
+ <p id='_'>Definition 7</p>
1720
+ </dd>
1721
+ <dt>
1722
+ <stem type='MathML'>
1723
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
1724
+ <mi>n</mi>
1725
+ </math>
1726
+ </stem>
1727
+ </dt>
1728
+ <dd>
1729
+ <p id='_'>Definition 6</p>
1730
+ </dd>
1678
1731
  <dt>x</dt>
1679
1732
  <dd>
1680
1733
  <p id='_'>Definition 5</p>
@@ -1717,7 +1770,7 @@ it "sorts symbols lists" do
1717
1770
  INPUT
1718
1771
  #{BLANK_HDR}
1719
1772
  <sections>
1720
- <definitions id='L'>
1773
+ <definitions id='L' obligation="normative">
1721
1774
  <title>Symbols and abbreviated terms</title>
1722
1775
  <dl id='_'>
1723
1776
  <dt>x</dt>
@@ -1727,8 +1780,12 @@ it "sorts symbols lists" do
1727
1780
  <dt><stem type='MathML'>
1728
1781
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
1729
1782
  <msub>
1730
- <mi>x</mi>
1731
- <mi>m</mi>
1783
+ <mrow>
1784
+ <mi>x</mi>
1785
+ </mrow>
1786
+ <mrow>
1787
+ <mi>m</mi>
1788
+ </mrow>
1732
1789
  </msub>
1733
1790
  </math>
1734
1791
  </stem></dt>
@@ -1738,8 +1795,12 @@ it "sorts symbols lists" do
1738
1795
  <dt><stem type='MathML'>
1739
1796
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
1740
1797
  <msub>
1741
- <mi>x</mi>
1742
- <mn>1</mn>
1798
+ <mrow>
1799
+ <mi>x</mi>
1800
+ </mrow>
1801
+ <mrow>
1802
+ <mn>1</mn>
1803
+ </mrow>
1743
1804
  </msub>
1744
1805
  </math>
1745
1806
  </stem></dt>
@@ -1872,6 +1933,9 @@ it "moves %beforeclause admonitions to right position" do
1872
1933
  INPUT
1873
1934
  #{BLANK_HDR}
1874
1935
  <preface>
1936
+ <note id='_'>
1937
+ <p id='_'>Note which is very important</p>
1938
+ </note>
1875
1939
  <foreword id='_' obligation='informative'>
1876
1940
  <title>Foreword</title>
1877
1941
  <p id='_'>Foreword</p>
@@ -1882,13 +1946,10 @@ INPUT
1882
1946
  </introduction>
1883
1947
  </preface>
1884
1948
  <sections>
1885
- <note id='_'>
1886
- <p id='_'>Note which is very important</p>
1887
- </note>
1888
1949
  <admonition id='_' type='important'>
1889
1950
  <p id='_'>Notice which is very important</p>
1890
1951
  </admonition>
1891
- <clause id='_' inline-header='false' obligation='normative'>
1952
+ <clause id='_' inline-header='false' obligation='normative' type="scope">
1892
1953
  <title>Scope</title>
1893
1954
  <p id='_'>Scope statement</p>
1894
1955
  </clause>
@@ -1899,6 +1960,1261 @@ OUTPUT
1899
1960
  end
1900
1961
 
1901
1962
 
1963
+ it "processes section names, with footnotes" do
1964
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1965
+ #{ASCIIDOC_BLANK_HDR}
1966
+ .Foreword.footnote:[A]
1967
+
1968
+ Text
1969
+
1970
+ [abstract]
1971
+ == Abstract.footnote:[A]
1972
+
1973
+ Text
1974
+
1975
+ [heading=introduction]
1976
+ == Introduction.footnote:[A]
1977
+
1978
+ === Introduction Subsection
1979
+
1980
+ [heading=acknowledgements]
1981
+ == Acknowledgements.footnote:[A]
1982
+
1983
+ [.preface]
1984
+ == Dedication
1985
+
1986
+ [heading=scope]
1987
+ == Scope.footnote:[A]
1988
+
1989
+ Text
1990
+
1991
+ [bibliography,heading=normative references]
1992
+ == Normative References.footnote:[A]
1993
+
1994
+ [bibliography,normative=true]
1995
+ == Normative References 2.footnote:[A]
1996
+
1997
+ [heading=terms and definitions]
1998
+ == Terms and Definitions.footnote:[A]
1999
+
2000
+ === Term1
2001
+
2002
+ [heading="terms and definitions"]
2003
+ == Terms, Definitions, Symbols and Abbreviated Terms.footnote:[A]
2004
+
2005
+ [.nonterm]
2006
+ === Introduction
2007
+
2008
+ ==== Intro 1
2009
+
2010
+ === Intro 2
2011
+
2012
+ [.nonterm]
2013
+ ==== Intro 3
2014
+
2015
+ === Intro 4
2016
+
2017
+ ==== Intro 5
2018
+
2019
+ ===== Term1
2020
+
2021
+ === Normal Terms
2022
+
2023
+ ==== Term2
2024
+
2025
+ [heading=symbols and abbreviated terms]
2026
+ === Symbols and Abbreviated Terms.footnote:[A]
2027
+
2028
+ [.nonterm]
2029
+ ==== General
2030
+
2031
+ [heading=symbols]
2032
+ ==== Symbols 1.footnote:[A]
2033
+
2034
+ [heading=abbreviated terms]
2035
+ == Abbreviated Terms.footnote:[A]
2036
+
2037
+ == Clause 4
2038
+
2039
+ === Introduction
2040
+
2041
+ === Clause 4.2
2042
+
2043
+ == Terms and Definitions
2044
+
2045
+ [appendix]
2046
+ == Annex.footnote:[A]
2047
+
2048
+ === Annex A.1
2049
+
2050
+ [bibliography,heading=bibliography]
2051
+ == Bibliography.footnote:[A]
2052
+
2053
+ [bibliography,normative=false]
2054
+ == Bibliography 2.footnote:[A]
2055
+
2056
+ === Bibliography Subsection
2057
+
2058
+ INPUT
2059
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
2060
+ <bibdata type='standard'>
2061
+ <title language='en' format='text/plain'>Document title</title>
2062
+ <language>en</language>
2063
+ <script>Latn</script>
2064
+ <abstract>
2065
+ <p>Text</p>
2066
+ </abstract>
2067
+ <status>
2068
+ <stage>published</stage>
2069
+ </status>
2070
+ <copyright>
2071
+ <from>2020</from>
2072
+ </copyright>
2073
+ <ext>
2074
+ <doctype>article</doctype>
2075
+ </ext>
2076
+ </bibdata>
2077
+ <preface>
2078
+ <abstract id='_'>
2079
+ <title>Abstract</title>
2080
+ <p id='_'>Text</p>
2081
+ </abstract>
2082
+ <foreword id='_' obligation='informative'>
2083
+ <title>
2084
+ Foreword
2085
+ <fn reference='1'>
2086
+ <p id='_'>A</p>
2087
+ </fn>
2088
+ </title>
2089
+ <p id='_'>Text</p>
2090
+ </foreword>
2091
+ <introduction id='_' obligation='informative'>
2092
+ <title>Introduction</title>
2093
+ <clause id='_' inline-header='false' obligation='informative'>
2094
+ <title>Introduction Subsection</title>
2095
+ </clause>
2096
+ </introduction>
2097
+ <clause id='_' inline-header='false' obligation='informative'>
2098
+ <title>Dedication</title>
2099
+ </clause>
2100
+ <acknowledgements id='_' obligation='informative'>
2101
+ <title>
2102
+ Acknowledgements
2103
+ <fn reference='1'>
2104
+ <p id='_'>A</p>
2105
+ </fn>
2106
+ </title>
2107
+ </acknowledgements>
2108
+ </preface>
2109
+ <sections>
2110
+ <clause id='_' type='scope' inline-header='false' obligation='normative'>
2111
+ <title>
2112
+ Scope
2113
+ <fn reference='1'>
2114
+ <p id='_'>A</p>
2115
+ </fn>
2116
+ </title>
2117
+ <p id='_'>Text</p>
2118
+ </clause>
2119
+ <terms id='_' obligation='normative'>
2120
+ <title>
2121
+ Terms and definitions
2122
+ <fn reference='1'>
2123
+ <p id='_'>A</p>
2124
+ </fn>
2125
+ </title>
2126
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
2127
+ <term id='_'>
2128
+ <preferred>Term1</preferred>
2129
+ </term>
2130
+ </terms>
2131
+ <clause id='_' inline-header='false' obligation='normative'>
2132
+ <title>
2133
+ Terms, Definitions, Symbols and Abbreviated Terms.
2134
+ <fn reference='1'>
2135
+ <p id='_'>A</p>
2136
+ </fn>
2137
+ </title>
2138
+ <clause id='_' inline-header='false' obligation='normative'>
2139
+ <title>Introduction</title>
2140
+ <clause id='_' inline-header='false' obligation='normative'>
2141
+ <title>Intro 1</title>
2142
+ </clause>
2143
+ </clause>
2144
+ <clause id='_' inline-header='false' obligation='normative'>
2145
+ <title>Intro 2</title>
2146
+ <clause id='_' inline-header='false' obligation='normative'>
2147
+ <title>Intro 3</title>
2148
+ </clause>
2149
+ </clause>
2150
+ <clause id='_' inline-header='false' obligation='normative'>
2151
+ <title>Intro 4</title>
2152
+ <clause id='_' inline-header='false' obligation='normative'>
2153
+ <title>Intro 5</title>
2154
+ <clause id='_' inline-header='false' obligation='normative'>
2155
+ <title>Term1</title>
2156
+ </clause>
2157
+ </clause>
2158
+ </clause>
2159
+ <clause id='_' inline-header='false' obligation='normative'>
2160
+ <title>Normal Terms</title>
2161
+ <clause id='_' inline-header='false' obligation='normative'>
2162
+ <title>Term2</title>
2163
+ </clause>
2164
+ </clause>
2165
+ <definitions id='_' obligation='normative'>
2166
+ <title>
2167
+ Symbols and abbreviated terms
2168
+ <fn reference='1'>
2169
+ <p id='_'>A</p>
2170
+ </fn>
2171
+ </title>
2172
+ <clause id='_' inline-header='false' obligation='normative'>
2173
+ <title>General</title>
2174
+ </clause>
2175
+ <definitions id='_' type='symbols' obligation='normative'>
2176
+ <title>
2177
+ Symbols
2178
+ <fn reference='1'>
2179
+ <p id='_'>A</p>
2180
+ </fn>
2181
+ </title>
2182
+ </definitions>
2183
+ </definitions>
2184
+ </clause>
2185
+ <definitions id='_' type='abbreviated_terms' obligation='normative'>
2186
+ <title>
2187
+ Abbreviated terms
2188
+ <fn reference='1'>
2189
+ <p id='_'>A</p>
2190
+ </fn>
2191
+ </title>
2192
+ </definitions>
2193
+ <clause id='_' inline-header='false' obligation='normative'>
2194
+ <title>Clause 4</title>
2195
+ <clause id='_' inline-header='false' obligation='normative'>
2196
+ <title>Introduction</title>
2197
+ </clause>
2198
+ <clause id='_' inline-header='false' obligation='normative'>
2199
+ <title>Clause 4.2</title>
2200
+ </clause>
2201
+ </clause>
2202
+ <clause id='_' inline-header='false' obligation='normative'>
2203
+ <title>Terms and Definitions</title>
2204
+ </clause>
2205
+ </sections>
2206
+ <annex id='_' inline-header='false' obligation='normative'>
2207
+ <title>
2208
+ Annex.
2209
+ <fn reference='1'>
2210
+ <p id='_'>A</p>
2211
+ </fn>
2212
+ </title>
2213
+ <clause id='_' inline-header='false' obligation='normative'>
2214
+ <title>Annex A.1</title>
2215
+ </clause>
2216
+ </annex>
2217
+ <bibliography>
2218
+ <references id='_' normative='true' obligation='informative'>
2219
+ <title>Normative references</title>
2220
+ <p id='_'>There are no normative references in this document.</p>
2221
+ </references>
2222
+ <references id='_' normative='false' obligation='informative'>
2223
+ <title>Bibliography</title>
2224
+ </references>
2225
+ <references id='_' normative='false' obligation='informative'>
2226
+ <title>Bibliography</title>
2227
+ </references>
2228
+ <clause id='_' obligation='informative'>
2229
+ <title>Bibliography</title>
2230
+ <references id='_' normative='false' obligation='informative'>
2231
+ <title>Bibliography Subsection</title>
2232
+ </references>
2233
+ </clause>
2234
+ </bibliography>
2235
+ </standard-document>
2236
+ OUTPUT
2237
+ end
2238
+
2239
+ it "processes section names, default to English" do
2240
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2241
+ #{ASCIIDOC_BLANK_HDR.sub(/:nodoc:/, ":language: tlh\n:script: Latn\n:nodoc:")}
2242
+ .Foreword
2243
+
2244
+ Text
2245
+
2246
+ [abstract]
2247
+ == Abstract
2248
+
2249
+ Text
2250
+
2251
+ [heading=introduction]
2252
+ == Introduction
2253
+
2254
+ === Introduction Subsection
2255
+
2256
+ [heading=acknowledgements]
2257
+ == Acknowledgements
2258
+
2259
+ [.preface]
2260
+ == Dedication
2261
+
2262
+ [heading=scope]
2263
+ == Scope
2264
+
2265
+ Text
2266
+
2267
+ [bibliography,heading=normative references]
2268
+ == Normative References
2269
+
2270
+ [bibliography,normative=true]
2271
+ == Normative References 2
2272
+
2273
+ [heading=terms and definitions]
2274
+ == Terms and Definitions
2275
+
2276
+ === Term1
2277
+
2278
+ [heading="terms and definitions"]
2279
+ == Terms, Definitions, Symbols and Abbreviated Terms
2280
+
2281
+ [.nonterm]
2282
+ === Introduction
2283
+
2284
+ ==== Intro 1
2285
+
2286
+ === Intro 2
2287
+
2288
+ [.nonterm]
2289
+ ==== Intro 3
2290
+
2291
+ === Intro 4
2292
+
2293
+ ==== Intro 5
2294
+
2295
+ ===== Term1
2296
+
2297
+ === Normal Terms
2298
+
2299
+ ==== Term2
2300
+
2301
+ [heading=symbols and abbreviated terms]
2302
+ === Symbols and Abbreviated Terms
2303
+
2304
+ [.nonterm]
2305
+ ==== General
2306
+
2307
+ [heading=symbols]
2308
+ ==== Symbols 1
2309
+
2310
+ [heading=abbreviated terms]
2311
+ == Abbreviated Terms
2312
+
2313
+ == Clause 4
2314
+
2315
+ === Introduction
2316
+
2317
+ === Clause 4.2
2318
+
2319
+ == Terms and Definitions
2320
+
2321
+ [appendix]
2322
+ == Annex
2323
+
2324
+ === Annex A.1
2325
+
2326
+ [bibliography,heading=bibliography]
2327
+ == Bibliography
2328
+
2329
+ [bibliography,normative=false]
2330
+ == Bibliography 2
2331
+
2332
+ === Bibliography Subsection
2333
+
2334
+ INPUT
2335
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
2336
+ <bibdata type='standard'>
2337
+ <title language='en' format='text/plain'>Document title</title>
2338
+ <language>tlh</language>
2339
+ <script>Latn</script>
2340
+ <abstract>
2341
+ <p>Text</p>
2342
+ </abstract>
2343
+ <status>
2344
+ <stage>published</stage>
2345
+ </status>
2346
+ <copyright>
2347
+ <from>2020</from>
2348
+ </copyright>
2349
+ <ext>
2350
+ <doctype>article</doctype>
2351
+ </ext>
2352
+ </bibdata>
2353
+ <preface>
2354
+ <abstract id='_'>
2355
+ <title>Abstract</title>
2356
+ <p id='_'>Text</p>
2357
+ </abstract>
2358
+ <foreword id='_' obligation='informative'>
2359
+ <title>Foreword</title>
2360
+ <p id='_'>Text</p>
2361
+ </foreword>
2362
+ <introduction id='_' obligation='informative'>
2363
+ <title>Introduction</title>
2364
+ <clause id='_' inline-header='false' obligation='informative'>
2365
+ <title>Introduction Subsection</title>
2366
+ </clause>
2367
+ </introduction>
2368
+ <clause id='_' inline-header='false' obligation='informative'>
2369
+ <title>Dedication</title>
2370
+ </clause>
2371
+ <acknowledgements id='_' obligation='informative'>
2372
+ <title>Acknowledgements</title>
2373
+ </acknowledgements>
2374
+ </preface>
2375
+ <sections>
2376
+ <clause id='_' type='scope' inline-header='false' obligation='normative'>
2377
+ <title>Scope</title>
2378
+ <p id='_'>Text</p>
2379
+ </clause>
2380
+ <terms id='_' obligation='normative'>
2381
+ <title>Terms and definitions</title>
2382
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
2383
+ <term id='_'>
2384
+ <preferred>Term1</preferred>
2385
+ </term>
2386
+ </terms>
2387
+ <clause id='_' inline-header='false' obligation='normative'>
2388
+ <title>Terms, Definitions, Symbols and Abbreviated Terms</title>
2389
+ <clause id='_' inline-header='false' obligation='normative'>
2390
+ <title>Introduction</title>
2391
+ <clause id='_' inline-header='false' obligation='normative'>
2392
+ <title>Intro 1</title>
2393
+ </clause>
2394
+ </clause>
2395
+ <clause id='_' inline-header='false' obligation='normative'>
2396
+ <title>Intro 2</title>
2397
+ <clause id='_' inline-header='false' obligation='normative'>
2398
+ <title>Intro 3</title>
2399
+ </clause>
2400
+ </clause>
2401
+ <clause id='_' inline-header='false' obligation='normative'>
2402
+ <title>Intro 4</title>
2403
+ <clause id='_' inline-header='false' obligation='normative'>
2404
+ <title>Intro 5</title>
2405
+ <clause id='_' inline-header='false' obligation='normative'>
2406
+ <title>Term1</title>
2407
+ </clause>
2408
+ </clause>
2409
+ </clause>
2410
+ <clause id='_' inline-header='false' obligation='normative'>
2411
+ <title>Normal Terms</title>
2412
+ <clause id='_' inline-header='false' obligation='normative'>
2413
+ <title>Term2</title>
2414
+ </clause>
2415
+ </clause>
2416
+ <definitions id='_' obligation='normative'>
2417
+ <title>Symbols and abbreviated terms</title>
2418
+ <clause id='_' inline-header='false' obligation='normative'>
2419
+ <title>General</title>
2420
+ </clause>
2421
+ <definitions id='_' type='symbols' obligation='normative'>
2422
+ <title>Symbols</title>
2423
+ </definitions>
2424
+ </definitions>
2425
+ </clause>
2426
+ <definitions id='_' type='abbreviated_terms' obligation='normative'>
2427
+ <title>Abbreviated terms</title>
2428
+ </definitions>
2429
+ <clause id='_' inline-header='false' obligation='normative'>
2430
+ <title>Clause 4</title>
2431
+ <clause id='_' inline-header='false' obligation='normative'>
2432
+ <title>Introduction</title>
2433
+ </clause>
2434
+ <clause id='_' inline-header='false' obligation='normative'>
2435
+ <title>Clause 4.2</title>
2436
+ </clause>
2437
+ </clause>
2438
+ <clause id='_' inline-header='false' obligation='normative'>
2439
+ <title>Terms and Definitions</title>
2440
+ </clause>
2441
+ </sections>
2442
+ <annex id='_' inline-header='false' obligation='normative'>
2443
+ <title>Annex</title>
2444
+ <clause id='_' inline-header='false' obligation='normative'>
2445
+ <title>Annex A.1</title>
2446
+ </clause>
2447
+ </annex>
2448
+ <bibliography>
2449
+ <references id='_' normative='true' obligation='informative'>
2450
+ <title>Normative references</title>
2451
+ <p id='_'>There are no normative references in this document.</p>
2452
+ </references>
2453
+ <references id='_' normative='false' obligation='informative'>
2454
+ <title>Bibliography</title>
2455
+ </references>
2456
+ <references id='_' normative='false' obligation='informative'>
2457
+ <title>Bibliography</title>
2458
+ </references>
2459
+ <clause id='_' obligation='informative'>
2460
+ <title>Bibliography</title>
2461
+ <references id='_' normative='false' obligation='informative'>
2462
+ <title>Bibliography Subsection</title>
2463
+ </references>
2464
+ </clause>
2465
+ </bibliography>
2466
+ </standard-document>
2467
+ OUTPUT
2468
+ end
2469
+
2470
+ it "processes section names, French" do
2471
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2472
+ #{ASCIIDOC_BLANK_HDR.sub(/:nodoc:/, ":language: fr\n:script: Latn\n:nodoc:")}
2473
+ .Foreword
2474
+
2475
+ Text
2476
+
2477
+ [abstract]
2478
+ == Abstract
2479
+
2480
+ Text
2481
+
2482
+ [heading=introduction]
2483
+ == Introduction
2484
+
2485
+ === Introduction Subsection
2486
+
2487
+ [heading=acknowledgements]
2488
+ == Acknowledgements
2489
+
2490
+ [.preface]
2491
+ == Dedication
2492
+
2493
+ [heading=scope]
2494
+ == Scope
2495
+
2496
+ Text
2497
+
2498
+ [bibliography,heading=normative references]
2499
+ == Normative References
2500
+
2501
+ [bibliography,normative=true]
2502
+ == Normative References 2
2503
+
2504
+ [heading=terms and definitions]
2505
+ == Terms and Definitions
2506
+
2507
+ === Term1
2508
+
2509
+ [heading="terms and definitions"]
2510
+ == Terms, Definitions, Symbols and Abbreviated Terms
2511
+
2512
+ [.nonterm]
2513
+ === Introduction
2514
+
2515
+ ==== Intro 1
2516
+
2517
+ === Intro 2
2518
+
2519
+ [.nonterm]
2520
+ ==== Intro 3
2521
+
2522
+ === Intro 4
2523
+
2524
+ ==== Intro 5
2525
+
2526
+ ===== Term1
2527
+
2528
+ === Normal Terms
2529
+
2530
+ ==== Term2
2531
+
2532
+ [heading=symbols and abbreviated terms]
2533
+ === Symbols and Abbreviated Terms
2534
+
2535
+ [.nonterm]
2536
+ ==== General
2537
+
2538
+ [heading=symbols]
2539
+ ==== Symbols 1
2540
+
2541
+ [heading=abbreviated terms]
2542
+ == Abbreviated Terms
2543
+
2544
+ == Clause 4
2545
+
2546
+ === Introduction
2547
+
2548
+ === Clause 4.2
2549
+
2550
+ == Terms and Definitions
2551
+
2552
+ [appendix]
2553
+ == Annex
2554
+
2555
+ === Annex A.1
2556
+
2557
+ [bibliography,heading=bibliography]
2558
+ == Bibliography
2559
+
2560
+ [bibliography,normative=false]
2561
+ == Bibliography 2
2562
+
2563
+ === Bibliography Subsection
2564
+
2565
+ INPUT
2566
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
2567
+ <bibdata type='standard'>
2568
+ <title language='en' format='text/plain'>Document title</title>
2569
+ <language>fr</language>
2570
+ <script>Latn</script>
2571
+ <abstract>
2572
+ <p>Text</p>
2573
+ </abstract>
2574
+ <status>
2575
+ <stage>published</stage>
2576
+ </status>
2577
+ <copyright>
2578
+ <from>2020</from>
2579
+ </copyright>
2580
+ <ext>
2581
+ <doctype>article</doctype>
2582
+ </ext>
2583
+ </bibdata>
2584
+ <preface>
2585
+ <abstract id='_'>
2586
+ <title>Résumé</title>
2587
+ <p id='_'>Text</p>
2588
+ </abstract>
2589
+ <foreword id='_' obligation='informative'>
2590
+ <title>Avant-propos</title>
2591
+ <p id='_'>Text</p>
2592
+ </foreword>
2593
+ <introduction id='_' obligation='informative'>
2594
+ <title>Introduction</title>
2595
+ <clause id='_' inline-header='false' obligation='informative'>
2596
+ <title>Introduction Subsection</title>
2597
+ </clause>
2598
+ </introduction>
2599
+ <clause id='_' inline-header='false' obligation='informative'>
2600
+ <title>Dedication</title>
2601
+ </clause>
2602
+ <acknowledgements id='_' obligation='informative'>
2603
+ <title>Remerciements</title>
2604
+ </acknowledgements>
2605
+ </preface>
2606
+ <sections>
2607
+ <clause id='_' type='scope' inline-header='false' obligation='normative'>
2608
+ <title>Domaine d’application</title>
2609
+ <p id='_'>Text</p>
2610
+ </clause>
2611
+ <terms id='_' obligation='normative'>
2612
+ <title>Terms et définitions</title>
2613
+ <p id='_'>
2614
+ Pour les besoins du présent document, les termes et définitions suivants
2615
+ s’appliquent.
2616
+ </p>
2617
+ <term id='_'>
2618
+ <preferred>Term1</preferred>
2619
+ </term>
2620
+ </terms>
2621
+ <clause id='_' inline-header='false' obligation='normative'>
2622
+ <title>Terms, Definitions, Symbols and Abbreviated Terms</title>
2623
+ <clause id='_' inline-header='false' obligation='normative'>
2624
+ <title>Introduction</title>
2625
+ <clause id='_' inline-header='false' obligation='normative'>
2626
+ <title>Intro 1</title>
2627
+ </clause>
2628
+ </clause>
2629
+ <clause id='_' inline-header='false' obligation='normative'>
2630
+ <title>Intro 2</title>
2631
+ <clause id='_' inline-header='false' obligation='normative'>
2632
+ <title>Intro 3</title>
2633
+ </clause>
2634
+ </clause>
2635
+ <clause id='_' inline-header='false' obligation='normative'>
2636
+ <title>Intro 4</title>
2637
+ <clause id='_' inline-header='false' obligation='normative'>
2638
+ <title>Intro 5</title>
2639
+ <clause id='_' inline-header='false' obligation='normative'>
2640
+ <title>Term1</title>
2641
+ </clause>
2642
+ </clause>
2643
+ </clause>
2644
+ <clause id='_' inline-header='false' obligation='normative'>
2645
+ <title>Normal Terms</title>
2646
+ <clause id='_' inline-header='false' obligation='normative'>
2647
+ <title>Term2</title>
2648
+ </clause>
2649
+ </clause>
2650
+ <definitions id='_' obligation='normative'>
2651
+ <title>Symboles et termes abrégés</title>
2652
+ <clause id='_' inline-header='false' obligation='normative'>
2653
+ <title>General</title>
2654
+ </clause>
2655
+ <definitions id='_' type='symbols' obligation='normative'>
2656
+ <title>Symboles</title>
2657
+ </definitions>
2658
+ </definitions>
2659
+ </clause>
2660
+ <definitions id='_' type='abbreviated_terms' obligation='normative'>
2661
+ <title>Termes abrégés</title>
2662
+ </definitions>
2663
+ <clause id='_' inline-header='false' obligation='normative'>
2664
+ <title>Clause 4</title>
2665
+ <clause id='_' inline-header='false' obligation='normative'>
2666
+ <title>Introduction</title>
2667
+ </clause>
2668
+ <clause id='_' inline-header='false' obligation='normative'>
2669
+ <title>Clause 4.2</title>
2670
+ </clause>
2671
+ </clause>
2672
+ <clause id='_' inline-header='false' obligation='normative'>
2673
+ <title>Terms and Definitions</title>
2674
+ </clause>
2675
+ </sections>
2676
+ <annex id='_' inline-header='false' obligation='normative'>
2677
+ <title>Annex</title>
2678
+ <clause id='_' inline-header='false' obligation='normative'>
2679
+ <title>Annex A.1</title>
2680
+ </clause>
2681
+ </annex>
2682
+ <bibliography>
2683
+ <references id='_' normative='true' obligation='informative'>
2684
+ <title>Références normatives</title>
2685
+ <p id='_'>Le présent document ne contient aucune référence normative.</p>
2686
+ </references>
2687
+ <references id='_' normative='false' obligation='informative'>
2688
+ <title>Bibliographie</title>
2689
+ </references>
2690
+ <references id='_' normative='false' obligation='informative'>
2691
+ <title>Bibliography</title>
2692
+ </references>
2693
+ <clause id='_' obligation='informative'>
2694
+ <title>Bibliography</title>
2695
+ <references id='_' normative='false' obligation='informative'>
2696
+ <title>Bibliography Subsection</title>
2697
+ </references>
2698
+ </clause>
2699
+ </bibliography>
2700
+ </standard-document>
2701
+ OUTPUT
2702
+ end
2703
+
2704
+ it "processes section names, Simplified Chinese" do
2705
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2706
+ #{ASCIIDOC_BLANK_HDR.sub(/:nodoc:/, ":language: zh\n:script: Hans\n:nodoc:")}
2707
+ .Foreword
2708
+
2709
+ Text
2710
+
2711
+ [abstract]
2712
+ == Abstract
2713
+
2714
+ Text
2715
+
2716
+ [heading=introduction]
2717
+ == Introduction
2718
+
2719
+ === Introduction Subsection
2720
+
2721
+ [heading=acknowledgements]
2722
+ == Acknowledgements
2723
+
2724
+ [.preface]
2725
+ == Dedication
2726
+
2727
+ [heading=scope]
2728
+ == Scope
2729
+
2730
+ Text
2731
+
2732
+ [bibliography,heading=normative references]
2733
+ == Normative References
2734
+
2735
+ [bibliography,normative=true]
2736
+ == Normative References 2
2737
+
2738
+ [heading=terms and definitions]
2739
+ == Terms and Definitions
2740
+
2741
+ === Term1
2742
+
2743
+ [heading="terms and definitions"]
2744
+ == Terms, Definitions, Symbols and Abbreviated Terms
2745
+
2746
+ [.nonterm]
2747
+ === Introduction
2748
+
2749
+ ==== Intro 1
2750
+
2751
+ === Intro 2
2752
+
2753
+ [.nonterm]
2754
+ ==== Intro 3
2755
+
2756
+ === Intro 4
2757
+
2758
+ ==== Intro 5
2759
+
2760
+ ===== Term1
2761
+
2762
+ === Normal Terms
2763
+
2764
+ ==== Term2
2765
+
2766
+ [heading=symbols and abbreviated terms]
2767
+ === Symbols and Abbreviated Terms
2768
+
2769
+ [.nonterm]
2770
+ ==== General
2771
+
2772
+ [heading=symbols]
2773
+ ==== Symbols 1
2774
+
2775
+ [heading=abbreviated terms]
2776
+ == Abbreviated Terms
2777
+
2778
+ == Clause 4
2779
+
2780
+ === Introduction
2781
+
2782
+ === Clause 4.2
2783
+
2784
+ == Terms and Definitions
2785
+
2786
+ [appendix]
2787
+ == Annex
2788
+
2789
+ === Annex A.1
2790
+
2791
+ [bibliography,heading=bibliography]
2792
+ == Bibliography
2793
+
2794
+ [bibliography,normative=false]
2795
+ == Bibliography 2
2796
+
2797
+ === Bibliography Subsection
2798
+
2799
+ INPUT
2800
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
2801
+ <bibdata type='standard'>
2802
+ <title language='en' format='text/plain'>Document title</title>
2803
+ <language>zh</language>
2804
+ <script>Hans</script>
2805
+ <abstract>
2806
+ <p>Text</p>
2807
+ </abstract>
2808
+ <status>
2809
+ <stage>published</stage>
2810
+ </status>
2811
+ <copyright>
2812
+ <from>2020</from>
2813
+ </copyright>
2814
+ <ext>
2815
+ <doctype>article</doctype>
2816
+ </ext>
2817
+ </bibdata>
2818
+ <preface>
2819
+ <abstract id='_'>
2820
+ <title>摘要</title>
2821
+ <p id='_'>Text</p>
2822
+ </abstract>
2823
+ <foreword id='_' obligation='informative'>
2824
+ <title>前言</title>
2825
+ <p id='_'>Text</p>
2826
+ </foreword>
2827
+ <introduction id='_' obligation='informative'>
2828
+ <title>引言</title>
2829
+ <clause id='_' inline-header='false' obligation='informative'>
2830
+ <title>Introduction Subsection</title>
2831
+ </clause>
2832
+ </introduction>
2833
+ <clause id='_' inline-header='false' obligation='informative'>
2834
+ <title>Dedication</title>
2835
+ </clause>
2836
+ <acknowledgements id='_' obligation='informative'>
2837
+ <title>致謝</title>
2838
+ </acknowledgements>
2839
+ </preface>
2840
+ <sections>
2841
+ <clause id='_' type='scope' inline-header='false' obligation='normative'>
2842
+ <title>范围</title>
2843
+ <p id='_'>Text</p>
2844
+ </clause>
2845
+ <terms id='_' obligation='normative'>
2846
+ <title>术语和定义</title>
2847
+ <p id='_'>下列术语和定义适用于本文件。</p>
2848
+ <term id='_'>
2849
+ <preferred>Term1</preferred>
2850
+ </term>
2851
+ </terms>
2852
+ <clause id='_' inline-header='false' obligation='normative'>
2853
+ <title>Terms, Definitions, Symbols and Abbreviated Terms</title>
2854
+ <clause id='_' inline-header='false' obligation='normative'>
2855
+ <title>Introduction</title>
2856
+ <clause id='_' inline-header='false' obligation='normative'>
2857
+ <title>Intro 1</title>
2858
+ </clause>
2859
+ </clause>
2860
+ <clause id='_' inline-header='false' obligation='normative'>
2861
+ <title>Intro 2</title>
2862
+ <clause id='_' inline-header='false' obligation='normative'>
2863
+ <title>Intro 3</title>
2864
+ </clause>
2865
+ </clause>
2866
+ <clause id='_' inline-header='false' obligation='normative'>
2867
+ <title>Intro 4</title>
2868
+ <clause id='_' inline-header='false' obligation='normative'>
2869
+ <title>Intro 5</title>
2870
+ <clause id='_' inline-header='false' obligation='normative'>
2871
+ <title>Term1</title>
2872
+ </clause>
2873
+ </clause>
2874
+ </clause>
2875
+ <clause id='_' inline-header='false' obligation='normative'>
2876
+ <title>Normal Terms</title>
2877
+ <clause id='_' inline-header='false' obligation='normative'>
2878
+ <title>Term2</title>
2879
+ </clause>
2880
+ </clause>
2881
+ <definitions id='_' obligation='normative'>
2882
+ <title>符号、代号和缩略语</title>
2883
+ <clause id='_' inline-header='false' obligation='normative'>
2884
+ <title>General</title>
2885
+ </clause>
2886
+ <definitions id='_' type='symbols' obligation='normative'>
2887
+ <title>符号</title>
2888
+ </definitions>
2889
+ </definitions>
2890
+ </clause>
2891
+ <definitions id='_' type='abbreviated_terms' obligation='normative'>
2892
+ <title>代号和缩略语</title>
2893
+ </definitions>
2894
+ <clause id='_' inline-header='false' obligation='normative'>
2895
+ <title>Clause 4</title>
2896
+ <clause id='_' inline-header='false' obligation='normative'>
2897
+ <title>Introduction</title>
2898
+ </clause>
2899
+ <clause id='_' inline-header='false' obligation='normative'>
2900
+ <title>Clause 4.2</title>
2901
+ </clause>
2902
+ </clause>
2903
+ <clause id='_' inline-header='false' obligation='normative'>
2904
+ <title>Terms and Definitions</title>
2905
+ </clause>
2906
+ </sections>
2907
+ <annex id='_' inline-header='false' obligation='normative'>
2908
+ <title>Annex</title>
2909
+ <clause id='_' inline-header='false' obligation='normative'>
2910
+ <title>Annex A.1</title>
2911
+ </clause>
2912
+ </annex>
2913
+ <bibliography>
2914
+ <references id='_' normative='true' obligation='informative'>
2915
+ <title>规范性引用文件</title>
2916
+ <p id='_'>本文件并没有规范性引用文件。</p>
2917
+ </references>
2918
+ <references id='_' normative='false' obligation='informative'>
2919
+ <title>参考文献</title>
2920
+ </references>
2921
+ <references id='_' normative='false' obligation='informative'>
2922
+ <title>Bibliography</title>
2923
+ </references>
2924
+ <clause id='_' obligation='informative'>
2925
+ <title>Bibliography</title>
2926
+ <references id='_' normative='false' obligation='informative'>
2927
+ <title>Bibliography Subsection</title>
2928
+ </references>
2929
+ </clause>
2930
+ </bibliography>
2931
+ </standard-document>
2932
+ OUTPUT
2933
+ end
2934
+
2935
+ it "processes section names, internationalisation file" do
2936
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2937
+ #{ASCIIDOC_BLANK_HDR.sub(/:nodoc:/, ":i18nyaml: spec/assets/i18n.yaml")}
2938
+ .Foreword
2939
+
2940
+ Text
2941
+
2942
+ [abstract]
2943
+ == Abstract
2944
+
2945
+ Text
2946
+
2947
+ [heading=introduction]
2948
+ == Introduction
2949
+
2950
+ === Introduction Subsection
2951
+
2952
+ [heading=acknowledgements]
2953
+ == Acknowledgements
2954
+
2955
+ [.preface]
2956
+ == Dedication
2957
+
2958
+ [heading=scope]
2959
+ == Scope
2960
+
2961
+ Text
2962
+
2963
+ [bibliography,heading=normative references]
2964
+ == Normative References
2965
+
2966
+ [bibliography,normative=true]
2967
+ == Normative References 2
2968
+
2969
+ [heading=terms and definitions]
2970
+ == Terms and Definitions
2971
+
2972
+ === Term1
2973
+
2974
+ [heading="terms and definitions"]
2975
+ == Terms, Definitions, Symbols and Abbreviated Terms
2976
+
2977
+ [.nonterm]
2978
+ === Introduction
2979
+
2980
+ ==== Intro 1
2981
+
2982
+ === Intro 2
2983
+
2984
+ [.nonterm]
2985
+ ==== Intro 3
2986
+
2987
+ === Intro 4
2988
+
2989
+ ==== Intro 5
2990
+
2991
+ ===== Term1
2992
+
2993
+ === Normal Terms
2994
+
2995
+ ==== Term2
2996
+
2997
+ [heading=symbols and abbreviated terms]
2998
+ === Symbols and Abbreviated Terms
2999
+
3000
+ [.nonterm]
3001
+ ==== General
3002
+
3003
+ [heading=symbols]
3004
+ ==== Symbols 1
3005
+
3006
+ [heading=abbreviated terms]
3007
+ == Abbreviated Terms
3008
+
3009
+ == Clause 4
3010
+
3011
+ === Introduction
3012
+
3013
+ === Clause 4.2
3014
+
3015
+ == Terms and Definitions
3016
+
3017
+ [appendix]
3018
+ == Annex
3019
+
3020
+ === Annex A.1
3021
+
3022
+ [bibliography,heading=bibliography]
3023
+ == Bibliography
3024
+
3025
+ [bibliography,normative=false]
3026
+ == Bibliography 2
3027
+
3028
+ === Bibliography Subsection
3029
+
3030
+ INPUT
3031
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
3032
+ <bibdata type='standard'>
3033
+ <title language='en' format='text/plain'>Document title</title>
3034
+ <language>en</language>
3035
+ <script>Latn</script>
3036
+ <abstract>
3037
+ <p>Text</p>
3038
+ </abstract>
3039
+ <status>
3040
+ <stage>published</stage>
3041
+ </status>
3042
+ <copyright>
3043
+ <from>2020</from>
3044
+ </copyright>
3045
+ <ext>
3046
+ <doctype>article</doctype>
3047
+ </ext>
3048
+ </bibdata>
3049
+ <preface>
3050
+ <abstract id='_'>
3051
+ <title>Abstract</title>
3052
+ <p id='_'>Text</p>
3053
+ </abstract>
3054
+ <foreword id='_' obligation='informative'>
3055
+ <title>Antaŭparolo</title>
3056
+ <p id='_'>Text</p>
3057
+ </foreword>
3058
+ <introduction id='_' obligation='informative'>
3059
+ <title>Enkonduko</title>
3060
+ <clause id='_' inline-header='false' obligation='informative'>
3061
+ <title>Introduction Subsection</title>
3062
+ </clause>
3063
+ </introduction>
3064
+ <clause id='_' inline-header='false' obligation='informative'>
3065
+ <title>Dedication</title>
3066
+ </clause>
3067
+ <acknowledgements id='_' obligation='informative'>
3068
+ <title>Acknowledgements</title>
3069
+ </acknowledgements>
3070
+ </preface>
3071
+ <sections>
3072
+ <clause id='_' type='scope' inline-header='false' obligation='normative'>
3073
+ <title>Amplekso</title>
3074
+ <p id='_'>Text</p>
3075
+ </clause>
3076
+ <terms id='_' obligation='normative'>
3077
+ <title>Terms and definitions</title>
3078
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
3079
+ <term id='_'>
3080
+ <preferred>Term1</preferred>
3081
+ </term>
3082
+ </terms>
3083
+ <clause id='_' inline-header='false' obligation='normative'>
3084
+ <title>Terms, Definitions, Symbols and Abbreviated Terms</title>
3085
+ <clause id='_' inline-header='false' obligation='normative'>
3086
+ <title>Introduction</title>
3087
+ <clause id='_' inline-header='false' obligation='normative'>
3088
+ <title>Intro 1</title>
3089
+ </clause>
3090
+ </clause>
3091
+ <clause id='_' inline-header='false' obligation='normative'>
3092
+ <title>Intro 2</title>
3093
+ <clause id='_' inline-header='false' obligation='normative'>
3094
+ <title>Intro 3</title>
3095
+ </clause>
3096
+ </clause>
3097
+ <clause id='_' inline-header='false' obligation='normative'>
3098
+ <title>Intro 4</title>
3099
+ <clause id='_' inline-header='false' obligation='normative'>
3100
+ <title>Intro 5</title>
3101
+ <clause id='_' inline-header='false' obligation='normative'>
3102
+ <title>Term1</title>
3103
+ </clause>
3104
+ </clause>
3105
+ </clause>
3106
+ <clause id='_' inline-header='false' obligation='normative'>
3107
+ <title>Normal Terms</title>
3108
+ <clause id='_' inline-header='false' obligation='normative'>
3109
+ <title>Term2</title>
3110
+ </clause>
3111
+ </clause>
3112
+ <definitions id='_' obligation='normative'>
3113
+ <title>Symbols and abbreviated terms</title>
3114
+ <clause id='_' inline-header='false' obligation='normative'>
3115
+ <title>General</title>
3116
+ </clause>
3117
+ <definitions id='_' type='symbols' obligation='normative'>
3118
+ <title>Simboloj kai mallongigitaj terminoj</title>
3119
+ </definitions>
3120
+ </definitions>
3121
+ </clause>
3122
+ <definitions id='_' type='abbreviated_terms' obligation='normative'>
3123
+ <title>Abbreviated terms</title>
3124
+ </definitions>
3125
+ <clause id='_' inline-header='false' obligation='normative'>
3126
+ <title>Clause 4</title>
3127
+ <clause id='_' inline-header='false' obligation='normative'>
3128
+ <title>Introduction</title>
3129
+ </clause>
3130
+ <clause id='_' inline-header='false' obligation='normative'>
3131
+ <title>Clause 4.2</title>
3132
+ </clause>
3133
+ </clause>
3134
+ <clause id='_' inline-header='false' obligation='normative'>
3135
+ <title>Terms and Definitions</title>
3136
+ </clause>
3137
+ </sections>
3138
+ <annex id='_' inline-header='false' obligation='normative'>
3139
+ <title>Annex</title>
3140
+ <clause id='_' inline-header='false' obligation='normative'>
3141
+ <title>Annex A.1</title>
3142
+ </clause>
3143
+ </annex>
3144
+ <bibliography>
3145
+ <references id='_' normative='true' obligation='informative'>
3146
+ <title>Normaj citaĵoj</title>
3147
+ <p id='_'>There are no normative references in this document.</p>
3148
+ </references>
3149
+ <references id='_' normative='false' obligation='informative'>
3150
+ <title>Bibliografio</title>
3151
+ </references>
3152
+ <references id='_' normative='false' obligation='informative'>
3153
+ <title>Bibliography</title>
3154
+ </references>
3155
+ <clause id='_' obligation='informative'>
3156
+ <title>Bibliography</title>
3157
+ <references id='_' normative='false' obligation='informative'>
3158
+ <title>Bibliography Subsection</title>
3159
+ </references>
3160
+ </clause>
3161
+ </bibliography>
3162
+ </standard-document>
3163
+ OUTPUT
3164
+ end
3165
+
3166
+ it "fixes illegal anchors" do
3167
+ input = <<~INPUT
3168
+ #{ASCIIDOC_BLANK_HDR}
3169
+
3170
+ [[a:b]]
3171
+ == A
3172
+ <</:ab>>
3173
+ <<:>>
3174
+ <<1>>
3175
+ <<1:>>
3176
+ <<1#b>>
3177
+ <<:a#b:>>
3178
+
3179
+ INPUT
3180
+ expect(xmlpp(Asciidoctor.convert(input, backend: :standoc, header_footer: true).gsub(/<p id="_[^"]+">/, "").gsub('</p>', ""))).to be_equivalent_to (<<~"OUTPUT")
3181
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
3182
+ <bibdata type='standard'>
3183
+ <title language='en' format='text/plain'>Document title</title>
3184
+ <language>en</language>
3185
+ <script>Latn</script>
3186
+ <status>
3187
+ <stage>published</stage>
3188
+ </status>
3189
+ <copyright>
3190
+ <from>2020</from>
3191
+ </copyright>
3192
+ <ext>
3193
+ <doctype>article</doctype>
3194
+ </ext>
3195
+ </bibdata>
3196
+ <sections>
3197
+ <clause id='a_b' inline-header='false' obligation='normative'>
3198
+ <title>A</title>
3199
+ <xref target='__ab'/>
3200
+ <xref target='_'/>
3201
+ <xref target='_1'/>
3202
+ <xref target='_1_'/>
3203
+ <xref target='1#b'/>
3204
+ <xref target='_a#b_'/>
3205
+ </clause>
3206
+ </sections>
3207
+ </standard-document>
3208
+ OUTPUT
3209
+ expect{Asciidoctor.convert(input, backend: :standoc, header_footer: true)}.to output(%r{normalised identifier in <clause id="a_b" inline-header="false" obligation="normative"/> from a:b}).to_stderr
3210
+ expect{Asciidoctor.convert(input, backend: :standoc, header_footer: true)}.to output(%r{normalised identifier in <xref target="__ab"/> from /:ab}).to_stderr
3211
+ expect{Asciidoctor.convert(input, backend: :standoc, header_footer: true)}.to output(%r{normalised identifier in <xref target="_"/> from :}).to_stderr
3212
+ expect{Asciidoctor.convert(input, backend: :standoc, header_footer: true)}.to output(%r{normalised identifier in <xref target="_1"/> from 1}).to_stderr
3213
+ expect{Asciidoctor.convert(input, backend: :standoc, header_footer: true)}.to output(%r{normalised identifier in <xref target="_1_"/> from 1:}).to_stderr
3214
+ expect{Asciidoctor.convert(input, backend: :standoc, header_footer: true)}.to output(%r{normalised identifier in <xref target="_a#b_"/> from :a#b:}).to_stderr
3215
+ end
3216
+
3217
+
1902
3218
  private
1903
3219
 
1904
3220
  def mock_iecbib_get_iec60050_103_01