metanorma-iso 2.3.6 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -84,15 +84,15 @@ module IsoDoc
84
84
  p = titlenums[:part]
85
85
  titlenums[:part] && titlenums[:subpart] and
86
86
  p = "#{titlenums[:part]}–#{titlenums[:subpart]}"
87
- "#{PART_LABEL[lang.to_sym]} #{p}"
87
+ "#{self.class::PART_LABEL[lang.to_sym]} #{p}"
88
88
  end
89
89
 
90
90
  def amd_prefix(titlenums, lang)
91
- "#{AMD_LABEL[lang.to_sym]} #{titlenums[:amd]}"
91
+ "#{self.class::AMD_LABEL[lang.to_sym]} #{titlenums[:amd]}"
92
92
  end
93
93
 
94
94
  def corr_prefix(titlenums, lang)
95
- "#{CORR_LABEL[lang.to_sym]} #{titlenums[:corr]}"
95
+ "#{self.class::CORR_LABEL[lang.to_sym]} #{titlenums[:corr]}"
96
96
  end
97
97
 
98
98
  def compose_title(tparts, tnums, lang)
@@ -220,6 +220,22 @@ module IsoDoc
220
220
  super
221
221
  end
222
222
 
223
+ def formula_where(dlist)
224
+ dlist.nil? and return
225
+ return super unless dlist.xpath(ns("./dt")).size == 1 &&
226
+ dlist.at(ns("./dd"))&.elements&.size == 1 &&
227
+ dlist.at(ns("./dd/p"))
228
+
229
+ formula_where_one(dlist)
230
+ end
231
+
232
+ def formula_where_one(dlist)
233
+ dt = to_xml(dlist.at(ns("./dt")).children)
234
+ dd = to_xml(dlist.at(ns("./dd/p")).children)
235
+ dlist.previous = "<p>#{@i18n.where_one} #{dt} #{dd}</p>"
236
+ dlist.remove
237
+ end
238
+
223
239
  include Init
224
240
  end
225
241
  end
@@ -7,24 +7,24 @@ module IsoDoc
7
7
  end
8
8
 
9
9
  def middle_title_main(out)
10
- out.p(**{ class: "zzSTDTitle1" }) do |p|
10
+ out.p(class: "zzSTDTitle1") do |p|
11
11
  p << @meta.get[:doctitleintro]
12
12
  p << " &#x2014; " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
13
13
  p << @meta.get[:doctitlemain]
14
14
  p << " &#x2014; " if @meta.get[:doctitlemain] && @meta.get[:doctitlepart]
15
15
  end
16
- a = @meta.get[:doctitlepart] and out.p(**{ class: "zzSTDTitle2" }) do |p|
16
+ a = @meta.get[:doctitlepart] and out.p(class: "zzSTDTitle2") do |p|
17
17
  b = @meta.get[:doctitlepartlabel] and p << "#{b}: "
18
18
  p << "<br/><b>#{a}</b>"
19
19
  end
20
20
  end
21
21
 
22
22
  def middle_title_amd(out)
23
- a = @meta.get[:doctitleamdlabel] and out.p(**{ class: "zzSTDTitle2" }) do |p|
23
+ a = @meta.get[:doctitleamdlabel] and out.p(class: "zzSTDTitle2") do |p|
24
24
  p << a
25
25
  a = @meta.get[:doctitleamd] and p << ": #{a}"
26
26
  end
27
- a = @meta.get[:doctitlecorrlabel] and out.p(**{ class: "zzSTDTitle2" }) do |p|
27
+ a = @meta.get[:doctitlecorrlabel] and out.p(class: "zzSTDTitle2") do |p|
28
28
  p << a
29
29
  end
30
30
  end
@@ -39,8 +39,8 @@ module IsoDoc
39
39
  f = isoxml.at(ns("//introduction")) || return
40
40
  title_attr = { class: "IntroTitle" }
41
41
  page_break(out)
42
- out.div **{ class: "Section3", id: f["id"] } do |div|
43
- clause_name(nil, f.at(ns("./title")), div, title_attr)
42
+ out.div class: "Section3", id: f["id"] do |div|
43
+ clause_name(f, f.at(ns("./title")), div, title_attr)
44
44
  f.elements.each do |e|
