isodoc 1.6.2 → 1.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +2 -12
- data/.hound.yml +3 -1
- data/.rubocop.yml +4 -6
- data/Rakefile +2 -2
- data/isodoc.gemspec +3 -2
- data/lib/isodoc-yaml/i18n-en.yaml +1 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- data/lib/isodoc.rb +0 -2
- data/lib/isodoc/convert.rb +7 -1
- data/lib/isodoc/function/blocks.rb +5 -4
- data/lib/isodoc/function/cleanup.rb +52 -43
- data/lib/isodoc/function/inline.rb +7 -7
- data/lib/isodoc/function/references.rb +32 -51
- data/lib/isodoc/function/section.rb +28 -16
- data/lib/isodoc/function/table.rb +21 -22
- data/lib/isodoc/function/terms.rb +6 -7
- data/lib/isodoc/function/to_word_html.rb +6 -3
- data/lib/isodoc/function/utils.rb +181 -163
- data/lib/isodoc/gem_tasks.rb +8 -9
- data/lib/isodoc/headlesshtml_convert.rb +8 -7
- data/lib/isodoc/html_convert.rb +5 -1
- data/lib/isodoc/html_function/comments.rb +14 -12
- data/lib/isodoc/html_function/footnotes.rb +14 -7
- data/lib/isodoc/html_function/html.rb +30 -26
- data/lib/isodoc/html_function/postprocess.rb +191 -182
- data/lib/isodoc/html_function/sectionsplit.rb +230 -0
- data/lib/isodoc/metadata.rb +22 -20
- data/lib/isodoc/metadata_contributor.rb +31 -28
- data/lib/isodoc/pdf_convert.rb +11 -13
- data/lib/isodoc/presentation_function/bibdata.rb +61 -30
- data/lib/isodoc/presentation_function/inline.rb +34 -27
- data/lib/isodoc/presentation_function/section.rb +54 -19
- data/lib/isodoc/presentation_xml_convert.rb +2 -0
- data/lib/isodoc/sassc_importer.rb +1 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/postprocess.rb +50 -36
- data/lib/isodoc/xref.rb +2 -0
- data/lib/isodoc/xref/xref_counter.rb +1 -2
- data/lib/isodoc/xref/xref_gen.rb +21 -14
- data/lib/isodoc/xref/xref_gen_seq.rb +60 -35
- data/lib/isodoc/xref/xref_sect_gen.rb +15 -15
- data/spec/assets/scripts_override.html +3 -0
- data/spec/isodoc/blocks_spec.rb +624 -997
- data/spec/isodoc/cleanup_spec.rb +40 -42
- data/spec/isodoc/i18n_spec.rb +694 -821
- data/spec/isodoc/inline_spec.rb +482 -328
- data/spec/isodoc/metadata_spec.rb +384 -379
- data/spec/isodoc/postproc_spec.rb +163 -55
- data/spec/isodoc/presentation_xml_spec.rb +355 -278
- data/spec/isodoc/ref_spec.rb +5 -5
- data/spec/isodoc/section_spec.rb +216 -199
- data/spec/isodoc/sectionsplit_spec.rb +190 -0
- data/spec/isodoc/table_spec.rb +41 -42
- data/spec/isodoc/terms_spec.rb +84 -84
- data/spec/isodoc/xref_spec.rb +974 -932
- metadata +22 -5
data/lib/isodoc/version.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
require "fileutils"
|
2
|
-
require_relative "./postprocess_cover
|
2
|
+
require_relative "./postprocess_cover"
|
3
3
|
|
4
4
|
module IsoDoc::WordFunction
|
5
5
|
module Postprocess
|
6
6
|
# add namespaces for Word fragments
|
7
7
|
WORD_NOKOHEAD = <<~HERE.freeze
|
8
|
-
|
9
|
-
|
10
|
-
xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"
|
11
|
-
xmlns:w="urn:schemas-microsoft-com:office:word"
|
12
|
-
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
13
|
-
|
14
|
-
|
8
|
+
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
9
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
10
|
+
xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"
|
11
|
+
xmlns:w="urn:schemas-microsoft-com:office:word"
|
12
|
+
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
13
|
+
<head> <title></title> <meta charset="UTF-8" /> </head>
|
14
|
+
<body> </body> </html>
|
15
15
|
HERE
|
16
16
|
|
17
17
|
def to_word_xhtml_fragment(xml)
|
@@ -22,7 +22,8 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
22
22
|
def table_note_cleanup(docxml)
|
23
23
|
super
|
24
24
|
# preempt html2doc putting MsoNormal there
|
25
|
-
docxml.xpath("//p[not(self::*[@class])][ancestor::*[@class = 'Note']]")
|
25
|
+
docxml.xpath("//p[not(self::*[@class])][ancestor::*[@class = 'Note']]")
|
26
|
+
.each do |p|
|
26
27
|
p["class"] = "Note"
|
27
28
|
end
|
28
29
|
end
|
@@ -38,16 +39,21 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
38
39
|
def toWord(result, filename, dir, header)
|
39
40
|
result = from_xhtml(word_cleanup(to_xhtml(result)))
|
40
41
|
@wordstylesheet = wordstylesheet_update
|
41
|
-
Html2Doc.process(
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
Html2Doc.process(
|
43
|
+
result,
|
44
|
+
filename: filename,
|
45
|
+
stylesheet: @wordstylesheet&.path,
|
46
|
+
header_file: header&.path, dir: dir,
|
47
|
+
asciimathdelims: [@openmathdelim, @closemathdelim],
|
48
|
+
liststyles: { ul: @ulstyle, ol: @olstyle }
|
49
|
+
)
|
45
50
|
header&.unlink
|
46
|
-
@wordstylesheet
|
51
|
+
@wordstylesheet.unlink if @wordstylesheet.is_a?(Tempfile)
|
47
52
|
end
|
48
53
|
|
49
|
-
def wordstylesheet_update
|
54
|
+
def wordstylesheet_update
|
50
55
|
return if @wordstylesheet.nil?
|
56
|
+
|
51
57
|
f = File.open(@wordstylesheet.path, "a")
|
52
58
|
@landscapestyle.empty? or f.write(@landscapestyle)
|
53
59
|
if @wordstylesheet_override && @wordstylesheet
|
@@ -62,7 +68,8 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
62
68
|
|
63
69
|
def word_admonition_images(docxml)
|
64
70
|
docxml.xpath("//div[@class = 'Admonition']//img").each do |i|
|
65
|
-
i["width"], i["height"] =
|
71
|
+
i["width"], i["height"] =
|
72
|
+
Html2Doc.image_resize(i, image_localfile(i), @maxheight, 300)
|
66
73
|
end
|
67
74
|
end
|
68
75
|
|
@@ -88,21 +95,23 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
88
95
|
cells2d = {}
|
89
96
|
docxml.xpath("//table[colgroup]").each do |t|
|
90
97
|
w = colgroup_widths(t)
|
91
|
-
t.xpath(".//tr").each_with_index { |
|
98
|
+
t.xpath(".//tr").each_with_index { |_tr, r| cells2d[r] = {} }
|
92
99
|
t.xpath(".//tr").each_with_index do |tr, r|
|
93
|
-
tr.xpath("./td | ./th").each_with_index do |td,
|
100
|
+
tr.xpath("./td | ./th").each_with_index do |td, _i|
|
94
101
|
x = 0
|
95
102
|
rs = td&.attr("rowspan")&.to_i || 1
|
96
103
|
cs = td&.attr("colspan")&.to_i || 1
|
97
|
-
while cells2d[r][x]
|
98
|
-
x += 1
|
104
|
+
while cells2d[r][x]
|
105
|
+
x += 1
|
99
106
|
end
|
100
|
-
|
101
|
-
|
107
|
+
(r..(r + rs - 1)).each do |y2|
|
108
|
+
(x..(x + cs - 1)).each do |x2|
|
102
109
|
cells2d[y2][x2] = 1
|
103
110
|
end
|
104
111
|
end
|
105
|
-
width = (x..(x+cs-1)).each_with_object({width: 0})
|
112
|
+
width = (x..(x + cs - 1)).each_with_object({ width: 0 }) do |z, m|
|
113
|
+
m[:width] += w[z]
|
114
|
+
end
|
106
115
|
td["width"] = "#{width[:width]}%"
|
107
116
|
x += cs
|
108
117
|
end
|
@@ -111,8 +120,8 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
111
120
|
end
|
112
121
|
|
113
122
|
# assume percentages
|
114
|
-
def colgroup_widths(
|
115
|
-
|
123
|
+
def colgroup_widths(table)
|
124
|
+
table.xpath("./colgroup/col").each_with_object([]) do |c, m|
|
116
125
|
m << c["width"].sub(/%$/, "").to_f
|
117
126
|
end
|
118
127
|
end
|
@@ -127,12 +136,13 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
127
136
|
|
128
137
|
def style_update(node, css)
|
129
138
|
return unless node
|
130
|
-
|
139
|
+
|
140
|
+
node["style"] = node["style"] ? node["style"].sub(/;?$/, ";#{css}") : css
|
131
141
|
end
|
132
142
|
|
133
143
|
def word_image_caption(docxml)
|
134
|
-
docxml.xpath("//p[@class = 'FigureTitle' or @class = 'SourceTitle']")
|
135
|
-
each do |t|
|
144
|
+
docxml.xpath("//p[@class = 'FigureTitle' or @class = 'SourceTitle']")
|
145
|
+
.each do |t|
|
136
146
|
if t&.previous_element&.name == "img"
|
137
147
|
img = t.previous_element
|
138
148
|
t.previous_element.swap("<p class=\'figure\'>#{img.to_xml}</p>")
|
@@ -150,7 +160,8 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
150
160
|
xpath.each do |list|
|
151
161
|
(list.xpath(".//li") - list.xpath(".//ol//li | .//ul//li")).each do |l|
|
152
162
|
l.xpath("./p | ./div | ./table").each_with_index do |p, i|
|
153
|
-
next if i
|
163
|
+
next if i.zero?
|
164
|
+
|
154
165
|
p.wrap(%{<div class="ListContLevel#{lvl}"/>})
|
155
166
|
end
|
156
167
|
list_add(l.xpath(".//ul") - l.xpath(".//ul//ul | .//ol//ul"), lvl + 1)
|
@@ -162,20 +173,21 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
162
173
|
def word_table_align(docxml)
|
163
174
|
docxml.xpath("//td[@align]/p | //th[@align]/p").each do |p|
|
164
175
|
next if p["align"]
|
165
|
-
|
176
|
+
|
177
|
+
style_update(p, "text-align: #{p.parent['align']}")
|
166
178
|
end
|
167
179
|
end
|
168
180
|
|
169
181
|
def word_table_separator(docxml)
|
170
182
|
docxml.xpath("//p[@class = 'TableTitle']").each do |t|
|
171
183
|
next unless t.children.empty?
|
184
|
+
|
172
185
|
t["style"] = t["style"].sub(/;?$/, ";font-size:0pt;")
|
173
186
|
t.children = " "
|
174
187
|
end
|
175
188
|
end
|
176
189
|
|
177
|
-
def word_annex_cleanup(docxml)
|
178
|
-
end
|
190
|
+
def word_annex_cleanup(docxml); end
|
179
191
|
|
180
192
|
def word_example_cleanup(docxml)
|
181
193
|
docxml.xpath("//div[@class = 'example']//p[not(@class)]").each do |p|
|
@@ -194,19 +206,21 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
194
206
|
docxml.xpath("//div[p/br]").each do |d|
|
195
207
|
/^WordSection\d+_\d+$/.match(d["class"]) or next
|
196
208
|
d.elements[0].name == "p" && !d.elements[0].elements.empty? or next
|
197
|
-
d.elements[0].elements[0].name == "br" &&
|
198
|
-
"
|
209
|
+
d.elements[0].elements[0].name == "br" &&
|
210
|
+
d.elements[0].elements[0]["style"] ==
|
211
|
+
"mso-special-character:line-break;page-break-before:always" or next
|
199
212
|
d.elements[0].remove
|
200
213
|
end
|
201
214
|
end
|
202
215
|
|
203
216
|
def word_footnote_format(docxml)
|
204
|
-
# the content is in a[@epub:type = 'footnote']//sup, but in Word,
|
217
|
+
# the content is in a[@epub:type = 'footnote']//sup, but in Word,
|
205
218
|
# we need to inject content around the autonumbered footnote reference
|
206
219
|
docxml.xpath("//a[@epub:type = 'footnote']").each do |x|
|
207
220
|
footnote_reference_format(x)
|
208
221
|
end
|
209
|
-
docxml.xpath("//a[@class = 'TableFootnoteRef'] |
|
222
|
+
docxml.xpath("//a[@class = 'TableFootnoteRef'] | "\
|
223
|
+
"//span[@class = 'TableFootnoteRef']").each do |x|
|
210
224
|
table_footnote_reference_format(x)
|
211
225
|
end
|
212
226
|
docxml
|
data/lib/isodoc/xref.rb
CHANGED
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -10,7 +10,7 @@ module IsoDoc::XrefGen
|
|
10
10
|
autonum = amend_autonums(a)
|
11
11
|
NUMBERED_BLOCKS.each do |b|
|
12
12
|
a.xpath(ns("./newcontent//#{b}")).each_with_index do |e, i|
|
13
|
-
autonum[b]
|
13
|
+
autonum[b] && i.zero? and e["number"] = autonum[b]
|
14
14
|
!autonum[b] and e["unnumbered"] = "true"
|
15
15
|
end
|
16
16
|
end
|
@@ -29,6 +29,13 @@ module IsoDoc::XrefGen
|
|
29
29
|
@labels["termnote"].gsub(/%/, note.to_s)
|
30
30
|
end
|
31
31
|
|
32
|
+
def increment_label(elems, node, counter, increment = true)
|
33
|
+
return "" if elems.size == 1 && !node["number"]
|
34
|
+
|
35
|
+
counter.increment(node) if increment
|
36
|
+
" #{counter.print}"
|
37
|
+
end
|
38
|
+
|
32
39
|
def termnote_anchor_names(docxml)
|
33
40
|
docxml.xpath(ns("//term[descendant::termnote]")).each do |t|
|
34
41
|
c = Counter.new
|
@@ -39,7 +46,7 @@ module IsoDoc::XrefGen
|
|
39
46
|
@anchors[n["id"]] =
|
40
47
|
{ label: termnote_label(c.print), type: "termnote", value: c.print,
|
41
48
|
xref: l10n("#{anchor(t['id'], :xref)}, "\
|
42
|
-
"#{@labels[
|
49
|
+
"#{@labels['note_xref']} #{c.print}") }
|
43
50
|
end
|
44
51
|
end
|
45
52
|
end
|
@@ -52,11 +59,11 @@ module IsoDoc::XrefGen
|
|
52
59
|
next if n["id"].nil? || n["id"].empty?
|
53
60
|
|
54
61
|
c.increment(n)
|
55
|
-
idx = examples
|
62
|
+
idx = increment_label(examples, n, c, false)
|
56
63
|
@anchors[n["id"]] = {
|
57
64
|
type: "termexample", label: idx, value: c.print,
|
58
65
|
xref: l10n("#{anchor(t['id'], :xref)}, "\
|
59
|
-
"#{@labels[
|
66
|
+
"#{@labels['example_xref']} #{c.print}") }
|
60
67
|
end
|
61
68
|
end
|
62
69
|
end
|
@@ -84,9 +91,9 @@ module IsoDoc::XrefGen
|
|
84
91
|
notes.each do |n|
|
85
92
|
next if @anchors[n["id"]] || n["id"].nil? || n["id"].empty?
|
86
93
|
|
87
|
-
|
88
|
-
|
89
|
-
|
94
|
+
@anchors[n["id"]] =
|
95
|
+
anchor_struct(increment_label(notes, n, c), n,
|
96
|
+
@labels["note_xref"], "note", false)
|
90
97
|
end
|
91
98
|
note_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
92
99
|
end
|
@@ -107,10 +114,9 @@ module IsoDoc::XrefGen
|
|
107
114
|
notes.each do |n|
|
108
115
|
next if @anchors[n["id"]] || n["id"].nil? || n["id"].empty?
|
109
116
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
"example", n["unnumbered"])
|
117
|
+
@anchors[n["id"]] =
|
118
|
+
anchor_struct(increment_label(notes, n, c), n,
|
119
|
+
@labels["example_xref"], "example", n["unnumbered"])
|
114
120
|
end
|
115
121
|
example_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
116
122
|
end
|
@@ -124,9 +130,8 @@ module IsoDoc::XrefGen
|
|
124
130
|
notes.each do |n|
|
125
131
|
next if n["id"].nil? || n["id"].empty?
|
126
132
|
|
127
|
-
|
128
|
-
|
129
|
-
false)
|
133
|
+
@anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n,
|
134
|
+
@labels["list"], "list", false)
|
130
135
|
list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
|
131
136
|
end
|
132
137
|
list_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
|
@@ -151,9 +156,11 @@ module IsoDoc::XrefGen
|
|
151
156
|
def bookmark_anchor_names(docxml)
|
152
157
|
docxml.xpath(ns(".//bookmark")).each do |n|
|
153
158
|
next if n["id"].nil? || n["id"].empty?
|
159
|
+
|
154
160
|
parent = nil
|
155
161
|
n.ancestors.each do |a|
|
156
162
|
next unless a["id"] && parent = @anchors.dig(a["id"], :xref)
|
163
|
+
|
157
164
|
break
|
158
165
|
end
|
159
166
|
@anchors[n["id"]] = { type: "bookmark", label: nil, value: nil,
|
@@ -8,25 +8,27 @@ module IsoDoc::XrefGen
|
|
8
8
|
"-"
|
9
9
|
end
|
10
10
|
|
11
|
-
def subfigure_increment(
|
12
|
-
if
|
11
|
+
def subfigure_increment(idx, counter, elem)
|
12
|
+
if elem.parent.name == "figure" then idx += 1
|
13
13
|
else
|
14
|
-
|
15
|
-
|
14
|
+
idx = 0
|
15
|
+
counter.increment(elem)
|
16
16
|
end
|
17
|
-
|
17
|
+
idx
|
18
18
|
end
|
19
19
|
|
20
20
|
def sequential_figure_names(clause)
|
21
21
|
c = Counter.new
|
22
22
|
j = 0
|
23
|
-
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
|
24
|
-
each do |t|
|
23
|
+
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
|
24
|
+
.each do |t|
|
25
25
|
j = subfigure_increment(j, c, t)
|
26
26
|
label = c.print + (j.zero? ? "" : "-#{j}")
|
27
27
|
next if t["id"].nil? || t["id"].empty?
|
28
|
-
|
29
|
-
|
28
|
+
|
29
|
+
@anchors[t["id"]] = anchor_struct(
|
30
|
+
label, nil, @labels["figure"], "figure", t["unnumbered"]
|
31
|
+
)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
@@ -34,8 +36,11 @@ module IsoDoc::XrefGen
|
|
34
36
|
c = Counter.new
|
35
37
|
clause.xpath(ns(".//table")).each do |t|
|
36
38
|
next if t["id"].nil? || t["id"].empty?
|
37
|
-
|
38
|
-
|
39
|
+
|
40
|
+
@anchors[t["id"]] = anchor_struct(
|
41
|
+
c.increment(t).print, nil,
|
42
|
+
@labels["table"], "table", t["unnumbered"]
|
43
|
+
)
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
@@ -43,10 +48,12 @@ module IsoDoc::XrefGen
|
|
43
48
|
c = Counter.new
|
44
49
|
clause.xpath(ns(".//formula")).each do |t|
|
45
50
|
next if t["id"].nil? || t["id"].empty?
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
51
|
+
|
52
|
+
@anchors[t["id"]] = anchor_struct(
|
53
|
+
c.increment(t).print, t,
|
54
|
+
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
55
|
+
"formula", t["unnumbered"]
|
56
|
+
)
|
50
57
|
end
|
51
58
|
end
|
52
59
|
|
@@ -57,22 +64,27 @@ module IsoDoc::XrefGen
|
|
57
64
|
c = Counter.new
|
58
65
|
clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}")).each do |t|
|
59
66
|
next if t["id"].nil? || t["id"].empty?
|
67
|
+
|
60
68
|
id = c.increment(t).print
|
61
69
|
@anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
|
62
70
|
sequential_permission_names2(t, id)
|
63
71
|
end
|
64
72
|
end
|
65
73
|
|
66
|
-
def sequential_permission_names2(
|
67
|
-
sequential_permission_names1(
|
68
|
-
|
69
|
-
sequential_permission_names1(
|
74
|
+
def sequential_permission_names2(elem, ident)
|
75
|
+
sequential_permission_names1(elem, ident, "permission",
|
76
|
+
@labels["permission"])
|
77
|
+
sequential_permission_names1(elem, ident, "requirement",
|
78
|
+
@labels["requirement"])
|
79
|
+
sequential_permission_names1(elem, ident, "recommendation",
|
80
|
+
@labels["recommendation"])
|
70
81
|
end
|
71
82
|
|
72
83
|
def sequential_permission_names1(block, lbl, klass, label)
|
73
84
|
c = Counter.new
|
74
85
|
block.xpath(ns("./#{klass}")).each do |t|
|
75
86
|
next if t["id"].nil? || t["id"].empty?
|
87
|
+
|
76
88
|
id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
|
77
89
|
@anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
|
78
90
|
sequential_permission_names2(t, id)
|
@@ -85,20 +97,22 @@ module IsoDoc::XrefGen
|
|
85
97
|
sequential_formula_names(clause)
|
86
98
|
sequential_permission_names(clause, "permission", @labels["permission"])
|
87
99
|
sequential_permission_names(clause, "requirement", @labels["requirement"])
|
88
|
-
sequential_permission_names(clause, "recommendation",
|
100
|
+
sequential_permission_names(clause, "recommendation",
|
101
|
+
@labels["recommendation"])
|
89
102
|
end
|
90
103
|
|
91
104
|
def hierarchical_figure_names(clause, num)
|
92
105
|
c = Counter.new
|
93
106
|
j = 0
|
94
|
-
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
|
95
|
-
each do |t|
|
107
|
+
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]"))
|
108
|
+
.each do |t|
|
96
109
|
j = subfigure_increment(j, c, t)
|
97
110
|
label = "#{num}#{hiersep}#{c.print}" +
|
98
111
|
(j.zero? ? "" : "#{hierfigsep}#{j}")
|
99
112
|
next if t["id"].nil? || t["id"].empty?
|
100
|
-
|
101
|
-
|
113
|
+
|
114
|
+
@anchors[t["id"]] = anchor_struct(label, nil, @labels["figure"],
|
115
|
+
"figure", t["unnumbered"])
|
102
116
|
end
|
103
117
|
end
|
104
118
|
|
@@ -106,6 +120,7 @@ module IsoDoc::XrefGen
|
|
106
120
|
c = Counter.new
|
107
121
|
clause.xpath(ns(".//table")).each do |t|
|
108
122
|
next if t["id"].nil? || t["id"].empty?
|
123
|
+
|
109
124
|
@anchors[t["id"]] =
|
110
125
|
anchor_struct("#{num}#{hiersep}#{c.increment(t).print}",
|
111
126
|
nil, @labels["table"], "table", t["unnumbered"])
|
@@ -116,7 +131,8 @@ module IsoDoc::XrefGen
|
|
116
131
|
hierarchical_table_names(clause, num)
|
117
132
|
hierarchical_figure_names(clause, num)
|
118
133
|
hierarchical_formula_names(clause, num)
|
119
|
-
hierarchical_permission_names(clause, num, "permission",
|
134
|
+
hierarchical_permission_names(clause, num, "permission",
|
135
|
+
@labels["permission"])
|
120
136
|
hierarchical_permission_names(clause, num, "requirement",
|
121
137
|
@labels["requirement"])
|
122
138
|
hierarchical_permission_names(clause, num, "recommendation",
|
@@ -127,10 +143,12 @@ module IsoDoc::XrefGen
|
|
127
143
|
c = Counter.new
|
128
144
|
clause.xpath(ns(".//formula")).each do |t|
|
129
145
|
next if t["id"].nil? || t["id"].empty?
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
146
|
+
|
147
|
+
@anchors[t["id"]] = anchor_struct(
|
148
|
+
"#{num}#{hiersep}#{c.increment(t).print}", nil,
|
149
|
+
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
150
|
+
"formula", t["unnumbered"]
|
151
|
+
)
|
134
152
|
end
|
135
153
|
end
|
136
154
|
|
@@ -138,24 +156,31 @@ module IsoDoc::XrefGen
|
|
138
156
|
c = Counter.new
|
139
157
|
clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}")).each do |t|
|
140
158
|
next if t["id"].nil? || t["id"].empty?
|
159
|
+
|
141
160
|
id = "#{num}#{hiersep}#{c.increment(t).print}"
|
142
|
-
@anchors[t["id"]] =
|
161
|
+
@anchors[t["id"]] =
|
162
|
+
anchor_struct(id, nil, label, klass, t["unnumbered"])
|
143
163
|
hierarchical_permission_names2(t, id)
|
144
164
|
end
|
145
165
|
end
|
146
166
|
|
147
|
-
def hierarchical_permission_names2(
|
148
|
-
hierarchical_permission_names1(
|
149
|
-
|
150
|
-
hierarchical_permission_names1(
|
167
|
+
def hierarchical_permission_names2(elem, ident)
|
168
|
+
hierarchical_permission_names1(elem, ident, "permission",
|
169
|
+
@labels["permission"])
|
170
|
+
hierarchical_permission_names1(elem, ident, "requirement",
|
171
|
+
@labels["requirement"])
|
172
|
+
hierarchical_permission_names1(elem, ident, "recommendation",
|
173
|
+
@labels["recommendation"])
|
151
174
|
end
|
152
175
|
|
153
176
|
def hierarchical_permission_names1(block, lbl, klass, label)
|
154
177
|
c = Counter.new
|
155
178
|
block.xpath(ns("./#{klass}")).each do |t|
|
156
179
|
next if t["id"].nil? || t["id"].empty?
|
180
|
+
|
157
181
|
id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
|
158
|
-
@anchors[t["id"]] =
|
182
|
+
@anchors[t["id"]] =
|
183
|
+
anchor_struct(id, nil, label, klass, t["unnumbered"])
|
159
184
|
hierarchical_permission_names2(t, id)
|
160
185
|
end
|
161
186
|
end
|