metanorma-bipm 2.6.10 → 2.7.0

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.
@@ -48,16 +48,20 @@ module IsoDoc
48
48
 
49
49
  def docid(isoxml, _out)
50
50
  super
51
- docid_part(isoxml, %w(Appendix Annexe), "appendix", :appendixid)
52
- docid_part(isoxml, %w(Annex Appendice), "annexid", :annexid)
53
- docid_part(isoxml, %w(Part Partie), "part", :partid)
51
+ docid_part(isoxml, [@i18n.get["level2_ancillary"],
52
+ @i18n.get["level2_ancillary_alt"]], "appendix", :appendixid)
53
+ docid_part(isoxml, [@i18n.get["level3_ancillary"],
54
+ @i18n.get["level3_ancillary_alt"]], "annexid", :annexid)
55
+ docid_part(isoxml, [@i18n.get["level4_ancillary"],
56
+ @i18n.get["level4_ancillary_alt"]], "part", :partid)
57
+ docid_part(isoxml, [@i18n.get["level5_ancillary"],
58
+ @i18n.get["level5_ancillary_alt"]], "subpart", :subpartid)
54
59
  set(:org_abbrev,
55
60
  isoxml.at(ns("//bibdata/ext/editorialgroup/committee"\
56
61
  "[@acronym = 'JCGM']")) ? "JCGM" : "BIPM")
57
62
  end
58
63
 
59
64
  def docid_part(isoxml, labels, elem, key)
60
- @lang == "fr" and labels.reverse!
61
65
  label1, label2 = labels
62
66
  dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/#{elem}"))
63
67
  dn and set(key, @i18n.l10n("#{label1} #{dn.text}"))
@@ -3,10 +3,35 @@ module IsoDoc
3
3
  class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
4
4
  def bibdata_i18n(bibdata)
5
5
  super
6
+ bibdata_id(bibdata)
6
7
  bibdata_dates(bibdata)
7
8
  bibdata_titles(bibdata)
8
9
  end
9
10
 
11
+ def bibdata_id(bibdata)
12
+ id = bibdata.at(ns("./docidentifier[@type = 'BIPM-parent-document']")) or
13
+ return
14
+ parts = %w(appendix annexid part subpart).each_with_object([]) do |w, m|
15
+ dn = bibdata.at(ns("./ext/structuredidentifier/#{w}"))
16
+ m << dn&.text
17
+ end
18
+ id.next = bibdata_id1(@lang, id.dup, parts, false)
19
+ id.next = bibdata_id1(@lang == "en" ? "fr" : "en", id.dup, parts, true)
20
+ end
21
+
22
+ def bibdata_id1(lang, id, parts, alt)
23
+ id["type"] = "BIPM"
24
+ id["language"] = lang
25
+ m = []
26
+ parts.each_with_index do |p, i|
27
+ p.nil? and next
28
+ lbl = @i18n.get["level#{i + 2}_ancillary#{alt ? '_alt' : ''}"]
29
+ m << "#{lbl} #{p}"
30
+ end
31
+ id.children = "#{id.text} #{m.join(' ')}"
32
+ id
33
+ end
34
+
10
35
  def bibdata_dates(bibdata)
11
36
  pubdate = bibdata.at(ns("./date[not(@format)][@type = 'published']"))
12
37
  pubdate or return
@@ -17,13 +42,28 @@ module IsoDoc
17
42
  end
18
43
 
19
44
  def bibdata_titles(bibdata)
20
- app = bibdata.at(ns("//bibdata/ext/" \
21
- "structuredidentifier/part")) or return
45
+ app = bibdata.at(ns("//bibdata/ext/structuredidentifier/part")) or
46
+ return
47
+ bibdata_part_titles(bibdata, app.text.sub(/\.\d+/, ""))
48
+ bibdata_subpart_titles(bibdata, app.text.sub(/\d+\./, ""))
49
+ end
50
+
51
+ def bibdata_part_titles(bibdata, num)
22
52
  bibdata.xpath(ns("//bibdata/title[@type = 'title-part']")).each do |t|
23
53
  t.previous = t.dup
24
54
  t["type"] = "title-part-with-numbering"