45
45
  parse(e, div) unless e.name == "title"
46
46
  end
@@ -86,7 +86,7 @@ module IsoDoc
86
86
  }.freeze
87
87
 
88
88
  def new_styles(docxml)
89
- STYLESMAP.each do |k, v|
89
+ self.class::STYLESMAP.each do |k, v|
90
90
  docxml.xpath("//*[@class = '#{k}']").each { |s| s["class"] = v }
91
91
  end
92
92
  docxml.xpath("//div[@class = 'Section3']//p[@class = 'Tabletitle']")
@@ -104,7 +104,7 @@ module IsoDoc
104
104
  def indexsect_title(clause, out)
105
105
  br(out, "always")
106
106
  out.div class: "WordSection3" do |div|
107
- clause_name(nil, clause.at(ns("./title")), div, nil)
107
+ clause_name(clause, clause.at(ns("./title")), div, nil)
108
108
  end
109
109
  end
110
110
 
@@ -8,11 +8,13 @@ module Metanorma
8
8
  "//clause[@type = 'scope']//fn".freeze
9
9
 
10
10
  NORMREF_FOOTNOTES =
11
- "//references[@normative = 'true']//fn".freeze
11
+ "//references[@normative = 'true']//fn | " \
12
+ "//clause[.//references[@normative = 'true']]//fn".freeze
12
13
 
13
14
  POST_NORMREF_FOOTNOTES =
14
15
  "//sections//clause[not(@type = 'scope')]//fn | " \
15
- "//annex//fn | //references[@normative = 'false']//fn".freeze
16
+ "//annex//fn | //references[@normative = 'false']//fn | " \
17
+ "//clause[.//references[@normative = 'false']]//fn".freeze
16
18
 
17
19
  def other_footnote_renumber(xmldoc)
18
20
  seen = {}
@@ -27,8 +29,7 @@ module Metanorma
27
29
 
28
30
  def id_prefix(prefix, id)
29
31
  # we're just inheriting the prefixes from parent doc
30
- return id.text if @amd
31
-
32
+ @amd and return id.text
32
33
  prefix.join("/") + (id.text.match?(%{^/}) ? "" : " ") + id.text
33
34
  end
34
35
 
@@ -105,8 +106,7 @@ module Metanorma
105
106
 
106
107
  def sections_cleanup(xml)
107
108
  super
108
- return unless @amd
109
-
109
+ @amd or return
110
110
  xml.xpath("//*[@inline-header]").each { |h| h.delete("inline-header") }
111
111
  end
112
112
 
@@ -153,8 +153,7 @@ module Metanorma
153
153
  def withdrawn_note(xmldoc)
154
154
  xmldoc.xpath("//bibitem[not(note[@type = 'Unpublished-Status'])]")
155
155
  .each do |b|
156
- next unless withdrawn_ref?(b)
157
-
156
+ withdrawn_ref?(b) or next
158
157
  if id = replacement_standard(b)
159
158
  insert_unpub_note(b, @i18n.cancelled_and_replaced.sub(/%/, id))
160
159
  else insert_unpub_note(b, @i18n.withdrawn)
@@ -163,8 +162,7 @@ module Metanorma
163
162
  end
164
163
 
165
164
  def withdrawn_ref?(biblio)
166
- return false if pub_class(biblio) > 2
167
-
165
+ pub_class(biblio) > 2 and return false
168
166
  (s = biblio.at("./status/stage")) && (s.text.to_i == 95) &&
169
167
  (t = biblio.at("./status/substage")) && (t.text.to_i == 99)
170
168
  end
@@ -220,24 +220,7 @@
220
220
  <attribute name="id">
221
221
  <data type="ID"/>
222
222
  </attribute>
223
- <optional>
224
- <attribute name="keep-with-next">
225
- <data type="boolean"/>
226
- </attribute>
227
- </optional>
228
- <optional>
229
- <attribute name="keep-lines-together">
230
- <data type="boolean"/>
231
- </attribute>
232
- </optional>
233
- <optional>
234
- <attribute name="tag"/>
235
- </optional>
236
- <optional>
237
- <attribute name="multilingual-rendering">
238
- <ref name="MultilingualRenderingType"/>
239
- </attribute>
240
- </optional>
223
+ <ref name="BlockAttributes"/>
241
224
  <optional>
