isodoc 1.8.2 → 1.8.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/lib/isodoc/function/cleanup.rb +1 -11
- data/lib/isodoc/function/inline.rb +2 -2
- data/lib/isodoc/function/terms.rb +0 -3
- data/lib/isodoc/function/utils.rb +10 -5
- data/lib/isodoc/i18n.rb +31 -10
- data/lib/isodoc/presentation_function/block.rb +2 -3
- data/lib/isodoc/presentation_function/image.rb +2 -2
- data/lib/isodoc/presentation_function/terms.rb +25 -1
- data/lib/isodoc/presentation_xml_convert.rb +2 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/xref/xref_gen.rb +10 -7
- data/lib/isodoc/xref/xref_gen_seq.rb +159 -148
- data/lib/isodoc/xref/xref_sect_gen.rb +5 -10
- data/lib/isodoc/xref.rb +2 -0
- data/lib/isodoc/xslfo_convert.rb +23 -1
- data/spec/isodoc/cleanup_spec.rb +0 -129
- data/spec/isodoc/i18n_spec.rb +38 -0
- data/spec/isodoc/inline_spec.rb +1 -1
- data/spec/isodoc/postproc_spec.rb +0 -73
- data/spec/isodoc/terms_spec.rb +149 -191
- data/spec/isodoc/xref_spec.rb +71 -0
- data/spec/isodoc/xslfo_convert_spec.rb +35 -0
- data/spec/spec_helper.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee178bd5fb88dd6ee3302731a8325eec443d80aac78adb9b9bd166157ffb4ebb
|
4
|
+
data.tar.gz: 95d464d67887b5ea80dd507a66815107c7e9c99d2e7ab4e11f86467524b5a9f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c5501c94696d11e07b7e7e0689eb3c4ae46917e7494f4c64407b150ba1171fb7d5c8723e59ab88c01f94f733a9880f8a40b6668c5c364f058d9865964957378
|
7
|
+
data.tar.gz: 6a4d747161c3a88b7be6034e82876d5aafd3c500ba1dffdd5f4359382da35285738f2a3fb7c3351892eb5472459054e5f2010dc0e769077052c5e1bd4a7b03ec
|
data/Gemfile
CHANGED
@@ -2,17 +2,7 @@ module IsoDoc
|
|
2
2
|
module Function
|
3
3
|
module Cleanup
|
4
4
|
def textcleanup(docxml)
|
5
|
-
|
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} — "))
|
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
|
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
|
41
|
-
|
42
|
-
|
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,
|
59
|
-
self.class.send(:define_method, k.downcase) {
|
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
|
-
|
73
|
-
|
74
|
-
|
71
|
+
if lang == "zh" && script == "Hans" then l10n_zh(text)
|
72
|
+
else bidiwrap(text, lang, script)
|
73
|
+
end
|
74
|
+
end
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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) ? "؜" : "‏"
|
80
|
+
"#{mark}#{text}#{mark}"
|
81
|
+
elsif !my_rtl && outer_rtl then "‎#{text}‎"
|
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, " — ",
|
@@ -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, " — ",
|
@@ -141,7 +141,7 @@ module IsoDoc
|
|
141
141
|
&.map { |u| u.children.to_xml }&.join(", ")
|
142
142
|
return nil if f&.empty?
|
143
143
|
|
144
|
-
name << ",
|
144
|
+
name << ", <#{f}>"
|
145
145
|
end
|
146
146
|
|
147
147
|
def designation_grammar(grammar)
|
@@ -219,5 +219,29 @@ module IsoDoc
|
|
219
219
|
end
|
220
220
|
end
|
221
221
|
end
|
222
|
+
|
223
|
+
def termsource(docxml)
|
224
|
+
docxml.xpath(ns("//termsource/modification")).each do |f|
|
225
|
+
termsource_modification(f)
|
226
|
+
end
|
227
|
+
docxml.xpath(ns("//termsource")).each do |f|
|
228
|
+
termsource1(f)
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def termsource1(elem)
|
233
|
+
while elem&.next_element&.name == "termsource"
|
234
|
+
elem << "; #{elem.next_element.remove.children.to_xml}"
|
235
|
+
end
|
236
|
+
elem.children = l10n("[#{@i18n.source}: #{elem.children.to_xml.strip}]")
|
237
|
+
end
|
238
|
+
|
239
|
+
def termsource_modification(mod)
|
240
|
+
mod.previous_element.next = ", #{@i18n.modified}"
|
241
|
+
mod.text.strip.empty? or mod.previous = " – "
|
242
|
+
mod.elements.size == 1 and
|
243
|
+
mod.elements[0].replace(mod.elements[0].children)
|
244
|
+
mod.replace(mod.children)
|
245
|
+
end
|
222
246
|
end
|
223
247
|
end
|
@@ -18,7 +18,7 @@ module IsoDoc
|
|
18
18
|
info docxml, nil
|
19
19
|
conversions(docxml)
|
20
20
|
docxml.root["type"] = "presentation"
|
21
|
-
docxml.to_xml
|
21
|
+
docxml.to_xml.gsub(/</, "<").gsub(/>/, ">")
|
22
22
|
end
|
23
23
|
|
24
24
|
def conversions(docxml)
|
@@ -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
|
data/lib/isodoc/version.rb
CHANGED
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -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
|
-
|
67
|
-
|
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
|
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
|
-
|
2
|
-
module Blocks
|
3
|
-
def hiersep
|
4
|
-
"."
|
5
|
-
end
|
6
|
-
|
7
|
-
def hierfigsep
|
8
|
-
"-"
|
9
|
-
end
|
1
|
+
require_relative "../function/utils"
|
10
2
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
30
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
59
|
-
|
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
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
86
|
-
|
87
|
-
|
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
|
-
|
112
|
-
|
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
|
-
|
117
|
-
|
118
|
-
|
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
|
-
|
121
|
-
|
122
|
-
|
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
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
105
|
+
sequential_permission_names(clause, "recommendation",
|
135
106
|
@labels["recommendation"])
|
136
|
-
|
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
|
-
|
139
|
-
|
140
|
-
|
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
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
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
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
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
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
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
|
-
|
172
|
-
|
173
|
-
|
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
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
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
|