metanorma-bipm 1.0.4 → 1.1.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.
@@ -8,7 +8,8 @@ module IsoDoc
8
8
  end
9
9
 
10
10
  SI_ASPECT = %w(A_e_deltanu A_e cd_Kcd_h_deltanu cd_Kcd full K_k_deltanu
11
- K_k kg_h_c_deltanu kg_h m_c_deltanu m_c mol_NA s_deltanu).freeze
11
+ K_k kg_h_c_deltanu kg_h m_c_deltanu m_c mol_NA
12
+ s_deltanu).freeze
12
13
 
13
14
  def initialize(lang, script, labels)
14
15
  super
@@ -24,12 +25,12 @@ module IsoDoc
24
25
  TITLE = "//bibdata/title".freeze
25
26
 
26
27
  def title(isoxml, _out)
27
- lang1, lang2 = @lang == "fr" ? %w(fr en) : %w(en fr)
28
+ lang1, lang2 = @lang == "fr" ? %w(fr en) : %w(en fr)
28
29
  set(:doctitle, @c.encode(isoxml&.at(
29
30
  ns("#{TITLE}[@type='main'][@language='#{lang1}']"))&.text || ""))
30
31
  set(:docsubtitle, @c.encode(isoxml&.at(
31
32
  ns("#{TITLE}[@type='main'][@language='#{lang2}']"))&.text || ""))
32
- %w(appendix annex part subtitle).each do |e|
33
+ %w(appendix annex part subtitle provenance).each do |e|
33
34
  set("#{e}title".to_sym, @c.encode(isoxml&.at(
34
35
  ns("#{TITLE}[@type='#{e}'][@language='#{lang1}']"))&.text || ""))
