metanorma-iso 2.1.2 → 2.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/html2doc/lists.rb +7 -4
  3. data/lib/isodoc/iso/html/isodoc-dis.css +4 -15
  4. data/lib/isodoc/iso/html/isodoc-dis.scss +4 -17
  5. data/lib/isodoc/iso/html/isodoc.css +4 -11
  6. data/lib/isodoc/iso/html/isodoc.scss +5 -15
  7. data/lib/isodoc/iso/i18n-en.yaml +1 -1
  8. data/lib/isodoc/iso/iso.amendment.xsl +429 -121
  9. data/lib/isodoc/iso/iso.international-standard.xsl +429 -121
  10. data/lib/isodoc/iso/metadata.rb +1 -1
  11. data/lib/isodoc/iso/presentation_xml_convert.rb +5 -1
  12. data/lib/isodoc/iso/word_cleanup.rb +40 -6
  13. data/lib/isodoc/iso/word_dis_cleanup.rb +10 -14
  14. data/lib/metanorma/iso/base.rb +0 -6
  15. data/lib/metanorma/iso/biblio.rng +102 -5
  16. data/lib/metanorma/iso/cleanup.rb +33 -20
  17. data/lib/metanorma/iso/front.rb +13 -6
  18. data/lib/metanorma/iso/isodoc.rng +33 -0
  19. data/lib/metanorma/iso/isostandard.rng +3 -1
  20. data/lib/metanorma/iso/validate_section.rb +0 -12
  21. data/lib/metanorma/iso/version.rb +1 -1
  22. data/spec/isodoc/blocks_spec.rb +3 -3
  23. data/spec/isodoc/metadata_spec.rb +1 -2
  24. data/spec/isodoc/postproc_spec.rb +2 -62
  25. data/spec/isodoc/section_spec.rb +2 -8
  26. data/spec/isodoc/terms_spec.rb +62 -0
  27. data/spec/isodoc/word_dis_spec.rb +185 -3
  28. data/spec/metanorma/amd_spec.rb +4 -40
  29. data/spec/metanorma/base_spec.rb +61 -103
  30. data/spec/metanorma/blocks_spec.rb +0 -33
  31. data/spec/metanorma/cleanup_spec.rb +201 -201
  32. data/spec/metanorma/refs_spec.rb +5 -3
  33. data/spec/metanorma/section_spec.rb +6 -6
  34. data/spec/metanorma/validate_spec.rb +8 -19
  35. data/spec/spec_helper.rb +1 -7
  36. data/spec/vcr_cassettes/withdrawn_iso.yml +28 -28
  37. metadata +3 -4
  38. data/lib/metanorma/iso/macros.rb +0 -29
@@ -126,66 +126,6 @@ RSpec.describe IsoDoc do
126
126
  expect(File.exist?("spec/assets/iso.pdf")).to be true
127
127
  end
128
128
 
129
- it "converts annex subheadings to h2Annex class for Word" do
130
- IsoDoc::Iso::WordConvert
131
- .new(WORD_HTML_CSS.dup)
132
- .convert("test", <<~"INPUT", false)
133
- <iso-standard xmlns="http://riboseinc.com/isoxml">
134
- <annex id="P" inline-header="false" obligation="normative">
135
- <title>Annex</title>
136
- <clause id="Q" inline-header="false" obligation="normative">
137
- <title>A.1
138
- <tab/>
139
- Annex A.1</title>
140
- </clause>
141
- <appendix id="Q2" inline-header="false" obligation="normative">
142
- <title>Appendix 1
143
- <tab/>
144
- An Appendix</title>
145
- </appendix>
146
- </annex>
147
- <bibliography>
148
- <references id="R" normative="false"><title>Bibliography</title></references>
149
- </bibliography>
150
- </iso-standard>
151
- INPUT
152
-
153
- word = File.read("test.doc", encoding: "UTF-8")
154
- .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
155
- .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
156
-
157
- expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
158
- <div class="WordSection3">
159
- <p class="zzSTDTitle1"/>
160
- <p class="MsoNormal">
161
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
162
- </p>
163
- <div class="Section3">
164
- <a id="P" name="P"/>
165
- <p class="ANNEX">Annex</p>
166
- <div>
167
- <a id="Q" name="Q"/>
168
- <p class="h2Annex">A.1
169
- <span style="mso-tab-count:1">  </span>
170
- Annex A.1</p>
171
- </div>
172
- <div>
173
- <a id="Q2" name="Q2"/>
174
- <p class="h2Annex">Appendix 1
175
- <span style="mso-tab-count:1">  </span>
176
- An Appendix</p>
177
- </div>
178
- </div>
179
- <p class='MsoNormal'>
180
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
181
- </p>
182
- <div>
183
- <p class='BiblioTitle'>Bibliography</p>
184
- </div>
185
- </div>
186
- OUTPUT
187
- end
188
-
189
129
  it "populates Word template with terms reference labels" do
