metanorma-iso 2.0.4 → 2.0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/iso/html/header.html +42 -33
  3. data/lib/isodoc/iso/html/isodoc.css +9 -7
  4. data/lib/isodoc/iso/html/isodoc.scss +7 -5
  5. data/lib/isodoc/iso/html/style-human.css +0 -1
  6. data/lib/isodoc/iso/html/style-human.scss +0 -1
  7. data/lib/isodoc/iso/html/style-iso.css +0 -1
  8. data/lib/isodoc/iso/html/style-iso.scss +0 -1
  9. data/lib/isodoc/iso/html/word_iso_titlepage.html +12 -11
  10. data/lib/isodoc/iso/html/wordstyle.css +46 -19
  11. data/lib/isodoc/iso/html/wordstyle.scss +52 -25
  12. data/lib/isodoc/iso/i18n-en.yaml +7 -2
  13. data/lib/isodoc/iso/i18n-fr.yaml +5 -2
  14. data/lib/isodoc/iso/i18n-ru.yaml +5 -2
  15. data/lib/isodoc/iso/i18n-zh-Hans.yaml +6 -2
  16. data/lib/isodoc/iso/init.rb +1 -2
  17. data/lib/isodoc/iso/iso.amendment.xsl +704 -328
  18. data/lib/isodoc/iso/iso.international-standard.xsl +704 -328
  19. data/lib/isodoc/iso/presentation_xml_convert.rb +58 -21
  20. data/lib/metanorma/iso/boilerplate-fr.xml +5 -6
  21. data/lib/metanorma/iso/boilerplate-ru.xml +4 -6
  22. data/lib/metanorma/iso/boilerplate.xml +5 -6
  23. data/lib/metanorma/iso/cleanup.rb +43 -10
  24. data/lib/metanorma/iso/front_id.rb +1 -0
  25. data/lib/metanorma/iso/processor.rb +14 -7
  26. data/lib/metanorma/iso/validate.rb +29 -1
  27. data/lib/metanorma/iso/validate_image.rb +3 -3
  28. data/lib/metanorma/iso/validate_list.rb +122 -0
  29. data/lib/metanorma/iso/validate_section.rb +39 -32
  30. data/lib/metanorma/iso/validate_style.rb +32 -2
  31. data/lib/metanorma/iso/validate_title.rb +13 -1
  32. data/lib/metanorma/iso/version.rb +1 -1
  33. data/metanorma-iso.gemspec +1 -1
  34. data/spec/isodoc/inline_spec.rb +127 -10
  35. data/spec/isodoc/postproc_spec.rb +2 -4
  36. data/spec/isodoc/terms_spec.rb +4 -4
  37. data/spec/metanorma/cleanup_spec.rb +11 -11
  38. data/spec/metanorma/refs_spec.rb +273 -61
  39. data/spec/metanorma/section_spec.rb +18 -26
  40. data/spec/metanorma/validate_spec.rb +448 -17
  41. data/spec/spec_helper.rb +6 -4
  42. data/spec/vcr_cassettes/docrels.yml +393 -0
  43. data/spec/vcr_cassettes/withdrawn_iso.yml +301 -0
  44. metadata +8 -5
@@ -537,7 +537,8 @@ RSpec.describe Metanorma::ISO do
537
537
  "specific elements"
538
538
  end
539
539
 
540
- it "do not warn that undated reference which is a bibliographic reference has locality" do
540
+ it "do not warn that undated reference which is a bibliographic reference "\
541
+ "has locality" do
541
542
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
542
543
  #{VALIDATING_BLANK_HDR}
543
544
 
@@ -640,7 +641,8 @@ RSpec.describe Metanorma::ISO do
640
641
  expect(File.read("test.err")).to include "number not broken up in threes"
641
642
  end
642
643
 
643
- it "gives No style warning if number not broken up in threes is ISO reference" do
644
+ it "gives No style warning if number not broken up in threes is "\
645
+ "ISO reference" do
644
646
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
645
647
  #{VALIDATING_BLANK_HDR}
646
648
 
@@ -733,6 +735,17 @@ RSpec.describe Metanorma::ISO do
733
735
  .to include "space between number and degrees/minutes/seconds"
734
736
  end
735
737
 
