metanorma-iso 2.8.9 → 2.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,35 +4,6 @@ module IsoDoc
4
4
  def bibdata(docxml)
5
5
  super
6
6
  editorialgroup_identifier(docxml)
7
- warning_for_missing_metadata(docxml)
8
- end
9
-
10
- def warning_for_missing_metadata(docxml)
11
- @meta.get[:unpublished] or return
12
- ret = warning_for_missing_metadata_create(docxml)
13
- ret.empty? and return
14
- warning_for_missing_metadata_post(docxml, ret)
15
- end
16
-
17
- def warning_for_missing_metadata_create(docxml)
18
- ret = ""
19
- docxml.at(ns("//bibdata/ext//secretariat")) or
20
- ret += "<p>Secretariat is missing.</p>"
21
- docxml.at(ns("//bibdata/ext//editorialgroup")) or
22
- ret += "<p>Editorial groups are missing.</p>"
23
- docxml.at(ns("//bibdata/date[@type = 'published' or @type = 'issued' " \
24
- "or @type = 'created']")) ||
25
- docxml.at(ns("//bibdata/version/revision-date")) or
26
- ret += "<p>Document date is missing.</p>"
27
- ret
28
- end
29
-
30
- def warning_for_missing_metadata_post(docxml, ret)
31
- id = UUIDTools::UUID.random_create
32
- ret = "<review date='#{Date.today}' reviewer='Metanorma' id='_#{id}'>" \
33
- "<p><strong>Metadata warnings:<strong></p> #{ret}</review>"
34
- ins = docxml.at(ns("//sections//title")) or return
35
- ins.children.first.previous = ret
36
7
  end
37
8
 
38
9
  def editorialgroup_identifier(docxml)
@@ -52,19 +52,6 @@ module IsoDoc
52
52
  node.children)
53
53
  end
54
54
 
55
- def termdefinition1(elem)
56
- prefix_domain_to_definition(elem)
57
- super
58
- end
59
-
60
- def prefix_domain_to_definition(elem)
61
- ((d = elem.at(ns("./domain"))) &&
62
- (v = elem.at(ns("./definition/verbal-definition"))) &&
63
- v.elements.first.name == "p") or return
64
- v.elements.first.children.first.previous =
65
- "&#x3c;#{to_xml(d.remove.children)}&#x3e; "
66
- end
67
-
68
55
  def insertall_after_here(node, insert, name)
69
56
  node.children.each do |n|
70
57
  n.name == name or next
@@ -23,6 +23,39 @@ module IsoDoc
23
23
  super
24
24
  end
25
25
 
26
+ def section(docxml)
27
+ super
28
+ warning_for_missing_metadata(docxml)
29
+ end
30
+
31
+ def warning_for_missing_metadata(docxml)
32
+ @meta.get[:unpublished] or return
33
+ ret = warning_for_missing_metadata_create(docxml)
34
+ ret.empty? and return
35
+ warning_for_missing_metadata_post(docxml, ret)
36
+ end
37
+
38
+ def warning_for_missing_metadata_create(docxml)
39
+ ret = ""
40
+ docxml.at(ns("//bibdata/ext//secretariat")) or
41
+ ret += "<p>Secretariat is missing.</p>"
42
+ docxml.at(ns("//bibdata/ext//editorialgroup")) or
43
+ ret += "<p>Editorial groups are missing.</p>"
44
+ docxml.at(ns("//bibdata/date[@type = 'published' or @type = 'issued' " \
45
+ "or @type = 'created']")) ||
46
+ docxml.at(ns("//bibdata/version/revision-date")) or
47
+ ret += "<p>Document date is missing.</p>"
48
+ ret
49
+ end
50
+
51
+ def warning_for_missing_metadata_post(docxml, ret)
52
+ id = UUIDTools::UUID.random_create
53
+ ret = "<review date='#{Date.today}' reviewer='Metanorma' id='_#{id}'>" \
54
+ "<p><strong>Metadata warnings:<strong></p> #{ret}</review>"
55
+ ins = docxml.at(ns("//sections//fmt-title")) or return
56
+ ins.add_first_child ret
57
+ end
58
+
26
59
  def block(docxml)
27
60
  amend docxml
28
61
  figure docxml