190
130
  IsoDoc::Iso::WordConvert
191
131
  .new(WORD_HTML_CSS.dup)
@@ -817,7 +757,7 @@ RSpec.describe IsoDoc do
817
757
  </p>
818
758
  <div class="Section3">
819
759
  <a id="P" name="P"/>
820
- <div class="figure">
760
+ <div class="MsoNormal" style='text-align:center;'>
821
761
  <a id="samplecode" name="samplecode"/>
822
762
  <p class="MsoNormal">Hello</p>
823
763
  <p class="MsoNormal">Key</p>
@@ -864,7 +804,7 @@ RSpec.describe IsoDoc do
864
804
  .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
865
805
  .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
866
806
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
867
- <div class='WordSection3'>
807
+ <div class='WordSection3'>
868
808
  <p class='zzSTDTitle1'/>
869
809
  <p class='MsoNormal'>
870
810
  <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
@@ -576,17 +576,11 @@ RSpec.describe IsoDoc do
576
576
  <ext>
577
577
  <doctype>standard</doctype>
578
578
  <subdoctype>vocabulary</subdoctype>
579
- <editorialgroup identifier='ISO/ / / '>
579
+ <editorialgroup identifier='ISO'>
580
580
  <agency>ISO</agency>
581
- <technical-committee/>
582
- <subcommittee/>
583
- <workgroup/>
584
581
  </editorialgroup>
585
- <approvalgroup identifier='ISO/ / / '>
582
+ <approvalgroup identifier='ISO'>
586
583
  <agency>ISO</agency>
587
- <technical-committee/>
588
- <subcommittee/>
589
- <workgroup/>
590
584
  </approvalgroup>
591
585
  <stagename>International standard</stagename>
592
586
  </ext>
@@ -249,4 +249,66 @@ RSpec.describe IsoDoc do
249
249
  .sub(%r{</div>\s*<br.*$}m, "")))
250
250
  .to be_equivalent_to xmlpp(word)
251
251
  end