35
36
  set("#{e}subtitle".to_sym, @c.encode(isoxml&.at(
@@ -40,9 +41,10 @@ module IsoDoc
40
41
  def status_print(status)
41
42
  return "Procès-Verbal" if status == "procès-verbal"
42
43
  return "CIPM-MRA" if status == "cipm-mra"
44
+
43
45
  status.split(/[- ]/).map.with_index do |s, i|
44
- (%w(en de).include?(s) && i > 0) ? s : s.capitalize
45
- end.join(' ')
46
+ %w(en de).include?(s) && i.positive? ? s : s.capitalize
47
+ end.join(" ")
46
48
  end
47
49
 
48
50
  def docid(isoxml, _out)
@@ -59,11 +61,19 @@ module IsoDoc
59
61
  dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/part"))
60
62
  dn and set(:partid, @i18n.l10n("#{label1} #{dn&.text}"))
61
63
  dn and set(:partid_alt, @i18n.l10n("#{label2} #{dn&.text}"))
64
+ set(:org_abbrev,
65
+ isoxml.at(ns("//bibdata/ext/editorialgroup/committee"\
66
+ "[@acronym = 'JCGM']")) ? "JCGM" : "BIPM")
62
67
  end
63
68
 
64
69
  def extract_person_names_affiliations(authors)
65
70
  extract_person_affiliations(authors)
66
71
  end
72
+
73
+ def bibdate(isoxml, _out)
74
+ pubdate = isoxml.at(ns("//bibdata/date[not(@format)][@type = 'published']"))
75
+ pubdate and set(:pubdate_monthyear, monthyr(pubdate.text))
76
+ end
67
77
  end
68
78
  end
69
79
  end
@@ -4,7 +4,7 @@ module IsoDoc
4
4
  module BIPM
5
5
  # A {Converter} implementation that generates PDF HTML output, and a
6
6
  # document schema encapsulation of the document for validation
7
- class PdfConvert < IsoDoc::XslfoPdfConvert
7
+ class PdfConvert < IsoDoc::XslfoPdfConvert
8
8
  def initialize(options)
9
9
  @libdir = File.dirname(__FILE__)
10
10
  super
@@ -15,20 +15,23 @@ module IsoDoc
15
15
  end
16
16
 
17
17
  def pdf_stylesheet(docxml)
18
- return "jcgm.standard.xsl" if docxml&.at(ns("//bibdata/ext/editorialgroup/committee/@acronym"))&.value == "JCGM"
18
+ docxml&.at(ns("//bibdata/ext/editorialgroup/committee/@acronym"))
19
+ &.value == "JCGM" and
20
+ return "jcgm.standard.xsl"
21
+
19
22
  doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
20
- doctype = "brochure" unless %w(guide mise-en-pratique rapport).
21
- include? doctype
23
+ doctype = "brochure" unless %w(guide mise-en-pratique rapport)
24
+ .include? doctype
22
25
  "bipm.#{doctype}.xsl"
23
26
  end
24
27
 
25
28
  def pdf_options(docxml)
29
+ n = configuration.document_namespace
30
+ q = "//m:bipm-standard/m:bibdata/m:language[@current = 'true']"
26
31
  if docxml.root.name == "metanorma-collection" &&
27
- docxml.at("//m:bipm-standard/m:bibdata/m:language[@current = 'true'][. = 'fr']",
28
- "m" => configuration.document_namespace) &&
29
- docxml.at("//m:bipm-standard/m:bibdata/m:language[@current = 'true'][. = 'en']",
30
- "m" => configuration.document_namespace)
31
- "--split-by-language"
32
+ docxml.at("#{q}[. = 'fr']", "m" => n) &&
33
+ docxml.at("#{q}[. = 'en']", "m" => n)
34
+ "#{super} --split-by-language"
32
35
  else
33
36
  super
34
37
  end
@@ -1,21 +1,43 @@
1
1
  require "isodoc"
2
2
  require "metanorma-generic"
3
+ require "metanorma-iso"
3
4
  require_relative "init"
4
5
  require_relative "index"
5
6
 
6
7
  module IsoDoc
7
8
  module BIPM
8
9
  class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
10
+ def convert1(docxml, filename, dir)
11
+ @jcgm = docxml&.at(ns("//bibdata/ext/editorialgroup/committee/"\
12
+ "@acronym"))&.value == "JCGM"
13
+ @iso = IsoDoc::Iso::PresentationXMLConvert
14
+ .new({ language: @lang, script: @script })
15
+ i18n = @iso.i18n_init(@lang, @script, nil)
16
+ @iso.metadata_init(@lang, @script, i18n)
17
+ super
18
+ end
19
+
20
+ def eref_localities1(target, type, from, to, delim, n, lang = "en")
21
+ if @jcgm
22
+ @iso.eref_localities1(target, type, from, to, delim, n, lang)
23
+ else
24
+ super
25
+ end
26
+ end
27
+
9
28
  def table1(f)
10
29
  return if labelled_ancestor(f)
11
- return if f["unnumbered"] && !f.at(ns("./name"))
12
- n = @xrefs.anchor(f['id'], :label, false)
30
+ return if f["unnumbered"]
31
+
32
+ n = @xrefs.anchor(f["id"], :label, false)
13
33
  prefix_name(f, ".<tab/>", l10n("#{@i18n.table.capitalize} #{n}"), "name")
14
34
  end
15
35
 
16
36
  def annex1(f)
37
+ return super if @jcgm
17
38
  return if f["unnumbered"] == "true"
18
- lbl = @xrefs.anchor(f['id'], :label)
39
+
40
+ lbl = @xrefs.anchor(f["id"], :label)
19
41
  if t = f.at(ns("./title"))
20
42
  t.children = "<strong>#{t.children.to_xml}</strong>"
21
43
  end
@@ -25,6 +47,7 @@ module IsoDoc
25
47
  def clause1(f)
26
48
  return if f["unnumbered"] == "true"
27
49
  return if f.at(("./ancestor::*[@unnumbered = 'true']"))
50
+
28
51
  super
29
52
  end
30
53
 
@@ -33,28 +56,43 @@ module IsoDoc
33
56
  doccontrol docxml
34
57
  end
35
58
 
36
- def doccontrol docxml
59
+ def doccontrol(docxml)
37
60
  return unless docxml.at(ns("//bibdata/relation[@type = 'supersedes']"))
61
+
38
62
  clause = <<~END
39
- <doccontrol>
40
- <title>Document Control</title>
41
- <table unnumbered="true"><tbody>
42
- <tr><td>Authors:</td><td/><td>#{list_authors(docxml)}</td></tr>
43
- <tr>#{list_draft(docxml, 1)&.map { |x| "<td>#{x}</td>" }&.join }
44
- <td>#{list_cochairs(docxml)}</td></tr>
45
- <tr>#{list_draft(docxml, 2)&.map { |x| "<td>#{x}</td>" }&.join }
46
- <td>#{list_chairs(docxml)}</td></tr>
47
- #{list_drafts(docxml)}
48
- </tbody></table></doccontrol>
63
+ <doccontrol>
64
+ <title>Document Control</title>
65
+ <table unnumbered="true"><tbody>
66
+ <tr><th>Authors:</th><td/><td>#{list_authors(docxml)}</td></tr>
67
+ #{doccontrol_row1(docxml)} #{doccontrol_row2(docxml)} #{list_drafts(docxml)}
68
+ </tbody></table></doccontrol>
49
69
  END
50
70
  docxml.root << clause
51
71
  end
52
72
 
73
+ def doccontrol_row1(docxml)
74
+ return "" if list_draft(docxml, 1) == ["", ""] && list_cochairs(docxml).empty?
75
+
76
+ <<~ROW
77
+ <tr>#{list_draft(docxml, 1)&.map { |x| "<td>#{x}</td>" }&.join}
78
+ <td>#{list_cochairs(docxml)}</td></tr>
79
+ ROW
80
+ end
81
+
82
+ def doccontrol_row2(docxml)
83
+ return "" if list_draft(docxml, 2) == ["", ""] && list_chairs(docxml).empty?
84
+
85
+ <<~ROW
86
+ <tr>#{list_draft(docxml, 2)&.map { |x| "<td>#{x}</td>" }&.join}
87
+ <td>#{list_chairs(docxml)}</td></tr>
88
+ ROW
89
+ end
90
+
53
91
  def list_drafts(xml)
54
92
  ret = ""
55
93
  i = 3
56
- while a = list_draft(xml, i)
57
- ret += "<tr>#{list_draft(xml, i).map { |x| "<td>#{x}</td>" }.join }"\
94
+ while list_draft(xml, i) != ["", ""]
95
+ ret += "<tr>#{list_draft(xml, i).map { |x| "<td>#{x}</td>" }.join} "\
58
96
  "<td/></tr>"
59
97
  i += 1
60
98
  end
@@ -62,19 +100,21 @@ module IsoDoc
62
100
  end
63
101
 
64
102
  def list_draft(xml, i)
65
- return unless d =
103
+ return ["", ""] unless d =
66
104
  xml.at(ns("//bibdata/relation[@type = 'supersedes'][#{i}]/bibitem"))
105
+
67
106
  date = d&.at(ns("./date"))&.text
68
107
  draft = d&.at(ns("./version/draft"))&.text and
69
108
  draft = "Draft #{draft}"
70
109
  edn = d&.at(ns("./edition"))&.text and
71
- edn = "Edition #{edn}"
72
- [date, [draft, edn].join(" ")]
110
+ edn = "Version #{edn}"
111
+ [[draft, edn].join(" "), date]
73
112
  end
74
113
 
75
114
  def list_authors(xml)
76
115
  ret = list_people(
77
- xml, "//bibdata/contributor[xmlns:role/@type = 'author']/person")
116
+ xml, "//bibdata/contributor[xmlns:role/@type = 'author']/person"
117
+ )
78
118
  @i18n.multiple_and(ret, @i18n.get["and"])
79
119
  end
80
120
 
@@ -84,16 +124,18 @@ module IsoDoc
84
124
 
85
125
  def list_cochairs(xml)
86
126
  ret = list_people(xml, "//bibdata/contributor[#{COCHAIR}]/person")
127
+ ret.empty? and return ""
87
128
  role = xml&.at(ns("//bibdata/contributor[#{COCHAIR}]/role"))&.text
88
129
  label = ret.size > 1 && role ? "#{role}s" : role
89
- "#{label}: #{@i18n.multiple_and(ret, @i18n.get["and"])}"
130
+ "#{label}: #{@i18n.multiple_and(ret, @i18n.get['and'])}"
90
131
  end
91
132
 
92
133
  def list_chairs(xml)
93
134
  ret = list_people(xml, "//bibdata/contributor#{CHAIR}/person")
135
+ ret.empty? and return ""
94
136
  role = xml&.at(ns("//bibdata/contributor#{CHAIR}/role"))&.text
95
137
  label = ret.size > 1 && role ? "#{role}s" : role
96
- "#{label}: #{@i18n.multiple_and(ret, @i18n.get["and"])}"
138
+ "#{label}: #{@i18n.multiple_and(ret, @i18n.get['and'])}"
97
139
  end
98
140
 
99
141
  def list_people(xml, xpath)
@@ -110,13 +152,29 @@ module IsoDoc
110
152
  end
111
153
 
112
154
  def twitter_cldr_localiser_symbols
113
- { group: "&#x202F;", fraction_group: "&#x202F;", fraction_group_digits: 3 }
155
+ { group: "&#x202F;", fraction_group: "&#x202F;",
156
+ fraction_group_digits: 3 }
114
157
  end
115
158
 
116
159
  def mathml1(f, locale)
117
160
  localize_maths(f, locale)
118
161
  end
119
162
 
163
+ def bibdata_i18n(bibdata)
164
+ super
165
+ bibdata_dates(bibdata)
166
+ end
167
+
168
+ def bibdata_dates(bibdata)
169
+ pubdate = bibdata.at(ns("./date[not(@format)][@type = 'published']"))
170
+ return unless pubdate
171
+
172
+ meta = metadata_init(@lang, @script, @i18n)
173
+ pubdate.next = pubdate.dup
174
+ pubdate.next["format"] = "ddMMMyyyy"
175
+ pubdate.next.children = meta.monthyr(pubdate.text)
176
+ end
177
+
120
178
  include Init
121
179
  end
122
180
  end
@@ -8,20 +8,56 @@ module IsoDoc
8
8
  super
9
9
  end
10
10
 
11
+ def parse(docxml)
12
+ @jcgm = docxml&.at(ns("//bibdata/ext/editorialgroup/committee/"\
13
+ "@acronym"))&.value == "JCGM"
14
+ @annexlbl =
15
+ if docxml.at(ns("//bibdata/ext/structuredidentifier/appendix"))
16
+ @labels["appendix"]
17
+ else
18
+ @labels["annex"]
19
+ end
20
+ super
21
+ end
22
+
23
+ def wrap_brackets(txt)
24
+ return txt if /^\[.*\]$/.match?(txt)
25
+
26
+ "[#{txt}]"
27
+ end
28
+
29
+ def reference_names(ref)
30
+ super
31
+ if @jcgm
32
+ @anchors[ref["id"]][:xref] = wrap_brackets(@anchors[ref["id"]][:xref])
33
+ end
34
+ end
35
+
11
36
  def clause_names(docxml, sect_num)
37
+ if @jcgm
38
+ clause_names_jcgm(docxml, sect_num)
39
+ else
40
+ clause_names_bipm(docxml, sect_num)
41
+ end
42
+ end
43
+
44
+ def clause_names_jcgm(docxml, sect_num)
45
+ docxml.xpath(ns("//clause[parent::sections][not(@type = 'scope')]"\
46
+ "[not(descendant::terms)]")).each do |c|
47
+ section_names(c, sect_num, 1)
48
+ end
49
+ end
50
+
51
+ def clause_names_bipm(docxml, _sect_num)
12
52
  n = Counter.new
13
53
  docxml.xpath(ns("//sections/clause[not(@unnumbered = 'true')] | "\
14
54
  "//sections/terms[not(@unnumbered = 'true')] | "\
15
- "//sections/definitions[not(@unnumbered = 'true')]")).
16
- each do |c|
17
- section_names(c, n, 1)
18
- end
55
+ "//sections/definitions[not(@unnumbered = 'true')]"))
56
+ .each { |c| section_names(c, n, 1) }
19
57
  docxml.xpath(ns("//sections/clause[@unnumbered = 'true'] | "\
20
58
  "//sections/terms[@unnumbered = 'true'] | "\
21
- "//sections/definitions[@unnumbered = 'true']")).
22
- each do |c|
23
- unnumbered_section_names(c, 1)
24
- end
59
+ "//sections/definitions[@unnumbered = 'true']"))
60
+ .each { |c| unnumbered_section_names(c, 1) }
25
61
  end