242
225
  <ref name="tname"/>
243
226
  </optional>
@@ -254,24 +237,7 @@
254
237
  <attribute name="id">
255
238
  <data type="ID"/>
256
239
  </attribute>
257
- <optional>
258
- <attribute name="keep-with-next">
259
- <data type="boolean"/>
260
- </attribute>
261
- </optional>
262
- <optional>
263
- <attribute name="keep-lines-together">
264
- <data type="boolean"/>
265
- </attribute>
266
- </optional>
267
- <optional>
268
- <attribute name="tag"/>
269
- </optional>
270
- <optional>
271
- <attribute name="multilingual-rendering">
272
- <ref name="MultilingualRenderingType"/>
273
- </attribute>
274
- </optional>
240
+ <ref name="BlockAttributes"/>
275
241
  <optional>
276
242
  <attribute name="type">
277
243
  <choice>
@@ -299,29 +265,12 @@
299
265
  <attribute name="id">
300
266
  <data type="ID"/>
301
267
  </attribute>
302
- <optional>
303
- <attribute name="keep-with-next">
304
- <data type="boolean"/>
305
- </attribute>
306
- </optional>
307
- <optional>
308
- <attribute name="keep-lines-together">
309
- <data type="boolean"/>
310
- </attribute>
311
- </optional>
268
+ <ref name="BlockAttributes"/>
312
269
  <optional>
313
270
  <attribute name="key">
314
271
  <data type="boolean"/>
315
272
  </attribute>
316
273
  </optional>
317
- <optional>
318
- <attribute name="tag"/>
319
- </optional>
320
- <optional>
321
- <attribute name="multilingual-rendering">
322
- <ref name="MultilingualRenderingType"/>
323
- </attribute>
324
- </optional>
325
274
  <optional>
326
275
  <ref name="tname"/>
327
276
  </optional>
@@ -362,24 +311,7 @@
362
311
  <optional>
363
312
  <attribute name="number"/>
364
313
  </optional>
365
- <optional>
366
- <attribute name="keep-with-next">
367
- <data type="boolean"/>
368
- </attribute>
369
- </optional>
370
- <optional>
371
- <attribute name="keep-lines-together">
372
- <data type="boolean"/>
373
- </attribute>
374
- </optional>
375
- <optional>
376
- <attribute name="tag"/>
377
- </optional>
378
- <optional>
379
- <attribute name="multilingual-rendering">
380
- <ref name="MultilingualRenderingType"/>
381
- </attribute>
382
- </optional>
314
+ <ref name="BlockAttributes"/>
383
315
  <optional>
384
316
  <ref name="tname"/>
385
317
  </optional>
@@ -427,27 +359,10 @@
427
359
  <data type="anyURI"/>
428
360
  </attribute>
429
361
  </optional>
430
- <optional>
431
- <attribute name="keep-with-next">
432
- <data type="boolean"/>
433
- </attribute>
434
- </optional>
435
- <optional>
436
- <attribute name="keep-lines-together">
437
- <data type="boolean"/>
438
- </attribute>
439
- </optional>
440
362
  <optional>
441
363
  <attribute name="width"/>
442
364
  </optional>
443
- <optional>
444
- <attribute name="tag"/>
445
- </optional>
446
- <optional>
447
- <attribute name="multilingual-rendering">
448
- <ref name="MultilingualRenderingType"/>
449
- </attribute>
450
- </optional>
365
+ <ref name="BlockAttributes"/>
451
366
  <optional>
452
367
  <ref name="colgroup"/>
453
368
  </optional>
@@ -485,27 +400,10 @@
485
400
  <optional>
486
401
  <attribute name="subsequence"/>
487
402
  </optional>
488
- <optional>
489
- <attribute name="keep-with-next">
490
- <data type="boolean"/>
491
- </attribute>
492
- </optional>
493
- <optional>
494
- <attribute name="keep-lines-together">
495
- <data type="boolean"/>
496
- </attribute>
497
- </optional>
498
403
  <optional>
499
404
  <attribute name="class"/>
500
405
  </optional>
