isodoc 1.8.2.2 → 1.8.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acaea1b02c6f852beb40a1344fff745a7ff335cebba6484151acc0e73d4146a4
4
- data.tar.gz: 23fce1207ac948de9b61c487dc8a91c2fd8ceeddb1a522b3608a85aad02c1923
3
+ metadata.gz: f13a3c3a1018484dfa9518b6831d188803ca83c2d89ee872ff17723994c0fae7
4
+ data.tar.gz: b4461e1537e949cbfbc851309cc1f29c974a38fda8728f405591dc586267943c
5
5
  SHA512:
6
- metadata.gz: ad28bd8420ad35320fc9f67470bf5e4b44b3dc7e27c48867e50bfc6446ed0b57709bc4576518337e87bf72f8920a8035e4a34dd7486c7f739c2edcfc348b709e
7
- data.tar.gz: 3c04a7a2eb965caeda51cd538a770387bb7d0a610893f46b6c09f4ef44178024b493c077390f0a6e765b17330e3af5004e2308964920061eef3f10c73e894b2e
6
+ metadata.gz: eb0cf999d3a0155a13913543101228f4c1d60c4705dfdd67ca76f4e21fd00e59853040e4bbe516b64d4fc11a0aaf7da3573f8932f6bf7112dd3293ccc82263a2
7
+ data.tar.gz: c43855701417ffcad7a7e85086b489995ac1af483752c5b9ad1f958fbf944e38a94ca5fd3b4dcf90103608cad6a2d9b6d08fa46a877dffaeef14475212e7056c
data/Gemfile CHANGED
@@ -9,3 +9,5 @@ gemspec
9
9
  if File.exist? "Gemfile.devel"
10
10
  eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
11
11
  end
12
+
13
+ gem "reline", "~> 0.2.8.pre.11"
@@ -2,17 +2,7 @@ module IsoDoc
2
2
  module Function
3
3
  module Cleanup
4
4
  def textcleanup(docxml)
5
- termref_cleanup(passthrough_cleanup(docxml))
6
- end
7
-
8
- def termref_cleanup(docxml)
9
- docxml
10
- .gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/,
11
- l10n(", #{@i18n.modified} [/TERMREF]"))
12
- .gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, "; ")
13
- .gsub(/\[TERMREF\]\s*/, l10n("[#{@i18n.source}: "))
14
- .gsub(%r{\s*\[/TERMREF\]\s*}, l10n("]"))
15
- .gsub(/\s*\[MODIFICATION\]/, l10n(", #{@i18n.modified} &mdash; "))
5
+ passthrough_cleanup(docxml)
16
6
  end
17
7
 
18
8
  def passthrough_cleanup(docxml)
@@ -41,8 +41,8 @@ module IsoDoc
41
41
  end
42
42
 
43
43
  def eref_target(node)
44
- return "##{node['bibitemid']}" unless url = @bibitems[node["bibitemid"]]
45
- &.at(ns("./uri[@type = 'citation']"))
44
+ return "##{node['bibitemid']}" unless (!@bibitems.nil? &&
45
+ url = @bibitems[node["bibitemid"]]&.at(ns("./uri[@type = 'citation']")))
46
46
 
47
47
  href = suffix_url(url.text)
48
48
  anchor = node&.at(ns(".//locality[@type = 'anchor']"))&.text&.strip
@@ -6,7 +6,6 @@ module IsoDoc
6
6
  end
7
7
 
8
8
  def modification_parse(node, out)
9
- out << "[MODIFICATION]"
10
9
  para = node.at(ns("./p"))
11
10
  para.children.each { |n| parse(n, out) }
12
11
  end
@@ -58,9 +57,7 @@ module IsoDoc
58
57
 
59
58
  def termref_parse(node, out)
60
59
  out.p do |p|
61
- p << "[TERMREF]"
62
60
  node.children.each { |n| parse(n, p) }
63
- p << "[/TERMREF]"
64
61
  end
65
62
  end
66
63
 
@@ -37,10 +37,9 @@ module IsoDoc
37
37
  end
