isodoc 1.6.7 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +1 -1
  3. data/lib/isodoc-yaml/i18n-ar.yaml +19 -25
  4. data/lib/isodoc-yaml/i18n-de.yaml +1 -0
  5. data/lib/isodoc-yaml/i18n-en.yaml +1 -0
  6. data/lib/isodoc-yaml/i18n-es.yaml +1 -0
  7. data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
  8. data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
  9. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
  10. data/lib/isodoc.rb +1 -0
  11. data/lib/isodoc/convert.rb +1 -1
  12. data/lib/isodoc/function/blocks.rb +180 -168
  13. data/lib/isodoc/function/form.rb +39 -36
  14. data/lib/isodoc/function/inline.rb +5 -1
  15. data/lib/isodoc/function/references.rb +1 -1
  16. data/lib/isodoc/function/to_word_html.rb +206 -204
  17. data/lib/isodoc/html_convert.rb +0 -4
  18. data/lib/isodoc/html_function/form.rb +48 -45
  19. data/lib/isodoc/html_function/html.rb +2 -0
  20. data/lib/isodoc/html_function/postprocess.rb +9 -4
  21. data/lib/isodoc/presentation_function/block.rb +7 -4
  22. data/lib/isodoc/presentation_function/inline.rb +29 -12
  23. data/lib/isodoc/presentation_function/section.rb +1 -2
  24. data/lib/isodoc/presentation_xml_convert.rb +2 -2
  25. data/lib/isodoc/version.rb +1 -1
  26. data/lib/isodoc/xref.rb +8 -7
  27. data/lib/isodoc/xref/xref_anchor.rb +45 -44
  28. data/lib/isodoc/xref/xref_counter.rb +113 -103
  29. data/lib/isodoc/xref/xref_gen.rb +39 -11
  30. data/lib/metanorma/output.rb +7 -0
  31. data/lib/metanorma/output/base.rb +13 -0
  32. data/lib/metanorma/output/utils.rb +17 -0
  33. data/lib/metanorma/output/xslfo.rb +21 -0
  34. data/spec/assets/outputtest/a.xml +66 -0
  35. data/spec/assets/outputtest/iso.international-standard.xsl +3011 -0
  36. data/spec/isodoc/blocks_spec.rb +327 -243
  37. data/spec/isodoc/form_spec.rb +94 -90
  38. data/spec/isodoc/inline_spec.rb +431 -234
  39. data/spec/isodoc/postproc_spec.rb +68 -25
  40. data/spec/isodoc/terms_spec.rb +2 -2
  41. data/spec/isodoc/xref_spec.rb +274 -652
  42. metadata +8 -18
  43. data/lib/isodoc/html_function/sectionsplit.rb +0 -230
  44. data/spec/isodoc/sectionsplit_spec.rb +0 -190
@@ -1535,7 +1535,7 @@ RSpec.describe IsoDoc do
1535
1535
  end
1536
1536
 
1537
1537
  it "processes term domains" do
1538
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1538
+ input = <<~INPUT
1539
1539
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1540
1540
  <sections>
1541
1541
  <terms>
@@ -1547,6 +1547,7 @@ RSpec.describe IsoDoc do
1547
1547
  </sections>
1548
1548
  </iso-standard>
1549
1549
  INPUT
1550
+ output = <<~OUTPUT
1550
1551
  #{HTML_HDR}
1551
1552
  <p class="zzSTDTitle1"/>
1552
1553
  <div><h1/>
@@ -1558,6 +1559,8 @@ RSpec.describe IsoDoc do
1558
1559
  </body>
1559
1560
  </html>
1560
1561
  OUTPUT
1562
+ expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", input, true)))
1563
+ .to be_equivalent_to xmlpp(output)
1561
1564
  end
1562
1565
 
1563
1566
  it "processes permissions" do
@@ -1617,109 +1620,111 @@ RSpec.describe IsoDoc do
1617
1620
  </iso-standard>
1618
1621
  INPUT
1619
1622
  presxml = <<~OUTPUT