501
- <optional>
502
- <attribute name="tag"/>
503
- </optional>
504
- <optional>
505
- <attribute name="multilingual-rendering">
506
- <ref name="MultilingualRenderingType"/>
507
- </attribute>
508
- </optional>
406
+ <ref name="BlockAttributes"/>
509
407
  <optional>
510
408
  <ref name="source"/>
511
409
  </optional>
@@ -551,27 +449,10 @@
551
449
  <optional>
552
450
  <attribute name="subsequence"/>
553
451
  </optional>
554
- <optional>
555
- <attribute name="keep-with-next">
556
- <data type="boolean"/>
557
- </attribute>
558
- </optional>
559
- <optional>
560
- <attribute name="keep-lines-together">
561
- <data type="boolean"/>
562
- </attribute>
563
- </optional>
564
452
  <optional>
565
453
  <attribute name="lang"/>
566
454
  </optional>
567
- <optional>
568
- <attribute name="tag"/>
569
- </optional>
570
- <optional>
571
- <attribute name="multilingual-rendering">
572
- <ref name="MultilingualRenderingType"/>
573
- </attribute>
574
- </optional>
455
+ <ref name="BlockAttributes"/>
575
456
  <optional>
576
457
  <attribute name="linenums">
577
458
  <data type="boolean"/>
@@ -610,29 +491,12 @@
610
491
  <optional>
611
492
  <attribute name="subsequence"/>
612
493
  </optional>
613
- <optional>
614
- <attribute name="keep-with-next">
615
- <data type="boolean"/>
616
- </attribute>
617
- </optional>
618
- <optional>
619
- <attribute name="keep-lines-together">
620
- <data type="boolean"/>
621
- </attribute>
622
- </optional>
623
494
  <optional>
624
495
  <attribute name="inequality">
625
496
  <data type="boolean"/>
626
497
  </attribute>
627
498
  </optional>
628
- <optional>
629
- <attribute name="tag"/>
630
- </optional>
631
- <optional>
632
- <attribute name="multilingual-rendering">
633
- <ref name="MultilingualRenderingType"/>
634
- </attribute>
635
- </optional>
499
+ <ref name="BlockAttributes"/>
636
500
  <ref name="stem"/>
637
501
  <optional>
638
502
  <ref name="dl"/>
@@ -651,27 +515,7 @@
651
515
  <ref name="Alignments"/>
652
516
  </attribute>
653
517
  </optional>
654
- <optional>
655
- <attribute name="keep-with-next">
656
- <data type="boolean"/>
657
- </attribute>
658
- </optional>
659
- <optional>
660
- <attribute name="keep-lines-together">
661
- <data type="boolean"/>
662
- </attribute>
663
- </optional>
664
- <optional>
665
- <attribute name="tag"/>
666
- </optional>
667
- <optional>
668
- <attribute name="type"/>
669
- </optional>
670
- <optional>
671
- <attribute name="multilingual-rendering">
672
- <ref name="MultilingualRenderingType"/>
673
- </attribute>
674
- </optional>
518
+ <ref name="BlockAttributes"/>
675
519
  <zeroOrMore>
676
520
  <ref name="TextElement"/>
677
521
  </zeroOrMore>
@@ -689,27 +533,10 @@
689
533
  <ref name="Alignments"/>
690
534
  </attribute>
691
535
  </optional>
692
- <optional>
693
- <attribute name="keep-with-next">
694
- <data type="boolean"/>
695
- </attribute>
696
- </optional>
697
- <optional>
698
- <attribute name="keep-lines-together">
699
- <data type="boolean"/>
700
- </attribute>
701
- </optional>
702
- <optional>
703
- <attribute name="tag"/>
704
- </optional>
705
536
  <optional>
706
537
  <attribute name="type"/>
707
538
  </optional>
708
- <optional>
709
- <attribute name="multilingual-rendering">
710
- <ref name="MultilingualRenderingType"/>
711
- </attribute>
712
- </optional>
539
+ <ref name="BlockAttributes"/>
713
540
  <zeroOrMore>
714
541
  <choice>
715
542
  <ref name="TextElement"/>
@@ -731,24 +558,7 @@
731
558
  <ref name="Alignments"/>
732
559
  </attribute>
733
560
  </optional>
