metanorma-iso 2.0.4 → 2.0.6.1

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/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
@@ -70,8 +70,8 @@ module Metanorma
70
70
  style(node, extract_text(node))
71
71
  end
72
72
 
73
- def style_regex(regex, warning, n, text)
74
- (m = regex.match(text)) && style_warning(n, warning, m[:num])
73
+ def style_regex(regex, warning, node, text)
74
+ (m = regex.match(text)) && style_warning(node, warning, m[:num])
75
75
  end
76
76
 
77
77
  # style check with a regex on a token
@@ -96,10 +96,12 @@ module Metanorma
96
96
  style_percent(node, text)
97
97
  style_abbrev(node, text)
98
98
  style_units(node, text)
99
+ style_punct(node, text)
99
100
  end
100
101
 
101
102
  # ISO/IEC DIR 2, 9.1
102
103
  # ISO/IEC DIR 2, Table B.1
104
+ # https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-n-numbers
103
105
  def style_number(node, text)
104
106
  style_two_regex_not_prev(
105
107
  node, text, /^(?<num>-?[0-9]{4,}[,0-9]*)\Z/,
@@ -110,6 +112,8 @@ module Metanorma
110
112
  "possible decimal point", node, text)
111
113
  style_regex(/\b(?<num>billions?)\b/i,
112
114
  "ambiguous number", node, text)
115
+ style_regex(/(^|\s)(?<num>-[0-9][0-9,.]*)/i,
116
+ "hyphen instead of minus sign U+2212", node, text)
113
117
  end
114
118
 
115
119
  # ISO/IEC DIR 2, 9.2.1
@@ -158,6 +162,15 @@ module Metanorma
158
162
  end
159
163
  end
160
164
 
165
+ # https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-p-and
166
+ # https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-p-andor
167
+ def style_punct(node, text)
168
+ style_regex(/\b(?<num>and\/?or)\b/i,
169
+ "Use 'either x or y, or both'", node, text)
170
+ style_regex(/\s(?<num>&)\s/i,
171
+ "Avoid ampersand in ordinary text'", node, text)
172
+ end
173
+
161
174
  def style_warning(node, msg, text = nil)
162
175
  return if @novalid
163
176
 
@@ -165,6 +178,23 @@ module Metanorma
165
178
  w += ": #{text}" if text
166
179
  @log.add("Style", node, w)
167
180
  end
181
+
182
+ ASSETS_TO_STYLE =
183
+ "//termsource | //formula | //termnote | "\
184
+ "//p[not(ancestor::boilerplate)] | //li[not(p)] | //dt | "\
185
+ "//dd[not(p)] | //td[not(p)] | //th[not(p)]".freeze
186
+
187
+ def asset_style(root)
188
+ root.xpath("//example | //termexample").each { |e| example_style(e) }
189
+ root.xpath("//definition/verbal-definition").each do |e|
190
+ definition_style(e)
191
+ end
192
+ root.xpath("//note").each { |e| note_style(e) }
193
+ root.xpath("//fn").each { |e| footnote_style(e) }
194
+ root.xpath(ASSETS_TO_STYLE).each { |e| style(e, extract_text(e)) }
195
+ norm_bibitem_style(root)
196
+ super
197
+ end
168
198
  end
169
199
  end
170
200
  end
@@ -68,7 +68,7 @@ module Metanorma
68
68
  title = s&.at("./title")&.text || s.name
69
69
  s.xpath("./clause | ./terms | ./references").each do |ss|
70
70
  subtitle = ss.at("./title")
71
- !subtitle.nil? && !subtitle&.text&.empty? or
71
+ (!subtitle.nil? && !subtitle&.text&.empty?) or
72
72
  @log.add("Style", ss,
73
73
  "#{title}: each first-level subclause must have a title")
74
74
  end
@@ -91,6 +91,17 @@ module Metanorma
91
91
  "#{label}: all subclauses must have a title, or none")
92
92
  end
93
93
 
