isodoc 2.12.1 → 2.12.3
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.
- checksums.yaml +4 -4
- data/isodoc.gemspec +1 -1
- data/lib/isodoc/convert.rb +0 -21
- data/lib/isodoc/function/blocks.rb +8 -8
- data/lib/isodoc/function/blocks_example_note.rb +46 -23
- data/lib/isodoc/function/inline.rb +31 -8
- data/lib/isodoc/function/lists.rb +4 -4
- data/lib/isodoc/function/references.rb +5 -5
- data/lib/isodoc/function/reqt.rb +2 -2
- data/lib/isodoc/function/section.rb +25 -25
- data/lib/isodoc/function/section_titles.rb +15 -12
- data/lib/isodoc/function/table.rb +1 -1
- data/lib/isodoc/function/terms.rb +17 -14
- data/lib/isodoc/function/to_word_html.rb +5 -0
- data/lib/isodoc/html_function/footnotes.rb +2 -1
- data/lib/isodoc/html_function/html.rb +1 -5
- data/lib/isodoc/init.rb +14 -4
- data/lib/isodoc/metadata.rb +9 -0
- data/lib/isodoc/metadata_contributor.rb +1 -1
- data/lib/isodoc/metadata_date.rb +1 -1
- data/lib/isodoc/presentation_function/autonum.rb +139 -0
- data/lib/isodoc/presentation_function/block.rb +48 -39
- data/lib/isodoc/presentation_function/docid.rb +0 -23
- data/lib/isodoc/presentation_function/erefs.rb +4 -2
- data/lib/isodoc/presentation_function/image.rb +21 -5
- data/lib/isodoc/presentation_function/inline.rb +1 -1
- data/lib/isodoc/presentation_function/reqt.rb +1 -1
- data/lib/isodoc/presentation_function/section.rb +46 -118
- data/lib/isodoc/presentation_function/sourcecode.rb +7 -4
- data/lib/isodoc/presentation_function/terms.rb +3 -4
- data/lib/isodoc/presentation_function/title.rb +107 -0
- data/lib/isodoc/presentation_function/xrefs.rb +17 -10
- data/lib/isodoc/presentation_xml_convert.rb +2 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +7 -35
- data/lib/isodoc/word_function/footnotes.rb +1 -1
- data/lib/isodoc/word_function/lists.rb +12 -10
- data/lib/isodoc/word_function/postprocess_cover.rb +0 -2
- data/lib/isodoc/word_function/postprocess_table.rb +1 -1
- data/lib/isodoc/word_function/postprocess_toc.rb +1 -1
- data/lib/isodoc/word_function/table.rb +2 -2
- data/lib/isodoc/xref/xref_anchor.rb +31 -16
- data/lib/isodoc/xref/xref_counter_types.rb +3 -2
- data/lib/isodoc/xref/xref_gen.rb +57 -33
- data/lib/isodoc/xref/xref_gen_seq.rb +145 -56
- data/lib/isodoc/xref/xref_sect_gen.rb +60 -28
- data/lib/isodoc/xref/xref_util.rb +43 -1
- data/lib/isodoc/xref.rb +3 -0
- data/lib/isodoc-yaml/i18n-ar.yaml +9 -9
- data/lib/isodoc-yaml/i18n-de.yaml +9 -9
- data/lib/isodoc-yaml/i18n-en.yaml +9 -9
- data/lib/isodoc-yaml/i18n-es.yaml +9 -9
- data/lib/isodoc-yaml/i18n-fr.yaml +9 -9
- data/lib/isodoc-yaml/i18n-ja.yaml +10 -10
- data/lib/isodoc-yaml/i18n-ru.yaml +9 -9
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +9 -9
- data/lib/nokogiri/xml/node.rb +1 -0
- metadata +6 -4
@@ -34,7 +34,7 @@ module IsoDoc
|
|
34
34
|
def make_tr_attr_style(cell, row, rowmax, totalrows, opt)
|
35
35
|
top = row.zero? ? "#{SW1} 1.5pt;" : "none;"
|
36
36
|
bottom = "#{SW1} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;"
|
37
|
-
ret = <<~STYLE.
|
37
|
+
ret = <<~STYLE.delete("\n")
|
38
38
|
border-top:#{top}mso-border-top-alt:#{top}
|
39
39
|
border-bottom:#{bottom}mso-border-bottom-alt:#{bottom}
|
40
40
|
STYLE
|
@@ -46,7 +46,7 @@ module IsoDoc
|
|
46
46
|
def keep_rows_together(_cell, rowmax, totalrows, opt)
|
47
47
|
opt[:header] and return true
|
48
48
|
@table_line_count > 15 and return false
|
49
|
-
|
49
|
+
totalrows <= 10 && rowmax < totalrows
|
50
50
|
end
|
51
51
|
|
52
52
|
def tbody_parse(node, table)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "singleton"
|
2
|
+
require_relative "xref_util"
|
2
3
|
|
3
4
|
module IsoDoc
|
4
5
|
module XrefGen
|
@@ -29,37 +30,51 @@ module IsoDoc
|
|
29
30
|
@anchors
|
30
31
|
end
|
31
32
|
|
32
|
-
def anchor_struct_label(lbl, elem)
|
33
|
+
def anchor_struct_label(lbl, node, elem)
|
33
34
|
case elem
|
34
|
-
when @labels["appendix"]
|
35
|
+
when @labels["appendix"]
|
36
|
+
s = "<semx element='autonum' source='#{node['id'] || node[:id]}'>" \
|
37
|
+
"#{lbl}</semx>"
|
38
|
+
"<span class='fmt-element-name'>#{elem}</span> #{s}"
|
35
39
|
else
|
36
|
-
lbl
|
40
|
+
anchor_struct_value(lbl, elem)
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
40
|
-
def anchor_struct_xref(lbl, elem)
|
41
|
-
|
44
|
+
def anchor_struct_xref(lbl, node, elem)
|
45
|
+
unless lbl.blank?
|
46
|
+
lbl = semx(node, lbl)
|
47
|
+
s = " #{anchor_struct_value(lbl, elem)}"
|
48
|
+
end
|
49
|
+
l10n("<span class='fmt-element-name'>#{elem}</span>#{s}")
|
50
|
+
.gsub(/ $/, "")
|
42
51
|
end
|
43
52
|
|
44
53
|
def anchor_struct_value(lbl, elem)
|
45
54
|
case elem
|
46
|
-
|
55
|
+
# TODO hardcoded ( ) ?
|
56
|
+
when @labels["formula"], @labels["inequality"] then <<~SPAN.strip
|
57
|
+
#{delim_wrap('(')}#{lbl}#{delim_wrap(')')}
|
58
|
+
SPAN
|
47
59
|
else
|
48
|
-
lbl
|
60
|
+
lbl.to_s
|
49
61
|
end
|
50
62
|
end
|
51
63
|
|
52
|
-
def anchor_struct(lbl, container, elem, type, unnumb = false)
|
53
|
-
|
54
|
-
ret
|
55
|
-
|
56
|
-
|
57
|
-
ret[:
|
58
|
-
|
59
|
-
|
60
|
-
ret[:
|
64
|
+
# def anchor_struct(lbl, container, elem, type, unnumb = false)
|
65
|
+
def anchor_struct(lbl, node, elem_name, type, opt = {})
|
66
|
+
ret = { type: type, elem: elem_name, label: nil }
|
67
|
+
opt[:unnumb] != "true" and
|
68
|
+
ret[:label] = anchor_struct_label(lbl, node, elem_name)
|
69
|
+
ret[:xref] =
|
70
|
+
anchor_struct_xref(opt[:unnumb] == "true" ? "(??)" : lbl, node,
|
71
|
+
elem_name)
|
72
|
+
ret[:container] = @klass.get_clause_id(node) if opt[:container]
|
73
|
+
ret[:value] = stripsemx(lbl)
|
61
74
|
ret
|
62
75
|
end
|
76
|
+
|
77
|
+
include ::IsoDoc::XrefGen::Util
|
63
78
|
end
|
64
79
|
end
|
65
80
|
end
|
@@ -2,11 +2,12 @@ require_relative "xref_counter"
|
|
2
2
|
|
3
3
|
module IsoDoc
|
4
4
|
class Xref
|
5
|
-
def clause_counter(num = 0, opts = {
|
5
|
+
def clause_counter(num = 0, opts = {})
|
6
|
+
opts[:numerals] ||= :arabic
|
6
7
|
::IsoDoc::XrefGen::Counter.new(num, opts)
|
7
8
|
end
|
8
9
|
|
9
|
-
def list_counter(num = 0, opts = {
|
10
|
+
def list_counter(num = 0, opts = {})
|
10
11
|
::IsoDoc::XrefGen::Counter.new(num, opts)
|
11
12
|
end
|
12
13
|
end
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -28,14 +28,18 @@ module IsoDoc
|
|
28
28
|
autonum
|
29
29
|
end
|
30
30
|
|
31
|
-
def termnote_label(
|
32
|
-
|
31
|
+
def termnote_label(node, label)
|
32
|
+
if label.blank?
|
33
|
+
@labels["termnote"].gsub(/%\s?/, "")
|
34
|
+
else
|
35
|
+
@labels["termnote"].gsub("%", semx(node, label.to_s))
|
36
|
+
end
|
33
37
|
end
|
34
38
|
|
35
39
|
def increment_label(elems, node, counter, increment: true)
|
36
40
|
elems.size == 1 && !node["number"] and return ""
|
37
41
|
counter.increment(node) if increment
|
38
|
-
|
42
|
+
counter.print
|
39
43
|
end
|
40
44
|
|
41
45
|
def termnote_anchor_names(docxml)
|
@@ -44,10 +48,10 @@ module IsoDoc
|
|
44
48
|
t.xpath(ns("./termnote")).noblank.each do |n|
|
45
49
|
c.increment(n)
|
46
50
|
@anchors[n["id"]] =
|
47
|
-
{ label: termnote_label(c.print), type: "termnote",
|
51
|
+
{ label: termnote_label(n, c.print), type: "termnote",
|
48
52
|
value: c.print, elem: @labels["termnote"],
|
49
53
|
container: t["id"],
|
50
|
-
xref:
|
54
|
+
xref: anchor_struct_xref(c.print, n, @labels["note_xref"]) }
|
51
55
|
end
|
52
56
|
end
|
53
57
|
end
|
@@ -63,7 +67,7 @@ module IsoDoc
|
|
63
67
|
{ label: idx, type: "termexample",
|
64
68
|
value: idx, elem: @labels["example_xref"],
|
65
69
|
container: t["id"],
|
66
|
-
xref:
|
70
|
+
xref: anchor_struct_xref(idx, n, @labels["example_xref"]) }
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
@@ -73,7 +77,7 @@ module IsoDoc
|
|
73
77
|
notes = s.xpath(child_asset_path("note")) -
|
74
78
|
s.xpath(ns(".//figure//note | .//table//note"))
|
75
79
|
note_anchor_names1(notes, Counter.new)
|
76
|
-
note_anchor_names(s.xpath(ns(
|
80
|
+
note_anchor_names(s.xpath(ns(child_sections)))
|
77
81
|
end
|
78
82
|
end
|
79
83
|
|
@@ -81,7 +85,8 @@ module IsoDoc
|
|
81
85
|
notes.noblank.each do |n|
|
82
86
|
@anchors[n["id"]] =
|
83
87
|
anchor_struct(increment_label(notes, n, counter), n,
|
84
|
-
@labels["note_xref"], "note",
|
88
|
+
@labels["note_xref"], "note",
|
89
|
+
{ container: true, unnumb: false })
|
85
90
|
end
|
86
91
|
end
|
87
92
|
|
@@ -90,7 +95,7 @@ module IsoDoc
|
|
90
95
|
s.at(ns(".//admonition[@type = 'box']")) or next
|
91
96
|
notes = s.xpath(child_asset_path("admonition[@type = 'box']"))
|
92
97
|
admonition_anchor_names1(notes, Counter.new)
|
93
|
-
admonition_anchor_names(s.xpath(ns(
|
98
|
+
admonition_anchor_names(s.xpath(ns(child_sections)))
|
94
99
|
end
|
95
100
|
end
|
96
101
|
|
@@ -98,7 +103,8 @@ module IsoDoc
|
|
98
103
|
notes.noblank.each do |n|
|
99
104
|
@anchors[n["id"]] ||=
|
100
105
|
anchor_struct(increment_label(notes, n, counter), n,
|
101
|
-
@labels["box"], "admonition",
|
106
|
+
@labels["box"], "admonition",
|
107
|
+
{ container: true, unnumb: n["unnumbered"] })
|
102
108
|
end
|
103
109
|
end
|
104
110
|
|
@@ -106,7 +112,7 @@ module IsoDoc
|
|
106
112
|
sections.each do |s|
|
107
113
|
notes = s.xpath(child_asset_path("example"))
|
108
114
|
example_anchor_names1(notes, Counter.new)
|
109
|
-
example_anchor_names(s.xpath(ns(
|
115
|
+
example_anchor_names(s.xpath(ns(child_sections)))
|
110
116
|
end
|
111
117
|
end
|
112
118
|
|
@@ -114,7 +120,8 @@ module IsoDoc
|
|
114
120
|
notes.noblank.each do |n|
|
115
121
|
@anchors[n["id"]] ||=
|
116
122
|
anchor_struct(increment_label(notes, n, counter), n,
|
117
|
-
@labels["example_xref"], "example",
|
123
|
+
@labels["example_xref"], "example",
|
124
|
+
{ unnumb: n["unnumbered"], container: true })
|
118
125
|
end
|
119
126
|
end
|
120
127
|
|
@@ -122,27 +129,35 @@ module IsoDoc
|
|
122
129
|
sections.each do |s|
|
123
130
|
notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
|
124
131
|
s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
|
125
|
-
c = list_counter
|
132
|
+
c = list_counter(0, {})
|
126
133
|
notes.noblank.each do |n|
|
127
|
-
@anchors[n["id"]] =
|
128
|
-
|
134
|
+
@anchors[n["id"]] =
|
135
|
+
anchor_struct(increment_label(notes, n, c), n,
|
136
|
+
@labels["list"], "list",
|
137
|
+
{ unnumb: false, container: true })
|
129
138
|
list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
|
130
139
|
end
|
131
|
-
list_anchor_names(s.xpath(ns(
|
140
|
+
list_anchor_names(s.xpath(ns(child_sections)))
|
132
141
|
end
|
133
142
|
end
|
134
143
|
|
135
|
-
def
|
136
|
-
|
144
|
+
def list_item_delim
|
145
|
+
")"
|
146
|
+
end
|
147
|
+
|
148
|
+
def list_item_anchor_names(list, list_anchor, depth, prev_label,
|
149
|
+
refer_list)
|
150
|
+
c = list_counter(list["start"] ? list["start"].to_i - 1 : 0, {})
|
137
151
|
list.xpath(ns("./li")).each do |li|
|
138
152
|
bare_label, label =
|
139
|
-
list_item_value(li, c, depth,
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
153
|
+
list_item_value(li, c, depth,
|
154
|
+
{ list_anchor:, prev_label:,
|
155
|
+
refer_list: depth == 1 ? refer_list : nil })
|
156
|
+
li["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
157
|
+
@anchors[li["id"]] =
|
158
|
+
{ label: bare_label, bare_xref: "#{label})", type: "listitem",
|
159
|
+
xref: %[#{label}#{delim_wrap(list_item_delim)}], refer_list:,
|
160
|
+
container: list_anchor[:container] }
|
146
161
|
(li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
|
147
162
|
list_item_anchor_names(ol, list_anchor, depth + 1, label,
|
148
163
|
refer_list)
|
@@ -152,18 +167,21 @@ module IsoDoc
|
|
152
167
|
|
153
168
|
def list_item_value(entry, counter, depth, opts)
|
154
169
|
label = counter.increment(entry).listlabel(entry.parent, depth)
|
170
|
+
s = semx(entry, label)
|
155
171
|
[label,
|
156
|
-
list_item_anchor_label(
|
172
|
+
list_item_anchor_label(s, opts[:list_anchor], opts[:prev_label],
|
157
173
|
opts[:refer_list])]
|
158
174
|
end
|
159
175
|
|
160
176
|
def list_item_anchor_label(label, list_anchor, prev_label, refer_list)
|
161
177
|
prev_label.empty? or
|
162
|
-
label = @i18n.list_nested_xref
|
163
|
-
.sub("%
|
178
|
+
label = @klass.connectives_spans(@i18n.list_nested_xref
|
179
|
+
.sub("%1", %[#{prev_label}#{delim_wrap(list_item_delim)}])
|
180
|
+
.sub("%2", label))
|
164
181
|
refer_list and
|
165
|
-
label = @i18n.list_nested_xref
|
166
|
-
.sub("%
|
182
|
+
label = @klass.connectives_spans(@i18n.list_nested_xref
|
183
|
+
.sub("%1", list_anchor[:xref])
|
184
|
+
.sub("%2", label))
|
167
185
|
label
|
168
186
|
end
|
169
187
|
|
@@ -172,7 +190,7 @@ module IsoDoc
|
|
172
190
|
notes = s.xpath(ns(".//dl")) - s.xpath(ns(".//clause//dl")) -
|
173
191
|
s.xpath(ns(".//appendix//dl")) - s.xpath(ns(".//dl//dl"))
|
174
192
|
deflist_anchor_names1(notes, Counter.new)
|
175
|
-
deflist_anchor_names(s.xpath(ns(
|
193
|
+
deflist_anchor_names(s.xpath(ns(child_sections)))
|
176
194
|
end
|
177
195
|
end
|
178
196
|
|
@@ -180,14 +198,15 @@ module IsoDoc
|
|
180
198
|
notes.noblank.each do |n|
|
181
199
|
@anchors[n["id"]] =
|
182
200
|
anchor_struct(increment_label(notes, n, counter), n,
|
183
|
-
@labels["deflist"], "deflist",
|
201
|
+
@labels["deflist"], "deflist",
|
202
|
+
{ unnumb: false, container: true })
|
184
203
|
deflist_term_anchor_names(n, @anchors[n["id"]])
|
185
204
|
end
|
186
205
|
end
|
187
206
|
|
188
207
|
def deflist_term_anchor_names(list, list_anchor)
|
189
208
|
list.xpath(ns("./dt")).each do |li|
|
190
|
-
label =
|
209
|
+
label = deflist_term_anchor_lbl(li, list_anchor)
|
191
210
|
li["id"] and @anchors[li["id"]] =
|
192
211
|
{ xref: label, type: "deflistitem",
|
193
212
|
container: list_anchor[:container] }
|
@@ -197,6 +216,11 @@ module IsoDoc
|
|
197
216
|
end
|
198
217
|
end
|
199
218
|
|
219
|
+
def deflist_term_anchor_lbl(listitem, list_anchor)
|
220
|
+
s = semx(listitem, dt2xreflabel(listitem))
|
221
|
+
%(#{list_anchor[:xref]}#{delim_wrap(":")} #{s}</semx>)
|
222
|
+
end
|
223
|
+
|
200
224
|
def dt2xreflabel(dterm)
|
201
225
|
label = dterm.dup
|
202
226
|
label.xpath(ns(".//p")).each { |x| x.replace(x.children) }
|
@@ -11,6 +11,10 @@ module IsoDoc
|
|
11
11
|
"-"
|
12
12
|
end
|
13
13
|
|
14
|
+
def hierreqtsep
|
15
|
+
"-"
|
16
|
+
end
|
17
|
+
|
14
18
|
def subfigure_increment(idx, counter, elem)
|
15
19
|
if elem.parent.name == "figure" then idx += 1
|
16
20
|
else
|
@@ -30,7 +34,8 @@ module IsoDoc
|
|
30
34
|
clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t|
|
31
35
|
# labelled_ancestor(t, %w(figure)) and next # disable nested figure labelling
|
32
36
|
j = subfigure_increment(j, c, t)
|
33
|
-
|
37
|
+
sublabel = subfigure_label(j)
|
38
|
+
figure_anchor(t, sublabel, c.print, "figure", container: container)
|
34
39
|
end
|
35
40
|
sequential_figure_class_names(clause, container:)
|
36
41
|
end
|
@@ -43,24 +48,69 @@ module IsoDoc
|
|
43
48
|
c[t["class"]] ||= Counter.new
|
44
49
|
# labelled_ancestor(t, %w(figure)) and next
|
45
50
|
j = subfigure_increment(j, c[t["class"]], t)
|
46
|
-
|
47
|
-
|
51
|
+
sublabel = subfigure_label(j)
|
52
|
+
figure_anchor(t, sublabel, c[t["class"]].print, t["class"],
|
53
|
+
container: container)
|
48
54
|
end
|
49
55
|
end
|
50
56
|
|
57
|
+
def hier_separator(markup: false)
|
58
|
+
h = hiersep
|
59
|
+
h.blank? || !markup or h = delim_wrap(h)
|
60
|
+
h
|
61
|
+
end
|
62
|
+
|
51
63
|
def subfigure_label(subfignum)
|
52
|
-
subfignum.zero? and return
|
53
|
-
|
64
|
+
subfignum.zero? and return
|
65
|
+
subfignum.to_s
|
66
|
+
end
|
67
|
+
|
68
|
+
def subfigure_separator(markup: false)
|
69
|
+
h = hierfigsep
|
70
|
+
h.blank? || !markup or h = delim_wrap(h)
|
71
|
+
h
|
72
|
+
end
|
73
|
+
|
74
|
+
def subreqt_separator(markup: false)
|
75
|
+
h = hierreqtsep
|
76
|
+
h.blank? || !markup or h = delim_wrap(h)
|
77
|
+
h
|
78
|
+
end
|
79
|
+
|
80
|
+
def subfigure_delim
|
81
|
+
""
|
82
|
+
end
|
83
|
+
|
84
|
+
def figure_anchor(elem, sublabel, label, klass, container: false)
|
85
|
+
if sublabel
|
86
|
+
/<semx/.match?(label) or label = semx(elem.parent, label)
|
87
|
+
subfigure_anchor(elem, sublabel, label, klass, container: false)
|
88
|
+
else
|
89
|
+
@anchors[elem["id"]] = anchor_struct(
|
90
|
+
label, elem, @labels[klass] || klass.capitalize, klass,
|
91
|
+
{ unnumb: elem["unnumbered"], container: }
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def fig_subfig_label(label, sublabel)
|
97
|
+
"#{label}#{subfigure_separator}#{sublabel}"
|
54
98
|
end
|
55
99
|
|
56
|
-
def
|
57
|
-
|
58
|
-
label &&= label + subfigure_label(subfig)
|
100
|
+
def subfigure_anchor(elem, sublabel, label, klass, container: false)
|
101
|
+
figlabel = fig_subfig_label(label, sublabel)
|
59
102
|
@anchors[elem["id"]] = anchor_struct(
|
60
|
-
|
61
|
-
|
62
|
-
elem["unnumbered"]
|
103
|
+
figlabel, elem, @labels[klass] || klass.capitalize, klass,
|
104
|
+
{ unnumb: elem["unnumbered"] }
|
63
105
|
)
|
106
|
+
if elem["unnumbered"] != "true"
|
107
|
+
x = "#{subfigure_separator(markup: true)}#{semx(elem, sublabel)}"
|
108
|
+
@anchors[elem["id"]][:label] = "#{label}#{x}" # "#{semx(elem.parent, label)}#{x}"
|
109
|
+
@anchors[elem["id"]][:xref] = @anchors[elem.parent["id"]][:xref] + x +
|
110
|
+
delim_wrap(subfigure_delim)
|
111
|
+
x = @anchors[elem.parent["id"]][:container] and
|
112
|
+
@anchors[elem["id"]][:container] = x
|
113
|
+
end
|
64
114
|
end
|
65
115
|
|
66
116
|
def sequential_table_names(clause, container: false)
|
@@ -68,8 +118,8 @@ module IsoDoc
|
|
68
118
|
clause.xpath(ns(".//table")).noblank.each do |t|
|
69
119
|
# labelled_ancestor(t) and next
|
70
120
|
@anchors[t["id"]] = anchor_struct(
|
71
|
-
c.increment(t).print,
|
72
|
-
@labels["table"], "table", t["unnumbered"]
|
121
|
+
c.increment(t).print, t,
|
122
|
+
@labels["table"], "table", { unnumb: t["unnumbered"], container: container }
|
73
123
|
)
|
74
124
|
end
|
75
125
|
end
|
@@ -80,7 +130,7 @@ module IsoDoc
|
|
80
130
|
@anchors[t["id"]] = anchor_struct(
|
81
131
|
c.increment(t).print, t,
|
82
132
|
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
83
|
-
"formula", t["unnumbered"]
|
133
|
+
"formula", { unnumb: t["unnumbered"], container: true }
|
84
134
|
)
|
85
135
|
end
|
86
136
|
end
|
@@ -95,39 +145,49 @@ module IsoDoc
|
|
95
145
|
./permission | ./requirement | ./recommendation
|
96
146
|
XPATH
|
97
147
|
|
98
|
-
def sequential_permission_names(clause, container:
|
148
|
+
def sequential_permission_names(clause, container: true)
|
99
149
|
c = ReqCounter.new
|
100
150
|
clause.xpath(ns(FIRST_LVL_REQ)).noblank.each do |t|
|
101
151
|
m = @reqt_models.model(t["model"])
|
102
152
|
klass, label = reqt2class_label(t, m)
|
103
153
|
id = c.increment(label, t).print
|
104
|
-
sequential_permission_body(id, t, label, klass, m,
|
154
|
+
sequential_permission_body(id, nil, t, label, klass, m,
|
105
155
|
container:)
|
106
|
-
sequential_permission_children(t, id, container:)
|
156
|
+
sequential_permission_children(t, id, klass, container:)
|
107
157
|
end
|
108
158
|
end
|
109
159
|
|
110
|
-
def sequential_permission_children(elem, lbl, container: false)
|
160
|
+
def sequential_permission_children(elem, lbl, klass, container: false)
|
111
161
|
c = ReqCounter.new
|
112
162
|
elem.xpath(ns(REQ_CHILDREN)).noblank.each do |t|
|
113
163
|
m = @reqt_models.model(t["model"])
|
114
164
|
klass, label = reqt2class_nested_label(t, m)
|
115
|
-
|
116
|
-
|
165
|
+
ctr = c.increment(label, t).print
|
166
|
+
id = "#{lbl}#{subreqt_separator}#{ctr}"
|
167
|
+
sequential_permission_body(ctr, lbl, t, label, klass, m,
|
117
168
|
container:)
|
118
|
-
sequential_permission_children(t, id, container:)
|
169
|
+
sequential_permission_children(t, id, klass, container:)
|
119
170
|
end
|
120
171
|
end
|
121
172
|
|
122
|
-
def sequential_permission_body(id, elem, label, klass, model,
|
173
|
+
def sequential_permission_body(id, parent_id, elem, label, klass, model,
|
123
174
|
container: false)
|
175
|
+
lbl = parent_id ? "#{parent_id}#{subreqt_separator}#{id}" : id
|
124
176
|
@anchors[elem["id"]] = model.postprocess_anchor_struct(
|
125
|
-
elem, anchor_struct(
|
126
|
-
label, klass, elem["unnumbered"])
|
177
|
+
elem, anchor_struct(lbl, elem,
|
178
|
+
label, klass, { unnumb: elem["unnumbered"], container: })
|
127
179
|
)
|
180
|
+
@anchors[elem["id"]][:semx] = semx(elem, lbl)
|
181
|
+
if parent_id
|
182
|
+
x = "#{subreqt_separator(markup: true)}#{semx(elem, id)}"
|
183
|
+
@anchors[elem["id"]][:semx] = @anchors[elem.parent["id"]][:semx] + x
|
184
|
+
@anchors[elem["id"]][:label] =
|
185
|
+
"<span class='fmt-element-name'>#{label}</span> #{@anchors[elem["id"]][:semx]}"
|
186
|
+
@anchors[elem["id"]][:xref] = "<span class='fmt-element-name'>#{label}</span> #{@anchors[elem["id"]][:semx]}"
|
187
|
+
end
|
128
188
|
model.permission_parts(elem, id, label, klass).each do |n|
|
129
189
|
@anchors[n[:id]] = anchor_struct(n[:number], n[:elem], n[:label],
|
130
|
-
n[:klass], false)
|
190
|
+
n[:klass], { unnumb: false, container: })
|
131
191
|
end
|
132
192
|
end
|
133
193
|
|
@@ -156,44 +216,61 @@ container: false)
|
|
156
216
|
sequential_permission_names(clause, container:)
|
157
217
|
end
|
158
218
|
|
159
|
-
def
|
219
|
+
def nodeSet(clauses)
|
220
|
+
case clauses
|
221
|
+
when Nokogiri::XML::Node
|
222
|
+
[clauses]
|
223
|
+
when Nokogiri::XML::NodeSet
|
224
|
+
clauses
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
# these can take a NodeSet as argument; semx will point to members of the NodeSet,
|
229
|
+
# but numbering will be consecutive
|
230
|
+
def hierarchical_figure_names(clauses, num)
|
160
231
|
c = Counter.new
|
161
232
|
j = 0
|
233
|
+
nodeSet(clauses).each do |clause|
|
162
234
|
clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t|
|
163
235
|
# labelled_ancestor(t, %w(figure)) and next
|
164
236
|
j = subfigure_increment(j, c, t)
|
165
|
-
|
237
|
+
sublabel = subfigure_label(j)
|
238
|
+
# hierarchical_figure_body(num, j, c, t, "figure")
|
239
|
+
#figure_anchor(t, sublabel, "#{num}#{hier_separator}#{c.print}", "figure")
|
240
|
+
#require "debug"; binding.b
|
241
|
+
figure_anchor(t, sublabel, hiersemx(clause, num, c, t), "figure")
|
166
242
|
end
|
167
243
|
hierarchical_figure_class_names(clause, num)
|
244
|
+
end
|
168
245
|
end
|
169
246
|
|
170
|
-
def hierarchical_figure_class_names(
|
247
|
+
def hierarchical_figure_class_names(clauses, num)
|
171
248
|
c = {}
|
172
249
|
j = 0
|
250
|
+
nodeSet(clauses).each do |clause|
|
173
251
|
clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
|
174
252
|
.noblank.each do |t|
|
175
253
|
# labelled_ancestor(t, %w(figure)) and next
|
176
254
|
c[t["class"]] ||= Counter.new
|
177
255
|
j = subfigure_increment(j, c[t["class"]], t)
|
178
|
-
|
256
|
+
sublabel = subfigure_label(j)
|
257
|
+
# hierarchical_figure_body(num, j, c[t["class"]], t, t["class"])
|
258
|
+
#figure_anchor(t, sublabel, "#{num}#{hier_separator}#{c[t['class']].print}", t["class"])
|
259
|
+
figure_anchor(t, sublabel, hiersemx(clause, num, c[t["class"]], t), t["class"])
|
260
|
+
end
|
179
261
|
end
|
180
262
|
end
|
181
263
|
|
182
|
-
def
|
183
|
-
label = "#{num}#{hiersep}#{counter.print}" +
|
184
|
-
subfigure_label(subfignum)
|
185
|
-
@anchors[block["id"]] =
|
186
|
-
anchor_struct(label, nil, @labels[klass] || klass.capitalize,
|
187
|
-
klass, block["unnumbered"])
|
188
|
-
end
|
189
|
-
|
190
|
-
def hierarchical_table_names(clause, num)
|
264
|
+
def hierarchical_table_names(clauses, num)
|
191
265
|
c = Counter.new
|
266
|
+
nodeSet(clauses).each do |clause|
|
192
267
|
clause.xpath(ns(".//table")).noblank.each do |t|
|
193
268
|
# labelled_ancestor(t) and next
|
194
269
|
@anchors[t["id"]] =
|
195
|
-
anchor_struct("#{num}#{
|
196
|
-
|
270
|
+
#anchor_struct("#{num}#{hier_separator}#{c.increment(t).print}",
|
271
|
+
anchor_struct(hiersemx(clause, num, c.increment(t), t),
|
272
|
+
t, @labels["table"], "table", { unnumb: t["unnumbered"], container: false })
|
273
|
+
end
|
197
274
|
end
|
198
275
|
end
|
199
276
|
|
@@ -204,47 +281,59 @@ container: false)
|
|
204
281
|
hierarchical_permission_names(clause, num)
|
205
282
|
end
|
206
283
|
|
207
|
-
def hierarchical_formula_names(
|
284
|
+
def hierarchical_formula_names(clauses, num)
|
208
285
|
c = Counter.new
|
286
|
+
nodeSet(clauses).each do |clause|
|
209
287
|
clause.xpath(ns(".//formula")).noblank.each do |t|
|
210
288
|
@anchors[t["id"]] = anchor_struct(
|
211
|
-
"#{num}#{
|
289
|
+
#"#{num}#{hier_separator}#{c.increment(t).print}", t,
|
290
|
+
hiersemx(clause, num, c.increment(t), t), t,
|
212
291
|
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
213
|
-
"formula", t["unnumbered"]
|
292
|
+
"formula", { unnumb: t["unnumbered"], container: false }
|
214
293
|
)
|
215
294
|
end
|
295
|
+
end
|
216
296
|
end
|
217
297
|
|
218
|
-
def hierarchical_permission_names(
|
298
|
+
def hierarchical_permission_names(clauses, num)
|
219
299
|
c = ReqCounter.new
|
300
|
+
nodeSet(clauses).each do |clause|
|
220
301
|
clause.xpath(ns(FIRST_LVL_REQ)).noblank.each do |t|
|
221
302
|
m = @reqt_models.model(t["model"])
|
222
303
|
klass, label = reqt2class_label(t, m)
|
223
|
-
id = "#{num}#{
|
224
|
-
|
225
|
-
|
304
|
+
#id = "#{num}#{hier_separator}#{c.increment(label, t).print}"
|
305
|
+
id = hiersemx(clause, num, c.increment(label, t), t)
|
306
|
+
sequential_permission_body(id, nil, t, label, klass, m, container: false)
|
307
|
+
sequential_permission_children(t, id, klass, container: false)
|
226
308
|
end
|
309
|
+
end
|
227
310
|
end
|
228
311
|
|
312
|
+
# TODO remove
|
229
313
|
def hierarchical_permission_children(block, lbl)
|
230
314
|
c = ReqCounter.new
|
231
315
|
block.xpath(ns(REQ_CHILDREN)).noblank.each do |t|
|
232
316
|
m = @reqt_models.model(t["model"])
|
233
317
|
klass, label = reqt2class_nested_label(t, m)
|
234
|
-
id = "#{lbl}#{
|
235
|
-
|
318
|
+
id = "#{lbl}#{subreqt_separator}#{c.increment(label, t).print}"
|
319
|
+
sequential_permission_body(c.print, lbl, t, label, klass, m)
|
236
320
|
hierarchical_permission_children(t, id)
|
237
321
|
end
|
238
322
|
end
|
239
323
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
324
|
+
# TODO remove
|
325
|
+
def hierarchical_permission_body(id, parent_id, elem, label, klass, model)
|
326
|
+
@anchors[elem["id"]] = model.postprocess_anchor_struct(
|
327
|
+
elem, anchor_struct(id, elem,
|
328
|
+
label, klass, { unnumb: elem["unnumbered"], container: false })
|
244
329
|
)
|
245
|
-
|
246
|
-
|
247
|
-
|
330
|
+
x = "#{subreqt_separator(markup: true)}#{semx(elem, id)}"
|
331
|
+
@anchors[elem["id"]][:label] = "#{semx(elem.parent, parent_id)}#{x}"
|
332
|
+
@anchors[elem["id"]][:xref] = @anchors[elem.parent["id"]][:xref] + x
|
333
|
+
model.permission_parts(elem, id, label, klass).each do |n|
|
334
|
+
# we don't have an n["id"], so we allow n[:id] in anchor_struct
|
335
|
+
@anchors[n[:id]] = anchor_struct(n[:number], n, n[:label],
|
336
|
+
n[:klass], { unnumb: false, container: false })
|
248
337
|
end
|
249
338
|
end
|
250
339
|
end
|