734
- <optional>
735
- <attribute name="keep-with-next">
736
- <data type="boolean"/>
737
- </attribute>
738
- </optional>
739
- <optional>
740
- <attribute name="keep-lines-together">
741
- <data type="boolean"/>
742
- </attribute>
743
- </optional>
744
- <optional>
745
- <attribute name="tag"/>
746
- </optional>
747
- <optional>
748
- <attribute name="multilingual-rendering">
749
- <ref name="MultilingualRenderingType"/>
750
- </attribute>
751
- </optional>
561
+ <ref name="BlockAttributes"/>
752
562
  <optional>
753
563
  <ref name="quote-source"/>
754
564
  </optional>
@@ -828,27 +638,9 @@
828
638
  <optional>
829
639
  <attribute name="subsequence"/>
830
640
  </optional>
831
- <optional>
832
- <attribute name="keep-with-next">
833
- <data type="boolean"/>
834
- </attribute>
835
- </optional>
836
- <optional>
837
- <attribute name="keep-lines-together">
838
- <data type="boolean"/>
839
- </attribute>
840
- </optional>
841
641
  <optional>
842
642
  <attribute name="type"/>
843
643
  </optional>
844
- <optional>
845
- <attribute name="tag"/>
846
- </optional>
847
- <optional>
848
- <attribute name="multilingual-rendering">
849
- <ref name="MultilingualRenderingType"/>
850
- </attribute>
851
- </optional>
852
644
  <optional>
853
645
  <attribute name="coverpage">
854
646
  <data type="boolean"/>
@@ -859,6 +651,7 @@
859
651
  <data type="boolean"/>
860
652
  </attribute>
861
653
  </optional>
654
+ <ref name="BlockAttributes"/>
862
655
  <oneOrMore>
863
656
  <choice>
864
657
  <ref name="paragraph"/>
@@ -1332,14 +1125,7 @@
1332
1125
  <optional>
1333
1126
  <attribute name="class"/>
1334
1127
  </optional>
1335
- <optional>
1336
- <attribute name="tag"/>
1337
- </optional>
1338
- <optional>
1339
- <attribute name="multilingual-rendering">
1340
- <ref name="MultilingualRenderingType"/>
1341
- </attribute>
1342
- </optional>
1128
+ <ref name="BlockAttributes"/>
1343
1129
  <zeroOrMore>
1344
1130
  <choice>
1345
1131
  <ref name="TextElement"/>
@@ -1908,7 +1694,10 @@
1908
1694
  </zeroOrMore>
1909
1695
  <choice>
1910
1696
  <oneOrMore>
1911
- <ref name="term"/>
1697
+ <choice>
1698
+ <ref name="term"/>
1699
+ <ref name="terms"/>
1700
+ </choice>
1912
1701
  </oneOrMore>
1913
1702
  <group>
1914
1703
  <zeroOrMore>
@@ -1934,14 +1723,7 @@
1934
1723
  <optional>
1935
1724
  <attribute name="script"/>
1936
1725
  </optional>
1937
- <optional>
1938
- <attribute name="tag"/>
1939
- </optional>
1940
- <optional>
1941
- <attribute name="multilingual-rendering">
1942
- <ref name="MultilingualRenderingType"/>
1943
- </attribute>
1944
- </optional>
1726
+ <ref name="BlockAttributes"/>
1945
1727
  <oneOrMore>
1946
1728
  <ref name="preferred"/>
1947
1729
  </oneOrMore>
@@ -2282,24 +2064,7 @@
2282
2064
  <optional>
2283
2065
  <attribute name="subsequence"/>
2284
2066
  </optional>
2285
- <optional>
2286
- <attribute name="keep-with-next">
2287
- <data type="boolean"/>
2288
- </attribute>
2289
- </optional>
2290
- <optional>
2291
- <attribute name="keep-lines-together">
2292
- <data type="boolean"/>
2293
- </attribute>
2294
- </optional>
2295
- <optional>
2296
- <attribute name="tag"/>
2297
- </optional>
2298
- <optional>
2299
- <attribute name="multilingual-rendering">
2300
- <ref name="MultilingualRenderingType"/>
2301
- </attribute>
2302
- </optional>
2067
+ <ref name="BlockAttributes"/>
2303
2068
  <oneOrMore>
2304
2069
  <choice>
2305
2070
  <ref name="paragraph"/>