@@ -30,40 +63,58 @@ module IsoDoc
30
63
  formula docxml
31
64
  admonition docxml
32
65
  source docxml
66
+ ul docxml
33
67
  ol docxml
68
+ quote docxml
34
69
  permission docxml
35
70
  requirement docxml
36
71
  recommendation docxml
37
72
  requirement_render docxml
38
73
  @xrefs.anchors_previous = @xrefs.anchors.dup # store old xrefs of reqts
39
74
  @xrefs.parse docxml
75
+ # TODO move this dependency around: requirements at root should be processed before everything else
40
76
  table docxml # have table include requirements newly converted to tables
77
+ # table feeds dl
78
+ dl docxml
41
79
  example docxml
42
80
  note docxml
43
81
  end
44
82
 
83
+ # Redo Amendment annex titles as numbered
45
84
  def annex(isoxml)
46
85
  amd?(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
47
86
  super
48
- isoxml.xpath(ns("//annex//clause | //annex//appendix")).each do |f|
87
+ amd?(isoxml) and @suppressheadingnumbers = true
88
+ end
89
+
90
+ # Redo Amendment annex subclause titles as numbered
91
+ def clause(docxml)
92
+ super
93
+ docxml.xpath(ns("//annex//appendix")).each { |f| clause1(f) }
94
+ amd?(docxml) or return
95
+ @suppressheadingnumbers = @oldsuppressheadingnumbers
96
+ docxml.xpath(ns("//annex//clause | //annex//appendix")).each do |f|
97
+ f.xpath(ns("./fmt-title | ./fmt-xref-label")).each(&:remove)
49
98
  clause1(f)
50
99
  end
51
- amd?(isoxml) and @suppressheadingnumbers = true
100
+ @suppressheadingnumbers = true
101
+ end
102
+
103
+ def subfigure_delim
104
+ "<span class='fmt-label-delim'>)</span>"
52
105
  end
53
106
 
54
- def figure1(node)
55
- lbl = @xrefs.anchor(node["id"], :label, false) or return
56
- figname = node.parent.name == "figure" ? "" : "#{@i18n.figure} "
57
- conn = node.parent.name == "figure" ? "&#xa0; " : "&#xa0;&#x2014; "
58
- prefix_name(node, conn, l10n("#{figname}#{lbl}"), "name")
107
+ def figure_delim(elem)
108
+ elem.parent.name == "figure" ? "&#xa0; " : "&#xa0;&#x2014; "
59
109
  end
60
110
 
61
- def example1(node)
62
- n = @xrefs.get[node["id"]]
63
- lbl = if n.nil? || blank?(n[:label]) then @i18n.example
64
- else l10n("#{@i18n.example} #{n[:label]}")
65
- end
66
- prefix_name(node, block_delim, lbl, "name")
111
+ def figure_name(elem)
112
+ elem.parent.name == "figure" and return ""
113
+ super
114
+ end
115
+
116
+ def figure_label?(_elem)
117
+ true
67
118
  end
68
119
 
69
120
  def example_span_label(_node, div, name)
@@ -74,30 +125,36 @@ module IsoDoc
74
125
  end
75
126
 
76
127
  def clause1(node)
77
- if !node.at(ns("./title")) &&
78
- !%w(sections preface bibliography).include?(node.parent.name)
128
+ !node.at(ns("./title")) &&
129
+ !%w(sections preface bibliography).include?(node.parent.name) and
79
130
  node["inline-header"] = "true"
80
- end
81
131
  super
82
- if node["type"] == "section"
83
- t = node.at(ns("./title/tab")) and
84
- t.previous = @i18n.l10n(": ").sub(/\p{Zs}$/, "")
85
- end
132
+ clause1_section_prefix(node)
86
133
  end
87
134
 
88
- def clause(docxml)
89
- docxml.xpath(ns("//clause[not(ancestor::annex)] | " \
90
- "//terms | //definitions | //references | " \
91
- "//preface/introduction[clause]")).each do |f|
92
- f.parent.name == "annex" &&
93
- @xrefs.klass.single_term_clause?(f.parent) and next
94
- clause1(f)
135
+ def clause1_section_prefix(node)
136
+ if node["type"] == "section" &&
137
+ c = node.at(ns("./fmt-title//span[@class = 'fmt-caption-delim']"))
138
+ c.add_first_child(":")
139
+ t = node.at(ns("./fmt-title"))
140
+ # French l10n needs tab to be treated as space
141
+ t.replace @i18n.l10n(to_xml(t).gsub("<tab/>", "<tab> </tab>"))
142
+ .gsub(%r{<tab>[^<]+</tab>}, "<tab/>")
95
143
  end
96
144
  end
97
145
 
146
+ # def clause(docxml)
147
+ # docxml.xpath(ns("//clause[not(ancestor::annex)] | " \
148
+ # "//terms | //definitions | //references | " \
149
+ # "//preface/introduction[clause]")).each do |f|
150
+ # f.parent.name == "annex" &&
151
+ # @xrefs.klass.single_term_clause?(f.parent) and next
152
+ # clause1(f)
153
+ # end
154
+ # end
155
+
98
156
  def admonition1(elem)
99
157
  super
100
- admonition_inline_name(elem)
101
158
  admonition_outside_clauses(elem)
102
159
  end
103
160
 
@@ -113,17 +170,6 @@ module IsoDoc
113
170
  cell.children.each { |p| wrap_in_bold(p) }
114
171
  end
115
172
 
116
- def admonition_inline_name(elem)
117
- n = elem.at(ns("./name")) or return
118
- if (p = n.next_element) && p&.name == "p"
119
- p.children.first.previous = admonition_name(to_xml(n.remove.children))
120
- end
121
- end
122
-
123
- def admonition_name(xml)
124
- "#{xml} &#x2014; "
125
- end
126
-
127
173
  def bibrender_formattedref(formattedref, xml)
128
174
  %w(techreport standard).include? xml["type"] and return
129
175
  super
@@ -146,10 +192,9 @@ module IsoDoc
146
192
 
147
193
  def formula_where(dlist)
148
194
  dlist.nil? and return
149
- return super unless dlist.xpath(ns("./dt")).size == 1 &&
195
+ dlist.xpath(ns("./dt")).size == 1 &&
150
196
  dlist.at(ns("./dd"))&.elements&.size == 1 &&
151
- dlist.at(ns("./dd/p"))
152
-
197
+ dlist.at(ns("./dd/p")) or return super
153
198
  formula_where_one(dlist)
154
199
  end
155
200
 
@@ -161,10 +206,22 @@ module IsoDoc
161
206
  end
162
207
 
163
208
  def table1(elem)
209
+ table1_key(elem)
210
+ if elem["class"] == "modspec"
211
+ n = elem.at(ns(".//fmt-name")).remove
212
+ n.name = "name"
213
+ elem.add_first_child(n)
214
+ elem.at(ns("./thead"))&.remove
215
+ super
216
+ elem.at(ns("./name")).remove
217
+ else super
218
+ end
219
+ end
220
+
221
+ def table1_key(elem)
164
222
  elem.xpath(ns(".//dl[@key = 'true'][not(./name)]")).each do |dl|
165
- dl.children.first.previous = "<name>#{@i18n.key}</name>"
223
+ dl.add_first_child "<name>#{@i18n.key}</name>"
166
224
  end
167
- super
168
225
  end
169
226
 
170
227
  def toc_title(docxml)
@@ -177,7 +234,7 @@ module IsoDoc
177
234
  return
178
235
  s = docxml.at(ns("//sections")) or return
179
236
  ret = "#{middle_title_main}#{middle_title_amd}"
180
- s.children.first.previous = ret
237
+ s.add_first_child ret
181
238
  end
182
239
 
183
240
  def middle_title_main
@@ -214,9 +271,7 @@ module IsoDoc
214
271
  end
215
272
 
216
273
  def move_norm_ref_to_sections(docxml)
217
- if amd?(docxml)
218
- else super
219
- end
274
+ amd?(docxml) or super
220
275
  end
221
276
 
222
277
  def twitter_cldr_localiser_symbols
@@ -224,6 +279,25 @@ module IsoDoc
224
279
  fraction_group_digits: 3 }