38
38
 
39
39
  def attr_code(attributes)
40
- attributes = attributes.compact.map
41
- attributes.map do |k, v|
42
- [k, v.is_a?(String) ? HTMLEntities.new.decode(v) : v]
43
- end.to_h
40
+ attributes.compact.transform_values do |v|
41
+ v.is_a?(String) ? HTMLEntities.new.decode(v) : v
42
+ end
44
43
  end
45
44
 
46
45
  DOCTYPE_HDR = "<!DOCTYPE html SYSTEM "\
@@ -188,10 +187,17 @@ module IsoDoc
188
187
  end
189
188
 
190
189
  def image_localfile(img)
190
+ case img["src"]
191
+ when /^data:/
192
+ save_dataimage(img["src"], false)
193
+ when %r{^([A-Z]:)?/}
194
+ img["src"]
195
+ =begin
191
196
  if /^data:/.match? img["src"]
192
197
  save_dataimage(img["src"], false)
193
198
  elsif %r{^([A-Z]:)?/}.match? img["src"]
194
199
  img["src"]
200
+ =end
195
201
  else
196
202
  File.join(@localdir, img["src"])
197
203
  end
@@ -211,7 +217,6 @@ module IsoDoc
211
217
  c = HTMLEntities.new
212
218
  text.split(/([<>])/).each_slice(4).map do |a|
213
219
  a[0] = c.encode(c.decode(a[0]), :hexadecimal)
214
- a[2] = c.encode(c.decode(a[2]), :hexadecimal) if a.size >= 3
215
220
  a
216
221
  end.join
217
222
  end
data/lib/isodoc/i18n.rb CHANGED
@@ -55,8 +55,8 @@ module IsoDoc
55
55
  @labels = y
56
56
  @labels["language"] = @lang
57
57
  @labels["script"] = @script
58
- @labels.each do |k, v|
59
- self.class.send(:define_method, k.downcase) { v }
58
+ @labels.each do |k, _v|
59
+ self.class.send(:define_method, k.downcase) { get[k] }
60
60
  end
61
61
  end
62
62
 
@@ -68,19 +68,40 @@ module IsoDoc
68
68
  # function localising spaces and punctuation.
69
69
  # Not clear if period needs to be localised for zh
70
70
  def l10n(text, lang = @lang, script = @script)
71
- if lang == "zh" && script == "Hans"
72
- xml = Nokogiri::HTML::DocumentFragment.parse(text)
73
- xml.traverse do |n|
74
- next unless n.text?
71
+ if lang == "zh" && script == "Hans" then l10n_zh(text)
72
+ else bidiwrap(text, lang, script)
73
+ end
74
+ end
75
75
 
76
- n.replace(n.text.gsub(/ /, "").gsub(/:/, ":").gsub(/,/, "、")
77
- .gsub(/\(/, "(").gsub(/\)/, ")").gsub(/\[/, "【").gsub(/\]/, "】"))
78
- end
79
- xml.to_xml.gsub(/<b>/, "").gsub("</b>", "").gsub(/<\?[^>]+>/, "")
76
+ def bidiwrap(text, lang, script)
77
+ my_script, my_rtl, outer_rtl = bidiwrap_vars(lang, script)
78
+ if my_rtl && !outer_rtl
79
+ mark = %w(Arab Aran).include?(my_script) ? "&#x61c;" : "&#x200f;"
80
+ "#{mark}#{text}#{mark}"
81
+ elsif !my_rtl && outer_rtl then "&#x200e;#{text}&#x200e;"
80
82
  else text
81
83
  end
82
84
  end
83
85
 