738
+ it "Style warning if hyphen instead of minus sign" do
739
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
740
+ #{VALIDATING_BLANK_HDR}
741
+
742
+ == Clause
743
+ -2
744
+ INPUT
745
+ expect(File.read("test.err"))
746
+ .to include "hyphen instead of minus sign U+2212"
747
+ end
748
+
736
749
  it "Style warning if no space between number and SI unit" do
737
750
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
738
751
  #{VALIDATING_BLANK_HDR}
@@ -754,6 +767,61 @@ RSpec.describe Metanorma::ISO do
754
767
  expect(File.read("test.err")).to include "non-standard unit"
755
768
  end
756
769
 
770
+ it "Style warning if and/or used" do
771
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
772
+ #{VALIDATING_BLANK_HDR}
773
+
774
+ == Clause
775
+ 7 and/or 8
776
+ INPUT
777
+ expect(File.read("test.err")).to include "Use 'either x or y, or both'"
778
+ end
779
+
780
+ it "Style warning if & used" do
781
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
782
+ #{VALIDATING_BLANK_HDR}
783
+
784
+ == Clause
785
+ 7 & 8
786
+ INPUT
787
+ expect(File.read("test.err")).to include "Avoid ampersand in ordinary text"
788
+ end
789
+
790
+ it "Style warning if full stop used in title or caption" do
791
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
792
+ #{VALIDATING_BLANK_HDR}
793
+
794
+ == Clause.
795
+
796
+ .Table.
797
+ |===
798
+ | A |B
799
+ |===
800
+
801
+ === Clause 2.
802
+
803
+ .Figure.
804
+ ....
805
+ Z
806
+ ....
807
+
808
+ .Other Figure
809
+ ....
810
+ A
811
+ ....
812
+ INPUT
813
+ expect(File.read("test.err"))
814
+ .to include "No full stop at end of title or caption: Clause."
815
+ expect(File.read("test.err"))
816
+ .to include "No full stop at end of title or caption: Clause 2."
817
+ expect(File.read("test.err"))
818
+ .to include "No full stop at end of title or caption: Table."
819
+ expect(File.read("test.err"))
820
+ .to include "No full stop at end of title or caption: Figure."
821
+ expect(File.read("test.err"))
822
+ .not_to include "No full stop at end of title or caption: Other Figure."
823
+ end
824
+
757
825
  # can't test: our asciidoc template won't allow this to be generated
758
826
  # it "Style warning if foreword contains subclauses" do
759
827
  # expect { Asciidoctor.convert(<<~"INPUT", *OPTIONS) }
@@ -791,7 +859,8 @@ RSpec.describe Metanorma::ISO do
791
859
  "in the standard"
792
860
  end
793
861
 
794
- it "Style warning if Symbols and Abbreviated Terms contains extraneous matter" do
862
+ it "Style warning if Symbols and Abbreviated Terms contains "\
863
+ "extraneous matter" do
795
864
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
796
865
  #{VALIDATING_BLANK_HDR}
797
866
 
@@ -1048,7 +1117,8 @@ RSpec.describe Metanorma::ISO do
1048
1117
  .not_to include "Scope must occur before Terms and Definitions"
1049
1118
  end
1050
1119
 
1051
- it "Warning if Symbols and Abbreviated Terms does not occur immediately after Terms and Definitions" do
1120
+ it "Warning if Symbols and Abbreviated Terms does not occur immediately "\
1121
+ "after Terms and Definitions" do
1052
1122
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1053
1123
  #{VALIDATING_BLANK_HDR}
1054
1124
 
@@ -1227,7 +1297,77 @@ RSpec.describe Metanorma::ISO do
1227
1297
  INPUT
1228
1298
  expect(File.read("test.err"))
1229
1299
  .not_to include "Only one Symbols and Abbreviated Terms section "\