252
+
253
+ it "processes related terms" do
254
+ input = <<~INPUT
255
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
256
+ <sections>
257
+ <terms id='A' obligation='normative'>
258
+ <title>Terms and definitions</title>
259
+ <term id='second'>
260
+ <preferred>
261
+ <expression>
262
+ <name>Second Term</name>
263
+ </expression>
264
+ <field-of-application>Field</field-of-application>
265
+ <usage-info>Usage Info 1</usage-info>
266
+ </preferred>
267
+ <definition><verbal-definition>Definition 1</verbal-definition></definition>
268
+ </term>
269
+ <term id="C">
270
+ <preferred language='fr' script='Latn' type='prefix'>
271
+ <expression>
272
+ <name>First Designation</name>
273
+ </expression></preferred>
274
+ <related type='contrast'>
275
+ <preferred>
276
+ <expression>
277
+ <name>Fifth Designation</name>
278
+ <grammar>
279
+ <gender>neuter</gender>
280
+ </grammar>
281
+ </expression>
282
+ </preferred>
283
+ <xref target='second'/>
284
+ </related>
285
+ <definition><verbal-definition>Definition 2</verbal-definition></definition>
286
+ </term>
287
+ </terms>
288
+ </sections>
289
+ </iso-standard>
290
+ INPUT
291
+ output = <<~OUTPUT
292
+ <?xml version='1.0'?>
293
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
294
+ <sections>
295
+ <terms id='A' obligation='normative' displayorder='1'>
296
+ <title depth='1'>1<tab/>Terms and definitions</title>
297
+ <term id='second'>
298
+ <name>1.1</name>
299
+ <preferred><strong>Second Term</strong>, &#x3c;Field, Usage Info 1&#x3e;</preferred>
300
+ <definition>Definition 1</definition>
301
+ </term>
302
+ <term id='C'>
303
+ <name>1.2</name>
304
+ <preferred language='fr' script='Latn' type='prefix'><strong>First Designation</strong></preferred>
305
+ <definition>Definition 2</definition>
306
+ </term>
307
+ </terms>
308
+ </sections>
309
+ </iso-standard>
310
+ OUTPUT
311
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({})
312
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
313
+ end
252
314
  end
@@ -673,6 +673,66 @@ RSpec.describe IsoDoc do
673
673
  .to be_equivalent_to xmlpp(word)
674
674
  end
675
675
 
676
+ it "deals with lists and paragraphs" do
677
+ input = <<~INPUT
678
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
679
+ <bibdata>
680
+ <status><stage>50</stage></status>
681
+ </bibdata>
682
+ <sections>
683
+ <clause id="A">
684
+ <p id="_eb2fd8cd-5cbe-1f1f-7bdb-282868a25828">ISO and IEC maintain terminological databases for use in
685
+ standardization at the following addresses:</p>
686
+
687
+ <ul id="_6f8dbb84-61d9-f774-264e-b7e249cf44d1">
688
+ <li> <p id="_9f56356a-3a58-64c4-e59e-a23ca3da7e88">ISO Online browsing platform: available at
689
+ <link target="https://www.iso.org/obp"/></p></li>
690
+ <li> <p id="_5dc6886f-a99c-e420-a29d-2aa6ca9f376e">IEC Electropedia: available at
691
+ <link target="https://www.electropedia.org"/>
692
+ </p> </li> </ul>
693
+ </clause>
694
+ </sections>
695
+ </iso-standard>
696
+ INPUT
697
+ word = <<~OUTPUT
698
+ <div class='WordSection3'>
699
+ <p class='zzSTDTitle'/>
700
+ <div>
701
+ <a name='A' id='A'/>
702
+ <h1>1</h1>
703
+ <p class='MsoBodyText'>
704
+ <a name='_eb2fd8cd-5cbe-1f1f-7bdb-282868a25828' id='_eb2fd8cd-5cbe-1f1f-7bdb-282868a25828'/>
705
+ ISO and IEC maintain terminological databases for use in standardization
706
+ at the following addresses:
707
+ </p>
708
+ <p class='ListContinue1'>
709
+
710
+ <span style='mso-tab-count:1'> </span>
711
+ ISO Online browsing platform: available at
712
+ <a href='https://www.iso.org/obp'>https://www.iso.org/obp</a>
713
+ </p>
714
+ <p class='ListContinue1'>
715
+
716
+ <span style='mso-tab-count:1'> </span>
717
+ IEC Electropedia: available at
718
+ <a href='https://www.electropedia.org'>https://www.electropedia.org</a>
719
+ </p>
720
+ </div>
721
+ </div>
722
+ OUTPUT
723
+ FileUtils.rm_f "test.doc"
724
+ presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
725
+ .convert("test", input, true)
726
+ IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
727
+ expect(File.exist?("test.doc")).to be true
728
+ output = File.read("test.doc", encoding: "UTF-8")
729
+ .sub(/^.*<html/m, "<html")
730
+ .sub(/<\/html>.*$/m, "</html>")
731
+ expect(xmlpp(Nokogiri::XML(output)
732
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml))
733
+ .to be_equivalent_to xmlpp(word)
734
+ end
735
+
676
736
  it "deals with ordered list start" do