86
+ def bidiwrap_vars(lang, script)
87
+ my_script = script || Metanorma::Utils.default_script(lang)
88
+ [my_script,
89
+ Metanorma::Utils.rtl_script?(my_script),
90
+ Metanorma::Utils.rtl_script?(@script || Metanorma::Utils
91
+ .default_script(@lang))]
92
+ end
93
+
94
+ def l10n_zh(text)
95
+ xml = Nokogiri::HTML::DocumentFragment.parse(text)
96
+ xml.traverse do |n|
97
+ next unless n.text?
98
+
99
+ n.replace(n.text.gsub(/ /, "").gsub(/:/, ":").gsub(/,/, "、")
100
+ .gsub(/\(/, "(").gsub(/\)/, ")").gsub(/\[/, "【").gsub(/\]/, "】"))
101
+ end
102
+ xml.to_xml.gsub(/<b>/, "").gsub("</b>", "").gsub(/<\?[^>]+>/, "")
103
+ end
104
+
84
105
  def multiple_and(names, andword)
85
106
  return "" if names.empty?
86
107
  return names[0] if names.length == 1
@@ -12,11 +12,11 @@ module IsoDoc
12
12
  return if number.nil? || number.empty?
13
13
 
14
14
  unless name = node.at(ns("./#{elem}"))
15
- node.children.empty? and node.add_child("<#{elem}></#{elem}>") or
15
+ (node.children.empty? and node.add_child("<#{elem}></#{elem}>")) or
16
16
  node.children.first.previous = "<#{elem}></#{elem}>"
17
17
  name = node.children.first
18
18
  end
19
- if name.children.empty? then name.add_child(number)
19
+ if name.children.empty? then name.add_child(cleanup_entities(number))
20
20
  else (name.children.first.previous = "#{number}#{delim}")
21
21
  end
22
22
  end
@@ -29,7 +29,6 @@ module IsoDoc
29
29
 
30
30
  def sourcecode1(elem)
31
31
  return if labelled_ancestor(elem)
32
- return unless elem.ancestors("example").empty?
33
32
 
34
33
  lbl = @xrefs.anchor(elem["id"], :label, false) or return