1230
- "in the standard"
1300
+ "in the standard"
1301
+ end
1302
+
1303
+ it "Warn if single terms section in vocabulary document not named properly" do
1304
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1305
+ = Document title
1306
+ Author
1307
+ :docfile: test.adoc
1308
+ :nodoc:
1309
+ :no-isobib:
1310
+ :docsubtype: vocabulary
1311
+
1312
+ == Scope
1313
+ [heading=terms and definitions]
1314
+ == Terms and redefinitions
1315
+
1316
+ INPUT
1317
+ expect(File.read("test.err"))
1318
+ .to include "Single terms clause in vocabulary document should have "\
1319
+ "normal Terms and definitions heading"
1320
+ expect(File.read("test.err"))
1321
+ .not_to include "Multiple terms clauses in vocabulary document should "\
1322
+ "have 'Terms related to' heading"
1323
+ end
1324
+
1325
+ it "Warn if vocabulary document contains Symbols section outside annex" do
1326
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1327
+ = Document title
1328
+ Author
1329
+ :docfile: test.adoc
1330
+ :nodoc:
1331
+ :no-isobib:
1332
+ :docsubtype: vocabulary
1333
+
1334
+ == Scope
1335
+
1336
+ == Terms and definitions
1337
+
1338
+ == A Clause
1339
+
1340
+ [heading=symbols and abbreviated terms]
1341
+ == Terms related to clinical psychology
1342
+
1343
+ INPUT
1344
+ expect(File.read("test.err"))
1345
+ .to include "In vocabulary documents, Symbols and Abbreviated Terms are "\
1346
+ "only permitted in annexes"
1347
+ end
1348
+
1349
+ it "Warning if multiple terms section in vocabulary document not named "\
1350
+ "properly" do
1351
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1352
+ = Document title
1353
+ Author
1354
+ :docfile: test.adoc
1355
+ :nodoc:
1356
+ :no-isobib:
1357
+ :docsubtype: vocabulary
1358
+
1359
+ == Terms and definitions
1360
+
1361
+ [heading=terms and definitions]
1362
+ == Terms related to fish
1363
+
1364
+ INPUT
1365
+ expect(File.read("test.err"))
1366
+ .not_to include "Single terms clause in vocabulary document should have "\
1367
+ "normal Terms and definitions heading"
1368
+ expect(File.read("test.err"))
1369
+ .to include "Multiple terms clauses in vocabulary document should "\
1370
+ "have 'Terms related to' heading"
1231
1371
  end
1232
1372
 
1233
1373
  it "Warning if final section is not named Bibliography" do
@@ -1656,12 +1796,7 @@ RSpec.describe Metanorma::ISO do
1656
1796
 
1657
1797
  it "Warn if more than 7 levels of subclause" do
1658
1798
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1659
- = Document title
1660
- Author
1661
- :docfile: test.adoc
1662
- :nodoc:
1663
- :no-isobib:
1664
- :language: fr
1799
+ #{VALIDATING_BLANK_HDR}
1665
1800
 
1666
1801
  == Clause
1667
1802
 
@@ -1689,12 +1824,7 @@ RSpec.describe Metanorma::ISO do
1689
1824
 
1690
1825
  it "Do not warn if not more than 7 levels of subclause" do
1691
1826
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1692
- = Document title
1693
- Author
1694
- :docfile: test.adoc
1695
- :nodoc:
1696
- :no-isobib:
1697
- :language: fr
1827
+ #{VALIDATING_BLANK_HDR}
1698
1828
 
1699
1829
  == Clause
1700
1830
 
@@ -1729,4 +1859,305 @@ RSpec.describe Metanorma::ISO do
1729
1859
  .to include "Reference ISO8 does not have an associated footnote "\
1730
1860
  "indicating unpublished status"
1731
1861
  end
