isodoc 3.1.1 → 3.1.2
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 +2 -12
- data/lib/isodoc/common.rb +2 -0
- data/lib/isodoc/function/blocks.rb +12 -0
- data/lib/isodoc/function/cleanup.rb +4 -12
- data/lib/isodoc/function/footnotes.rb +57 -0
- data/lib/isodoc/function/inline.rb +10 -6
- data/lib/isodoc/function/section.rb +7 -0
- data/lib/isodoc/function/setup.rb +64 -0
- data/lib/isodoc/function/table.rb +2 -0
- data/lib/isodoc/function/to_word_html.rb +5 -57
- data/lib/isodoc/function/utils.rb +4 -7
- data/lib/isodoc/headlesshtml_convert.rb +0 -2
- data/lib/isodoc/html_convert.rb +0 -2
- data/lib/isodoc/html_function/postprocess.rb +2 -1
- data/lib/isodoc/html_function/postprocess_footnotes.rb +2 -1
- data/lib/isodoc/pdf_convert.rb +0 -2
- data/lib/isodoc/presentation_function/block.rb +21 -25
- data/lib/isodoc/presentation_function/concepts.rb +7 -8
- data/lib/isodoc/presentation_function/erefs.rb +2 -3
- data/lib/isodoc/presentation_function/footnotes.rb +140 -0
- data/lib/isodoc/presentation_function/image.rb +0 -18
- data/lib/isodoc/presentation_function/inline.rb +11 -13
- data/lib/isodoc/presentation_function/refs.rb +9 -4
- data/lib/isodoc/presentation_function/sourcecode.rb +2 -19
- data/lib/isodoc/presentation_xml_convert.rb +3 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +5 -3
- data/lib/isodoc/word_function/footnotes.rb +57 -68
- data/lib/isodoc/word_function/postprocess.rb +6 -2
- data/lib/isodoc/xref/xref_gen.rb +1 -9
- data/lib/isodoc/xref/xref_gen_seq.rb +47 -92
- data/lib/isodoc/xref/xref_util.rb +49 -0
- metadata +19 -3
- data/lib/isodoc/html_function/footnotes.rb +0 -92
@@ -1,20 +1,9 @@
|
|
1
1
|
require_relative "../function/utils"
|
2
|
+
require_relative "xref_util"
|
2
3
|
|
3
4
|
module IsoDoc
|
4
5
|
module XrefGen
|
5
6
|
module Blocks
|
6
|
-
def hiersep
|
7
|
-
"."
|
8
|
-
end
|
9
|
-
|
10
|
-
def hierfigsep
|
11
|
-
"-"
|
12
|
-
end
|
13
|
-
|
14
|
-
def hierreqtsep
|
15
|
-
"-"
|
16
|
-
end
|
17
|
-
|
18
7
|
def subfigure_increment(idx, counter, elem)
|
19
8
|
if elem.parent.name == "figure" then idx += 1
|
20
9
|
else
|
@@ -54,33 +43,11 @@ module IsoDoc
|
|
54
43
|
end
|
55
44
|
end
|
56
45
|
|
57
|
-
def hier_separator(markup: false)
|
58
|
-
h = hiersep
|
59
|
-
h.blank? || !markup or h = delim_wrap(h)
|
60
|
-
h
|
61
|
-
end
|
62
|
-
|
63
46
|
def subfigure_label(subfignum)
|
64
47
|
subfignum.zero? and return
|
65
48
|
subfignum.to_s
|
66
49
|
end
|
67
50
|
|
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
51
|
def figure_anchor(elem, sublabel, label, klass, container: false)
|
85
52
|
if sublabel
|
86
53
|
/<semx/.match?(label) or label = semx(elem.parent, label)
|
@@ -106,11 +73,11 @@ module IsoDoc
|
|
106
73
|
)
|
107
74
|
if elem["unnumbered"] != "true"
|
108
75
|
x = "#{subfigure_separator(markup: true)}#{semx(elem, sublabel)}"
|
109
|
-
@anchors[elem["id"]][:label] = "#{label}#{x}"
|
76
|
+
@anchors[elem["id"]][:label] = "#{label}#{x}"
|
110
77
|
@anchors[elem["id"]][:xref] = @anchors[elem.parent["id"]][:xref] + x +
|
111
78
|
delim_wrap(subfigure_delim)
|
112
79
|
x = @anchors[elem.parent["id"]][:container] and
|
113
|
-
|
80
|
+
@anchors[elem["id"]][:container] = x
|
114
81
|
end
|
115
82
|
end
|
116
83
|
|
@@ -119,8 +86,8 @@ module IsoDoc
|
|
119
86
|
clause.xpath(ns(".//table")).noblank.each do |t|
|
120
87
|
# labelled_ancestor(t) and next
|
121
88
|
@anchors[t["id"]] = anchor_struct(
|
122
|
-
c.increment(t).print, t,
|
123
|
-
|
89
|
+
c.increment(t).print, t, @labels["table"], "table",
|
90
|
+
{ unnumb: t["unnumbered"], container: container }
|
124
91
|
)
|
125
92
|
end
|
126
93
|
end
|
@@ -183,8 +150,9 @@ container: false)
|
|
183
150
|
x = "#{subreqt_separator(markup: true)}#{semx(elem, id)}"
|
184
151
|
@anchors[elem["id"]][:semx] = @anchors[elem.parent["id"]][:semx] + x
|
185
152
|
@anchors[elem["id"]][:label] =
|
186
|
-
"<span class='fmt-element-name'>#{label}</span> #{@anchors[elem[
|
187
|
-
@anchors[elem["id"]][:xref] =
|
153
|
+
"<span class='fmt-element-name'>#{label}</span> #{@anchors[elem['id']][:semx]}"
|
154
|
+
@anchors[elem["id"]][:xref] =
|
155
|
+
"<span class='fmt-element-name'>#{label}</span> #{@anchors[elem['id']][:semx]}"
|
188
156
|
end
|
189
157
|
model.permission_parts(elem, id, label, klass).each do |n|
|
190
158
|
@anchors[n[:id]] = anchor_struct(n[:number], n[:elem], n[:label],
|
@@ -217,31 +185,19 @@ container: false)
|
|
217
185
|
sequential_permission_names(clause, container:)
|
218
186
|
end
|
219
187
|
|
220
|
-
def nodeSet(clauses)
|
221
|
-
case clauses
|
222
|
-
when Nokogiri::XML::Node
|
223
|
-
[clauses]
|
224
|
-
when Nokogiri::XML::NodeSet
|
225
|
-
clauses
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
188
|
# these can take a NodeSet as argument; semx will point to members of the NodeSet,
|
230
189
|
# but numbering will be consecutive
|
231
190
|
def hierarchical_figure_names(clauses, num)
|
232
191
|
c = Counter.new
|
233
192
|
j = 0
|
234
193
|
nodeSet(clauses).each do |clause|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
figure_anchor(t, sublabel, hiersemx(clause, num, c, t), "figure")
|
243
|
-
end
|
244
|
-
hierarchical_figure_class_names(clause, num)
|
194
|
+
clause.xpath(ns(self.class::FIGURE_NO_CLASS)).noblank.each do |t|
|
195
|
+
# labelled_ancestor(t, %w(figure)) and next
|
196
|
+
j = subfigure_increment(j, c, t)
|
197
|
+
sublabel = subfigure_label(j)
|
198
|
+
figure_anchor(t, sublabel, hiersemx(clause, num, c, t), "figure")
|
199
|
+
end
|
200
|
+
hierarchical_figure_class_names(clause, num)
|
245
201
|
end
|
246
202
|
end
|
247
203
|
|
@@ -249,29 +205,27 @@ container: false)
|
|
249
205
|
c = {}
|
250
206
|
j = 0
|
251
207
|
nodeSet(clauses).each do |clause|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
end
|
208
|
+
clause.xpath(ns(".//figure[@class][not(@class = 'pseudocode')]"))
|
209
|
+
.noblank.each do |t|
|
210
|
+
# labelled_ancestor(t, %w(figure)) and next
|
211
|
+
c[t["class"]] ||= Counter.new
|
212
|
+
j = subfigure_increment(j, c[t["class"]], t)
|
213
|
+
sublabel = subfigure_label(j)
|
214
|
+
figure_anchor(t, sublabel, hiersemx(clause, num, c[t["class"]], t),
|
215
|
+
t["class"])
|
216
|
+
end
|
262
217
|
end
|
263
218
|
end
|
264
219
|
|
265
220
|
def hierarchical_table_names(clauses, num)
|
266
221
|
c = Counter.new
|
267
222
|
nodeSet(clauses).each do |clause|
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
end
|
223
|
+
clause.xpath(ns(".//table")).noblank.each do |t|
|
224
|
+
# labelled_ancestor(t) and next
|
225
|
+
@anchors[t["id"]] =
|
226
|
+
anchor_struct(hiersemx(clause, num, c.increment(t), t),
|
227
|
+
t, @labels["table"], "table", { unnumb: t["unnumbered"], container: false })
|
228
|
+
end
|
275
229
|
end
|
276
230
|
end
|
277
231
|
|
@@ -285,29 +239,30 @@ container: false)
|
|
285
239
|
def hierarchical_formula_names(clauses, num)
|
286
240
|
c = Counter.new
|
287
241
|
nodeSet(clauses).each do |clause|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
242
|
+
clause.xpath(ns(".//formula")).noblank.each do |t|
|
243
|
+
@anchors[t["id"]] = anchor_struct(
|
244
|
+
# "#{num}#{hier_separator}#{c.increment(t).print}", t,
|
245
|
+
hiersemx(clause, num, c.increment(t), t), t,
|
246
|
+
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
247
|
+
"formula", { unnumb: t["unnumbered"], container: false }
|
248
|
+
)
|
249
|
+
end
|
296
250
|
end
|
297
251
|
end
|
298
252
|
|
299
253
|
def hierarchical_permission_names(clauses, num)
|
300
254
|
c = ReqCounter.new
|
301
255
|
nodeSet(clauses).each do |clause|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
256
|
+
clause.xpath(ns(FIRST_LVL_REQ)).noblank.each do |t|
|
257
|
+
m = @reqt_models.model(t["model"])
|
258
|
+
klass, label = reqt2class_label(t, m)
|
259
|
+
# id = "#{num}#{hier_separator}#{c.increment(label, t).print}"
|
260
|
+
id = hiersemx(clause, num, c.increment(label, t), t)
|
261
|
+
sequential_permission_body(id, nil, t, label, klass, m,
|
262
|
+
container: false)
|
263
|
+
sequential_permission_children(t, id, klass, container: false)
|
264
|
+
end
|
309
265
|
end
|
310
|
-
end
|
311
266
|
end
|
312
267
|
end
|
313
268
|
end
|
@@ -23,6 +23,49 @@ module IsoDoc
|
|
23
23
|
xpath.reject { |n| blank?(n["id"]) }
|
24
24
|
end
|
25
25
|
|
26
|
+
def hiersep
|
27
|
+
"."
|
28
|
+
end
|
29
|
+
|
30
|
+
def hierfigsep
|
31
|
+
"-"
|
32
|
+
end
|
33
|
+
|
34
|
+
def hierreqtsep
|
35
|
+
"-"
|
36
|
+
end
|
37
|
+
|
38
|
+
def hier_separator(markup: false)
|
39
|
+
h = hiersep
|
40
|
+
h.blank? || !markup or h = delim_wrap(h)
|
41
|
+
h
|
42
|
+
end
|
43
|
+
|
44
|
+
def subfigure_separator(markup: false)
|
45
|
+
h = hierfigsep
|
46
|
+
h.blank? || !markup or h = delim_wrap(h)
|
47
|
+
h
|
48
|
+
end
|
49
|
+
|
50
|
+
def subreqt_separator(markup: false)
|
51
|
+
h = hierreqtsep
|
52
|
+
h.blank? || !markup or h = delim_wrap(h)
|
53
|
+
h
|
54
|
+
end
|
55
|
+
|
56
|
+
def subfigure_delim
|
57
|
+
""
|
58
|
+
end
|
59
|
+
|
60
|
+
def nodeSet(clauses)
|
61
|
+
case clauses
|
62
|
+
when Nokogiri::XML::Node
|
63
|
+
[clauses]
|
64
|
+
when Nokogiri::XML::NodeSet
|
65
|
+
clauses
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
26
69
|
SECTIONS_XPATH =
|
27
70
|
"//foreword | //introduction | //acknowledgements | " \
|
28
71
|
"//preface/abstract | " \
|
@@ -85,6 +128,12 @@ module IsoDoc
|
|
85
128
|
label.blank? and return autonum
|
86
129
|
l10n("<span class='fmt-element-name'>#{label}</span> #{autonum}")
|
87
130
|
end
|
131
|
+
|
132
|
+
def increment_label(elems, node, counter, increment: true)
|
133
|
+
elems.size == 1 && !node["number"] and return ""
|
134
|
+
counter.increment(node) if increment
|
135
|
+
counter.print
|
136
|
+
end
|
88
137
|
end
|
89
138
|
end
|
90
139
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isodoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -178,6 +178,20 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: lutaml-model
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 0.6.0
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 0.6.0
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: bigdecimal
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -417,6 +431,7 @@ files:
|
|
417
431
|
- lib/isodoc/function/blocks.rb
|
418
432
|
- lib/isodoc/function/blocks_example_note.rb
|
419
433
|
- lib/isodoc/function/cleanup.rb
|
434
|
+
- lib/isodoc/function/footnotes.rb
|
420
435
|
- lib/isodoc/function/form.rb
|
421
436
|
- lib/isodoc/function/inline.rb
|
422
437
|
- lib/isodoc/function/inline_simple.rb
|
@@ -425,6 +440,7 @@ files:
|
|
425
440
|
- lib/isodoc/function/reqt.rb
|
426
441
|
- lib/isodoc/function/section.rb
|
427
442
|
- lib/isodoc/function/section_titles.rb
|
443
|
+
- lib/isodoc/function/setup.rb
|
428
444
|
- lib/isodoc/function/table.rb
|
429
445
|
- lib/isodoc/function/terms.rb
|
430
446
|
- lib/isodoc/function/to_word_html.rb
|
@@ -434,7 +450,6 @@ files:
|
|
434
450
|
- lib/isodoc/html_convert.rb
|
435
451
|
- lib/isodoc/html_function.rb
|
436
452
|
- lib/isodoc/html_function/comments.rb
|
437
|
-
- lib/isodoc/html_function/footnotes.rb
|
438
453
|
- lib/isodoc/html_function/form.rb
|
439
454
|
- lib/isodoc/html_function/html.rb
|
440
455
|
- lib/isodoc/html_function/mathvariant_to_plain.rb
|
@@ -453,6 +468,7 @@ files:
|
|
453
468
|
- lib/isodoc/presentation_function/concepts.rb
|
454
469
|
- lib/isodoc/presentation_function/docid.rb
|
455
470
|
- lib/isodoc/presentation_function/erefs.rb
|
471
|
+
- lib/isodoc/presentation_function/footnotes.rb
|
456
472
|
- lib/isodoc/presentation_function/image.rb
|
457
473
|
- lib/isodoc/presentation_function/index.rb
|
458
474
|
- lib/isodoc/presentation_function/inline.rb
|
@@ -1,92 +0,0 @@
|
|
1
|
-
module IsoDoc
|
2
|
-
module HtmlFunction
|
3
|
-
module Footnotes
|
4
|
-
def footnotes(div)
|
5
|
-
return if @footnotes.empty?
|
6
|
-
|
7
|
-
@footnotes.each { |fn| div.parent << fn }
|
8
|
-
end
|
9
|
-
|
10
|
-
def make_table_footnote_link(out, fnid, fnref)
|
11
|
-
attrs = { href: "##{fnid}", class: "TableFootnoteRef" }
|
12
|
-
out.a **attrs do |a|
|
13
|
-
a << fnref
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def make_table_footnote_target(out, fnid, fnref)
|
18
|
-
attrs = { id: fnid, class: "TableFootnoteRef" }
|
19
|
-
out.span do |s|
|
20
|
-
out.span **attrs do |a|
|
21
|
-
a << fnref
|
22
|
-
end
|
23
|
-
insert_tab(s, 1)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Move to Presentation XML, as <fmt-footnote>: it's a footnote body
|
28
|
-
def make_table_footnote_text(node, fnid, fnref)
|
29
|
-
attrs = { id: "fn:#{fnid}" }
|
30
|
-
noko do |xml|
|
31
|
-
xml.div **attr_code(attrs) do |div|
|
32
|
-
make_table_footnote_target(div, fnid, fnref)
|
33
|
-
node.children.each { |n| parse(n, div) }
|
34
|
-
end
|
35
|
-
end.join("\n")
|
36
|
-
end
|
37
|
-
|
38
|
-
def make_generic_footnote_text(node, fnid)
|
39
|
-
noko do |xml|
|
40
|
-
xml.aside id: "fn:#{fnid}", class: "footnote" do |div|
|
41
|
-
node.children.each { |n| parse(n, div) }
|
42
|
-
end
|
43
|
-
end.join("\n")
|
44
|
-
end
|
45
|
-
|
46
|
-
def get_table_ancestor_id(node)
|
47
|
-
table = node.ancestors("table") || node.ancestors("figure")
|
48
|
-
return UUIDTools::UUID.random_create.to_s if table.empty?
|
49
|
-
|
50
|
-
table.last["id"]
|
51
|
-
end
|
52
|
-
|
53
|
-
# @seen_footnote:
|
54
|
-
# do not output footnote text if we have already seen it for this table
|
55
|
-
|
56
|
-
def table_footnote_parse(node, out)
|
57
|
-
fn = node["reference"] || UUIDTools::UUID.random_create.to_s
|
58
|
-
tid = get_table_ancestor_id(node)
|
59
|
-
make_table_footnote_link(out, tid + fn, fn)
|
60
|
-
return if @seen_footnote.include?(tid + fn)
|
61
|
-
|
62
|
-
@in_footnote = true
|
63
|
-
out.aside class: "footnote" do |a|
|
64
|
-
a << make_table_footnote_text(node, tid + fn, fn)
|
65
|
-
end
|
66
|
-
@in_footnote = false
|
67
|
-
@seen_footnote << (tid + fn)
|
68
|
-
end
|
69
|
-
|
70
|
-
def footnote_parse(node, out)
|
71
|
-
return table_footnote_parse(node, out) if (@in_table || @in_figure) &&
|
72
|
-
!node.ancestors.map(&:name).include?("fmt-name")
|
73
|
-
|
74
|
-
fn = node["reference"] || UUIDTools::UUID.random_create.to_s
|
75
|
-
attrs = { class: "FootnoteRef", href: "#fn:#{fn}" }
|
76
|
-
out.a **attrs do |a|
|
77
|
-
a.sup { |sup| sup << fn }
|
78
|
-
end
|
79
|
-
make_footnote(node, fn)
|
80
|
-
end
|
81
|
-
|
82
|
-
def make_footnote(node, fnote)
|
83
|
-
return if @seen_footnote.include?(fnote)
|
84
|
-
|
85
|
-
@in_footnote = true
|
86
|
-
@footnotes << make_generic_footnote_text(node, fnote)
|
87
|
-
@in_footnote = false
|
88
|
-
@seen_footnote << fnote
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|