35
34
  prefix_name(elem, "&nbsp;&mdash; ",
@@ -29,8 +29,8 @@ module IsoDoc
29
29
  def figure1(elem)
30
30
  return sourcecode1(elem) if elem["class"] == "pseudocode" ||
31
31
  elem["type"] == "pseudocode"
32
- return if labelled_ancestor(elem) && elem.ancestors("figure").empty? ||
33
- elem.at(ns("./figure")) && !elem.at(ns("./name"))
32
+ return if (labelled_ancestor(elem) && elem.ancestors("figure").empty?) ||
33
+ (elem.at(ns("./figure")) && !elem.at(ns("./name")))
34
34
 
35
35
  lbl = @xrefs.anchor(elem["id"], :label, false) or return
36
36
  prefix_name(elem, "&nbsp;&mdash; ",
@@ -121,8 +121,8 @@ module IsoDoc
121
121
  end
122
122
 
123
123
  def designation_annotate(desgn, name)
124
- designation_field(desgn, name)
125
124
  designation_boldface(desgn)
125
+ designation_field(desgn, name)
126
126
  g = desgn.at(ns("./expression/grammar")) and
127
127
  name << ", #{designation_grammar(g).join(', ')}"
128
128
  designation_localization(desgn, name)
@@ -219,5 +219,26 @@ module IsoDoc
219
219
  end
220
220
  end
221
221
  end
222
+
223
+ def termsource(docxml)
224
+ docxml.xpath(ns("//termsource")).each do |f|
225
+ termsource1(f)
226
+ end
227
+ end
228
+
229
+ def termsource1(elem)
230
+ mod = elem.at(ns("./modification")) and
231
+ termsource_modification(mod)
232
+ elem.children = l10n("[#{@i18n.source}: #{elem.children.to_xml.strip}]")
233
+ elem&.next_element&.name == "termsource" and elem.next = "; "
234
+ end
235
+
236
+ def termsource_modification(mod)
237
+ mod.previous_element.next = ", #{@i18n.modified}"
238
+ mod.text.strip.empty? or mod.previous = " &#x2013; "
239
+ mod.elements.size == 1 and
240
+ mod.elements[0].replace(mod.elements[0].children)
241
+ mod.replace(mod.children)
242
+ end
222
243
  end
223
244
  end
@@ -68,6 +68,7 @@ module IsoDoc
68
68
  termnote docxml
69
69
  termdefinition docxml
70
70
  designation docxml
71
+ termsource docxml
71
72
  concept docxml
72
73
  related docxml
73
74
  end
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "1.8.2.2".freeze
2
+ VERSION = "1.8.3".freeze
3
3
  end
@@ -63,11 +63,8 @@ module IsoDoc
63
63
  c.increment(n)
64
64
  idx = increment_label(examples, n, c, false)
65
65
  @anchors[n["id"]] =
66
- # { type: "termexample", label: idx, value: c.print,
67
- # xref: l10n("#{anchor(t['id'], :xref)}, "\
68
- # "#{@labels['example_xref']} #{c.print}") }
69
- anchor_struct(idx, n,
70
- @labels["example_xref"], "termexample", n["unnumbered"])
66
+ anchor_struct(idx, n, @labels["example_xref"], "termexample",
67
+ n["unnumbered"])
71
68
  end
72
69
  end
73
70
  end
@@ -170,8 +167,7 @@ module IsoDoc
170
167
 
171
168
  def deflist_term_anchor_names(list, list_anchor)
172
169
  list.xpath(ns("./dt")).each do |li|
173
- label = li.text
174
- label = l10n("#{list_anchor[:xref]}: #{label}")
170
+ label = l10n("#{list_anchor[:xref]}: #{dt2xreflabel(li)}")
175
171
  li["id"] and @anchors[li["id"]] =
176
172
  { xref: label, type: "deflistitem",
177
173
  container: list_anchor[:container] }
@@ -181,6 +177,13 @@ module IsoDoc
181
177
  end
182
178
  end
183
179
 
180
+ def dt2xreflabel(dterm)
181
+ label = dterm.dup
182
+ label.xpath(ns(".//p")).each { |x| x.replace(x.children) }
183
+ label.xpath(ns(".//index")).each(&:remove)
184
+ label.children.to_xml
185
+ end
186
+
184
187
  def bookmark_anchor_names(xml)
185
188
  xml.xpath(ns(".//bookmark")).reject { |n| blank?(n["id"]) }.each do |n|
186
189
  parent = nil
@@ -1,181 +1,192 @@
1
- module IsoDoc::XrefGen
2
- module Blocks
3
- def hiersep
4
- "."
5
- end
6
-
7
- def hierfigsep
8
- "-"
9
- end
1
+ require_relative "../function/utils"
10
2
 
11
- def subfigure_increment(idx, counter, elem)
12
- if elem.parent.name == "figure" then idx += 1
13
- else
14
- idx = 0
15
- counter.increment(elem)
3
+ module IsoDoc
4
+ module XrefGen
5
+ module Blocks
6
+ def hiersep
7
+ "."
16
8
  end
17
- idx
18
- end
19
-
20
- def sequential_figure_names(clause)
21
- c = Counter.new
22
- j = 0
23
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
24
- .each do |t|
25
- j = subfigure_increment(j, c, t)
26
- label = c.print + (j.zero? ? "" : "-#{j}")
27
- next if t["id"].nil? || t["id"].empty?
28
9
 
29
- @anchors[t["id"]] = anchor_struct(
30
- label, nil, @labels["figure"], "figure", t["unnumbered"]
31
- )
10
+ def hierfigsep
11
+ "-"
32
12
  end
33
- end
34
-
35
- def sequential_table_names(clause)
36
- c = Counter.new
37
- clause.xpath(ns(".//table")).reject { |n| blank?(n["id"]) }.each do |t|
38
13
 
39
- @anchors[t["id"]] = anchor_struct(
40
- c.increment(t).print, nil,
41
- @labels["table"], "table", t["unnumbered"]
42
- )
14
+ def subfigure_increment(idx, counter, elem)
15
+ if elem.parent.name == "figure" then idx += 1
16
+ else
17
+ idx = 0
18
+ counter.increment(elem)
19
+ end
20
+ idx
43
21
  end
44
- end
45
22
 
46
- def sequential_formula_names(clause)
47
- c = Counter.new
48
- clause.xpath(ns(".//formula")).reject { |n| blank?(n["id"]) }.each do |t|
49
-
50
- @anchors[t["id"]] = anchor_struct(
51
- c.increment(t).print, t,
52
- t["inequality"] ? @labels["inequality"] : @labels["formula"],
53
- "formula", t["unnumbered"]
54
- )
23
+ def sequential_figure_names(clause)
24
+ c = Counter.new
25
+ j = 0
26
+ clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
27
+ .each do |t|
28
+ next if labelled_ancestor(t) && t.ancestors("figure").empty?
29
+
30
+ j = subfigure_increment(j, c, t)
31
+ label = c.print + (j.zero? ? "" : "-#{j}")
32
+ next if t["id"].nil? || t["id"].empty?
33
+
34
+ @anchors[t["id"]] = anchor_struct(
35
+ label, nil, @labels["figure"], "figure", t["unnumbered"]
36
+ )
37
+ end
55
38
  end
56
- end
57
39
 
58
- FIRST_LVL_REQ = "[not(ancestor::permission or ancestor::requirement or "\
59
- "ancestor::recommendation)]".freeze
40
+ def sequential_table_names(clause)
41
+ c = Counter.new
42
+ clause.xpath(ns(".//table")).reject { |n| blank?(n["id"]) }.each do |t|
43
+ next if labelled_ancestor(t)
60
44
 
61
- def sequential_permission_names(clause, klass, label)
62
- c = Counter.new
63
- clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}"))
64
- .reject { |n| blank?(n["id"]) }.each do |t|
65
-
66
- id = c.increment(t).print
67
- @anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
68
- sequential_permission_names2(t, id)
45
+ @anchors[t["id"]] = anchor_struct(
46
+ c.increment(t).print, nil,
47
+ @labels["table"], "table", t["unnumbered"]
48
+ )
49
+ end
69
50
  end
70
- end
71
-
72
- def sequential_permission_names2(elem, ident)
73
- sequential_permission_names1(elem, ident, "permission",
74
- @labels["permission"])
75
- sequential_permission_names1(elem, ident, "requirement",
76
- @labels["requirement"])
77
- sequential_permission_names1(elem, ident, "recommendation",
78
- @labels["recommendation"])
79
- end
80
-
81
- def sequential_permission_names1(block, lbl, klass, label)
82
- c = Counter.new
83
- block.xpath(ns("./#{klass}")).reject { |n| blank?(n["id"]) }.each do |t|
84
51
 
85
- id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
86
- @anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
87
- sequential_permission_names2(t, id)
52
+ def sequential_formula_names(clause)
53
+ c = Counter.new
54
+ clause.xpath(ns(".//formula")).reject do |n|
55
+ blank?(n["id"])
56
+ end.each do |t|
57
+ @anchors[t["id"]] = anchor_struct(
58
+ c.increment(t).print, t,
59
+ t["inequality"] ? @labels["inequality"] : @labels["formula"],
60
+ "formula", t["unnumbered"]
61
+ )
62
+ end
88
63
  end
89
- end
90
-
91
- def sequential_asset_names(clause)
92
- sequential_table_names(clause)
93
- sequential_figure_names(clause)
94
- sequential_formula_names(clause)
95
- sequential_permission_names(clause, "permission", @labels["permission"])
96
- sequential_permission_names(clause, "requirement", @labels["requirement"])
97
- sequential_permission_names(clause, "recommendation",
98
- @labels["recommendation"])
99
- end
100
-
101
- def hierarchical_figure_names(clause, num)
102
- c = Counter.new
103
- j = 0
104
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
105
- .each do |t|
106
- j = subfigure_increment(j, c, t)
107
- label = "#{num}#{hiersep}#{c.print}" +
108
- (j.zero? ? "" : "#{hierfigsep}#{j}")
109
- next if t["id"].nil? || t["id"].empty?
110
64
 
111
- @anchors[t["id"]] = anchor_struct(label, nil, @labels["figure"],
112
- "figure", t["unnumbered"])
65
+ FIRST_LVL_REQ = "[not(ancestor::permission or ancestor::requirement or "\
66
+ "ancestor::recommendation)]".freeze
67
+
68
+ def sequential_permission_names(clause, klass, label)
69
+ c = Counter.new
70
+ clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}"))
71
+ .reject { |n| blank?(n["id"]) }.each do |t|
72
+ id = c.increment(t).print
73
+ @anchors[t["id"]] =
74
+ anchor_struct(id, t, label, klass, t["unnumbered"])
75
+ sequential_permission_names2(t, id)
76
+ end
113
77
  end