26
62
 
27
63
  NUMBERED_SUBCLAUSES = "./clause[not(@unnumbered = 'true')] | "\
@@ -36,18 +72,24 @@ module IsoDoc
36
72
  "./terms[@unnumbered = 'true'] | "\
37
73
  "./definitions[@unnumbered = 'true']".freeze
38
74
 
75
+ def section_name_anchors(clause, num, lvl)
76
+ lbl = @jcgm ? "clause_jcgm" : "clause"
77
+ @anchors[clause["id"]] =
78
+ { label: num.print, xref: l10n("#{@labels[lbl]} #{num.print}"),
79
+ level: lvl, type: "clause" }
80
+ end
81
+
39
82
  def section_names(clause, num, lvl)
40
83
  return num if clause.nil?
84
+
41
85
  num.increment(clause)
42
- @anchors[clause["id"]] =
43
- { label: num.print, xref: l10n("#{@labels["clause"]} #{num.print}"),
44
- level: lvl, type: "clause" }
86
+ @anchors[clause["id"]] = section_name_anchors(clause, num, lvl)
45
87
  i = Counter.new
46
88
  clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
47
89
  i.increment(c)
48
90
  section_names1(c, "#{num.print}.#{i.print}", lvl + 1)
49
91
  end
50
- clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each_with_index do |c, i|
92
+ clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
51
93
  unnumbered_section_names1(c, lvl + 1)