677
737
  input = <<~INPUT
678
738
  <iso-standard xmlns="http://riboseinc.com/isoxml">
@@ -950,9 +1010,9 @@ RSpec.describe IsoDoc do
950
1010
  Note
951
1011
  </p>
952
1012
  </div>
953
- <div style='page-break-after:avoid;'>
1013
+ <div class="Figureexample" style='page-break-after:avoid;'>
954
1014
  <a name='D' id='D'/>
955
- <p class='Example'>
1015
+ <p class='Figureexample'>
956
1016
  <span style='mso-tab-count:1'>  </span>
957
1017
  Example
958
1018
  </p>
@@ -1627,7 +1687,7 @@ RSpec.describe IsoDoc do
1627
1687
  <span style='mso-tab-count:1'>  </span>
1628
1688
  Example start
1629
1689
  </p>
1630
- <p class='Code--'>X</p>
1690
+ <p class='Code--' style='margin-bottom:12pt;'>X</p>
1631
1691
  <p class='Exampleindentcontinued'>Example continued</p>
1632
1692
  </div>
1633
1693
  <p class='Code-'>X</p>
@@ -1883,4 +1943,126 @@ RSpec.describe IsoDoc do
1883
1943
  </div>
1884
1944
  OUTPUT
1885
1945
  end