225
280
  end
226
281
 
282
+ def implicit_reference(bib)
283
+ bib.at(ns("./docidentifier"))&.text == "IEV" and return true
284
+ super
285
+ end
286
+
287
+ def render_identifier(ident)
288
+ ret = super
289
+ ret[:sdo] = std_docid_semantic(ret[:sdo])
290
+ ret
291
+ end
292
+
293
+ def admonition_delim(elem)
294
+ if elem.at("./*[not(self::xmlns:name)]")&.name == "p"
295
+ " &#x2014; "
296
+ else
297
+ ""
298
+ end
299
+ end
300
+
227
301
  include Init
228
302
  end
229
303
  end
@@ -74,7 +74,7 @@ module IsoDoc
74
74
 
75
75
  def locality_span_wrap(ret, type)
76
76
  type or return ret
77
- m = /^(\s*)(?=\S)(.+?)(\s*)$/.match(ret) or return ret
77
+ m = /\A(\s*)(?=\S)(.+?)(\s*)\Z/m.match(ret) or return ret
78
78
  ret = [m[1], m[2], m[3]]
79
79
  spanclass = LOCALITY2SPAN[type.to_sym] and
80
80
  ret[1] = "<span class='#{spanclass}'>#{ret[1]}</span>"
@@ -115,7 +115,9 @@ module IsoDoc
115
115
  prefix_container_template(container, node, target)
