metanorma-bipm 2.2.14 → 2.3.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.
@@ -4,14 +4,16 @@ module IsoDoc
4
4
  end
5
5
 
6
6
  class Xref < IsoDoc::Xref
7
+ attr_accessor :jcgm
8
+
7
9
  def initialize(lang, script, klass, i18n, options = {})
8
10
  @iso = IsoDoc::Iso::Xref.new(lang, script, klass, i18n, options)
9
11
  super
10
12
  end
11
13
 
12
14
  def parse(docxml)
13
- @jcgm = docxml&.at(ns("//bibdata/ext/editorialgroup/committee/"\
14
- "@acronym"))&.value == "JCGM"
15
+ @jcgm = docxml.at(ns("//bibdata/ext/editorialgroup/committee/" \
16
+ "@acronym"))&.value == "JCGM"
15
17
  @annexlbl =
16
18
  if @jcgm then @labels["iso_annex"]
17
19
  elsif docxml.at(ns("//bibdata/ext/structuredidentifier/appendix"))
@@ -31,41 +33,40 @@ module IsoDoc
31
33
  @anchors[ref["id"]][:xref] = wrap_brackets(@anchors[ref["id"]][:xref])
32
34
  end
33
35
 
34
- def clause_names(docxml, sect_num)
35
- if @jcgm then clause_names_jcgm(docxml, sect_num)
36
- else clause_names_bipm(docxml, sect_num)
37
- end
38
- end
39
-
40
- def clause_names_jcgm(docxml, sect_num)
41
- docxml.xpath(ns("//clause[parent::sections][not(@type = 'scope')]"\
42
- "[not(descendant::terms)]")).each do |c|
43
- section_names(c, sect_num, 1)
44
- end
45
- end
46
-
47
36
  UNNUM = "@unnumbered = 'true'".freeze
48
37
 
49
- def clause_names_bipm(docxml, _sect_num)
38
+ def clause_order_main(docxml)
39
+ @jcgm and return @iso.clause_order_main(docxml)
40
+ [{ path: "//sections/clause[not(#{UNNUM})] | " \
41
+ "//sections/terms[not(#{UNNUM})] | " \
42
+ "//sections/definitions[not(#{UNNUM})] | " \
43
+ "//sections/references[not(#{UNNUM})]", multi: true },
44
+ { path: "//sections/clause[#{UNNUM}] | " \
45
+ "//sections/terms[#{UNNUM}] | " \
46
+ "//sections/definitions[#{UNNUM}] | " \
47
+ "//sections/references[#{UNNUM}]", multi: true }]
48
+ end
49
+
50
+ def main_anchor_names(xml)
51
+ @jcgm and return super
52
+ t = clause_order_main(xml)
50
53
  n = Counter.new
51
- docxml.xpath(ns("//sections/clause[not(#{UNNUM})] | "\
52
- "//sections/terms[not(#{UNNUM})] | "\
53
- "//sections/definitions[not(#{UNNUM})]"))
54
- .each { |c| section_names(c, n, 1) }
55
- docxml.xpath(ns("//sections/clause[#{UNNUM}] | "\
56
- "//sections/terms[#{UNNUM}] | "\
57
- "//sections/definitions[#{UNNUM}]"))
58
- .each { |c| unnumbered_section_names(c, 1) }
54
+ t.each_with_index do |a, i|
55
+ xml.xpath(ns(a[:path])).each do |c|
56
+ i.zero? ? section_names(c, n, 1) : unnumbered_section_names(c, 1)
57
+ a[:multi] or break
58
+ end
59
+ end
59
60
  end
60
61
 
61
62
  NUMBERED_SUBCLAUSES =
62
- "./clause[not(#{UNNUM})] | ./references[not(#{UNNUM})] | "\
63
- "./term[not(#{UNNUM})] | ./terms[not(#{UNNUM})] | "\
63
+ "./clause[not(#{UNNUM})] | ./references[not(#{UNNUM})] | " \
64
+ "./term[not(#{UNNUM})] | ./terms[not(#{UNNUM})] | " \
64
65
  "./definitions[not(#{UNNUM})]".freeze
65
66
 
66
67
  UNNUMBERED_SUBCLAUSES =
67
- "./clause[#{UNNUM}] | ./references[#{UNNUM}] | "\
68
- "./term[#{UNNUM}] | ./terms[#{UNNUM}] | "\
68
+ "./clause[#{UNNUM}] | ./references[#{UNNUM}] | " \
69
+ "./term[#{UNNUM}] | ./terms[#{UNNUM}] | " \
69
70
  "./definitions[#{UNNUM}]".freeze