1946
+
1947
+ it "deals with Simple Template styles" do
1948
+ input = <<~INPUT
1949
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1950
+ <bibdata>
1951
+ <status><stage>20</stage></status>
1952
+ </bibdata>
1953
+ <sections>
1954
+ <clause id="A"><title>Clause Title</title>
1955
+ <ul><li>List</li></ul>
1956
+ <note id="B"><p>Note</p>
1957
+ <ul><li>Note List</li></ul>
1958
+ </note>
1959
+ <example id="C"><p>Example</p>
1960
+ <ul><li>Example List</li></ul>
1961
+ </example>
1962
+ <figure id="D"><name>Figure Title</name></figure>
1963
+ <sourcecode id="E">XYZ</sourcecode>
1964
+ <table id="F"><name>Table</name></table>
1965
+ </clause>
1966
+ </sections>
1967
+ <annex id="G"><title>Annex Title</title>
1968
+ <table id="H"><name>Annex Table</name></table>
1969
+ <clause id="I"><title>Annex Clause Title</title>
1970
+ </clause>
1971
+ </annex>
1972
+ <bibliography>
1973
+ <references id="_normative_references" normative="false" obligation="informative">
1974
+ <title>Bibliography</title>
1975
+ <bibitem id="ISO712" type="standard">
1976
+ <formattedref>ALUFFI, Paolo, ed. (2022). <em><span class="std_class">Facets of Algebraic Geometry: A Collection in Honor of William Fulton's 80th Birthday</span></em>, 1st edition. Cambridge, UK: CUP.</formattedref>
1977
+ <docidentifier type="ISO">ISO/IEC 712-3:2022</docidentifier>
1978
+ </bibitem>
1979
+ </references>
1980
+ </bibliography>
1981
+ </iso-standard>
1982
+ INPUT
1983
+ word = <<~WORD
1984
+ <div class='WordSection3'>
1985
+ <p class='zzSTDTitle1'/>
1986
+ <div>
1987
+ <a name='A' id='A'/>
1988
+ <h1>Clause Title</h1>
1989
+ <p style='mso-list:l3 level1 lfo1;' class='MsoListParagraphCxSpFirst'>List</p>
1990
+ <div class='Note'>
1991
+ <a name='B' id='B'/>
1992
+ <p class='Note'>
1993
+ <span class='note_label'/>
1994
+ <span style='mso-tab-count:1'>  </span>
1995
+ Note
1996
+ </p>
1997
+ <p style='font-size:10.0pt;;mso-list:l3 level1 lfo2;' class='MsoListParagraphCxSpFirst'>Note List</p>
1998
+ </div>
1999
+ <div class='Example'>
2000
+ <a name='C' id='C'/>
2001
+ <p class='Example'>
2002
+ <span style='mso-tab-count:1'>  </span>
2003
+ Example
2004
+ </p>
2005
+ <p style='font-size:10.0pt;;mso-list:l3 level1 lfo3;' class='MsoListParagraphCxSpFirst'>Example List</p>
2006
+ </div>
2007
+ <div class='MsoNormal' style='text-align:center;'>
2008
+ <a name='D' id='D'/>
2009
+ <p class='FigureTitle' style='text-align:center;'>Figure Title</p>
2010
+ </div>
2011
+ <p class='Code'>
2012
+ <a name='E' id='E'/>
2013
+ XYZ
2014
+ </p>
2015
+ <p class='Tabletitle' style='text-align:center;'>Table</p>
2016
+ <div align='center' class='table_container'>
2017
+ <table class='MsoISOTable' style='mso-table-anchor-horizontal:column;mso-table-overlap:never;border-spacing:0;border-width:1px;'>
2018
+ <a name='F' id='F'/>
2019
+ </table>
2020
+ </div>
2021
+ </div>
2022
+ <p class='MsoNormal'>
2023
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
2024
+ </p>
2025
+ <div class='Section3'>
2026
+ <a name='G' id='G'/>
2027
+ <p class='ANNEX'>Annex Title</p>
2028
+ <p class='AnnexTableTitle' style='text-align:center;'>Annex Table</p>
2029
+ <div align='center' class='table_container'>
2030
+ <table class='MsoISOTable' style='mso-table-anchor-horizontal:column;mso-table-overlap:never;border-spacing:0;border-width:1px;'>
2031
+ <a name='H' id='H'/>
2032
+ </table>
2033
+ </div>
2034
+ <div>
2035
+ <a name='I' id='I'/>
2036
+ <p class='a2'>Annex Clause Title</p>
2037
+ </div>
2038
+ </div>
2039
+ <p class='MsoNormal'>
2040
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
2041
+ </p>
2042
+ <div>
2043
+ <p class='BiblioTitle'>Bibliography</p>
2044
+ <p class='MsoNormal'>
2045
+ <a name='ISO712' id='ISO712'/>
2046
+ [1]
2047
+ <span style='mso-tab-count:1'>  </span>
2048
+ ISO/IEC 712-3:2022, ALUFFI, Paolo, ed. (2022).
2049
+ <i>
2050
+ Facets of Algebraic Geometry: A Collection in Honor of William Fulton's
2051
+ 80th Birthday
2052
+ </i>
2053
+ , 1st edition. Cambridge, UK: CUP.
2054
+ </p>
2055
+ </div>
2056
+ </div>
2057
+ WORD
2058
+ FileUtils.rm_f "test.doc"
2059
+ IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
2060
+ expect(File.exist?("test.doc")).to be true
2061
+ output = File.read("test.doc", encoding: "UTF-8")
2062
+ .sub(/^.*<html/m, "<html")
2063
+ .sub(/<\/html>.*$/m, "</html>")
2064
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
2065
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
2066
+ .to be_equivalent_to xmlpp(word)
2067
+ end
1886
2068
  end
@@ -352,15 +352,9 @@ RSpec.describe Metanorma::ISO do
352
352
  <doctype>amendment</doctype>
353
353
  <editorialgroup>
354
354
  <agency>ISO</agency>
355
- <technical-committee/>
356
- <subcommittee/>
357
- <workgroup/>
358
355
  </editorialgroup>
