isodoc 1.7.6 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +1 -1
- data/lib/isodoc/class_utils.rb +23 -0
- data/lib/isodoc/convert.rb +9 -0
- data/lib/isodoc/function/cleanup.rb +4 -0
- data/lib/isodoc/function/inline.rb +2 -4
- data/lib/isodoc/function/utils.rb +1 -1
- data/lib/isodoc/html_function/html.rb +1 -0
- data/lib/isodoc/html_function/postprocess.rb +4 -6
- data/lib/isodoc/metadata_date.rb +13 -11
- data/lib/isodoc/presentation_function/bibdata.rb +2 -2
- data/lib/isodoc/presentation_function/block.rb +0 -36
- data/lib/isodoc/presentation_function/inline.rb +14 -11
- data/lib/isodoc/presentation_function/terms.rb +179 -0
- data/lib/isodoc/presentation_xml_convert.rb +11 -4
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +24 -14
- data/lib/isodoc/word_function/comments.rb +0 -4
- data/lib/isodoc/word_function/postprocess.rb +184 -176
- data/lib/isodoc/xref/xref_gen.rb +18 -22
- data/lib/isodoc/xref/xref_gen_seq.rb +10 -16
- data/lib/isodoc/xref/xref_sect_gen.rb +134 -129
- data/lib/isodoc/xslfo_convert.rb +11 -7
- data/lib/isodoc-yaml/i18n-ar.yaml +22 -0
- data/lib/isodoc-yaml/i18n-de.yaml +20 -0
- data/lib/isodoc-yaml/i18n-en.yaml +20 -0
- data/lib/isodoc-yaml/i18n-es.yaml +20 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +20 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +21 -1
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +21 -0
- data/lib/metanorma/output/xslfo.rb +4 -11
- data/spec/assets/i18n.yaml +3 -1
- data/spec/isodoc/blocks_spec.rb +14 -8
- data/spec/isodoc/i18n_spec.rb +8 -8
- data/spec/isodoc/inline_spec.rb +200 -6
- data/spec/isodoc/lists_spec.rb +344 -222
- data/spec/isodoc/section_spec.rb +11 -10
- data/spec/isodoc/table_spec.rb +71 -73
- data/spec/isodoc/terms_spec.rb +354 -34
- data/spec/isodoc/xref_numbering_spec.rb +347 -0
- data/spec/isodoc/xref_spec.rb +271 -350
- data/spec/isodoc/xslfo_convert_spec.rb +34 -9
- metadata +7 -6
- data/lib/isodoc/presentation_function/concept.rb +0 -68
@@ -1,229 +1,237 @@
|
|
1
1
|
require "fileutils"
|
2
2
|
require_relative "./postprocess_cover"
|
3
3
|
|
4
|
-
module IsoDoc
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
4
|
+
module IsoDoc
|
5
|
+
module WordFunction
|
6
|
+
module Postprocess
|
7
|
+
# add namespaces for Word fragments
|
8
|
+
WORD_NOKOHEAD = <<~HERE.freeze
|
9
|
+
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
10
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
11
|
+
xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"
|
12
|
+
xmlns:w="urn:schemas-microsoft-com:office:word"
|
13
|
+
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
14
|
+
<head> <title></title> <meta charset="UTF-8" /> </head>
|
15
|
+
<body> </body> </html>
|
16
|
+
HERE
|
17
|
+
|
18
|
+
def to_word_xhtml_fragment(xml)
|
19
|
+
doc = ::Nokogiri::XML.parse(WORD_NOKOHEAD)
|
20
|
+
::Nokogiri::XML::DocumentFragment.new(doc, xml, doc.root)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
def table_note_cleanup(docxml)
|
24
|
+
super
|
25
|
+
# preempt html2doc putting MsoNormal there
|
26
|
+
docxml.xpath("//p[not(self::*[@class])][ancestor::*[@class = 'Note']]")
|
27
|
+
.each do |p|
|
28
|
+
p["class"] = "Note"
|
29
|
+
end
|
28
30
|
end
|
29
|
-
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
def postprocess(result, filename, dir)
|
33
|
+
filename = filename.sub(/\.doc$/, "")
|
34
|
+
header = generate_header(filename, dir)
|
35
|
+
result = from_xhtml(cleanup(to_xhtml(textcleanup(result))))
|
36
|
+
toWord(result, filename, dir, header)
|
37
|
+
@files_to_delete.each { |f| FileUtils.rm_f f }
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
40
|
+
def toWord(result, filename, dir, header)
|
41
|
+
result = from_xhtml(word_cleanup(to_xhtml(result)))
|
42
|
+
@wordstylesheet = wordstylesheet_update
|
43
|
+
Html2Doc.process(
|
44
|
+
result,
|
45
|
+
filename: filename,
|
46
|
+
imagedir: @localdir,
|
47
|
+
stylesheet: @wordstylesheet&.path,
|
48
|
+
header_file: header&.path, dir: dir,
|
49
|
+
asciimathdelims: [@openmathdelim, @closemathdelim],
|
50
|
+
liststyles: { ul: @ulstyle, ol: @olstyle }
|
51
|
+
)
|
52
|
+
header&.unlink
|
53
|
+
@wordstylesheet.unlink if @wordstylesheet.is_a?(Tempfile)
|
54
|
+
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
+
def wordstylesheet_update
|
57
|
+
return if @wordstylesheet.nil?
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
f = File.open(@wordstylesheet.path, "a")
|
60
|
+
@landscapestyle.empty? or f.write(@landscapestyle)
|
61
|
+
if @wordstylesheet_override && @wordstylesheet
|
62
|
+
f.write(@wordstylesheet_override.read)
|
63
|
+
@wordstylesheet_override.close
|
64
|
+
elsif @wordstylesheet_override && !@wordstylesheet
|
65
|
+
@wordstylesheet = @wordstylesheet_override
|
66
|
+
end
|
67
|
+
f.close
|
68
|
+
@wordstylesheet
|
64
69
|
end
|
65
|
-
f.close
|
66
|
-
@wordstylesheet
|
67
|
-
end
|
68
70
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
71
|
+
def word_admonition_images(docxml)
|
72
|
+
docxml.xpath("//div[@class = 'Admonition']//img").each do |i|
|
73
|
+
i["width"], i["height"] =
|
74
|
+
Html2Doc.image_resize(i, image_localfile(i), @maxheight, 300)
|
75
|
+
end
|
73
76
|
end
|
74
|
-
end
|
75
77
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
78
|
+
def word_cleanup(docxml)
|
79
|
+
word_annex_cleanup(docxml)
|
80
|
+
word_preface(docxml)
|
81
|
+
word_nested_tables(docxml)
|
82
|
+
word_colgroup(docxml)
|
83
|
+
word_table_align(docxml)
|
84
|
+
word_table_separator(docxml)
|
85
|
+
word_admonition_images(docxml)
|
86
|
+
word_list_continuations(docxml)
|
87
|
+
word_example_cleanup(docxml)
|
88
|
+
word_pseudocode_cleanup(docxml)
|
89
|
+
word_image_caption(docxml)
|
90
|
+
word_section_breaks(docxml)
|
91
|
+
authority_cleanup(docxml)
|
92
|
+
word_footnote_format(docxml)
|
93
|
+
docxml
|
94
|
+
end
|
93
95
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
107
|
-
(r..(r + rs - 1)).each do |y2|
|
108
|
-
(x..(x + cs - 1)).each do |x2|
|
109
|
-
cells2d[y2][x2] = 1
|
96
|
+
def word_colgroup(docxml)
|
97
|
+
cells2d = {}
|
98
|
+
docxml.xpath("//table[colgroup]").each do |t|
|
99
|
+
w = colgroup_widths(t)
|
100
|
+
t.xpath(".//tr").each_with_index { |_tr, r| cells2d[r] = {} }
|
101
|
+
t.xpath(".//tr").each_with_index do |tr, r|
|
102
|
+
tr.xpath("./td | ./th").each_with_index do |td, _i|
|
103
|
+
x = 0
|
104
|
+
rs = td&.attr("rowspan")&.to_i || 1
|
105
|
+
cs = td&.attr("colspan")&.to_i || 1
|
106
|
+
while cells2d[r][x]
|
107
|
+
x += 1
|
110
108
|
end
|
109
|
+
(r..(r + rs - 1)).each do |y2|
|
110
|
+
(x..(x + cs - 1)).each do |x2|
|
111
|
+
cells2d[y2][x2] = 1
|
112
|
+
end
|
113
|
+
end
|
114
|
+
width = (x..(x + cs - 1)).each_with_object({ width: 0 }) do |z, m|
|
115
|
+
m[:width] += w[z]
|
116
|
+
end
|
117
|
+
td["width"] = "#{width[:width]}%"
|
118
|
+
x += cs
|
111
119
|
end
|
112
|
-
width = (x..(x + cs - 1)).each_with_object({ width: 0 }) do |z, m|
|
113
|
-
m[:width] += w[z]
|
114
|
-
end
|
115
|
-
td["width"] = "#{width[:width]}%"
|
116
|
-
x += cs
|
117
120
|
end
|
118
121
|
end
|
119
122
|
end
|
120
|
-
end
|
121
123
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
124
|
+
# assume percentages
|
125
|
+
def colgroup_widths(table)
|
126
|
+
table.xpath("./colgroup/col").each_with_object([]) do |c, m|
|
127
|
+
m << c["width"].sub(/%$/, "").to_f
|
128
|
+
end
|
126
129
|
end
|
127
|
-
end
|
128
130
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
131
|
+
def word_nested_tables(docxml)
|
132
|
+
docxml.xpath("//table").each do |t|
|
133
|
+
t.xpath(".//table").reverse.each do |tt|
|
134
|
+
t.next = tt.remove
|
135
|
+
end
|
133
136
|
end
|
134
137
|
end
|
135
|
-
end
|
136
138
|
|
137
|
-
|
138
|
-
|
139
|
+
def style_update(node, css)
|
140
|
+
return unless node
|
139
141
|
|
140
|
-
|
141
|
-
|
142
|
+
node["style"] =
|
143
|
+
node["style"] ? node["style"].sub(/;?$/, ";#{css}") : css
|
144
|
+
end
|
142
145
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
146
|
+
def word_image_caption(docxml)
|
147
|
+
docxml.xpath("//p[@class = 'FigureTitle' or @class = 'SourceTitle']")
|
148
|
+
.each do |t|
|
149
|
+
if t&.previous_element&.name == "img"
|
150
|
+
img = t.previous_element
|
151
|
+
t.previous_element.swap("<p class=\'figure\'>#{img.to_xml}</p>")
|
152
|
+
end
|
153
|
+
style_update(t&.previous_element, "page-break-after:avoid;")
|
149
154
|
end
|
150
|
-
style_update(t&.previous_element, "page-break-after:avoid;")
|
151
155
|
end
|
152
|
-
end
|
153
156
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
157
|
+
def word_list_continuations(docxml)
|
158
|
+
list_add(docxml.xpath("//ul[not(ancestor::ul) and not(ancestor::ol)]"),
|
159
|
+
1)
|
160
|
+
list_add(docxml.xpath("//ol[not(ancestor::ul) and not(ancestor::ol)]"),
|
161
|
+
1)
|
162
|
+
end
|
158
163
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
+
def list_add(xpath, lvl)
|
165
|
+
xpath.each do |list|
|
166
|
+
(list.xpath(".//li") - list.xpath(".//ol//li | .//ul//li")).each do |l|
|
167
|
+
l.xpath("./p | ./div | ./table").each_with_index do |p, i|
|
168
|
+
next if i.zero?
|
164
169
|
|
165
|
-
|
170
|
+
p.wrap(%{<div class="ListContLevel#{lvl}"/>})
|
171
|
+
end
|
172
|
+
list_add(l.xpath(".//ul") - l.xpath(".//ul//ul | .//ol//ul"),
|
173
|
+
lvl + 1)
|
174
|
+
list_add(l.xpath(".//ol") - l.xpath(".//ul//ol | .//ol//ol"),
|
175
|
+
lvl + 1)
|
166
176
|
end
|
167
|
-
list_add(l.xpath(".//ul") - l.xpath(".//ul//ul | .//ol//ul"), lvl + 1)
|
168
|
-
list_add(l.xpath(".//ol") - l.xpath(".//ul//ol | .//ol//ol"), lvl + 1)
|
169
177
|
end
|
170
178
|
end
|
171
|
-
end
|
172
179
|
|
173
|
-
|
174
|
-
|
175
|
-
|
180
|
+
def word_table_align(docxml)
|
181
|
+
docxml.xpath("//td[@align]/p | //th[@align]/p").each do |p|
|
182
|
+
next if p["align"]
|
176
183
|
|
177
|
-
|
184
|
+
style_update(p, "text-align: #{p.parent['align']}")
|
185
|
+
end
|
178
186
|
end
|
179
|
-
end
|
180
187
|
|
181
|
-
|
182
|
-
|
183
|
-
|
188
|
+
def word_table_separator(docxml)
|
189
|
+
docxml.xpath("//p[@class = 'TableTitle']").each do |t|
|
190
|
+
next unless t.children.empty?
|
184
191
|
|
185
|
-
|
186
|
-
|
192
|
+
t["style"] = t["style"].sub(/;?$/, ";font-size:0pt;")
|
193
|
+
t.children = " "
|
194
|
+
end
|
187
195
|
end
|
188
|
-
end
|
189
196
|
|
190
|
-
|
197
|
+
def word_annex_cleanup(docxml); end
|
191
198
|
|
192
|
-
|
193
|
-
|
194
|
-
|
199
|
+
def word_example_cleanup(docxml)
|
200
|
+
docxml.xpath("//div[@class = 'example']//p[not(@class)]").each do |p|
|
201
|
+
p["class"] = "example"
|
202
|
+
end
|
195
203
|
end
|
196
|
-
end
|
197
204
|
|
198
|
-
|
199
|
-
|
200
|
-
|
205
|
+
def word_pseudocode_cleanup(docxml)
|
206
|
+
docxml.xpath("//div[@class = 'pseudocode']//p[not(@class)]").each do |p|
|
207
|
+
p["class"] = "pseudocode"
|
208
|
+
end
|
201
209
|
end
|
202
|
-
end
|
203
210
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
211
|
+
# applies for <div class="WordSectionN_M"><p><pagebreak/></p>...
|
212
|
+
def word_remove_pb_before_annex(docxml)
|
213
|
+
docxml.xpath("//div[p/br]").each do |d|
|
214
|
+
/^WordSection\d+_\d+$/.match(d["class"]) or next
|
215
|
+
d.elements[0].name == "p" && !d.elements[0].elements.empty? or next
|
216
|
+
d.elements[0].elements[0].name == "br" &&
|
217
|
+
d.elements[0].elements[0]["style"] ==
|
218
|
+
"mso-special-character:line-break;page-break-before:always" or next
|
219
|
+
d.elements[0].remove
|
220
|
+
end
|
213
221
|
end
|
214
|
-
end
|
215
222
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
223
|
+
def word_footnote_format(docxml)
|
224
|
+
# the content is in a[@epub:type = 'footnote']//sup, but in Word,
|
225
|
+
# we need to inject content around the autonumbered footnote reference
|
226
|
+
docxml.xpath("//a[@epub:type = 'footnote']").each do |x|
|
227
|
+
footnote_reference_format(x)
|
228
|
+
end
|
229
|
+
docxml.xpath("//a[@class = 'TableFootnoteRef'] | "\
|
230
|
+
"//span[@class = 'TableFootnoteRef']").each do |x|
|
231
|
+
table_footnote_reference_format(x)
|
232
|
+
end
|
233
|
+
docxml
|
225
234
|
end
|
226
|
-
docxml
|
227
235
|
end
|
228
236
|
end
|
229
237
|
end
|
data/lib/isodoc/xref/xref_gen.rb
CHANGED
@@ -7,6 +7,10 @@ module IsoDoc
|
|
7
7
|
recommendation permission figure table formula
|
8
8
|
admonition sourcecode).freeze
|
9
9
|
|
10
|
+
def blank?(text)
|
11
|
+
text.nil? || text.empty?
|
12
|
+
end
|
13
|
+
|
10
14
|
def amend_preprocess(xmldoc)
|
11
15
|
xmldoc.xpath(ns("//amend[newcontent]")).each do |a|
|
12
16
|
autonum = amend_autonums(a)
|
@@ -39,11 +43,9 @@ module IsoDoc
|
|
39
43
|
end
|
40
44
|
|
41
45
|
def termnote_anchor_names(docxml)
|
42
|
-
docxml.xpath(ns("//term[
|
46
|
+
docxml.xpath(ns("//term[termnote]")).each do |t|
|
43
47
|
c = Counter.new
|
44
|
-
t.xpath(ns("
|
45
|
-
next if n["id"].nil? || n["id"].empty?
|
46
|
-
|
48
|
+
t.xpath(ns("./termnote")).reject { |n| blank?(n["id"]) }.each do |n|
|
47
49
|
c.increment(n)
|
48
50
|
@anchors[n["id"]] =
|
49
51
|
{ label: termnote_label(c.print), type: "termnote", value: c.print,
|
@@ -54,18 +56,18 @@ module IsoDoc
|
|
54
56
|
end
|
55
57
|
|
56
58
|
def termexample_anchor_names(docxml)
|
57
|
-
docxml.xpath(ns("//term[
|
58
|
-
examples = t.xpath(ns("
|
59
|
+
docxml.xpath(ns("//term[termexample]")).each do |t|
|
60
|
+
examples = t.xpath(ns("./termexample"))
|
59
61
|
c = Counter.new
|
60
|
-
examples.each do |n|
|
61
|
-
next if n["id"].nil? || n["id"].empty?
|
62
|
-
|
62
|
+
examples.reject { |n| blank?(n["id"]) }.each do |n|
|
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
|
-
|
68
|
-
|
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"])
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
@@ -127,9 +129,7 @@ module IsoDoc
|
|
127
129
|
notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
|
128
130
|
s.xpath(ns(".//appendix//ol")) - s.xpath(ns(".//ol//ol"))
|
129
131
|
c = Counter.new
|
130
|
-
notes.each do |n|
|
131
|
-
next if n["id"].nil? || n["id"].empty?
|
132
|
-
|
132
|
+
notes.reject { |n| blank?(n["id"]) }.each do |n|
|
133
133
|
@anchors[n["id"]] = anchor_struct(increment_label(notes, n, c), n,
|
134
134
|
@labels["list"], "list", false)
|
135
135
|
list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
|
@@ -158,9 +158,7 @@ module IsoDoc
|
|
158
158
|
notes = s.xpath(ns(".//dl")) - s.xpath(ns(".//clause//dl")) -
|
159
159
|
s.xpath(ns(".//appendix//dl")) - s.xpath(ns(".//dl//dl"))
|
160
160
|
c = Counter.new
|
161
|
-
notes.each do |n|
|
162
|
-
next if n["id"].nil? || n["id"].empty?
|
163
|
-
|
161
|
+
notes.reject { |n| blank?(n["id"]) }.each do |n|
|
164
162
|
@anchors[n["id"]] =
|
165
163
|
anchor_struct(increment_label(notes, n, c), n,
|
166
164
|
@labels["deflist"], "deflist", false)
|
@@ -183,10 +181,8 @@ module IsoDoc
|
|
183
181
|
end
|
184
182
|
end
|
185
183
|
|
186
|
-
def bookmark_anchor_names(
|
187
|
-
|
188
|
-
next if n["id"].nil? || n["id"].empty?
|
189
|
-
|
184
|
+
def bookmark_anchor_names(xml)
|
185
|
+
xml.xpath(ns(".//bookmark")).reject { |n| blank?(n["id"]) }.each do |n|
|
190
186
|
parent = nil
|
191
187
|
n.ancestors.each do |a|
|
192
188
|
next unless a["id"] && parent = @anchors.dig(a["id"], :xref)
|
@@ -34,8 +34,7 @@ module IsoDoc::XrefGen
|
|
34
34
|
|
35
35
|
def sequential_table_names(clause)
|
36
36
|
c = Counter.new
|
37
|
-
clause.xpath(ns(".//table")).each do |t|
|
38
|
-
next if t["id"].nil? || t["id"].empty?
|
37
|
+
clause.xpath(ns(".//table")).reject { |n| blank?(n["id"]) }.each do |t|
|
39
38
|
|
40
39
|
@anchors[t["id"]] = anchor_struct(
|
41
40
|
c.increment(t).print, nil,
|
@@ -46,8 +45,7 @@ module IsoDoc::XrefGen
|
|
46
45
|
|
47
46
|
def sequential_formula_names(clause)
|
48
47
|
c = Counter.new
|
49
|
-
clause.xpath(ns(".//formula")).each do |t|
|
50
|
-
next if t["id"].nil? || t["id"].empty?
|
48
|
+
clause.xpath(ns(".//formula")).reject { |n| blank?(n["id"]) }.each do |t|
|
51
49
|
|
52
50
|
@anchors[t["id"]] = anchor_struct(
|
53
51
|
c.increment(t).print, t,
|
@@ -62,8 +60,8 @@ module IsoDoc::XrefGen
|
|
62
60
|
|
63
61
|
def sequential_permission_names(clause, klass, label)
|
64
62
|
c = Counter.new
|
65
|
-
clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}"))
|
66
|
-
|
63
|
+
clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}"))
|
64
|
+
.reject { |n| blank?(n["id"]) }.each do |t|
|
67
65
|
|
68
66
|
id = c.increment(t).print
|
69
67
|
@anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
|
@@ -82,8 +80,7 @@ module IsoDoc::XrefGen
|
|
82
80
|
|
83
81
|
def sequential_permission_names1(block, lbl, klass, label)
|
84
82
|
c = Counter.new
|
85
|
-
block.xpath(ns("./#{klass}")).each do |t|
|
86
|
-
next if t["id"].nil? || t["id"].empty?
|
83
|
+
block.xpath(ns("./#{klass}")).reject { |n| blank?(n["id"]) }.each do |t|
|
87
84
|
|
88
85
|
id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
|
89
86
|
@anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
|
@@ -118,8 +115,7 @@ module IsoDoc::XrefGen
|
|
118
115
|
|
119
116
|
def hierarchical_table_names(clause, num)
|
120
117
|
c = Counter.new
|
121
|
-
clause.xpath(ns(".//table")).each do |t|
|
122
|
-
next if t["id"].nil? || t["id"].empty?
|
118
|
+
clause.xpath(ns(".//table")).reject { |n| blank?(n["id"]) }.each do |t|
|
123
119
|
|
124
120
|
@anchors[t["id"]] =
|
125
121
|
anchor_struct("#{num}#{hiersep}#{c.increment(t).print}",
|
@@ -141,8 +137,7 @@ module IsoDoc::XrefGen
|
|
141
137
|
|
142
138
|
def hierarchical_formula_names(clause, num)
|
143
139
|
c = Counter.new
|
144
|
-
clause.xpath(ns(".//formula")).each do |t|
|
145
|
-
next if t["id"].nil? || t["id"].empty?
|
140
|
+
clause.xpath(ns(".//formula")).reject { |n| blank?(n["id"]) }.each do |t|
|
146
141
|
|
147
142
|
@anchors[t["id"]] = anchor_struct(
|
148
143
|
"#{num}#{hiersep}#{c.increment(t).print}", nil,
|
@@ -154,8 +149,8 @@ module IsoDoc::XrefGen
|
|
154
149
|
|
155
150
|
def hierarchical_permission_names(clause, num, klass, label)
|
156
151
|
c = Counter.new
|
157
|
-
clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}"))
|
158
|
-
|
152
|
+
clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}"))
|
153
|
+
.reject { |n| blank?(n["id"]) }.each do |t|
|
159
154
|
|
160
155
|
id = "#{num}#{hiersep}#{c.increment(t).print}"
|
161
156
|
@anchors[t["id"]] =
|
@@ -175,8 +170,7 @@ module IsoDoc::XrefGen
|
|
175
170
|
|
176
171
|
def hierarchical_permission_names1(block, lbl, klass, label)
|
177
172
|
c = Counter.new
|
178
|
-
block.xpath(ns("./#{klass}")).each do |t|
|
179
|
-
next if t["id"].nil? || t["id"].empty?
|
173
|
+
block.xpath(ns("./#{klass}")).reject { |n| blank?(n["id"]) }.each do |t|
|
180
174
|
|
181
175
|
id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
|
182
176
|
@anchors[t["id"]] =
|