70
71
 
71
72
  def section_name_anchors(clause, num, lvl)
@@ -76,8 +77,7 @@ module IsoDoc
76
77
  end
77
78
 
78
79
  def section_names(clause, num, lvl)
79
- return num if clause.nil?
80
-
80
+ clause.nil? and return num
81
81
  num.increment(clause)
82
82
  @anchors[clause["id"]] = section_name_anchors(clause, num, lvl)
83
83
  i = Counter.new
@@ -92,9 +92,8 @@ module IsoDoc
92
92
  end
93
93
 
94
94
  def unnumbered_section_names(clause, lvl)
95
- return if clause.nil?
96
-
97
- lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
95
+ clause.nil? and return num
96
+ lbl = clause.at(ns("./title"))&.text || "[#{clause['id']}]"
98
97
  @anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}),
99
98
  level: lvl, type: "clause" }
100
99
  clause.xpath(ns(SUBCLAUSES)).each do |c|
@@ -122,7 +121,7 @@ module IsoDoc
122
121
  end
123
122
 
124
123
  def unnumbered_section_names1(clause, level)
125
- lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
124
+ lbl = clause.at(ns("./title"))&.text || "[#{clause['id']}]"
126
125
  @anchors[clause["id"]] =
127
126
  { label: lbl, xref: l10n(%{"#{lbl}"}), level: level, type: "clause" }
128
127
  clause.xpath(ns(SUBCLAUSES)).each do |c|
@@ -130,16 +129,22 @@ module IsoDoc
130
129
  end
131
130
  end
132
131
 
133
- def back_anchor_names(docxml)
134
- super
135
- i = @jcgm ? Counter.new("@", skip_i: true) : Counter.new(0)
136
- docxml.xpath(ns("//annex[not(#{UNNUM})]")).each do |c|
137
- i.increment(c)
138
- annex_names(c, i.print)
132
+ def clause_order_annex(_docxml)
133
+ [{ path: "//annex[not(#{UNNUM})]", multi: true },
134
+ { path: "//annex[#{UNNUM}]", multi: true }]
135
+ end
136
+
137
+ def annex_anchor_names(docxml)
138
+ n = @jcgm ? Counter.new("@", skip_i: true) : Counter.new(0)
139
+ clause_order_annex(docxml).each_with_index do |a, i|
140
+ docxml.xpath(ns(a[:path])).each do |c|
141
+ if i.zero?
142
+ n.increment(c)
143
+ annex_names(c, n.print)
144
+ else unnumbered_annex_names(c) end
145
+ a[:multi] or break
146
+ end
139
147
  end
140
- docxml.xpath(ns("//annex[#{UNNUM}]"))
141
- .each { |c| unnumbered_annex_names(c) }
142
- docxml.xpath(ns("//indexsect")).each { |b| preface_names(b) }
143
148
  end
144
149
 
145
150
  def annex_name_anchors(clause, num)
@@ -171,7 +176,7 @@ module IsoDoc
171
176
  end
172
177
 
173
178
  def unnumbered_annex_names(clause)
174
- lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
179
+ lbl = clause.at(ns("./title"))&.text || "[#{clause['id']}]"
175
180
  @anchors[clause["id"]] = unnumbered_annex_anchors(lbl)
176
181
  if @klass.single_term_clause?(clause)