359
356
  <approvalgroup>
360
357
  <agency>ISO</agency>
361
- <technical-committee/>
362
- <subcommittee/>
363
- <workgroup/>
364
358
  </approvalgroup>
365
359
  <structuredidentifier>
366
360
  <project-number amendment="1" part="1">17301</project-number>
@@ -431,15 +425,9 @@ RSpec.describe Metanorma::ISO do
431
425
  <doctype>amendment</doctype>
432
426
  <editorialgroup>
433
427
  <agency>ISO</agency>
434
- <technical-committee/>
435
- <subcommittee/>
436
- <workgroup/>
437
428
  </editorialgroup>
438
429
  <approvalgroup>
439
430
  <agency>ISO</agency>
440
- <technical-committee/>
441
- <subcommittee/>
442
- <workgroup/>
443
431
  </approvalgroup>
444
432
  <structuredidentifier>
445
433
  <project-number amendment="1" part="1">17301</project-number>
@@ -507,17 +495,11 @@ RSpec.describe Metanorma::ISO do
507
495
  </copyright>
508
496
  <ext>
509
497
  <doctype>amendment</doctype>
510
- <editorialgroup>
498
+ <editorialgroup>
511
499
  <agency>ISO</agency>
512
- <technical-committee/>
513
- <subcommittee/>
514
- <workgroup/>
515
500
  </editorialgroup>
516
501
  <approvalgroup>
517
502
  <agency>ISO</agency>
518
- <technical-committee/>
519
- <subcommittee/>
520
- <workgroup/>
521
503
  </approvalgroup>
522
504
  <structuredidentifier>
523
505
  <project-number amendment="1" part="1">17301</project-number>
@@ -586,17 +568,11 @@ RSpec.describe Metanorma::ISO do
586
568
  </copyright>
587
569
  <ext>
588
570
  <doctype>technical-corrigendum</doctype>
589
- <editorialgroup>
571
+ <editorialgroup>
590
572
  <agency>ISO</agency>
591
- <technical-committee/>
592
- <subcommittee/>
593
- <workgroup/>
594
573
  </editorialgroup>
595
574
  <approvalgroup>
596
575
  <agency>ISO</agency>
597
- <technical-committee/>
598
- <subcommittee/>
599
- <workgroup/>
600
576
  </approvalgroup>
601
577
  <structuredidentifier>
602
578
  <project-number corrigendum="3" part="1">17301</project-number>
@@ -665,17 +641,11 @@ RSpec.describe Metanorma::ISO do
665
641
  </copyright>
666
642
  <ext>
667
643
  <doctype>technical-corrigendum</doctype>
668
- <editorialgroup>
644
+ <editorialgroup>
669
645
  <agency>ISO</agency>
670
- <technical-committee/>
671
- <subcommittee/>
672
- <workgroup/>
673
646
  </editorialgroup>
674
647
  <approvalgroup>
675
648
  <agency>ISO</agency>
676
- <technical-committee/>
677
- <subcommittee/>
678
- <workgroup/>
679
649
  </approvalgroup>
680
650
  <structuredidentifier>
681
651
  <project-number part='1' corrigendum='3'>17301</project-number>
@@ -743,17 +713,11 @@ RSpec.describe Metanorma::ISO do
743
713
  </copyright>
744
714
  <ext>
745
715
  <doctype>technical-corrigendum</doctype>
746
- <editorialgroup>
716
+ <editorialgroup>
747
717
  <agency>ISO</agency>
748
- <technical-committee/>
749
- <subcommittee/>
750
- <workgroup/>
751
718
  </editorialgroup>
752
719
  <approvalgroup>
753
720
  <agency>ISO</agency>
754
- <technical-committee/>
755
- <subcommittee/>
756
- <workgroup/>
757
721
  </approvalgroup>
758
722
  <structuredidentifier>
759
723
  <project-number corrigendum="3" part="1">17301</project-number>