94
+ # https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-p-full
95
+ def title_no_full_stop_validate(root)
96
+ root.xpath("//preface//title | //sections//title | //annex//title | "\
97
+ "//references/title | //preface//name | //sections//name | "\
98
+ "//annex//name").each do |t|
99
+ style_regex(/\A(?<num>.+\.\Z)/i,
100
+ "No full stop at end of title or caption",
101
+ t, t.text.strip)
102
+ end
103
+ end
104
+
94
105
  def title_validate(root)
95
106
  title_intro_validate(root)
96
107
  title_main_validate(root)
@@ -99,6 +110,7 @@ module Metanorma
99
110
  title_names_type_validate(root)
100
111
  title_first_level_validate(root)
101
112
  title_all_siblings(root.xpath(SECTIONS_XPATH), "(top level)")
113
+ title_no_full_stop_validate(root)
102
114
  end
103
115
  end
104
116
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.0.4".freeze
3
+ VERSION = "2.0.6.1".freeze
4
4
  end
5
5
  end
@@ -46,6 +46,6 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency "sassc", "2.4.0"
47
47
  spec.add_development_dependency "simplecov", "~> 0.15"
48
48
  spec.add_development_dependency "timecop", "~> 0.9"
49
- spec.add_development_dependency "vcr", "~> 5.0.0"
49
+ spec.add_development_dependency "vcr", "~> 6.1.0"
50
50
  spec.add_development_dependency "webmock"
51
51
  end
@@ -437,12 +437,12 @@ RSpec.describe IsoDoc do
437
437
  <li><concept><refterm>term6</refterm>
438
438
  <renderterm>word</renderterm>
439
439
  <eref bibitemid="ISO712" type="inline" citeas="ISO 712">
440
- <localityStack>
440
+ <localityStack connective="and">
441
441
  <locality type='clause'>
442
442
  <referenceFrom>3.1</referenceFrom>
443
443
  </locality>
444
444
  </localityStack>
445
- <localityStack>
445
+ <localityStack connective="and">
446
446
  <locality type='figure'>
447
447
  <referenceFrom>b</referenceFrom>
448
448
  </locality>
@@ -452,12 +452,12 @@ RSpec.describe IsoDoc do
452
452
  <li><concept><refterm>term7</refterm>
453
453
  <renderterm>word</renderterm>
454
454
  <eref bibitemid="ISO712" type="inline" citeas="ISO 712">
455
- <localityStack>
455
+ <localityStack connective="and">
456
456
  <locality type='clause'>
457
457
  <referenceFrom>3.1</referenceFrom>
458
458
  </locality>
459
459
  </localityStack>
460
- <localityStack>
460
+ <localityStack connective="and">
461
461
  <locality type='figure'>
462
462
  <referenceFrom>b</referenceFrom>
463
463
  </locality>
@@ -537,25 +537,25 @@ RSpec.describe IsoDoc do
537
537
  </li>
538
538
  <li>
539
539
  <em>word</em>
540
- (<eref bibitemid="ISO712" type="inline" citeas="ISO 712"><localityStack>
540
+ (<eref bibitemid="ISO712" type="inline" citeas="ISO 712"><localityStack connective="and">
541
541
  <locality type="clause">
542
542
  <referenceFrom>3.1</referenceFrom>
543
543
  </locality>
544
- </localityStack><localityStack>
544
+ </localityStack><localityStack connective="and">
545
545
  <locality type="figure">
546
546
  <referenceFrom>b</referenceFrom>
547
547
  </locality>
548
- </localityStack>ISO 712, 3.1; Figure b</eref>)
548
+ </localityStack>ISO 712, 3.1 and Figure b</eref>)
549
549
  </li>
550
550
  <li>
551
551
  <em>word</em>
552
552
  (<eref bibitemid="ISO712" type="inline" citeas="ISO 712">
553
- <localityStack>
553
+ <localityStack connective="and">
554
554
  <locality type="clause">
555
555
  <referenceFrom>3.1</referenceFrom>
556
556
  </locality>
557
557
  </localityStack>
558
- <localityStack>
558
+ <localityStack connective="and">
559
559
  <locality type="figure">
560
560
  <referenceFrom>b</referenceFrom>
561
561
  </locality>
@@ -658,7 +658,7 @@ RSpec.describe IsoDoc do
658
658
  <li>
659
659
  <i>word</i>
660
660
  (
661
- <a href='#ISO712'>ISO 712, 3.1; Figure b</a>
661
+ <a href='#ISO712'>ISO 712, 3.1 and Figure b</a>
662
662
  )
663
663
  </li>
664
664
  <li>
@@ -947,4 +947,121 @@ RSpec.describe IsoDoc do
947
947
  expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({})
948
948
  .convert("test", presxml, true))).to be_equivalent_to xmlpp(output)
