isodoc 1.8.1 → 1.8.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/Gemfile +2 -0
- data/isodoc.gemspec +1 -1
- data/lib/isodoc/class_utils.rb +1 -1
- data/lib/isodoc/function/cleanup.rb +1 -11
- data/lib/isodoc/function/inline.rb +3 -3
- 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 +95 -30
- 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/lib/isodoc-yaml/i18n-ar.yaml +3 -0
- data/lib/isodoc-yaml/i18n-de.yaml +3 -0
- data/lib/isodoc-yaml/i18n-en.yaml +8 -5
- data/lib/isodoc-yaml/i18n-es.yaml +3 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +3 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +3 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +3 -0
- data/spec/isodoc/cleanup_spec.rb +0 -129
- data/spec/isodoc/i18n_spec.rb +53 -10
- data/spec/isodoc/inline_spec.rb +33 -43
- data/spec/isodoc/lists_spec.rb +64 -64
- data/spec/isodoc/postproc_spec.rb +0 -73
- data/spec/isodoc/section_spec.rb +12 -12
- data/spec/isodoc/terms_spec.rb +317 -303
- data/spec/isodoc/xref_spec.rb +80 -9
- data/spec/isodoc/xslfo_convert_spec.rb +35 -0
- data/spec/spec_helper.rb +1 -1
- metadata +8 -8
@@ -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
|
@@ -4,8 +4,7 @@ module IsoDoc
|
|
4
4
|
def back_anchor_names(docxml)
|
5
5
|
i = Counter.new("@")
|
6
6
|
docxml.xpath(ns("//annex")).each do |c|
|
7
|
-
i.increment(c)
|
8
|
-
annex_names(c, i.print)
|
7
|
+
annex_names(c, i.increment(c).print)
|
9
8
|
end
|
10
9
|
docxml.xpath(ns(@klass.bibliography_xpath)).each do |b|
|
11
10
|
preface_names(b)
|
@@ -86,8 +85,7 @@ module IsoDoc
|
|
86
85
|
level: lvl, type: "clause" }
|
87
86
|
i = Counter.new
|
88
87
|
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
89
|
-
i.increment(c)
|
90
|
-
section_names1(c, "#{num.print}.#{i.print}", lvl + 1)
|
88
|
+
section_names1(c, "#{num.print}.#{i.increment(c).print}", lvl + 1)
|
91
89
|
end
|
92
90
|
num
|
93
91
|
end
|
@@ -98,8 +96,7 @@ module IsoDoc
|
|
98
96
|
type: "clause" }
|
99
97
|
i = Counter.new
|
100
98
|
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
101
|
-
i.increment(c)
|
102
|
-
section_names1(c, "#{num}.#{i.print}", level + 1)
|
99
|
+
section_names1(c, "#{num}.#{i.increment(c).print}", level + 1)
|
103
100
|
end
|
104
101
|
end
|
105
102
|
|
@@ -129,8 +126,7 @@ module IsoDoc
|
|
129
126
|
else
|
130
127
|
i = Counter.new
|
131
128
|
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
132
|
-
i.increment(c)
|
133
|
-
annex_names1(c, "#{num}.#{i.print}", 2)
|
129
|
+
annex_names1(c, "#{num}.#{i.increment(c).print}", 2)
|
134
130
|
end
|
135
131
|
end
|
136
132
|
hierarchical_asset_names(clause, num)
|
@@ -141,8 +137,7 @@ module IsoDoc
|
|
141
137
|
label: num, level: level, type: "clause" }
|
142
138
|
i = Counter.new
|
143
139
|
clause.xpath(ns(SUBCLAUSES)).each do |c|
|
144
|
-
i.increment(c)
|
145
|
-
annex_names1(c, "#{num}.#{i.print}", level + 1)
|
140
|
+
annex_names1(c, "#{num}.#{i.increment(c).print}", level + 1)
|
146
141
|
end
|
147
142
|
end
|
148
143
|
|
data/lib/isodoc/xref.rb
CHANGED
@@ -4,12 +4,14 @@ require_relative "xref/xref_gen_seq"
|
|
4
4
|
require_relative "xref/xref_gen"
|
5
5
|
require_relative "xref/xref_sect_gen"
|
6
6
|
require_relative "class_utils"
|
7
|
+
require_relative "function/utils"
|
7
8
|
|
8
9
|
module IsoDoc
|
9
10
|
class Xref
|
10
11
|
include XrefGen::Anchor
|
11
12
|
include XrefGen::Blocks
|
12
13
|
include XrefGen::Sections
|
14
|
+
include Function::Utils
|
13
15
|
|
14
16
|
attr_reader :klass
|
15
17
|
|
data/lib/isodoc/xslfo_convert.rb
CHANGED
@@ -8,9 +8,30 @@ module IsoDoc
|
|
8
8
|
def initialize(options)
|
9
9
|
@format = :pdf
|
10
10
|
@suffix = "pdf"
|
11
|
+
@pdf_cmd_options = extract_cmd_options(options)
|
11
12
|
super
|
12
13
|
end
|
13
14
|
|
15
|
+
def extract_cmd_options(options)
|
16
|
+
ret = {}
|
17
|
+
a = options[:pdfencryptionlength] and ret["--encryption-length"] = a
|
18
|
+
a = options[:pdfownerpassword] and ret["--owner-password"] = a
|
19
|
+
a = options[:pdfuserpassword] and ret["--user-password"] = a
|
20
|
+
a = options[:pdfallowprint] and ret["--allow-print"] = a
|
21
|
+
a = options[:pdfallowcopycontent] and ret["--allow-copy-content"] = a
|
22
|
+
a = options[:pdfalloweditcontent] and ret["--allow-edit-content"] = a
|
23
|
+
a = options[:pdfalloweditannotations] and
|
24
|
+
ret["--allow-edit-annotations"] = a
|
25
|
+
a = options[:pdfallowfillinforms] and ret["--allow-fill-in-forms"] = a
|
26
|
+
a = options[:pdfallowaccesscontent] and
|
27
|
+
ret["--allow-access-content"] = a
|
28
|
+
a = options[:pdfallowassembledocument] and
|
29
|
+
ret["--allow-assemble-document"] = a
|
30
|
+
a = options[:pdfallowprinthq] and ret["--allow-print-hq"] = a
|
31
|
+
a = options[:pdfencryptmetadata] and ret["--encrypt-metadata"] = a
|
32
|
+
ret
|
33
|
+
end
|
34
|
+
|
14
35
|
def tmpimagedir_suffix
|
15
36
|
"_pdfimages"
|
16
37
|
end
|
@@ -29,7 +50,7 @@ module IsoDoc
|
|
29
50
|
@aligncrosselements.gsub(/,/, " ")
|
30
51
|
@baseassetpath and
|
31
52
|
ret["--param baseassetpath="] = @baseassetpath
|
32
|
-
ret
|
53
|
+
ret.merge(@pdf_cmd_options)
|
33
54
|
end
|
34
55
|
|
35
56
|
def convert(input_filename, file = nil, debug = false,
|
@@ -37,6 +58,7 @@ module IsoDoc
|
|
37
58
|
file = File.read(input_filename, encoding: "utf-8") if file.nil?
|
38
59
|
input_filename, docxml, filename = input_xml_path(input_filename,
|
39
60
|
file, debug)
|
61
|
+
warn pdf_options(docxml).merge(@options)
|
40
62
|
::Metanorma::Output::XslfoPdf.new.convert(
|
41
63
|
input_filename,
|
42
64
|
output_filename || "#{filename}.#{@suffix}",
|
@@ -100,16 +100,19 @@ locality: {
|
|
100
100
|
formula: Formula
|
101
101
|
}
|
102
102
|
grammar_abbrevs:
|
103
|
-
masculine:
|
104
|
-
feminine:
|
105
|
-
neuter:
|
103
|
+
masculine: m
|
104
|
+
feminine: f
|
105
|
+
neuter: n
|
106
106
|
common: common
|
107
|
+
singular: sg
|
108
|
+
dual: dual
|
109
|
+
pl: pl
|
107
110
|
isPreposition: prep
|
108
111
|
isParticiple: part
|
109
112
|
isAdjective: adj
|
110
113
|
isAdverb: adv
|
111
|
-
isNoun:
|
112
|
-
isVerb:
|
114
|
+
isNoun: noun
|
115
|
+
isVerb: verb
|
113
116
|
relatedterms:
|
114
117
|
deprecates: deprecates
|
115
118
|
supersedes: supersedes
|