52
94
  end
53
95
  num
@@ -55,30 +97,37 @@ module IsoDoc
55
97
 
56
98
  def unnumbered_section_names(clause, lvl)
57
99
  return if clause.nil?
58
- lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
59
- @anchors[clause["id"]] =
60
- { label: lbl, xref: l10n(%{"#{lbl}"}), level: lvl, type: "clause" }
61
- clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
100
+
101
+ lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
102
+ @anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}),
103
+ level: lvl, type: "clause" }
104
+ clause.xpath(ns(SUBCLAUSES)).each do |c|
62
105
  unnumbered_section_names1(c, lvl + 1)
63
106
  end
64
107
  end
65
108
 
66
- def section_names1(clause, num, level)
109
+ def section_name1_anchors(clause, num, level)
110
+ lbl = @jcgm ? "" : "#{@labels['subclause']} "
67
111
  @anchors[clause["id"]] =
68
- { label: num, level: level, xref: l10n("#{@labels["subclause"]} #{num}"),
112
+ { label: num, level: level,
113
+ xref: l10n("#{lbl}#{num}"),
69
114
  type: "clause" }
115
+ end
116
+
117
+ def section_names1(clause, num, level)
118
+ @anchors[clause["id"]] = section_name1_anchors(clause, num, level)
70
119
  i = Counter.new
71
120
  clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
72
121
  i.increment(c)
73
122
  section_names1(c, "#{num}.#{i.print}", level + 1)
74
123
  end
75
- clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each_with_index do |c, i|
124
+ clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
76
125
  unnumbered_section_names1(c, lvl + 1)
77
126
  end
78
127
  end
79
128
 
80
129
  def unnumbered_section_names1(clause, level)
81
- lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
130
+ lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
82
131
  @anchors[clause["id"]] =
83
132
  { label: lbl, xref: l10n(%{"#{lbl}"}), level: level, type: "clause" }
84
133
  clause.xpath(ns(SUBCLAUSES)).each do |c|
@@ -88,75 +137,95 @@ module IsoDoc
88
137
 
89
138
  def back_anchor_names(docxml)
90
139
  super
91
- @annexlbl = docxml.at(ns("//bibdata/ext/structuredidentifier/appendix")) ?
92
- @labels["appendix"] : @labels["annex"]
93
- docxml.xpath(ns("//annex[not(@unnumbered = 'true')]")).
94
- each_with_index { |c, i| annex_names(c, (i+1).to_s) }
95
- docxml.xpath(ns("//annex[@unnumbered = 'true']")).
96
- each { |c| unnumbered_annex_names(c) }
140
+ i = @jcgm ? Counter.new("@", skip_i: true) : Counter.new(0)
141
+ docxml.xpath(ns("//annex[not(@unnumbered = 'true')]")).each do |c|
142
+ i.increment(c)
143
+ annex_names(c, i.print)
144
+ end
145
+ docxml.xpath(ns("//annex[@unnumbered = 'true']"))
146
+ .each { |c| unnumbered_annex_names(c) }
147
+ docxml.xpath(ns("//indexsect")).each { |b| preface_names(b) }
148
+ end
149
+
150
+ def annex_name_anchors(clause, num)
151
+ { label: annex_name_lbl(clause, num), type: "clause", value: num.to_s,
152
+ xref: l10n("#{@annexlbl} #{num}"), level: 1 }
97
153
  end
98
154
 
99
155
  def annex_names(clause, num)
100
- @anchors[clause["id"]] =
101
- { label: annex_name_lbl(clause, num), type: "clause", value: num.to_s,
102
- xref: l10n("#{@annexlbl} #{num}"), level: 1 }
156
+ @anchors[clause["id"]] = annex_name_anchors(clause, num)
103
157
  if a = single_annex_special_section(clause)
104
- annex_names1(a, "#{num}", 1)
158
+ annex_names1(a, num.to_s, 1)
105
159
  else
106
160
  i = Counter.new
107
161
  clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
108
162
  i.increment(c)
109
163
  annex_names1(c, "#{num}.#{i.print}", 2)
110
164
  end
111
- clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
112
- unnumbered_annex_names1(c, 2)
113
- end
165
+ clause.xpath(ns(UNNUMBERED_SUBCLAUSES))
166
+ .each { |c| unnumbered_annex_names1(c, 2) }
114
167
  end
115
168
  hierarchical_asset_names(clause, num)
116
169
  end
117
170
 
171
+ def unnumbered_annex_anchors(lbl)
172
+ { label: lbl, type: "clause", value: "",
173
+ xref: l10n(%{"#{lbl}"}), level: 1 }
174
+ end
175
+
118
176
  def unnumbered_annex_names(clause)
119
- lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
120
- @anchors[clause["id"]] =
121
- { label: lbl, type: "clause", value: "",
122
- xref: l10n(%{"#{lbl}"}), level: 1 }
177
+ lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
178
+ @anchors[clause["id"]] = unnumbered_annex_anchors(lbl)
123
179
  if a = single_annex_special_section(clause)
124
- annex_names1(a, "#{num}", 1)
180
+ annex_names1(a, num.to_s, 1)
125
181
  else
126
- clause.xpath(ns(SUBCLAUSES)).each do |c|
127
- unnumbered_annex_names1(c, 2)
128
- end
182
+ clause.xpath(ns(SUBCLAUSES))
183
+ .each { |c| unnumbered_annex_names1(c, 2) }
129
184
  end
130
185
  hierarchical_asset_names(clause, lbl)
131
186
  end
132
187
 
188
+ def annex_names1_anchors(num, level)
189
+ lbl = @jcgm ? "" : "#{@annexlbl} "
190
+ { label: num, xref: l10n("#{lbl}#{num}"),
191
+ level: level, type: "clause" }
192
+ end
193
+
133
194
  def annex_names1(clause, num, level)
134
- @anchors[clause["id"]] =
135
- { label: num, xref: l10n("#{@annexlbl} #{num}"),
136
- level: level, type: "clause" }
195
+ @anchors[clause["id"]] = annex_names1_anchors(num, level)
137
196
  i = Counter.new
138
197
  clause.xpath(ns(NUMBERED_SUBCLAUSES)).each do |c|
139
198
  i.increment(c)
140
199
  annex_names1(c, "#{num}.#{i.print}", level + 1)
141
200
  end
142
- clause.xpath(ns(UNNUMBERED_SUBCLAUSES)).each do |c|
143
- unnumbered_annex_names1(c, level + 1)
144
- end
201
+ clause.xpath(ns(UNNUMBERED_SUBCLAUSES))
202
+ .each { |c| unnumbered_annex_names1(c, level + 1) }
145
203
  end
146
204
 
147
205
  def unnumbered_annex_names1(clause, level)
148
- lbl = clause&.at(ns("./title"))&.text || "[#{clause["id"]}]"
149
- @anchors[clause["id"]] =
150
- { label: lbl, xref: l10n(%{"#{lbl}"}),
151
- level: level, type: "clause" }
152
- clause.xpath(ns(SUBCLAUSES)).each do |c|
153
- unnumbered_annex_names1(c, level + 1)
154
- end
206
+ lbl = clause&.at(ns("./title"))&.text || "[#{clause['id']}]"
207
+ @anchors[clause["id"]] = { label: lbl, xref: l10n(%{"#{lbl}"}),
208
+ level: level, type: "clause" }
209
+ clause.xpath(ns(SUBCLAUSES))
210
+ .each { |c| unnumbered_annex_names1(c, level + 1) }
155
211
  end
156
212
 
157
- def annex_name_lbl(clause, num)
213
+ def annex_name_lbl(_clause, num)
158
214
  l10n("<strong>#{@annexlbl} #{num}</strong>")
159
215
  end
216
+
217
+ def sequential_formula_names(clause)
218
+ c = Counter.new
219
+ clause.xpath(ns(".//formula")).each do |t|
220
+ next if t["id"].nil? || t["id"].empty?
221
+
222
+ @anchors[t["id"]] = anchor_struct(
223
+ c.increment(t).print, nil,
224
+ t["inequality"] ? @labels["inequality"] : @labels["formula"],
225
+ "formula", t["unnumbered"]
226
+ )
227
+ end
228
+ end
160
229
  end
161
230
  end
162
231
  end