949
949
  end
950
+
951
+ it "combines locality stacks with connectives, omitting subclauses" do
952
+ input = <<~INPUT
953
+ <itu-standard xmlns="https://www.calconnect.org/standards/itu">
954
+ <p id='_'>
955
+ <eref type='inline' bibitemid='ref1' citeas='XYZ'>
956
+ <localityStack connective='from'>
957
+ <locality type='clause'>
958
+ <referenceFrom>3</referenceFrom>
959
+ </locality>
960
+ </localityStack>
961
+ <localityStack connective='to'>
962
+ <locality type='clause'>
963
+ <referenceFrom>5</referenceFrom>
964
+ </locality>
965
+ </localityStack>
966
+ </eref>
967
+ <eref type='inline' bibitemid='ref1' citeas='XYZ'>
968
+ <localityStack connective='from'>
969
+ <locality type='clause'>
970
+ <referenceFrom>3.1</referenceFrom>
971
+ </locality>
972
+ </localityStack>
973
+ <localityStack connective='to'>
974
+ <locality type='clause'>
975
+ <referenceFrom>5.1</referenceFrom>
976
+ </locality>
977
+ </localityStack>
978
+ </eref>
979
+ <eref type='inline' bibitemid='ref1' citeas='XYZ'>
980
+ <localityStack connective='from'>
981
+ <locality type='clause'>
982
+ <referenceFrom>3.1</referenceFrom>
983
+ </locality>
984
+ </localityStack>
985
+ <localityStack connective='to'>
986
+ <locality type='clause'>
987
+ <referenceFrom>5</referenceFrom>
988
+ </locality>
989
+ </localityStack>
990
+ </eref>
991
+ <eref type='inline' bibitemid='ref1' citeas='XYZ'>
992
+ <localityStack connective='from'>
993
+ <locality type='clause'>
994
+ <referenceFrom>3.1</referenceFrom>
995
+ </locality>
996
+ </localityStack>
997
+ <localityStack connective='to'>
998
+ <locality type='table'>
999
+ <referenceFrom>5</referenceFrom>
1000
+ </locality>
1001
+ </localityStack>
1002
+ </eref>
1003
+ </p>
1004
+ </itu-standard>
1005
+ INPUT
1006
+ output = <<~OUTPUT
1007
+ <itu-standard xmlns='https://www.calconnect.org/standards/itu' type='presentation'>
1008
+ <p id='_'>
1009
+ <eref type='inline' bibitemid='ref1' citeas='XYZ' droploc=''>
1010
+ <localityStack connective='from'>
1011
+ <locality type='clause'>
1012
+ <referenceFrom>3</referenceFrom>
1013
+ </locality>
1014
+ </localityStack>
1015
+ <localityStack connective='to'>
1016
+ <locality type='clause'>
1017
+ <referenceFrom>5</referenceFrom>
1018
+ </locality>
1019
+ </localityStack>
1020
+ XYZ, Clause 3 to 5
1021
+ </eref>
1022
+ <eref type='inline' bibitemid='ref1' citeas='XYZ' droploc=''>
1023
+ <localityStack connective='from'>
1024
+ <locality type='clause'>
1025
+ <referenceFrom>3.1</referenceFrom>
1026
+ </locality>
1027
+ </localityStack>
1028
+ <localityStack connective='to'>
1029
+ <locality type='clause'>
1030
+ <referenceFrom>5.1</referenceFrom>
1031
+ </locality>
1032
+ </localityStack>
1033
+ XYZ, 3.1 to 5.1
1034
+ </eref>
1035
+ <eref type='inline' bibitemid='ref1' citeas='XYZ'>
1036
+ <localityStack connective='from'>
1037
+ <locality type='clause'>
1038
+ <referenceFrom>3.1</referenceFrom>
1039
+ </locality>
1040
+ </localityStack>
1041
+ <localityStack connective='to'>
1042
+ <locality type='clause'>
1043
+ <referenceFrom>5</referenceFrom>
1044
+ </locality>
1045
+ </localityStack>
1046
+ XYZ, 3.1 to Clause 5
1047
+ </eref>
1048
+ <eref type='inline' bibitemid='ref1' citeas='XYZ'>
1049
+ <localityStack connective='from'>
1050
+ <locality type='clause'>
1051
+ <referenceFrom>3.1</referenceFrom>
1052
+ </locality>
1053
+ </localityStack>
1054
+ <localityStack connective='to'>
1055
+ <locality type='table'>
1056
+ <referenceFrom>5</referenceFrom>
1057
+ </locality>
1058
+ </localityStack>
1059
+ XYZ, 3.1 to Table 5
1060
+ </eref>
1061
+ </p>
1062
+ </itu-standard>
1063
+ OUTPUT
1064
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({})
1065
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1066
+ end
950
1067
  end