114
- end
115
78
 
116
- def hierarchical_table_names(clause, num)
117
- c = Counter.new
118
- clause.xpath(ns(".//table")).reject { |n| blank?(n["id"]) }.each do |t|
79
+ def sequential_permission_names2(elem, ident)
80
+ sequential_permission_names1(elem, ident, "permission",
81
+ @labels["permission"])
82
+ sequential_permission_names1(elem, ident, "requirement",
83
+ @labels["requirement"])
84
+ sequential_permission_names1(elem, ident, "recommendation",
85
+ @labels["recommendation"])
86
+ end
119
87
 
120
- @anchors[t["id"]] =
121
- anchor_struct("#{num}#{hiersep}#{c.increment(t).print}",
122
- nil, @labels["table"], "table", t["unnumbered"])
88
+ def sequential_permission_names1(block, lbl, klass, label)
89
+ c = Counter.new
90
+ block.xpath(ns("./#{klass}")).reject { |n| blank?(n["id"]) }.each do |t|
91
+ id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
92
+ @anchors[t["id"]] =
93
+ anchor_struct(id, t, label, klass, t["unnumbered"])
94
+ sequential_permission_names2(t, id)
95
+ end
123
96
  end
124
- end
125
97
 
126
- def hierarchical_asset_names(clause, num)
127
- hierarchical_table_names(clause, num)
128
- hierarchical_figure_names(clause, num)
129
- hierarchical_formula_names(clause, num)
130
- hierarchical_permission_names(clause, num, "permission",
131
- @labels["permission"])
132
- hierarchical_permission_names(clause, num, "requirement",
98
+ def sequential_asset_names(clause)
99
+ sequential_table_names(clause)
100
+ sequential_figure_names(clause)
101
+ sequential_formula_names(clause)
102
+ sequential_permission_names(clause, "permission", @labels["permission"])
103
+ sequential_permission_names(clause, "requirement",
133
104
  @labels["requirement"])
134
- hierarchical_permission_names(clause, num, "recommendation",
105
+ sequential_permission_names(clause, "recommendation",
135
106
  @labels["recommendation"])
136
- end
107
+ end
108
+
109
+ def hierarchical_figure_names(clause, num)
110
+ c = Counter.new
111
+ j = 0
112
+ clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
113
+ .each do |t|
114
+ next if labelled_ancestor(t) && t.ancestors("figure").empty?
115
+
116
+ j = subfigure_increment(j, c, t)
117
+ label = "#{num}#{hiersep}#{c.print}" +
118
+ (j.zero? ? "" : "#{hierfigsep}#{j}")
119
+ next if t["id"].nil? || t["id"].empty?
120
+
121
+ @anchors[t["id"]] = anchor_struct(label, nil, @labels["figure"],
122
+ "figure", t["unnumbered"])
123
+ end
124
+ end
137
125
 
138
- def hierarchical_formula_names(clause, num)
139
- c = Counter.new
140
- clause.xpath(ns(".//formula")).reject { |n| blank?(n["id"]) }.each do |t|
126
+ def hierarchical_table_names(clause, num)
127
+ c = Counter.new
128
+ clause.xpath(ns(".//table")).reject { |n| blank?(n["id"]) }.each do |t|
129
+ next if labelled_ancestor(t)
141
130
 
142
- @anchors[t["id"]] = anchor_struct(
143
- "#{num}#{hiersep}#{c.increment(t).print}", nil,
144
- t["inequality"] ? @labels["inequality"] : @labels["formula"],
145
- "formula", t["unnumbered"]
146
- )
131
+ @anchors[t["id"]] =
132
+ anchor_struct("#{num}#{hiersep}#{c.increment(t).print}",
133
+ nil, @labels["table"], "table", t["unnumbered"])
134
+ end
147
135
  end
148
- end
149
136
 
150
- def hierarchical_permission_names(clause, num, klass, label)
151
- c = Counter.new
152
- clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}"))
153
- .reject { |n| blank?(n["id"]) }.each do |t|
137
+ def hierarchical_asset_names(clause, num)
138
+ hierarchical_table_names(clause, num)
139
+ hierarchical_figure_names(clause, num)
140
+ hierarchical_formula_names(clause, num)
141
+ hierarchical_permission_names(clause, num, "permission",
142
+ @labels["permission"])
143
+ hierarchical_permission_names(clause, num, "requirement",
144
+ @labels["requirement"])
145
+ hierarchical_permission_names(clause, num, "recommendation",
146
+ @labels["recommendation"])
147
+ end
154
148
 
155
- id = "#{num}#{hiersep}#{c.increment(t).print}"
156
- @anchors[t["id"]] =
157
- anchor_struct(id, nil, label, klass, t["unnumbered"])
158
- hierarchical_permission_names2(t, id)
149
+ def hierarchical_formula_names(clause, num)
150
+ c = Counter.new
151
+ clause.xpath(ns(".//formula")).reject do |n|
152
+ blank?(n["id"])
153
+ end.each do |t|
154
+ @anchors[t["id"]] = anchor_struct(
155
+ "#{num}#{hiersep}#{c.increment(t).print}", nil,
156
+ t["inequality"] ? @labels["inequality"] : @labels["formula"],
157
+ "formula", t["unnumbered"]
158
+ )
159
+ end
159
160
  end
160
- end
161
161
 
162
- def hierarchical_permission_names2(elem, ident)
163
- hierarchical_permission_names1(elem, ident, "permission",
164
- @labels["permission"])
165
- hierarchical_permission_names1(elem, ident, "requirement",
166
- @labels["requirement"])
167
- hierarchical_permission_names1(elem, ident, "recommendation",
168
- @labels["recommendation"])
169
- end
162
+ def hierarchical_permission_names(clause, num, klass, label)
163
+ c = Counter.new
164
+ clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}"))
165
+ .reject { |n| blank?(n["id"]) }.each do |t|
166
+ id = "#{num}#{hiersep}#{c.increment(t).print}"
167
+ @anchors[t["id"]] =
168
+ anchor_struct(id, nil, label, klass, t["unnumbered"])
169
+ hierarchical_permission_names2(t, id)
170
+ end
171
+ end
170
172
 
171
- def hierarchical_permission_names1(block, lbl, klass, label)
172
- c = Counter.new
173
- block.xpath(ns("./#{klass}")).reject { |n| blank?(n["id"]) }.each do |t|
173
+ def hierarchical_permission_names2(elem, ident)
174
+ hierarchical_permission_names1(elem, ident, "permission",
175
+ @labels["permission"])
176
+ hierarchical_permission_names1(elem, ident, "requirement",
177
+ @labels["requirement"])
178
+ hierarchical_permission_names1(elem, ident, "recommendation",
179
+ @labels["recommendation"])
180
+ end
174
181
 
175
- id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
176
- @anchors[t["id"]] =
177
- anchor_struct(id, nil, label, klass, t["unnumbered"])
178
- hierarchical_permission_names2(t, id)
182
+ def hierarchical_permission_names1(block, lbl, klass, label)
183
+ c = Counter.new
184
+ block.xpath(ns("./#{klass}")).reject { |n| blank?(n["id"]) }.each do |t|
185
+ id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
186
+ @anchors[t["id"]] =
187
+ anchor_struct(id, nil, label, klass, t["unnumbered"])
188
+ hierarchical_permission_names2(t, id)
189
+ end
179
190
  end
180
191
  end
181
192
  end