25
- part = t["language"] == "en" ? "Part" : "Partie" # not looking up in YAML
26
- t.children = l10n("#{part} #{app.text}: #{to_xml(t.children)}",
55
+ alt = t["language"] == @lang ? "" : "_alt"
56
+ t.children = l10n("#{@i18n.get["level4_ancillary#{alt}"]} #{num}: #{to_xml(t.children)}",
57
+ t["language"])
58
+ end
59
+ end
60
+
61
+ def bibdata_subpart_titles(bibdata, num)
62
+ bibdata.xpath(ns("//bibdata/title[@type = 'title-subpart']")).each do |t|
63
+ t.previous = t.dup
64
+ t["type"] = "title-subpart-with-numbering"
65
+ alt = t["language"] == @lang ? "" : "_alt"
66
+ t.children = l10n("#{@i18n.get["level5_ancillary#{alt}"]} #{num}: #{to_xml(t.children)}",
27
67
  t["language"])
28
68
  end
29
69
  end
@@ -19,6 +19,30 @@ module IsoDoc
19
19
  super
20
20
  end
21
21
 
22
+ def update_i18n(i18n)
23
+ if %w(2019).include?(@docscheme)
24
+ %w(level2_ancillary level3_ancillary level2_ancillary_alt
25
+ level3_ancillary_alt).each do |w|
26
+ i18n_conditional_set(i18n, w, "#{w}_2019")
27
+ end
28
+ end
29
+ i18n.set("annex", i18n.get["level2_ancillary"])
30
+ i18n.set("appendix", i18n.get["level3_ancillary"])
31
+ end
32
+
33
+ def convert_i18n_init(docxml)
34
+ @docscheme =
35
+ docxml.at(ns("//presentation-metadata[name" \
36
+ "[text() = 'document-scheme']]/value"))&.text || "2021"
37
+ super
38
+ update_i18n(@i18n)
39
+ end
40
+
41
+ def i18n_conditional_set(i18n, old, new)
42
+ i18n.get[new] or return
43
+ i18n.set(old, i18n.get[new])
44
+ end
45
+
22
46
  def iso_processor(docxml)
23
47
  iso = IsoDoc::Iso::PresentationXMLConvert
24
48
  .new({ language: @lang, script: @script })
@@ -148,6 +148,7 @@ module IsoDoc
148
148
  end
149
149
 
150
150
  def annex_names(clause, num)
151
+ appendix_names(clause, num)
151
152
  lbl = semx(clause, num)
152
153
  prefix = @jcgm ? "" : "A"
153
154
  lbl1 = semx(clause, "#{prefix}#{num}")
@@ -39,19 +39,6 @@ module Metanorma
39
39
  super
40
40
  end
41
41
 
42
- ID_LABELS = {
43
- "en" => {
44
- "appendix" => "Appendix",
45
- "annexid" => "Annex",
46
- "part" => "Part",
47
- },
48
- "fr" => {
49
- "appendix" => "Annexe",
50
- "annexid" => "Appendice",
51
- "part" => "Partie",
52
- },
53
- }.freeze
54
-
55
42
  def bibdata_docidentifier_cleanup(isoxml)
56
43
  bibdata_docidentifier_i18n(isoxml)
57
44
  super
@@ -62,24 +49,24 @@ module Metanorma
62
49
  parts.empty? and return
63
50
  id_alt = id.dup
64
51
  id.next = id_alt
65
- bibdata_docidentifier_enhance(id, @lang, parts)
66
- bibdata_docidentifier_enhance(id_alt, @lang == "en" ? "fr" : "en",
67
- parts)
52
+ id_alt["type"] = "BIPM-parent-document"
53
+ id_alt.delete("primary")
54
+ bibdata_docidentifier_enhance(id, parts)
68
55
  end
69
56
 
70
57
  def bibdata_docidentifier_i18n_prep(isoxml)
71
58
  id = isoxml.at("//bibdata/docidentifier[@type = 'BIPM']")
72
- parts = %w(appendix annexid part).each_with_object({}) do |w, m|
59
+ parts = %w(appendix annexid part subpart).each_with_object({}) do |w, m|
73
60
  dn = isoxml.at("//bibdata/ext/structuredidentifier/#{w}") and
74
61
  m[w] = dn.text
75
62
  end
76
63
  [id, parts]
77
64
  end
78
65
 
79
- def bibdata_docidentifier_enhance(id, lang, parts)
80
- id["language"] = lang
81
- ret = %w(appendix annexid part).each_with_object([]) do |w, m|
82
- p = parts[w] and m << "#{ID_LABELS[lang][w]} #{p}"
66
+ # not language-specific, just space-delimited
67
+ def bibdata_docidentifier_enhance(id, parts)
68
+ ret = %w(appendix annexid part subpart).each_with_object([]) do |w, m|
69
+ p = parts[w] and m << p
83
70
  end
84
71
  id.children = "#{id.text} #{ret.join(' ')}"
85
72
  end
@@ -77,10 +77,6 @@ module Metanorma
77
77
  super
78
78
  end
79
79
 
80
- def ol_attrs(node)
81
- super.merge(attr_code(start: node.attr("start")))
82
- end
83
-
84
80
  def committee_validate(xml)
85
81
  committees = Array(configuration&.committees) || return
86
82
  committees.empty? and return
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <!-- VERSION v2.0.6 -->
3
+ <!-- VERSION v2.0.8 -->
4
4
 
5
5
  <!--
6
6
  ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
@@ -72,10 +72,51 @@ but to `@anchor`, the user-supplied cross-reference</a:documentation>
72
72
  </oneOrMore>
73
73
  </element>
74
74
  </define>
75
+ <define name="review">
76
+ <a:documentation>Generalise BasicDoc element from just review comments, to general annotations;
77
+ the type attribute defaults to `review` for reviews</a:documentation>
78
+ <element name="annotation">
79
+ <ref name="RequiredId"/>
80
+ <ref name="ReviewAttributes"/>
81
+ <oneOrMore>
82
+ <ref name="paragraph">
83
+ <a:documentation>Reviewer comments content</a:documentation>
84
+ </ref>
85
+ </oneOrMore>
86
+ </element>
87
+ </define>
88
+ <define name="ruby_pronunciation">
89
+ <a:documentation>Ruby annotation giving pronunciation of text: change tag from BasicDoc for disambiguation</a:documentation>
90
+ <element name="ruby-pronunciation">
91
+ <attribute name="value">
92
+ <a:documentation>Ruby annotation value</a:documentation>
93
+ </attribute>
94
+ <ref name="LocalizedStringAttributes"/>
95
+ </element>
96
+ </define>
97
+ <define name="ruby_annotation">
98
+ <a:documentation>Ruby annotation giving information other than pronunciation of text: change tag from BasicDoc for disambiguation</a:documentation>
99
+ <element name="ruby-annotation">
100
+ <attribute name="value">
101
+ <a:documentation>Ruby annotation value</a:documentation>
102
+ </attribute>
103
+ <ref name="LocalizedStringAttributes"/>
104
+ </element>
105
+ </define>
106
+ <define name="annotation">
107
+ <a:documentation>Source code annotation, corresponding to a callout</a:documentation>
108
+ <element name="callout-annotation">
109
+ <ref name="RequiredId"/>
110
+ <oneOrMore>
111
+ <ref name="paragraph"/>
112
+ </oneOrMore>
113
+ </element>
114
+ </define>
75
115
  <define name="section-title">
76
116
  <a:documentation>Title(s) of a clause</a:documentation>
77
117
  <element name="title">
78
118
  <a:documentation>Title proper for a clause</a:documentation>
119
+ <ref name="RequiredId"/>
79
120
  <zeroOrMore>
80
121
  <ref name="TextElement"/>
81
122
  </zeroOrMore>
@@ -83,10 +124,19 @@ but to `@anchor`, the user-supplied cross-reference</a:documentation>
83
124
  <zeroOrMore>
84
125
  <element name="variant-title">
85
126
  <a:documentation>Alternate title for a clause</a:documentation>
127
+ <ref name="RequiredId"/>
86
128
  <ref name="TypedTitleString"/>
87
129
  </element>
88
130
  </zeroOrMore>
89
131
  </define>
132
+ <define name="tname">
133
+ <element name="name">
134
+ <ref name="RequiredId"/>
135
+ <oneOrMore>
136
+ <ref name="NestedTextElement"/>
137
+ </oneOrMore>
138
+ </element>
139
+ </define>
90
140
  <define name="UlBody">
91
141
  <optional>
92
142
  <ref name="tname">
@@ -475,6 +525,7 @@ normative or informative references, some split references into sections organiz
475
525
  <!-- exclude figures? -->
476
526
  <define name="dd">
477
527
  <element name="dd">
528
+ <ref name="OptionalId"/>
478
529
  <zeroOrMore>
479
530
  <!-- exclude figures? -->
480
531
  <ref name="BasicBlock"/>
@@ -526,9 +577,10 @@ normative or informative references, some split references into sections organiz
526
577
  </choice>
527
578
  </define>
528
579
  <define name="TrAttributes">
580
+ <ref name="OptionalId"/>
529
581
  <optional>
530
582
  <attribute name="style">
531
- <a:documentation>CSS style: only background-color supported</a:documentation>
583
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
532
584
  </attribute>
533
585
  </optional>
534
586
  </define>
@@ -595,6 +647,7 @@ gives an explicit page orientation</a:documentation>
595
647
  </include>
596
648
  <!-- end overrides -->
597
649
  <define name="FnAttributes" combine="interleave">
650
+ <ref name="RequiredId"/>
598
651
  <optional>
599
652
  <attribute name="hiddenref">
600
653
  <a:documentation>If true, number the footnote as normal, but suppress display of the footnote reference in the document body.
@@ -604,9 +657,10 @@ This is done if the footnote reference is already presented in some other form,
604
657
  </optional>
605
658
  </define>
606
659
  <define name="TdAttributes" combine="interleave">
660
+ <ref name="RequiredId"/>
607
661
  <optional>
608
662
  <attribute name="style">
609
- <a:documentation>CSS style: only background-color supported</a:documentation>
663
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
610
664
  </attribute>
611
665
  </optional>
612
666
  </define>
@@ -686,6 +740,11 @@ titlecase, or lowercase</a:documentation>
686
740
  <a:documentation>Width of the table block in rendering</a:documentation>
687
741
  </attribute>
688
742
  </optional>
743
+ <optional>
744
+ <attribute name="style">
745
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
746
+ </attribute>
747
+ </optional>
689
748
  <ref name="BlockAttributes"/>
690
749
  </define>
691
750
  <define name="FigureAttributes" combine="interleave">
@@ -1403,7 +1462,7 @@ numbers</a:documentation>
1403
1462
  </optional>
1404
1463
  <ref name="DocumentBody"/>
1405
1464
  <optional>
1406
- <ref name="review-container">
1465
+ <ref name="annotation-container">
1407
1466
  <a:documentation>Annotations to the document</a:documentation>
1408
1467
  </ref>
1409
1468
  </optional>
@@ -1447,8 +1506,8 @@ numbers</a:documentation>
1447
1506
  </oneOrMore>
1448
1507
  </element>
1449
1508
  </define>
1450
- <define name="review-container">
1451
- <element name="review-container">
1509
+ <define name="annotation-container">
1510
+ <element name="annotation-container">
1452
1511
  <oneOrMore>
1453
1512
  <ref name="review"/>
1454
1513
  </oneOrMore>
@@ -1821,7 +1880,7 @@ used in document amendments</a:documentation>
1821
1880
  </element>
1822
1881
  </define>
1823
1882
  <define name="TermAttributes">
1824
- <ref name="OptionalId"/>
1883
+ <ref name="RequiredId"/>
1825
1884
  <ref name="LocalizedStringAttributes"/>
1826
1885
  <ref name="BlockAttributes"/>
1827
1886
  </define>
@@ -2164,6 +2223,7 @@ used in document amendments</a:documentation>
2164
2223
  <define name="termdefinition">
2165
2224
  <a:documentation>The definition of a term applied in the current document</a:documentation>
2166
2225
  <element name="definition">
2226
+ <ref name="RequiredId"/>
2167
2227
  <optional>
2168
2228
  <attribute name="type">
2169
2229
  <a:documentation>Type of definition, used to differentiate it from other definitions of the same term if present</a:documentation>
@@ -2185,6 +2245,7 @@ used in document amendments</a:documentation>
2185
2245
  </define>
2186
2246
  <define name="verbaldefinition">
2187
2247
  <element name="verbal-definition">
2248
+ <ref name="RequiredId"/>
2188
2249
  <oneOrMore>
2189
2250
  <choice>
2190
2251
  <a:documentation>Content of the verbal representation of the term</a:documentation>
@@ -2205,6 +2266,7 @@ used in document amendments</a:documentation>
2205
2266
  <define name="nonverbalrep">
2206
2267
  <a:documentation>Non-verbal representation of the term</a:documentation>
2207
2268
  <element name="non-verbal-representation">
2269
+ <ref name="RequiredId"/>
2208
2270
  <oneOrMore>
2209
2271
  <choice>
2210
2272
  <a:documentation>Content of the non-verbal representation of the term</a:documentation>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Bipm
3
- VERSION = "2.6.10".freeze
3
+ VERSION = "2.7.0".freeze
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
29
29
 
30
30
  spec.add_dependency "metanorma-generic", "~> 3.0.4"
31
- spec.add_dependency "metanorma-iso", "~> 3.0.10"
31
+ spec.add_dependency "metanorma-iso", "~> 3.1.0"
32
32
 
33
33
  spec.add_development_dependency "debug"
34
34
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-bipm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.10
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-06-23 00:00:00.000000000 Z
11
+ date: 2025-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.0.10
33
+ version: 3.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.0.10
40
+ version: 3.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: debug
43
43
  requirement: !ruby/object:Gem::Requirement