177
182
  annex_names1(clause.at(ns("./references | ./terms | ./definitions")),
@@ -214,9 +219,7 @@ module IsoDoc
214
219
 
215
220
  def sequential_formula_names(clause)
216
221
  c = Counter.new
217
- clause.xpath(ns(".//formula")).each do |t|
218
- next if t["id"].nil? || t["id"].empty?
219
-
222
+ clause.xpath(ns(".//formula")).noblank.each do |t|
220
223
  @anchors[t["id"]] = anchor_struct(
221
224
  c.increment(t).print, nil,
222
225
  t["inequality"] ? @labels["inequality"] : @labels["formula"],
@@ -234,19 +237,15 @@ module IsoDoc
234
237
  end
235
238
 
236
239
  def sequential_figure_names(clause)
237
- if @jcgm
238
- @iso.sequential_figure_names(clause)
239
- @anchors.merge!(@iso.get)
240
- else super
241
- end
240
+ @jcgm or return super
241
+ @iso.sequential_figure_names(clause)
242
+ @anchors.merge!(@iso.get)
242
243
  end
243
244
 
244
245
  def hierarchical_figure_names(clause, num)
245
- if @jcgm
246
- @iso.hierarchical_figure_names(clause, num)
247
- @anchors.merge!(@iso.get)
248
- else super
249
- end
246
+ @jcgm or return super
247
+ @iso.hierarchical_figure_names(clause, num)
248
+ @anchors.merge!(@iso.get)
250
249
  end
251
250
  end
252
251
  end
@@ -91,7 +91,7 @@ module Metanorma
91
91
  def title(node, xml)
92
92
  ["en", "fr"].each do |lang|
93
93
  at = { language: lang, format: "text/plain" }
94
- xml.title **attr_code(at.merge(type: "main")) do |t1|
94
+ xml.title **attr_code(at.merge(type: "title-main")) do |t1|
95
95
  t1 << Metanorma::Utils::asciidoc_sub(node.attr("title-#{lang}"))
96
96
  end
97
97
  %w(cover appendix annex part subpart provenance).each do |w|
@@ -104,7 +104,7 @@ module Metanorma
104
104
  at = { language: lang, format: "text/plain" }
105
105
  return unless title = node.attr("title-#{type}-#{lang}")
106
106
 
107
- xml.title **attr_code(at.merge(type: type)) do |t1|
107
+ xml.title **attr_code(at.merge(type: "title-#{type}")) do |t1|
108
108
  t1 << Metanorma::Utils::asciidoc_sub(title)
109
109
  end
110
110
  end
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.2.2 -->
20
+ <!-- VERSION v1.2.4 -->
21
21
  <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">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -192,9 +192,11 @@
192
192
  </attribute>
193
193
  </optional>
194
194
  <attribute name="citeas"/>
195
- <attribute name="type">
196
- <ref name="ReferenceFormat"/>
197
- </attribute>
195
+ <optional>
196
+ <attribute name="type">
197
+ <ref name="ReferenceFormat"/>
198
+ </attribute>
199
+ </optional>
198
200
  <optional>
199
201
  <attribute name="alt"/>
200
202
  </optional>
@@ -836,6 +838,26 @@
836
838
  <ref name="paragraph"/>
837
839
  </element>
838
840
  </define>
841
+ <define name="stem">
842
+ <element name="stem">
843
+ <attribute name="type">
844
+ <choice>
845
+ <value>MathML</value>
846
+ <value>AsciiMath</value>
847
+ <value>LatexMath</value>
848
+ </choice>
849
+ </attribute>
850
+ <attribute name="block">
851
+ <data type="boolean"/>
852
+ </attribute>
853
+ <oneOrMore>
854
+ <choice>
855
+ <text/>
856
+ <ref name="AnyElement"/>
857
+ </choice>
858
+ </oneOrMore>
859
+ </element>
860
+ </define>
839
861
  <define name="em">
840
862
  <element name="em">
841
863
  <zeroOrMore>
@@ -2046,6 +2068,9 @@
2046
2068
  </define>
2047
2069
  <define name="termdefinition">
2048
2070
  <element name="definition">
2071
+ <optional>
2072
+ <attribute name="type"/>
2073
+ </optional>
2049
2074
  <choice>
2050
2075
  <ref name="verbaldefinition"/>
2051
2076
  <ref name="nonverbalrep"/>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module BIPM
3
- VERSION = "2.2.14".freeze
3
+ VERSION = "2.3.1".freeze
4
4
  end
5
5
  end
@@ -27,8 +27,8 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
29
29
 
30
- spec.add_dependency "metanorma-generic", "~> 2.4.1"
31
- spec.add_dependency "metanorma-iso", "~> 2.4.2"
30
+ spec.add_dependency "metanorma-generic", "~> 2.5.1"
31
+ spec.add_dependency "metanorma-iso", "~> 2.5.1"
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.2.14
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-24 00:00:00.000000000 Z
11
+ date: 2023-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.4.1
19
+ version: 2.5.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.4.1
26
+ version: 2.5.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: metanorma-iso
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.4.2
33
+ version: 2.5.1
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: 2.4.2
40
+ version: 2.5.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: debug
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -258,6 +258,7 @@ files:
258
258
  - lib/isodoc/bipm/jcgm.standard.xsl
259
259
  - lib/isodoc/bipm/metadata.rb
260
260
  - lib/isodoc/bipm/pdf_convert.rb
261
+ - lib/isodoc/bipm/presentation_blocks.rb
261
262
  - lib/isodoc/bipm/presentation_xml_convert.rb
262
263
  - lib/isodoc/bipm/xref.rb
263
264
  - lib/metanorma-bipm.rb