@@ -2316,24 +2081,7 @@
2316
2081
  <attribute name="id">
2317
2082
  <data type="ID"/>
2318
2083
  </attribute>
2319
- <optional>
2320
- <attribute name="keep-with-next">
2321
- <data type="boolean"/>
2322
- </attribute>
2323
- </optional>
2324
- <optional>
2325
- <attribute name="keep-lines-together">
2326
- <data type="boolean"/>
2327
- </attribute>
2328
- </optional>
2329
- <optional>
2330
- <attribute name="tag"/>
2331
- </optional>
2332
- <optional>
2333
- <attribute name="multilingual-rendering">
2334
- <ref name="MultilingualRenderingType"/>
2335
- </attribute>
2336
- </optional>
2084
+ <ref name="BlockAttributes"/>
2337
2085
  <oneOrMore>
2338
2086
  <choice>
2339
2087
  <ref name="formula"/>
@@ -2460,14 +2208,7 @@
2460
2208
  <optional>
2461
2209
  <attribute name="title"/>
2462
2210
  </optional>
2463
- <optional>
2464
- <attribute name="tag"/>
2465
- </optional>
2466
- <optional>
2467
- <attribute name="multilingual-rendering">
2468
- <ref name="MultilingualRenderingType"/>
2469
- </attribute>
2470
- </optional>
2211
+ <ref name="BlockAttributes"/>
2471
2212
  <optional>
2472
2213
  <element name="location">
2473
2214
  <zeroOrMore>
@@ -2527,14 +2268,7 @@
2527
2268
  </define>
2528
2269
  <define name="imagemap">
2529
2270
  <element name="imagemap">
2530
- <optional>
2531
- <attribute name="tag"/>
2532
- </optional>
2533
- <optional>
2534
- <attribute name="multilingual-rendering">
2535
- <ref name="MultilingualRenderingType"/>
2536
- </attribute>
2537
- </optional>
2271
+ <ref name="BlockAttributes"/>
2538
2272
  <ref name="figure"/>
2539
2273
  <zeroOrMore>
2540
2274
  <element name="area">
@@ -2580,14 +2314,7 @@
2580
2314
  </define>
2581
2315
  <define name="svgmap">
2582
2316
  <element name="svgmap">
2583
- <optional>
2584
- <attribute name="tag"/>
2585
- </optional>
2586
- <optional>
2587
- <attribute name="multilingual-rendering">
2588
- <ref name="MultilingualRenderingType"/>
2589
- </attribute>
2590
- </optional>
2317
+ <ref name="BlockAttributes"/>
2591
2318
  <ref name="figure"/>
2592
2319
  <zeroOrMore>
2593
2320
  <element name="target">
@@ -2694,6 +2421,29 @@
2694
2421
  </oneOrMore>
2695
2422
  </element>
2696
2423
  </define>
2424
+ <define name="BlockAttributes">
2425
+ <optional>
2426
+ <attribute name="keep-with-next">
2427
+ <data type="boolean"/>
2428
+ </attribute>
2429
+ </optional>
2430
+ <optional>
2431
+ <attribute name="keep-lines-together">
2432
+ <data type="boolean"/>
2433
+ </attribute>
2434
+ </optional>
2435
+ <optional>
2436
+ <attribute name="tag"/>
2437
+ </optional>
2438
+ <optional>
2439
+ <attribute name="multilingual-rendering">
2440
+ <ref name="MultilingualRenderingType"/>
2441
+ </attribute>
2442
+ </optional>
2443
+ <optional>
2444
+ <attribute name="columns"/>
2445
+ </optional>
2446
+ </define>
2697
2447
  <start>
2698
2448
  <ref name="standard-document"/>
2699
2449
  </start>
@@ -88,14 +88,7 @@
88
88
  <optional>
89
89
  <attribute name="script"/>
90
90
  </optional>
91
- <optional>
92
- <attribute name="tag"/>
93
- </optional>
94
- <optional>
95
- <attribute name="multilingual-rendering">
96
- <ref name="MultilingualRenderingType"/>
97
- </attribute>
98
- </optional>
91
+ <ref name="BlockAttributes"/>
99
92
  <ref name="preferred"/>
100
93
  <zeroOrMore>
101
94
  <ref name="admitted"/>