1862
+
1863
+ it "Warn if no colon or full stop before list" do
1864
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1865
+ #{VALIDATING_BLANK_HDR}
1866
+
1867
+ == Clause
1868
+
1869
+ X
1870
+
1871
+ * A very long
1872
+ * B list
1873
+ * C
1874
+ INPUT
1875
+ expect(File.read("test.err"))
1876
+ .to include "All lists must be preceded by colon or full stop"
1877
+ end
1878
+
1879
+ it "Do not warn if colon or full stop before list" do
1880
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1881
+ #{VALIDATING_BLANK_HDR}
1882
+
1883
+ == Clause
1884
+
1885
+ X.
1886
+
1887
+ * A very long
1888
+ * B list
1889
+ * C
1890
+
1891
+ X:
1892
+
1893
+ . A very long
1894
+ . B list
1895
+ . C
1896
+ INPUT
1897
+ expect(File.read("test.err"))
1898
+ .not_to include "All lists must be preceded by colon or full stop"
1899
+ end
1900
+
1901
+ it "Warn of list punctuation after colon" do
1902
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1903
+ #{VALIDATING_BLANK_HDR}
1904
+
1905
+ == Clause
1906
+
1907
+ X:
1908
+
1909
+ * this is;
1910
+ * another broken up;
1911
+ * Sentence.
1912
+
1913
+ X:
1914
+
1915
+ . this is
1916
+ . another broken up;
1917
+ . sentence
1918
+
1919
+ X:
1920
+
1921
+ . sentence.
1922
+
1923
+ X:
1924
+
1925
+ . This is.
1926
+ . Another broken up.
1927
+ . Sentence.
1928
+ INPUT
1929
+ expect(File.read("test.err"))
1930
+ .to include "List entry of broken up sentence must start with "\
1931
+ "lowercase letter: Sentence."
1932
+ expect(File.read("test.err"))
1933
+ .not_to include "List entry of broken up sentence must start with "\
1934
+ "lowercase letter: another broken up;."
1935
+ expect(File.read("test.err"))
1936
+ .to include "List entry of broken up sentence must end with semicolon: "\
1937
+ "this is"
1938
+ expect(File.read("test.err"))
1939
+ .to include "Final list entry of broken up sentence must end with "\
1940
+ "full stop: sentence"
1941
+ expect(File.read("test.err"))
1942
+ .not_to include "Final list entry of broken up sentence must end with "\
1943
+ "full stop: sentence."
1944
+ expect(File.read("test.err"))
1945
+ .not_to include "List entry of broken up sentence must start with "\
1946
+ "lowercase letter: Another broken up."
1947
+ expect(File.read("test.err"))
1948
+ .not_to include "List entry of broken up sentence must end with "\
1949
+ "semicolon: This is."
1950
+ end
1951
+
1952
+ it "Warn of list punctuation after full stop" do
1953
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1954
+ #{VALIDATING_BLANK_HDR}
1955
+
1956
+ == Clause
1957
+
1958
+ X.
1959
+
1960
+ * This is;
1961
+ * Another broken up.
1962
+ * sentence.
1963
+
1964
+ INPUT
1965
+ expect(File.read("test.err"))
1966
+ .to include "List entry of separate sentences must end with full stop: "\
1967
+ "This is;"
1968
+ expect(File.read("test.err"))
1969
+ .not_to include "List entry of separate sentences must end with "\
1970
+ "full stop: Another broken up."
1971
+ expect(File.read("test.err"))
1972
+ .to include "List entry of separate sentences must start with "\
1973
+ "uppercase letter: sentence."
1974
+ end
1975
+
1976
+ it "Skips punctuation check for short entries in lists" do
1977
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1978
+ #{VALIDATING_BLANK_HDR}
1979
+
1980
+ == Clause
1981
+
1982
+ X.
1983
+
1984
+ * This is
1985
+ * Another
1986
+ * sentence
1987
+
1988
+ INPUT
1989
+ expect(File.read("test.err"))
1990
+ .not_to include "List entry after full stop must end with full stop: "\
1991
+ "This is"
1992
+ end
1993
+
1994
+ it "Skips punctuation check for lists within tables" do
1995
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
1996
+ #{VALIDATING_BLANK_HDR}
1997
+
1998
+ == Clause
1999
+
2000
+ |===
2001
+ | A
2002
+ a|
2003
+ * This is
2004
+ * Another
2005
+ * sentence
2006
+ |===
2007
+
2008
+ INPUT
2009
+ expect(File.read("test.err"))
2010
+ .not_to include "List entry after full stop must end with full stop: "\
2011
+ "This is"
2012
+ end
2013
+
2014
+ it "Warn if more than one ordered lists in a clause" do
2015
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2016
+ #{VALIDATING_BLANK_HDR}
2017
+
2018
+ == Clause
2019
+
2020
+ . A
2021
+ .. B
2022
+ ... C
2023
+
2024
+ a
2025
+
2026
+ . A
2027
+ .. B
2028
+
2029
+ a
2030
+
2031
+ . B
2032
+
2033
+ INPUT
2034
+ expect(File.read("test.err"))
2035
+ .to include "More than 1 ordered list in a numbered clause"
2036
+
2037
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2038
+ #{VALIDATING_BLANK_HDR}
2039
+
2040
+ == Clause
2041
+
2042
+ . A
2043
+ .. B
2044
+ ... C
2045
+
2046
+ === Clause
2047
+ a
2048
+
2049
+ . A
2050
+ .. B
2051
+
2052
+ a
2053
+
2054
+ INPUT
2055
+ expect(File.read("test.err"))
2056
+ .not_to include "More than 1 ordered list in a numbered clause"
2057
+ end
2058
+
2059
+ it "Warn if list more than four levels deep" do
2060
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2061
+ #{VALIDATING_BLANK_HDR}
2062
+
2063
+ == Clause
2064
+
2065
+ . A
2066
+ .. B
2067
+ ... C
2068
+ .... D
2069
+
2070
+ INPUT
2071
+ expect(File.read("test.err"))
2072
+ .not_to include "List more than four levels deep"
2073
+
2074
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2075
+ #{VALIDATING_BLANK_HDR}
2076
+
2077
+ == Clause
2078
+
2079
+ . A
2080
+ .. B
2081
+ ... C
2082
+ .... D
2083
+ ..... E
2084
+
2085
+ INPUT
2086
+ expect(File.read("test.err"))
2087
+ .to include "List more than four levels deep"
2088
+
2089
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2090
+ #{VALIDATING_BLANK_HDR}
2091
+
2092
+ == Clause
2093
+
2094
+ * A
2095
+ ** B
2096
+ *** C
2097
+ **** D
2098
+ ***** E
2099
+
2100
+ INPUT
2101
+ expect(File.read("test.err"))
2102
+ .to include "List more than four levels deep"
2103
+
2104
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2105
+ #{VALIDATING_BLANK_HDR}
2106
+
2107
+ == Clause
2108
+
2109
+ * A
2110
+ .. B
2111
+ *** C
2112
+ .... D
2113
+ ***** E
2114
+
2115
+ INPUT
2116
+ expect(File.read("test.err"))
2117
+ .to include "List more than four levels deep"
2118
+ end
2119
+
2120
+ it "warn if term clause crossreferences non-term reference" do
2121
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2122
+ #{VALIDATING_BLANK_HDR}
2123
+
2124
+ == Terms and definitions
2125
+
2126
+ [[b]]
2127
+ === Term 1
2128
+ <<b>>
2129
+ <<c>>
2130
+
2131
+ [[c]]
2132
+ == Clause
2133
+
2134
+ INPUT
2135
+ expect(File.read("test.err"))
2136
+ .to include "non-terms clauses cannot cross-reference terms clause (c)"
2137
+ expect(File.read("test.err"))
2138
+ .not_to include "non-terms clauses cannot cross-reference terms "\
2139
+ "clause (b)"
2140
+ end
2141
+
2142
+ it "warn if non-term clause crossreferences term reference" do
2143
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
2144
+ #{VALIDATING_BLANK_HDR}
2145
+
2146
+ == Terms and definitions
2147
+
2148
+ [[b]]
2149
+ === Term 1
2150
+ <<b>>
2151
+ <<c>>
2152
+
2153
+ == Clause
2154
+ <<b>>
2155
+ <<c>>
2156
+
2157
+ INPUT
2158
+ expect(File.read("test.err"))
2159
+ .to include "only terms clauses can cross-reference terms clause (b)"
2160
+ expect(File.read("test.err"))
2161
+ .not_to include "only terms clauses can cross-reference terms clause (c)"
2162
+ end
1732
2163
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "vcr"
2
-
2
+
3
3
  VCR.configure do |config|
4
4
  config.cassette_library_dir = "spec/vcr_cassettes"
5
5
  config.hook_into :webmock
@@ -51,7 +51,9 @@ def strip_guid(xml)
51
51
  end
52
52
 
53
53
  def metadata(hash)
54
- Hash[hash.sort].delete_if { |_, v| v.nil? || v.respond_to?(:empty?) && v.empty? }
54
+ hash.sort.to_h.delete_if do |_, v|
55
+ v.nil? || (v.respond_to?(:empty?) && v.empty?)
56
+ end
55
57
  end
56
58
 
57
59
  def xmlpp(xml)
@@ -216,11 +218,11 @@ TERM_BOILERPLATE = <<~TERM.freeze
216
218
  <ul id="_">
217
219
  <li>
218
220
  <p id="_">ISO Online browsing platform: available at
219
- <link target="http://www.iso.org/obp"/></p>
221
+ <link target="https://www.iso.org/obp"/></p>
220
222
  </li>
221
223
  <li>
222
224
  <p id="_">IEC Electropedia: available at
223
- <link target="http://www.electropedia.org"/>
225
+ <link target="https://www.electropedia.org"/>
224
226
  </p>
225
227
  </li>
226
228
  </ul>