1620
- <iso-standard xmlns="http://riboseinc.com/isoxml" type='presentation'>
1621
- <preface><foreword displayorder='1'>
1622
- <permission id="_" keep-with-next="true" keep-lines-together="true">
1623
- <name>Permission 1</name>
1624
- <label>/ogc/recommendation/wfs/2</label>
1625
- <inherit>/ss/584/2015/level/1</inherit>
1626
- <inherit><eref type="inline" bibitemid="rfc2616" citeas="RFC 2616">RFC 2616 (HTTP/1.1)</eref></inherit>
1627
- <subject>user</subject>
1628
- <classification> <tag>control-class</tag> <value>Technical</value> </classification><classification> <tag>priority</tag> <value>P0</value> </classification><classification> <tag>family</tag> <value>System and Communications Protection</value> </classification><classification> <tag>family</tag> <value>System and Communications Protocols</value> </classification>
1629
- <description>
1630
- <p id="_">I recommend <em>this</em>.</p>
1631
- </description>
1632
- <specification exclude="true" type="tabular">
1633
- <p id="_">This is the object of the recommendation:</p>
1634
- <table id="_">
1635
- <tbody>
1636
- <tr>
1637
- <td style="text-align:left;">Object</td>
1638
- <td style="text-align:left;">Value</td>
1639
- </tr>
1640
- <tr>
1641
- <td style="text-align:left;">Mission</td>
1642
- <td style="text-align:left;">Accomplished</td>
1643
- </tr>
1644
- </tbody>
1645
- </table>
1646
- </specification>
1647
- <description>
1648
- <p id="_">As for the measurement targets,</p>
1649
- </description>
1650
- <measurement-target exclude="false">
1651
- <p id="_">The measurement target shall be measured as:</p>
1652
- <formula id="_">
1653
- <name>1</name>
1654
- <stem type="AsciiMath">r/1 = 0</stem>
1655
- </formula>
1656
- </measurement-target>
1657
- <verification exclude="false">
1658
- <p id="_">The following code will be run for verification:</p>
1659
- <sourcecode id="_">CoreRoot(success): HttpResponse
1660
- if (success)
1661
- recommendation(label: success-response)
1662
- end
1663
- </sourcecode>
1664
- </verification>
1665
- <import exclude="true">
1666
- <sourcecode id="_">success-response()</sourcecode>
1667
- </import>
1668
- </permission>
1669
- </foreword></preface>
1670
- <bibliography><references id="_bibliography" obligation="informative" normative="false" displayorder='2'>
1671
- <title depth='1'>Bibliography</title>
1672
- <bibitem id="rfc2616" type="standard"> <fetched>2020-03-27</fetched> <title format="text/plain" language="en" script="Latn">Hypertext Transfer Protocol — HTTP/1.1</title> <uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2616.xml</uri> <uri type="src">https://www.rfc-editor.org/info/rfc2616</uri> <docidentifier type="IETF">IETF RFC 2616</docidentifier> <docidentifier type="rfc-anchor">RFC2616</docidentifier> <docidentifier type="DOI">DOI 10.17487/RFC2616</docidentifier> <date type="published"> <on>1999-06</on> </date> <contributor> <role type="author"/> <person> <name> <completename language="en">R. Fielding</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Gettys</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Mogul</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">H. Frystyk</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">L. Masinter</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">P. Leach</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">T. Berners-Lee</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <language>en</language> <script>Latn</script> <abstract format="text/plain" language="en" script="Latn">HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as “HTTP/1.1”, and is an update to RFC 2068. [STANDARDS-TRACK]</abstract> <series type="main"> <title format="text/plain" language="en" script="Latn">RFC</title> <number>2616</number> </series> <place>Fremont, CA</place></bibitem>
1673
- </references></bibliography>
1674
- </iso-standard>
1675
- OUTPUT
1676
- html = <<~OUTPUT
1677
- #{HTML_HDR}
1678
- <br/>
1679
- <div>
1680
- <h1 class="ForewordTitle">Foreword</h1>
1681
- <div class="permission" id='_' style='page-break-after: avoid;page-break-inside: avoid;'>
1682
- <p class="RecommendationTitle">Permission 1:<br/>/ogc/recommendation/wfs/2</p>
1683
- <p><i>Subject: user<br/>
1684
- Inherits: /ss/584/2015/level/1
1685
- <br/>
1686
- Inherits: <a href='#rfc2616'>RFC 2616 (HTTP/1.1)</a>
1687
- <br/>Control-class: Technical<br/>Priority: P0<br/>Family: System and Communications Protection<br/>Family: System and Communications Protocols</i></p>
1688
- <div class="requirement-description">
1689
- <p id="_">I recommend <i>this</i>.</p>
1690
- </div>
1691
- <div class="requirement-description">
1692
- <p id="_">As for the measurement targets,</p>
1693
- </div>
1694
- <div class="requirement-measurement-target">
1695
- <p id="_">The measurement target shall be measured as:</p>
1696
- <div id="_"><div class="formula"><p><span class="stem">(#(r/1 = 0)#)</span>&#160; (1)</p></div></div>
1697
- </div>
1698
- <div class="requirement-verification">
1699
- <p id="_">The following code will be run for verification:</p>
1700
- <pre id="_" class="prettyprint ">CoreRoot(success): HttpResponse<br/>&#160;&#160;&#160;&#160;&#160; if (success)<br/>&#160;&#160;&#160;&#160;&#160; recommendation(label: success-response)<br/>&#160;&#160;&#160;&#160;&#160; end<br/>&#160;&#160;&#160; </pre>
1701
- </div>
1623
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type='presentation'>
1624
+ <preface><foreword displayorder='1'>
1625
+ <permission id="_" keep-with-next="true" keep-lines-together="true">
1626
+ <name>Permission 1</name>
1627
+ <label>/ogc/recommendation/wfs/2</label>
1628
+ <inherit>/ss/584/2015/level/1</inherit>
1629
+ <inherit><eref type="inline" bibitemid="rfc2616" citeas="RFC 2616">RFC 2616 (HTTP/1.1)</eref></inherit>
1630
+ <subject>user</subject>
1631
+ <classification> <tag>control-class</tag> <value>Technical</value> </classification><classification> <tag>priority</tag> <value>P0</value> </classification><classification> <tag>family</tag> <value>System and Communications Protection</value> </classification><classification> <tag>family</tag> <value>System and Communications Protocols</value> </classification>
1632
+ <description>
1633
+ <p id="_">I recommend <em>this</em>.</p>
1634
+ </description>
1635
+ <specification exclude="true" type="tabular">
1636
+ <p id="_">This is the object of the recommendation:</p>
1637
+ <table id="_">
1638
+ <tbody>
1639
+ <tr>
1640
+ <td style="text-align:left;">Object</td>
1641
+ <td style="text-align:left;">Value</td>
1642
+ </tr>
1643
+ <tr>
1644
+ <td style="text-align:left;">Mission</td>
1645
+ <td style="text-align:left;">Accomplished</td>
1646
+ </tr>
1647
+ </tbody>
1648
+ </table>
1649
+ </specification>
1650
+ <description>
1651
+ <p id="_">As for the measurement targets,</p>
1652
+ </description>
1653
+ <measurement-target exclude="false">
1654
+ <p id="_">The measurement target shall be measured as:</p>
1655
+ <formula id="_">
1656
+ <name>1</name>
1657
+ <stem type="AsciiMath">r/1 = 0</stem>
1658
+ </formula>
1659
+ </measurement-target>
1660
+ <verification exclude="false">
1661
+ <p id="_">The following code will be run for verification:</p>
1662
+ <sourcecode id="_">CoreRoot(success): HttpResponse
1663
+ if (success)
1664
+ recommendation(label: success-response)
1665
+ end
1666
+ </sourcecode>
1667
+ </verification>
1668
+ <import exclude="true">
1669
+ <sourcecode id="_">success-response()</sourcecode>
1670
+ </import>
1671
+ </permission>
1672
+ </foreword></preface>
1673
+ <bibliography><references id="_bibliography" obligation="informative" normative="false" displayorder='2'>
1674
+ <title depth='1'>Bibliography</title>
1675
+ <bibitem id="rfc2616" type="standard"> <fetched>2020-03-27</fetched> <title format="text/plain" language="en" script="Latn">Hypertext Transfer Protocol — HTTP/1.1</title> <uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2616.xml</uri> <uri type="src">https://www.rfc-editor.org/info/rfc2616</uri> <docidentifier type="IETF">IETF RFC 2616</docidentifier> <docidentifier type="rfc-anchor">RFC2616</docidentifier> <docidentifier type="DOI">DOI 10.17487/RFC2616</docidentifier> <date type="published"> <on>1999-06</on> </date> <contributor> <role type="author"/> <person> <name> <completename language="en">R. Fielding</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Gettys</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Mogul</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">H. Frystyk</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">L. Masinter</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">P. Leach</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">T. Berners-Lee</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <language>en</language> <script>Latn</script> <abstract format="text/plain" language="en" script="Latn">HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as “HTTP/1.1”, and is an update to RFC 2068. [STANDARDS-TRACK]</abstract> <series type="main"> <title format="text/plain" language="en" script="Latn">RFC</title> <number>2616</number> </series> <place>Fremont, CA</place></bibitem>
1676
+ </references></bibliography>
1677
+ </iso-standard>
1678
+ OUTPUT
1679
+ html = <<~OUTPUT
1680
+ #{HTML_HDR}
1681
+ <br/>
1682
+ <div>
1683
+ <h1 class="ForewordTitle">Foreword</h1>
1684
+ <div class="permission" id='_' style='page-break-after: avoid;page-break-inside: avoid;'>
1685
+ <p class="RecommendationTitle">Permission 1:<br/>/ogc/recommendation/wfs/2</p>
1686
+ <p><i>Subject: user<br/>
1687
+ Inherits: /ss/584/2015/level/1
1688
+ <br/>
1689
+ Inherits: <a href='#rfc2616'>RFC 2616 (HTTP/1.1)</a>
1690
+ <br/>Control-class: Technical<br/>Priority: P0<br/>Family: System and Communications Protection<br/>Family: System and Communications Protocols</i></p>
1691
+ <div class="requirement-description">
1692
+ <p id="_">I recommend <i>this</i>.</p>
1702
1693
  </div>
1703
- </div>
1704
- <p class="zzSTDTitle1"/>
1705
- <br/>
1706
- <div>
1707
- <h1 class='Section3'>Bibliography</h1>
1708
- <p id='rfc2616' class='Biblio'>
1709
- [1]&#160; IETF RFC 2616,
1710
- <i>Hypertext Transfer Protocol&#8201;&#8212;&#8201;HTTP/1.1</i>
1711
- </p>
1712
- </div>
1694
+ <div class="requirement-description">
1695
+ <p id="_">As for the measurement targets,</p>
1696
+ </div>
1697
+ <div class="requirement-measurement-target">
1698
+ <p id="_">The measurement target shall be measured as:</p>
1699
+ <div id="_"><div class="formula"><p><span class="stem">(#(r/1 = 0)#)</span>&#160; (1)</p></div></div>
1700
+ </div>
1701
+ <div class="requirement-verification">
1702
+ <p id="_">The following code will be run for verification:</p>
1703
+ <pre id="_" class="prettyprint ">CoreRoot(success): HttpResponse<br/>&#160;&#160;&#160;&#160;&#160; if (success)<br/>&#160;&#160;&#160;&#160;&#160; recommendation(label: success-response)<br/>&#160;&#160;&#160;&#160;&#160; end<br/>&#160;&#160;&#160; </pre>
1704
+ </div>
1705
+ </div>
1713
1706
  </div>
1714
- </body>
1715
- </html>
1707
+ <p class="zzSTDTitle1"/>
1708
+ <br/>
1709
+ <div>
1710
+ <h1 class='Section3'>Bibliography</h1>
1711
+ <p id='rfc2616' class='Biblio'>
1712
+ [1]&#160; IETF RFC 2616,
1713
+ <i>Hypertext Transfer Protocol&#8201;&#8212;&#8201;HTTP/1.1</i>
1714
+ </p>
1715
+ </div>
1716
+ </div>
1717
+ </body>
1718
+ </html>
1716
1719
  OUTPUT
1717
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
1718
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
1720
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1721
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
1722
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1723
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
1719
1724
  end
1720
1725
 
1721
- it "processes requirements (Presentation XML)" do
1722
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1726
+ it "processes requirements" do
1727
+ input = <<~INPUT
1723
1728
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1724
1729
  <preface><foreword>
1725
1730
  <requirement id="A" unnumbered="true" keep-with-next="true" keep-lines-together="true">
@@ -1769,6 +1774,7 @@ RSpec.describe IsoDoc do
1769
1774
  </foreword></preface>
1770
1775
  </iso-standard>
1771
1776
  INPUT
1777
+ presxml = <<~OUTPUT
1772
1778
  <?xml version='1.0'?>
1773
1779
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1774
1780
  <preface>
@@ -1806,17 +1812,14 @@ RSpec.describe IsoDoc do
1806
1812
  </description>
1807
1813
  <measurement-target exclude='false' keep-with-next='true' keep-lines-together='true'>
1808
1814
  <p id='_'>The measurement target shall be measured as:</p>
1809
- <formula id='B'>
1810
- <name>1</name>
1811
- <stem type='AsciiMath'>r/1 = 0</stem>
1812
- </formula>
1813
- </measurement-target>
1815
+ <formula id='B'><name>1</name><stem type='AsciiMath'>r/1 = 0</stem></formula></measurement-target>
1814
1816
  <verification exclude='false'>
1815
1817
  <p id='_'>The following code will be run for verification:</p>
1816
- <sourcecode id='_'>
1817
- CoreRoot(success): HttpResponse if (success) recommendation(label:
1818
- success-response) end
1819
- </sourcecode>
1818
+ <sourcecode id='_'>CoreRoot(success): HttpResponse
1819
+ if (success)
1820
+ recommendation(label: success-response)
1821
+ end
1822
+ </sourcecode>
1820
1823
  </verification>
1821
1824
  <import exclude='true'>
1822
1825
  <sourcecode id='_'>success-response()</sourcecode>
@@ -1826,60 +1829,8 @@ RSpec.describe IsoDoc do
1826
1829
  </preface>
1827
1830
  </iso-standard>
1828
1831
  OUTPUT
1829
- end
1830
1832
 
1831
- it "processes requirements (HTML)" do
1832
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1833
- <iso-standard xmlns="http://riboseinc.com/isoxml">
1834
- <preface><foreword>
1835
- <requirement id="A" unnumbered="true" keep-with-next="true" keep-lines-together="true">
1836
- <name>Requirement</name>
1837
- <title>A New Requirement</title>
1838
- <label>/ogc/recommendation/wfs/2</label>
1839
- <inherit>/ss/584/2015/level/1</inherit>
1840
- <subject>user</subject>
1841
- <description>
1842
- <p id="_">I recommend <em>this</em>.</p>
1843
- </description>
1844
- <specification exclude="true" type="tabular">
1845
- <p id="_">This is the object of the recommendation:</p>
1846
- <table id="_">
1847
- <tbody>
1848
- <tr>
1849
- <td style="text-align:left;">Object</td>
1850
- <td style="text-align:left;">Value</td>
1851
- </tr>
1852
- <tr>
1853
- <td style="text-align:left;">Mission</td>
1854
- <td style="text-align:left;">Accomplished</td>
1855
- </tr>
1856
- </tbody>
1857
- </table>
1858
- </specification>
1859
- <description>
1860
- <p id="_">As for the measurement targets,</p>
1861
- </description>
1862
- <measurement-target exclude="false" keep-with-next="true" keep-lines-together="true">
1863
- <p id="_">The measurement target shall be measured as:</p>
1864
- <formula id="B">
1865
- <stem type="AsciiMath">r/1 = 0</stem>
1866
- </formula>
1867
- </measurement-target>
1868
- <verification exclude="false">
1869
- <p id="_">The following code will be run for verification:</p>
1870
- <sourcecode id="_">CoreRoot(success): HttpResponse
1871
- if (success)
1872
- recommendation(label: success-response)
1873
- end
1874
- </sourcecode>
1875
- </verification>
1876
- <import exclude="true">
1877
- <sourcecode id="_">success-response()</sourcecode>
1878
- </import>
1879
- </requirement>
1880
- </foreword></preface>
1881
- </iso-standard>
1882
- INPUT
1833
+ output = <<~OUTPUT
1883
1834
  #{HTML_HDR}
1884
1835
  <br/>
1885
1836
  <div>
@@ -1894,7 +1845,7 @@ RSpec.describe IsoDoc do
1894
1845
  </div>
1895
1846
  <div class="requirement-measurement-target" style='page-break-after: avoid;page-break-inside: avoid;'>
1896
1847
  <p id="_">The measurement target shall be measured as:</p>
1897
- <div id="B"><div class="formula"><p><span class="stem">(#(r/1 = 0)#)</span></p></div></div>
1848
+ <div id="B"><div class="formula"><p><span class="stem">(#(r/1 = 0)#)</span> &#160; (1)</p></div></div>
1898
1849
  </div>
1899
1850
  <div class="requirement-verification">
1900
1851
  <p id="_">The following code will be run for verification:</p>
@@ -1907,6 +1858,10 @@ RSpec.describe IsoDoc do
1907
1858
  </body>
1908
1859
  </html>
1909
1860
  OUTPUT
1861
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1862
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
1863
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
1864
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
1910
1865
  end
1911
1866
 
1912
1867
  it "processes requirements in French" do
@@ -2078,12 +2033,16 @@ RSpec.describe IsoDoc do
2078
2033
  </body>
2079
2034
  </html>
2080
2035
  OUTPUT
2081
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
2082
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2036
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
2037
+ .convert("test", input, true))
2038
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
2039
+ .to be_equivalent_to xmlpp(presxml)
2040
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
2041
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2083
2042
  end
2084
2043
 
2085
- it "processes recommendation (Presentation XML)" do
2086
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2044
+ it "processes recommendation" do
2045
+ input = <<~INPUT
2087
2046
  <iso-standard xmlns="http://riboseinc.com/isoxml">
2088
2047
  <preface><foreword>
2089
2048
  <recommendation id="_" obligation="shall,could" keep-with-next="true" keep-lines-together="true">
@@ -2134,6 +2093,7 @@ RSpec.describe IsoDoc do
2134
2093
  </foreword></preface>
2135
2094
  </iso-standard>
2136
2095
  INPUT
2096
+ presxml = <<~OUTPUT
2137
2097
  <?xml version='1.0'?>
2138
2098
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
2139
2099
  <preface>
@@ -2178,17 +2138,15 @@ RSpec.describe IsoDoc do
2178
2138
  </description>
2179
2139
  <measurement-target exclude='false'>
2180
2140
  <p id='_'>The measurement target shall be measured as:</p>
2181
- <formula id='_'>
2182
- <name>1</name>
2183
- <stem type='AsciiMath'>r/1 = 0</stem>
2184
- </formula>
2141
+ <formula id='_'><name>1</name><stem type='AsciiMath'>r/1 = 0</stem></formula>
2185
2142
  </measurement-target>
2186
2143
  <verification exclude='false'>
2187
2144
  <p id='_'>The following code will be run for verification:</p>
2188
- <sourcecode id='_'>
2189
- CoreRoot(success): HttpResponse if (success) recommendation(label:
2190
- success-response) end
2191
- </sourcecode>
2145
+ <sourcecode id='_'>CoreRoot(success): HttpResponse
2146
+ if (success)
2147
+ recommendation(label: success-response)
2148
+ end
2149
+ </sourcecode>
2192
2150
  </verification>
2193
2151
  <import exclude='true'>
2194
2152
  <sourcecode id='_'>success-response()</sourcecode>
@@ -2198,61 +2156,8 @@ RSpec.describe IsoDoc do
2198
2156
  </preface>
2199
2157
  </iso-standard>
2200
2158
  OUTPUT
2201
- end
2202
2159
 
2203
- it "processes recommendation (HTML)" do
2204
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2205
- <iso-standard xmlns="http://riboseinc.com/isoxml">
2206
- <preface><foreword>
2207
- <recommendation id="_" obligation="shall,could" keep-with-next="true" keep-lines-together="true">
2208
- <name>Recommendation 1</name>
2209
- <label>/ogc/recommendation/wfs/2</label>
2210
- <inherit>/ss/584/2015/level/1</inherit>
2211
- <classification><tag>type</tag><value>text</value></classification>
2212
- <classification><tag>language</tag><value>BASIC</value></classification>
2213
- <subject>user</subject>
2214
- <description>
2215
- <p id="_">I recommend <em>this</em>.</p>
2216
- </description>
2217
- <specification exclude="true" type="tabular">
2218
- <p id="_">This is the object of the recommendation:</p>
2219
- <table id="_">
2220
- <tbody>
2221
- <tr>
2222
- <td style="text-align:left;">Object</td>
2223
- <td style="text-align:left;">Value</td>
2224
- </tr>
2225
- <tr>
2226
- <td style="text-align:left;">Mission</td>
2227
- <td style="text-align:left;">Accomplished</td>
2228
- </tr>
2229
- </tbody>
2230
- </table>
2231
- </specification>
2232
- <description>
2233
- <p id="_">As for the measurement targets,</p>
2234
- </description>
2235
- <measurement-target exclude="false">
2236
- <p id="_">The measurement target shall be measured as:</p>
2237
- <formula id="_">
2238
- <stem type="AsciiMath">r/1 = 0</stem>
2239
- </formula>
2240
- </measurement-target>
2241
- <verification exclude="false">
2242
- <p id="_">The following code will be run for verification:</p>
2243
- <sourcecode id="_">CoreRoot(success): HttpResponse
2244
- if (success)
2245
- recommendation(label: success-response)
2246
- end
2247
- </sourcecode>
2248
- </verification>
2249
- <import exclude="true">
2250
- <sourcecode id="_">success-response()</sourcecode>
2251
- </import>
2252
- </recommendation>
2253
- </foreword></preface>
2254
- </iso-standard>
2255
- INPUT
2160
+ output = <<~OUTPUT
2256
2161
  #{HTML_HDR}
2257
2162
  <br/>
2258
2163
  <div>
@@ -2267,7 +2172,7 @@ RSpec.describe IsoDoc do
2267
2172
  </div>
2268
2173
  <div class="requirement-measurement-target">
2269
2174
  <p id="_">The measurement target shall be measured as:</p>
2270
- <div id="_"><div class="formula"><p><span class="stem">(#(r/1 = 0)#)</span></p></div></div>
2175
+ <div id="_"><div class="formula"><p><span class="stem">(#(r/1 = 0)#)</span>&#160; (1)</p></div></div>
2271
2176
  </div>
2272
2177
  <div class="requirement-verification">
2273
2178
  <p id="_">The following code will be run for verification:</p>
@@ -2280,6 +2185,11 @@ RSpec.describe IsoDoc do
2280
2185
  </body>
2281
2186
  </html>
2282
2187
  OUTPUT
2188
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
2189
+ .convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
2190
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
2191
+ .convert("test", presxml, true)))
2192
+ .to be_equivalent_to xmlpp(output)
2283
2193
  end
2284
2194
 
2285
2195
  it "processes pseudocode" do
@@ -2325,18 +2235,25 @@ RSpec.describe IsoDoc do
2325
2235
  OUTPUT
2326
2236
 
2327
2237
  FileUtils.rm_f "test.doc"
2328
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
2329
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2238
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
2239
+ .convert("test", input, true))
2240
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
2241
+ .to be_equivalent_to xmlpp(presxml)
2242
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
2243
+ .convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
2330
2244
  IsoDoc::WordConvert.new({}).convert("test", presxml, false)
2331
- expect(xmlpp(File.read("test.doc").gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h1>}m, "").gsub(%r{</div>.*}m, "</div>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2332
- <div class="pseudocode" style='page-break-after: avoid;page-break-inside: avoid;'><a name="_" id="_"></a><p class="pseudocode"><a name="_" id="_"></a>&#xA0;&#xA0;<b>A</b><br/>
2333
- &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<span style="font-variant:small-caps;">B</span></p>
2334
- <p class="pseudocode" style="page-break-after:avoid;"><a name="_" id="_"></a>&#xA0;&#xA0;<i>C</i></p><p class="SourceTitle" style="text-align:center;">Figure 1&#xA0;&#x2014; Label</p></div>
2335
- OUTPUT
2245
+ expect(xmlpp(File.read("test.doc")
2246
+ .gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h1>}m, "")
2247
+ .gsub(%r{</div>.*}m, "</div>")))
2248
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
2249
+ <div class="pseudocode" style='page-break-after: avoid;page-break-inside: avoid;'><a name="_" id="_"></a><p class="pseudocode"><a name="_" id="_"></a>&#xA0;&#xA0;<b>A</b><br/>
2250
+ &#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<span style="font-variant:small-caps;">B</span></p>
2251
+ <p class="pseudocode" style="page-break-after:avoid;"><a name="_" id="_"></a>&#xA0;&#xA0;<i>C</i></p><p class="SourceTitle" style="text-align:center;">Figure 1&#xA0;&#x2014; Label</p></div>
2252
+ OUTPUT
2336
2253
  end
2337
2254
 
2338
2255
  it "does not label embedded figures, sourcecode" do
2339
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2256
+ input = <<~INPUT
2340
2257
  <itu-standard xmlns="http://riboseinc.com/isoxml">
2341
2258
  <bibdata>
2342
2259
  <language>en</language>
@@ -2350,6 +2267,7 @@ RSpec.describe IsoDoc do
2350
2267
  </example>
2351
2268
  </preface></itu-standard>
2352
2269
  INPUT
2270
+ output = <<~OUTPUT
2353
2271
  #{HTML_HDR}
2354
2272
  <br/>
2355
2273
  <div>
@@ -2380,6 +2298,8 @@ RSpec.describe IsoDoc do
2380
2298
  </body>
2381
2299
  </html>
2382
2300
  OUTPUT
2301
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
2302
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
2383
2303
  end
2384
2304
 
2385
2305
  it "processes passthrough with compatible format" do
@@ -2391,35 +2311,42 @@ RSpec.describe IsoDoc do
2391
2311
  </foreword></preface>
2392
2312
  </iso-standard>
2393
2313
  INPUT
2394
- expect((File.read("test.html").gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h1>}m, "").gsub(%r{</div>.*}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2395
- <A><i>Hello</i></A>
2396
- OUTPUT
2314
+ expect((File.read("test.html")
2315
+ .gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h1>}m, "")
2316
+ .gsub(%r{</div>.*}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2317
+ <A><i>Hello</i></A>
2318
+ OUTPUT
2397
2319
  end
2398
2320
 
2399
2321
  it "aborts if passthrough results in malformed XML" do
2400
2322
  FileUtils.rm_f "test.html"
2401
2323
  FileUtils.rm_f "test.html.err"
2402
2324
  begin
2403
- expect { IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", false) }.to raise_error(SystemExit)
2325
+ input = <<~INPUT
2404
2326
  <iso-standard xmlns="http://riboseinc.com/isoxml">
2405
2327
  <preface><foreword>
2406
2328
  <passthrough format="html,rfc">&lt;A&gt;</passthrough><em>Hello</em>
2407
2329
  </foreword></preface>
2408
2330
  </iso-standard>
2409
2331
  INPUT
2332
+ expect do
2333
+ IsoDoc::HtmlConvert.new({})
2334
+ .convert("test", input, false)
2335
+ end.to raise_error(SystemExit)
2410
2336
  rescue SystemExit
2411
2337
  end
2412
2338
  expect(File.exist?("test.html.err")).to be true
2413
2339
  end
2414
2340
 
2415
2341
  it "ignores passthrough with incompatible format" do
2416
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
2342
+ input = <<~INPUT
2417
2343
  <iso-standard xmlns="http://riboseinc.com/isoxml">
2418
2344
  <preface><foreword>
2419
2345
  <passthrough format="doc,rfc">&lt;A&gt;</passthrough>
2420
2346
  </foreword></preface>
2421
2347
  </iso-standard>
2422
2348
  INPUT
2349
+ output = <<~OUTPUT
2423
2350
  #{HTML_HDR}
2424
2351
  <br/>
2425
2352
  <div>
@@ -2430,10 +2357,12 @@ RSpec.describe IsoDoc do
2430
2357
  </body>
2431
2358
  </html>
2432
2359
  OUTPUT
2360
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
2361
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
2433
2362
  end
2434
2363
 
2435
2364
  it "processes svgmap" do
2436
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~INPUT, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(<<~OUTPUT)
2365
+ input = <<~INPUT
2437
2366
  <iso-standard xmlns="http://riboseinc.com/isoxml">
2438
2367
  <sections>
2439
2368
  <svgmap id='_'>
@@ -2469,6 +2398,7 @@ RSpec.describe IsoDoc do
2469
2398
  </bibliography>
2470
2399
  </iso-standard>
2471
2400
  INPUT
2401
+ output = <<~OUTPUT
2472
2402
  <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
2473
2403
  <sections>
2474
2404
  <figure id='_'>
@@ -2487,5 +2417,159 @@ RSpec.describe IsoDoc do
2487
2417
  </bibliography>
2488
2418
  </iso-standard>
2489
2419
  OUTPUT
2420
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
2421
+ .convert("test", input, true))
2422
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
2423
+ .to be_equivalent_to xmlpp(output)
2424
+ end
2425
+
2426
+ it "processes toc" do
2427
+ input = <<~INPUT
2428
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='1.10.2'>
2429
+ <bibdata type='standard'>
2430
+ <title language='en' format='text/plain'>Document title</title>
2431
+ <language>en</language>
2432
+ <script>Latn</script>
2433
+ <status>
2434
+ <stage>published</stage>
2435
+ </status>
2436
+ <copyright>
2437
+ <from>2021</from>
2438
+ </copyright>
2439
+ <ext>
2440
+ <doctype>article</doctype>
2441
+ </ext>
2442
+ </bibdata>
2443
+ <sections>
2444
+ <clause id='clause1' inline-header='false' obligation='normative'>
2445
+ <title>Clause 1</title>
2446
+ <clause id='clause1A' inline-header='false' obligation='normative'>
2447
+ <title>Clause 1A</title>
2448
+ <clause id='clause1Aa' inline-header='false' obligation='normative'>
2449
+ <title>Clause 1Aa</title>
2450
+ </clause>
2451
+ <clause id='clause1Ab' inline-header='false' obligation='normative'>
2452
+ <title>Clause 1Ab</title>
2453
+ </clause>
2454
+ </clause>
2455
+ <clause id='clause1B' inline-header='false' obligation='normative'>
2456
+ <title>Clause 1B</title>
2457
+ <clause id='clause1Ba' inline-header='false' obligation='normative'>
2458
+ <title>Clause 1Ba</title>
2459
+ </clause>
2460
+ </clause>
2461
+ </clause>
2462
+ <clause id='clause2' inline-header='false' obligation='normative'>
2463
+ <title>Clause 2</title>
2464
+ <p id='A'>And introducing: </p>
2465
+ <toc>
2466
+ <ul id='B'>
2467
+ <li>
2468
+ <xref target='clause1A'>Clause 1A</xref>
2469
+ </li>
2470
+ <li>
2471
+ <ul id='C'>
2472
+ <li>
2473
+ <xref target='clause1Aa'>Clause 1Aa</xref>
2474
+ </li>
2475
+ <li>
2476
+ <xref target='clause1Ab'>Clause 1Ab</xref>
2477
+ </li>
2478
+ </ul>
2479
+ </li>
2480
+ <li>
2481
+ <xref target='clause1B'>Clause 1B</xref>
2482
+ </li>
2483
+ <li>
2484
+ <ul id='D'>
2485
+ <li>
2486
+ <xref target='clause1Ba'>Clause 1Ba</xref>
2487
+ </li>
2488
+ </ul>
2489
+ </li>
2490
+ </ul>
2491
+ </toc>
2492
+ <toc>
2493
+ <ul id='E'>
2494
+ <li>
2495
+ <xref target='clause1A'>Clause 1A</xref>
2496
+ </li>
2497
+ <li>
2498
+ <xref target='clause1B'>Clause 1B</xref>
2499
+ </li>
2500
+ </ul>
2501
+ </toc>
2502
+ </clause>
2503
+ </sections>
2504
+ </standard-document>
2505
+ INPUT
2506
+ output = <<~OUTPUT
2507
+ #{HTML_HDR}
2508
+ <p class='zzSTDTitle1'>Document title</p>
2509
+ <div id='clause1'>
2510
+ <h1>Clause 1</h1>
2511
+ <div id='clause1A'>
2512
+ <h2>Clause 1A</h2>
2513
+ <div id='clause1Aa'>
2514
+ <h3>Clause 1Aa</h3>
2515
+ </div>
2516
+ <div id='clause1Ab'>
2517
+ <h3>Clause 1Ab</h3>
2518
+ </div>
2519
+ </div>
2520
+ <div id='clause1B'>
2521
+ <h2>Clause 1B</h2>
2522
+ <div id='clause1Ba'>
2523
+ <h3>Clause 1Ba</h3>
2524
+ </div>
2525
+ </div>
2526
+ </div>
2527
+ <div id='clause2'>
2528
+ <h1>Clause 2</h1>
2529
+ <p id='A'>And introducing: </p>
2530
+ <div class='toc'>
2531
+ <ul id='B'>
2532
+ <li>
2533
+ <a href='#clause1A'>Clause 1A</a>
2534
+ </li>
2535
+ <li>
2536
+ <ul id='C'>
2537
+ <li>
2538
+ <a href='#clause1Aa'>Clause 1Aa</a>
2539
+ </li>
2540
+ <li>
2541
+ <a href='#clause1Ab'>Clause 1Ab</a>
2542
+ </li>
2543
+ </ul>
2544
+ </li>
2545
+ <li>
2546
+ <a href='#clause1B'>Clause 1B</a>
2547
+ </li>
2548
+ <li>
2549
+ <ul id='D'>
2550
+ <li>
2551
+ <a href='#clause1Ba'>Clause 1Ba</a>
2552
+ </li>
2553
+ </ul>
2554
+ </li>
2555
+ </ul>
2556
+ </div>
2557
+ <div class='toc'>
2558
+ <ul id='E'>
2559
+ <li>
2560
+ <a href='#clause1A'>Clause 1A</a>
2561
+ </li>
2562
+ <li>
2563
+ <a href='#clause1B'>Clause 1B</a>
2564
+ </li>
2565
+ </ul>
2566
+ </div>
2567
+ </div>
2568
+ </div>
2569
+ </body>
2570
+ </html>
2571
+ OUTPUT
2572
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
2573
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
2490
2574
  end
2491
2575
  end