116
116
  container_label = prefix_container(container_container,
117
117
  container_label, node, target)
118
- l10n(nested_xref.sub("%1", container_label).sub("%2", linkend))
118
+ l10n(connectives_spans(nested_xref
119
+ .sub("%1", "<span class='fmt-xref-container'>#{container_label}</span>")
120
+ .sub("%2", linkend)))
119
121
  end
120
122
 
121
123
  def prefix_container_template(container, node, target)
@@ -130,6 +132,8 @@ module IsoDoc
130
132
  end
131
133
 
132
134
  def expand_citeas(text)
135
+ ret = super or return
136
+ ret.include?("<span") and return ret
133
137
  std_docid_semantic(super)
134
138
  end
135
139
 
@@ -12,9 +12,9 @@ module IsoDoc
12
12
  @foreword = true
13
13
  page_break(out)
14
14
  out.div **attr_code(id: clause["id"]) do |s|
15
- clause_name(nil, clause.at(ns("./title")) || @i18n.foreword, s,
15
+ clause_name(nil, clause.at(ns("./fmt-title")), s,
16
16
  { class: "ForewordTitle" })
17
- clause.elements.each { |e| parse(e, s) unless e.name == "title" }
17
+ clause.elements.each { |e| parse(e, s) unless e.name == "fmt-title" }
18
18
  end
19
19
  @foreword = false
20
20
  end
@@ -108,7 +108,7 @@ module IsoDoc
108
108
  br(out, "auto")
109
109
  out.div class: "index" do |div|
110
110
  elem.children.each do |e|
111
- parse(e, div) unless e.name == "title"
111
+ parse(e, div) unless e.name == "fmt-title"
112
112
  end
113
113
  end
114
114
  end
@@ -116,7 +116,7 @@ module IsoDoc
116
116
  def indexsect_title(clause, out)
117
117
  br(out, "always")
118
118
  out.div class: "WordSection3" do |div|
119
- clause_name(clause, clause.at(ns("./title")), div, nil)
119
+ clause_name(clause, clause.at(ns("./fmt-title")), div, nil)
120
120
  end
121
121
  end
122
122
 
@@ -145,7 +145,7 @@ module IsoDoc
145
145
  page_break(out)
146
146
  out.div do |div|
147
147
  div.h1 **bibliography_attrs do |h1|
148
- node&.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
148
+ node&.at(ns("./fmt-title"))&.children&.each { |c2| parse(c2, h1) }
149
149
  end
150
150
  biblio_list(node, div, true)
151
151
  end
@@ -154,7 +154,7 @@ module IsoDoc
154
154
  def bibliography_parse(node, out)
155
155
  node["hidden"] != true or return
156
156
  out.div do |div|
157
- clause_parse_title(node, div, node.at(ns("./title")), out,
157
+ clause_parse_title(node, div, node.at(ns("./fmt-title")), out,
158
158
  bibliography_attrs)
159
159
  biblio_list(node, div, true)
160
160
  end
@@ -201,7 +201,7 @@ module IsoDoc
201
201
  end
202
202
 
203
203
  def table_title_parse(node, out)
204
- name = node.at(ns("./name")) or return
204
+ name = node.at(ns("./fmt-name")) or return
205
205
  out.p **table_title_attrs(node) do |p|
206
206
  name&.children&.each { |n| parse(n, p) }
207
207
  end
@@ -209,7 +209,7 @@ module IsoDoc
209
209
 
210
210
  def annex_name(_annex, name, div)
211
211
  name.nil? and return
212
- name&.at(ns("./strong"))&.remove # supplied by CSS list numbering
212
+ name&.at(ns(".//strong"))&.remove # label supplied by CSS list numbering
213
213
  div.h1 class: "Annex" do |t|
214
214
  annex_name1(name, t)
215
215
  clause_parse_subtitle(name, t)
@@ -217,14 +217,12 @@ module IsoDoc
217
217
  end
218
218
 
219
219
  def annex_name1(name, out)
220
- name.children.each do |c2|
221
- if c2.name == "span" && c2["class"] == "obligation"
222
- out.span style: "font-weight:normal;" do |s|
223
- c2.children.each { |c3| parse(c3, s) }
224
- end
225
- else parse(c2, out)
226
- end
220
+ n = name.dup
221
+ n.xpath(ns(".//span[@class = 'fmt-obligation']")).each do |s|
222
+ s.delete("class")
223
+ s["style"] = "font-weight:normal;"
227
224
  end
225
+ children_parse(n, out)
228
226
  end
229
227
 
230
228
  def table_attrs(node)
@@ -111,10 +111,7 @@ module IsoDoc
111
111
  out.span **attr_code(style: st) do |s|
112
112
  node.children.each { |n| parse(n, s) }
113
113
  end
114
- else
115
- out.span **attr_code(class: node["class"], style: st) do |x|
116
- node.children.each { |n| parse(n, x) }
117
- end
114
+ else super
118
115
  end
119
116
  end
120
117
 
@@ -48,25 +48,56 @@ module IsoDoc
48
48
  c = IsoDoc::XrefGen::Counter.new
49
49
  clause.xpath(ns(".//formula")).noblank.each do |t|
50
50
  @anchors[t["id"]] = anchor_struct(
51
- "#{num}#{hiersep}#{c.increment(t).print}", t,
51
+ #"#{num}#{hier_separator}#{c.increment(t).print}", t,
52
+ hiersemx(clause, num, c.increment(t), t), t,
52
53
  t["inequality"] ? @labels["inequality"] : @labels["formula"],
53
- "formula", t["unnumbered"]
54
+ "formula", { unnumb: t["unnumbered"], container: true }
54
55
  )
55
56
  end
56
57
  end
57
58
 
59
+ def subfigure_delim
60
+ ")"
61
+ end
62
+
58
63
  def figure_anchor(elem, sublabel, label, klass, container: false)
64
+ if sublabel
65
+ subfigure_anchor(elem, sublabel, label, klass, container: container)
66
+ else
67
+ @anchors[elem["id"]] = anchor_struct(
68
+ label, elem, @labels[klass] || klass.capitalize, klass,
69
+ { unnumb: elem["unnumbered"], container: }
70
+ )
71
+ end
72
+ end
73
+
74
+ def fig_subfig_label(label, sublabel)
75
+ "#{label} #{sublabel}"
76
+ end
77
+
78
+ def subfigure_anchor(elem, sublabel, label, klass, container: false)
79
+ figlabel = fig_subfig_label(label, sublabel)
59
80
  @anchors[elem["id"]] = anchor_struct(
60
- "#{label}#{sublabel}", container ? elem : nil,
61
- @labels[klass] || klass.capitalize, klass, elem["unnumbered"]
81
+ figlabel, elem, @labels[klass] || klass.capitalize, klass,
82
+ { unnumb: elem["unnumbered"] }
62
83
  )
63
- !sublabel.empty? && elem["unnumbered"] != "true" and
84
+ if elem["unnumbered"] != "true"
85
+ # Dropping the parent figure label is specific to ISO
64
86
  @anchors[elem["id"]][:label] = sublabel
87
+ @anchors[elem["id"]][:xref] = @anchors[elem.parent["id"]][:xref] +
88
+ " " + semx(elem, sublabel) + delim_wrap(subfigure_delim)
89
+ x = @anchors[elem.parent["id"]][:container] and
90
+ @anchors[elem["id"]][:container] = x
91
+ end
65
92
  end
66
93
 
67
94
  def subfigure_label(subfignum)
68
- subfignum.zero? and return ""
69
- " #{(subfignum + 96).chr})"
95
+ subfignum.zero? and return
96
+ (subfignum + 96).chr
97
+ end
98
+
99
+ def hierfigsep
100
+ " "
70
101
  end
71
102
 
72
103
  def sequential_figure_names(clause, container: false)
@@ -97,9 +128,9 @@ module IsoDoc
97
128
  j = 0
98
129
  clause.xpath(ns(FIGURE_NO_CLASS)).noblank.each do |t|
99
130
  j = subfigure_increment(j, c, t)
100
- label = "#{num}#{hiersep}#{c.print}"
131
+ #label = "#{num}#{hier_separator}#{c.print}"
101
132
  sublabel = subfigure_label(j)
102
- figure_anchor(t, sublabel, label, "figure")
133
+ figure_anchor(t, sublabel, hiersemx(clause, num, c, t), "figure")
103
134
  end
104
135
  hierarchical_figure_class_names(clause, num)
105
136
  end
@@ -111,9 +142,9 @@ module IsoDoc
111
142
  .noblank.each do |t|
112
143
  c[t["class"]] ||= IsoDoc::XrefGen::Counter.new
113
144
  j = subfigure_increment(j, c[t["class"]], t)
114
- label = "#{num}#{hiersep}#{c.print}"
145
+ #label = "#{num}#{hier_separator}#{c.print}"
115
146
  sublabel = j.zero? ? nil : "#{(j + 96).chr})"
116
- figure_anchor(t, sublabel, label, t["class"])
147
+ figure_anchor(t, sublabel, hiersemx(clause, num, c[t["class"]], t), t["class"])
117
148
  end
118
149
  end
119
150
 
@@ -129,8 +160,10 @@ module IsoDoc
129
160
  s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
130
161
  c = Counter.new
131
162
  notes.noblank.each do |n|
163
+ n["id"] ||= "_#{UUIDTools::UUID.random_create}"
132
164
  @anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n,
133
- @labels["list"], "list", false)
165
+ @labels["list"], "list",
166
+ { unnumb: false, container: true })
134
167
  list_item_anchor_names(n, @anchors[n["id"]], 1, "",
135
168
  !single_ol_for_xrefs?(notes))