@@ -222,7 +222,7 @@ RSpec.describe IsoDoc do
222
222
  .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
223
223
 
224
224
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
225
- <div class='WordSection3'>
225
+ <div class='WordSection3'>
226
226
  <p class='zzSTDTitle1'/>
227
227
  <div>
228
228
  <a name='_terms_and_definitions' id='_terms_and_definitions'/>
@@ -241,9 +241,7 @@ RSpec.describe IsoDoc do
241
241
  rice retaining its husk after threshing
242
242
  </p>
243
243
  <p class='Source'>
244
- [SOURCE:
245
- <a href='#ISO7301'>ISO 7301:2011, 3.1</a>
246
- , modified &#x2013; The term "cargo rice" is shown as deprecated, and Note
244
+ [SOURCE: ISO 7301:2011, 3.1, modified &#x2013; The term "cargo rice" is shown as deprecated, and Note
247
245
  1 to entry is not included here]
248
246
  </p>
249
247
  </div>
@@ -161,7 +161,7 @@ RSpec.describe IsoDoc do
161
161
  </ul>
162
162
  </div>
163
163
  <p>[SOURCE:
164
- <a href="#ISO7301">ISO 7301:2011, 3.1</a>, modified &#8211;
164
+ ISO 7301:2011, 3.1, modified &#8211;
165
165
  The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here]</p>
166
166
  <p class="TermNum" id="paddy">1.2</p>
167
167
  <p class="Terms" style="text-align:left;"><b>paddy</b></p>
@@ -187,7 +187,7 @@ RSpec.describe IsoDoc do
187
187
  <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
188
188
  </p>
189
189
  </div>
190
- <p>[SOURCE: <a href="#ISO7301">ISO 7301:2011, 3.1</a>]</p>
190
+ <p>[SOURCE: ISO 7301:2011, 3.1]</p>
191
191
  <p class='TermNum' id='A'>1.3</p>
192
192
  <p class='Terms' style='text-align:left;'><b>term1</b></p>
193
193
  term1 definition
@@ -213,7 +213,7 @@ RSpec.describe IsoDoc do
213
213
  </ul></div>
214
214
 
215
215
  <p class="Source">[SOURCE:
216
- <a href="#ISO7301">ISO 7301:2011, 3.1</a>, modified &#8211;
216
+ ISO 7301:2011, 3.1, modified &#8211;
217
217
  The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here]</p>
218
218
  <p class="TermNum" id="paddy">1.2</p>
219
219
  <p class="Terms" style="text-align:left;"><b>paddy</b></p>
@@ -228,7 +228,7 @@ RSpec.describe IsoDoc do
228
228
  </div>
229
229
  <div id='_671a1994-4783-40d0-bc81-987d06ffb74e' class="Note"><p class="Note">Note 1 to entry: The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p></div>
230
230
  <div id='_671a1994-4783-40d0-bc81-987d06ffb74f' class="Note"><p class="Note">Note 2 to entry: <ul><li>A</li></ul><p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p></p></div>
231
- <p class="Source">[SOURCE: <a href="#ISO7301">ISO 7301:2011, 3.1</a>]</p>
231
+ <p class="Source">[SOURCE: ISO 7301:2011, 3.1]</p>
232
232
  <p class='TermNum' id='A'>1.3</p>
233
233
  <p class='Terms' style='text-align:left;'><b>term1</b></p>
234
234
  term1 definition
@@ -137,7 +137,7 @@ RSpec.describe Metanorma::ISO do
137
137
  <terms id="_" obligation="normative">
138
138
  <title>Terms and definitions</title>
139
139
  #{TERM_BOILERPLATE}
140
- <term id="term-_-t90-">
140
+ <term id="term-t90">
141
141
  <preferred>
142
142
  <letter-symbol><name>
143
143
  <stem type="MathML">
@@ -1247,13 +1247,13 @@ RSpec.describe Metanorma::ISO do
1247
1247
  <li>
1248
1248
  <p id='_'>
1249
1249
  ISO Online browsing platform: available at
1250
- <link target='http://www.iso.org/obp'/>
1250
+ <link target='https://www.iso.org/obp'/>
1251
1251
  </p>
1252
1252
  </li>
1253
1253
  <li>
1254
1254
  <p id='_'>
1255
1255
  IEC Electropedia: available at
1256
- <link target='http://www.electropedia.org'/>
1256
+ <link target='https://www.electropedia.org'/>
1257
1257
  </p>
1258
1258
  </li>
1259
1259
  </ul>
@@ -1296,13 +1296,13 @@ RSpec.describe Metanorma::ISO do
1296
1296
  <li>
1297
1297
  <p id='_'>
1298
1298
  ISO Online browsing platform: available at
1299
- <link target='http://www.iso.org/obp'/>
1299
+ <link target='https://www.iso.org/obp'/>
1300
1300
  </p>
1301
1301
  </li>
1302
1302
  <li>
1303
1303
  <p id='_'>
1304
1304
  IEC Electropedia: available at
1305
- <link target='http://www.electropedia.org'/>
1305
+ <link target='https://www.electropedia.org'/>
1306
1306
  </p>
1307
1307
  </li>
1308
1308
  </ul>
@@ -1360,13 +1360,13 @@ RSpec.describe Metanorma::ISO do
1360
1360
  <li>
1361
1361
  <p id='_'>
1362
1362
  ISO Online browsing platform: available at
1363
- <link target='http://www.iso.org/obp'/>
1363
+ <link target='https://www.iso.org/obp'/>
1364
1364
  </p>
1365
1365
  </li>
1366
1366
  <li>
1367
1367
  <p id='_'>
1368
1368
  IEC Electropedia: available at
1369
- <link target='http://www.electropedia.org'/>
1369
+ <link target='https://www.electropedia.org'/>
1370
1370
  </p>
1371
1371
  </li>
1372
1372
  </ul>
@@ -1427,13 +1427,13 @@ RSpec.describe Metanorma::ISO do
1427
1427
  <li>
1428
1428
  <p id='_'>
1429
1429
  ISO Online browsing platform: available at
1430
- <link target='http://www.iso.org/obp'/>
1430
+ <link target='https://www.iso.org/obp'/>
1431
1431
  </p>
1432
1432
  </li>
1433
1433
  <li>
1434
1434
  <p id='_'>
1435
1435
  IEC Electropedia: available at
1436
- <link target='http://www.electropedia.org'/>
1436
+ <link target='https://www.electropedia.org'/>
1437
1437
  </p>
1438
1438
  </li>
1439
1439
  </ul>
@@ -1485,13 +1485,13 @@ RSpec.describe Metanorma::ISO do
1485
1485
  <li>
1486
1486
  <p id='_'>
1487
1487
  ISO Online browsing platform: available at
1488
- <link target='http://www.iso.org/obp'/>
1488
+ <link target='https://www.iso.org/obp'/>
1489
1489
  </p>
1490
1490
  </li>
1491
1491
  <li>
1492
1492
  <p id='_'>
1493
1493
  IEC Electropedia: available at
1494
- <link target='http://www.electropedia.org'/>
1494
+ <link target='https://www.electropedia.org'/>
1495
1495
  </p>
1496
1496
  </li>
1497
1497
  </ul>