136
169
  end
@@ -174,7 +207,11 @@ module IsoDoc
174
207
  (@anchors[id] && !@anchors[id][:has_modspec]) or return
175
208
  @anchors[id][:has_modspec] = true
176
209
  x = @anchors_previous[id][:xref_bare] || @anchors_previous[id][:xref]
177
- @anchors[id][:xref] = l10n("#{table_label}, #{x}")
210
+ # @anchors[id][:xref] = l10n("#{table_label}<span class='fmt-comma'>,</span> #{x}")
211
+
212
+ @anchors[id][:xref] = l10n(@klass.connectives_spans(@i18n.nested_xref
213
+ .sub("%1", table_label).sub("%2", x)))
214
+
178
215
  @anchors[id][:modspec] = @anchors_previous[id][:modspec]
179
216
  @anchors[id][:subtype] = "modspec" # prevents citetbl style from beign applied
180
217
  true
@@ -194,7 +231,8 @@ module IsoDoc
194
231
  countable.each do |n|
195
232
  @anchors[n["id"]] =
196
233
  anchor_struct(increment_label(countable, n, counter), n,
197
- @labels["note_xref"], "note", false)
234
+ @labels["note_xref"], "note",
235
+ { unnum: false, container: true })
198
236
  end
199
237
  end
200
238
  end
@@ -7,9 +7,10 @@ module IsoDoc
7
7
  clause.at(ns("./clause")) and
8
8
  @anchors[clause["id"]] = { label: nil, level: 1, type: "clause",
9
9
  xref: clause.at(ns("./title"))&.text }
10
- i = Counter.new(0, prefix: "0")
10
+ #i = Counter.new(0, prefix: "0")
11
+ i = clause_counter(0)
11
12
  clause.xpath(ns("./clause")).each do |c|
12
- section_names1(c, i.increment(c).print, 2)
13
+ section_names1(c, semx(clause, "0"), i.increment(c).print, 2)
13
14
  end
14
15
  end
15
16
 
@@ -19,17 +20,18 @@ module IsoDoc
19
20
  end
20
21
 
21
22
  def appendix_names(clause, _num)
22
- i = Counter.new
23
+ i = clause_counter(0)
23
24
  clause.xpath(ns("./appendix")).each do |c|
24
25
  i.increment(c)
26
+ num = semx(c, i.print)
27
+ lbl = labelled_autonum(@labels["appendix"], num)
25
28
  @anchors[c["id"]] =
26
- anchor_struct(i.print, nil, @labels["appendix"],
29
+ anchor_struct(i.print, c, @labels["appendix"],
27
30
  "clause").merge(level: 2, subtype: "annex",
28
31
  container: clause["id"])
29
- j = Counter.new(0, prefix: i.print)
32
+ j = clause_counter(0)
30
33
  c.xpath(ns("./clause | ./references")).each do |c1|
31
- lbl = "#{@labels['appendix']} #{j.increment(c1).print}"
32
- appendix_names1(c1, l10n(lbl), 3, clause["id"])
34
+ appendix_names1(c1, lbl, j.increment(c1).print, 3, clause["id"])
33
35
  end
34
36
  end
35
37
  end
@@ -38,48 +40,41 @@ module IsoDoc
38
40
  # retaining subtype for the semantics
39
41
  def section_name_anchors(clause, num, level)
40
42
  if clause["type"] == "section"
43
+ xref = labelled_autonum(@labels["section"], num)
44
+ label = labelled_autonum(@labels["section"], num)
41
45
  @anchors[clause["id"]] =
42
- { label: l10n("#{@labels['section']} #{num}"),
43
- xref: l10n("#{@labels['section']} #{num}"),
44
- title: clause_title(clause), level: level, type: "clause",
45
- elem: @labels["section"] }
46
+ { label:, xref:, elem: @labels["section"],
47
+ title: clause_title(clause), level: level, type: "clause" }
46
48
  elsif level > 1
49
+ #num = semx(clause, num)
47
50
  @anchors[clause["id"]] =
48
51
  { label: num, level: level, xref: num, subtype: "clause" }
49
52
  else super end
50
53
  end
51
54
 
52
55
  def annex_name_anchors1(clause, num, level)
56
+ level == 1 and return annex_name_anchors(clause, num, level)
53
57
  ret = { label: num, level: level, subtype: "annex" }
54
58
  ret2 = if level == 2
55
- { xref: l10n("#{@labels['clause']} #{num}"),
59
+ xref = labelled_autonum(@labels["clause"], num)
60
+ { xref:, # l10n("#{@labels['clause']} #{num}"),
56
61
  elem: @labels["clause"] }
57
62
  else
58
- { xref: num }
63
+ { xref: semx(clause, num) }
59
64
  end
60
65
  @anchors[clause["id"]] = ret.merge(ret2)
61
66
  end
62
67
 
63
- def annex_names1(clause, num, level)
64
- annex_name_anchors1(clause, num, level)
65
- i = Counter.new(0, prefix: num)
66
- clause.xpath(ns("./clause | ./references")).each do |c|
67
- annex_names1(c, i.increment(c).print, level + 1)
68
- end
69
- end
70
-
71
- def appendix_names1(clause, num, level, container)
68
+ def appendix_names1(clause, parentnum, num, level, container)
69
+ #num = labelled_autonum(@labels["appendix"], num)
70
+ num = clause_number_semx(parentnum, clause, num)
72
71
  @anchors[clause["id"]] = { label: num, xref: num, level: level,
73
72
  container: container }
74
- i = Counter.new(0, prefix: num)
73
+ i = clause_counter(0)
75
74
  clause.xpath(ns("./clause | ./references")).each do |c|
76
- appendix_names1(c, i.increment(c).print, level + 1, container)
75
+ appendix_names1(c, num, i.increment(c).print, level + 1, container)
77
76
  end
78
77
  end
79
-
80
- def annex_name_lbl(clause, num)
81
- super.sub(%r{<br/>(.*)$}, "<br/><span class='obligation'>\\1</span>")
82
- end
83
78
  end
84
79
  end
85
80
  end