isodoc 1.7.3.1 → 1.7.6.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 +7 -4
- data/lib/isodoc/class_utils.rb +2 -2
- data/lib/isodoc/convert.rb +2 -0
- data/lib/isodoc/function/blocks_example_note.rb +85 -79
- data/lib/isodoc/function/cleanup.rb +181 -175
- data/lib/isodoc/function/inline.rb +110 -108
- data/lib/isodoc/function/inline_simple.rb +55 -55
- data/lib/isodoc/function/lists.rb +75 -71
- data/lib/isodoc/function/references.rb +165 -160
- data/lib/isodoc/function/section.rb +140 -190
- data/lib/isodoc/function/section_titles.rb +82 -0
- data/lib/isodoc/function/table.rb +90 -87
- data/lib/isodoc/function/terms.rb +58 -56
- data/lib/isodoc/function/to_word_html.rb +3 -1
- data/lib/isodoc/function/utils.rb +34 -14
- data/lib/isodoc/html_function/comments.rb +107 -111
- data/lib/isodoc/html_function/footnotes.rb +68 -67
- data/lib/isodoc/html_function/html.rb +113 -103
- data/lib/isodoc/html_function/mathvariant_to_plain.rb +5 -3
- data/lib/isodoc/presentation_function/block.rb +73 -78
- data/lib/isodoc/presentation_function/concept.rb +68 -0
- data/lib/isodoc/presentation_function/image.rb +112 -0
- data/lib/isodoc/presentation_function/inline.rb +6 -39
- data/lib/isodoc/presentation_function/math.rb +9 -0
- data/lib/isodoc/presentation_function/section.rb +12 -1
- data/lib/isodoc/presentation_xml_convert.rb +3 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +176 -174
- data/lib/isodoc/word_function/comments.rb +117 -112
- data/lib/isodoc/word_function/footnotes.rb +88 -86
- data/lib/isodoc/word_function/inline.rb +42 -67
- data/lib/isodoc/word_function/postprocess_cover.rb +121 -110
- data/lib/isodoc/xref/xref_gen.rb +153 -150
- data/lib/isodoc/xslfo_convert.rb +2 -2
- data/spec/assets/odf.svg +1 -4
- data/spec/isodoc/blocks_spec.rb +187 -32
- data/spec/isodoc/inline_spec.rb +300 -116
- data/spec/isodoc/postproc_spec.rb +38 -0
- data/spec/isodoc/presentation_xml_spec.rb +144 -0
- data/spec/isodoc/section_spec.rb +764 -0
- data/spec/isodoc/terms_spec.rb +116 -0
- metadata +63 -18
@@ -1,251 +1,201 @@
|
|
1
|
-
|
2
|
-
module Section
|
3
|
-
def clausedelim
|
4
|
-
"."
|
5
|
-
end
|
6
|
-
|
7
|
-
def clausedelimspace(out)
|
8
|
-
insert_tab(out, 1)
|
9
|
-
end
|
10
|
-
|
11
|
-
def inline_header_title(out, _node, title)
|
12
|
-
out.span **{ class: "zzMoveToFollowing" } do |s|
|
13
|
-
s.b do |b|
|
14
|
-
title&.children&.each { |c2| parse(c2, b) }
|
15
|
-
clausedelimspace(out) if /\S/.match?(title&.text)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# used for subclauses
|
21
|
-
def clause_parse_title(node, div, title, out, header_class = {})
|
22
|
-
return if title.nil?
|
1
|
+
require_relative "./section_titles"
|
23
2
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
"acknowledgements, introduction, foreword").size + 1
|
30
|
-
end
|
31
|
-
div.send "h#{depth}", **attr_code(header_class) do |h|
|
32
|
-
title&.children&.each { |c2| parse(c2, h) }
|
33
|
-
end
|
3
|
+
module IsoDoc
|
4
|
+
module Function
|
5
|
+
module Section
|
6
|
+
def clause_attrs(node)
|
7
|
+
{ id: node["id"] }
|
34
8
|
end
|
35
|
-
end
|
36
9
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
clause_parse_title(node, div, node.at(ns("./title")), out)
|
45
|
-
node.children.reject { |c1| c1.name == "title" }.each do |c1|
|
46
|
-
parse(c1, div)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def clause_name(_num, title, div, header_class)
|
52
|
-
header_class = {} if header_class.nil?
|
53
|
-
div.h1 **attr_code(header_class) do |h1|
|
54
|
-
if title.is_a?(String)
|
55
|
-
h1 << title
|
56
|
-
else
|
57
|
-
title&.children&.each { |c2| parse(c2, h1) }
|
10
|
+
# used for subclauses
|
11
|
+
def clause_parse(node, out)
|
12
|
+
out.div **attr_code(clause_attrs(node)) do |div|
|
13
|
+
clause_parse_title(node, div, node.at(ns("./title")), out)
|
14
|
+
node.children.reject { |c1| c1.name == "title" }.each do |c1|
|
15
|
+
parse(c1, div)
|
16
|
+
end
|
58
17
|
end
|
59
18
|
end
|
60
|
-
div.parent.at(".//h1")
|
61
|
-
end
|
62
19
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
20
|
+
def clause(isoxml, out)
|
21
|
+
isoxml.xpath(ns(middle_clause(isoxml))).each do |c|
|
22
|
+
out.div **attr_code(clause_attrs(c)) do |s|
|
23
|
+
clause_name(nil, c&.at(ns("./title")), s, nil)
|
24
|
+
c.elements.reject { |c1| c1.name == "title" }.each do |c1|
|
25
|
+
parse(c1, s)
|
26
|
+
end
|
69
27
|
end
|
70
28
|
end
|
71
29
|
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def annex_name(_annex, name, div)
|
75
|
-
return if name.nil?
|
76
30
|
|
77
|
-
|
78
|
-
|
31
|
+
def annex_attrs(node)
|
32
|
+
{ id: node["id"], class: "Section3" }
|
79
33
|
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def annex_attrs(node)
|
83
|
-
{ id: node["id"], class: "Section3" }
|
84
|
-
end
|
85
34
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
35
|
+
def annex(isoxml, out)
|
36
|
+
isoxml.xpath(ns("//annex")).each do |c|
|
37
|
+
page_break(out)
|
38
|
+
out.div **attr_code(annex_attrs(c)) do |s|
|
39
|
+
c.elements.each do |c1|
|
40
|
+
if c1.name == "title" then annex_name(c, c1, s)
|
41
|
+
else
|
42
|
+
parse(c1, s)
|
43
|
+
end
|
94
44
|
end
|
95
45
|
end
|
96
46
|
end
|
97
47
|
end
|
98
|
-
end
|
99
48
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
49
|
+
def scope(isoxml, out, num)
|
50
|
+
f = isoxml.at(ns("//clause[@type = 'scope']")) or return num
|
51
|
+
out.div **attr_code(id: f["id"]) do |div|
|
52
|
+
num = num + 1
|
53
|
+
clause_name(num, f&.at(ns("./title")), div, nil)
|
54
|
+
f.elements.each do |e|
|
55
|
+
parse(e, div) unless e.name == "title"
|
56
|
+
end
|
107
57
|
end
|
58
|
+
num
|
108
59
|
end
|
109
|
-
num
|
110
|
-
end
|
111
60
|
|
112
|
-
|
113
|
-
|
61
|
+
TERM_CLAUSE = "//sections/terms | "\
|
62
|
+
"//sections/clause[descendant::terms]".freeze
|
114
63
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
64
|
+
def terms_defs(isoxml, out, num)
|
65
|
+
f = isoxml.at(ns(TERM_CLAUSE)) or return num
|
66
|
+
out.div **attr_code(id: f["id"]) do |div|
|
67
|
+
num = num + 1
|
68
|
+
clause_name(num, f&.at(ns("./title")), div, nil)
|
69
|
+
f.elements.each do |e|
|
70
|
+
parse(e, div) unless %w{title source}.include? e.name
|
71
|
+
end
|
122
72
|
end
|
73
|
+
num
|
123
74
|
end
|
124
|
-
num
|
125
|
-
end
|
126
|
-
|
127
|
-
# subclause
|
128
|
-
def terms_parse(isoxml, out)
|
129
|
-
clause_parse(isoxml, out)
|
130
|
-
end
|
131
75
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
num = num + 1
|
136
|
-
clause_name(num, f&.at(ns("./title")) || @i18n.symbols, div, nil)
|
137
|
-
f.elements.each do |e|
|
138
|
-
parse(e, div) unless e.name == "title"
|
139
|
-
end
|
76
|
+
# subclause
|
77
|
+
def terms_parse(isoxml, out)
|
78
|
+
clause_parse(isoxml, out)
|
140
79
|
end
|
141
|
-
num
|
142
|
-
end
|
143
|
-
|
144
|
-
# subclause
|
145
|
-
def symbols_parse(isoxml, out)
|
146
|
-
isoxml.at(ns("./title")) or
|
147
|
-
isoxml.children.first.previous = "<title>#{@i18n.symbols}</title>"
|
148
|
-
clause_parse(isoxml, out)
|
149
|
-
end
|
150
80
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
81
|
+
def symbols_abbrevs(isoxml, out, num)
|
82
|
+
f = isoxml.at(ns("//sections/definitions")) or return num
|
83
|
+
out.div **attr_code(id: f["id"], class: "Symbols") do |div|
|
84
|
+
num = num + 1
|
85
|
+
clause_name(num, f&.at(ns("./title")) || @i18n.symbols, div, nil)
|
86
|
+
f.elements.each do |e|
|
87
|
+
parse(e, div) unless e.name == "title"
|
88
|
+
end
|
158
89
|
end
|
90
|
+
num
|
159
91
|
end
|
160
|
-
end
|
161
92
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
{ class: "ForewordTitle" })
|
168
|
-
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
93
|
+
# subclause
|
94
|
+
def symbols_parse(isoxml, out)
|
95
|
+
isoxml.at(ns("./title")) or
|
96
|
+
isoxml.children.first.previous = "<title>#{@i18n.symbols}</title>"
|
97
|
+
clause_parse(isoxml, out)
|
169
98
|
end
|
170
|
-
end
|
171
99
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
100
|
+
def introduction(isoxml, out)
|
101
|
+
f = isoxml.at(ns("//introduction")) || return
|
102
|
+
page_break(out)
|
103
|
+
out.div **{ class: "Section3", id: f["id"] } do |div|
|
104
|
+
clause_name(nil, f.at(ns("./title")), div, { class: "IntroTitle" })
|
105
|
+
f.elements.each do |e|
|
106
|
+
parse(e, div) unless e.name == "title"
|
107
|
+
end
|
180
108
|
end
|
181
109
|
end
|
182
|
-
end
|
183
110
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
111
|
+
def foreword(isoxml, out)
|
112
|
+
f = isoxml.at(ns("//foreword")) || return
|
113
|
+
page_break(out)
|
114
|
+
out.div **attr_code(id: f["id"]) do |s|
|
115
|
+
clause_name(nil, f.at(ns("./title")) || @i18n.foreword, s,
|
116
|
+
{ class: "ForewordTitle" })
|
117
|
+
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
118
|
+
end
|
190
119
|
end
|
191
|
-
end
|
192
120
|
|
193
|
-
|
194
|
-
|
195
|
-
|
121
|
+
def acknowledgements(isoxml, out)
|
122
|
+
f = isoxml.at(ns("//acknowledgements")) || return
|
123
|
+
title_attr = { class: "IntroTitle" }
|
196
124
|
page_break(out)
|
197
125
|
out.div **{ class: "Section3", id: f["id"] } do |div|
|
198
|
-
clause_name(nil, f&.at(ns("./title")), div,
|
126
|
+
clause_name(nil, f&.at(ns("./title")), div, title_attr)
|
199
127
|
f.elements.each do |e|
|
200
128
|
parse(e, div) unless e.name == "title"
|
201
129
|
end
|
202
130
|
end
|
203
131
|
end
|
204
|
-
end
|
205
132
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
133
|
+
def abstract(isoxml, out)
|
134
|
+
f = isoxml.at(ns("//preface/abstract")) || return
|
135
|
+
page_break(out)
|
136
|
+
out.div **attr_code(id: f["id"]) do |s|
|
137
|
+
clause_name(nil, f.at(ns("./title")), s, { class: "AbstractTitle" })
|
138
|
+
f.elements.each { |e| parse(e, s) unless e.name == "title" }
|
139
|
+
end
|
140
|
+
end
|
210
141
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
142
|
+
def preface(isoxml, out)
|
143
|
+
isoxml.xpath(ns("//preface/clause | //preface/references | "\
|
144
|
+
"//preface/definitions | //preface/terms")).each do |f|
|
145
|
+
page_break(out)
|
146
|
+
out.div **{ class: "Section3", id: f["id"] } do |div|
|
147
|
+
clause_name(nil, f&.at(ns("./title")), div, { class: "IntroTitle" })
|
148
|
+
f.elements.each do |e|
|
149
|
+
parse(e, div) unless e.name == "title"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
215
154
|
|
216
|
-
|
155
|
+
def is_clause?(name)
|
156
|
+
%w(clause references definitions terms foreword introduction abstract
|
157
|
+
acknowledgements).include? name
|
217
158
|
end
|
218
|
-
end
|
219
159
|
|
220
|
-
|
221
|
-
|
160
|
+
def preface_block(isoxml, out)
|
161
|
+
p = isoxml.at(ns("//preface")) or return
|
162
|
+
p.elements.each do |e|
|
163
|
+
next if is_clause?(e.name)
|
222
164
|
|
223
|
-
|
224
|
-
|
165
|
+
parse(e, out)
|
166
|
+
end
|
225
167
|
end
|
226
|
-
end
|
227
168
|
|
228
|
-
|
229
|
-
|
169
|
+
def copyright_parse(node, out)
|
170
|
+
return if @bare
|
230
171
|
|
231
|
-
|
232
|
-
|
172
|
+
out.div **{ class: "boilerplate-copyright" } do |div|
|
173
|
+
node.children.each { |n| parse(n, div) }
|
174
|
+
end
|
233
175
|
end
|
234
|
-
end
|
235
176
|
|
236
|
-
|
237
|
-
|
177
|
+
def license_parse(node, out)
|
178
|
+
return if @bare
|
238
179
|
|
239
|
-
|
240
|
-
|
180
|
+
out.div **{ class: "boilerplate-license" } do |div|
|
181
|
+
node.children.each { |n| parse(n, div) }
|
182
|
+
end
|
241
183
|
end
|
242
|
-
end
|
243
184
|
|
244
|
-
|
245
|
-
|
185
|
+
def legal_parse(node, out)
|
186
|
+
return if @bare
|
246
187
|
|
247
|
-
|
248
|
-
|
188
|
+
out.div **{ class: "boilerplate-legal" } do |div|
|
189
|
+
node.children.each { |n| parse(n, div) }
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def feedback_parse(node, out)
|
194
|
+
return if @bare
|
195
|
+
|
196
|
+
out.div **{ class: "boilerplate-feedback" } do |div|
|
197
|
+
node.children.each { |n| parse(n, div) }
|
198
|
+
end
|
249
199
|
end
|
250
200
|
end
|
251
201
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module Function
|
3
|
+
module Section
|
4
|
+
def clausedelim
|
5
|
+
"."
|
6
|
+
end
|
7
|
+
|
8
|
+
def clausedelimspace(out)
|
9
|
+
insert_tab(out, 1)
|
10
|
+
end
|
11
|
+
|
12
|
+
def inline_header_title(out, _node, title)
|
13
|
+
out.span **{ class: "zzMoveToFollowing" } do |s|
|
14
|
+
s.b do |b|
|
15
|
+
title&.children&.each { |c2| parse(c2, b) }
|
16
|
+
clausedelimspace(out) if /\S/.match?(title&.text)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# used for subclauses
|
22
|
+
def clause_parse_title(node, div, title, out, header_class = {})
|
23
|
+
return if title.nil?
|
24
|
+
|
25
|
+
if node["inline-header"] == "true"
|
26
|
+
inline_header_title(out, node, title)
|
27
|
+
else
|
28
|
+
clause_parse_title1(node, div, title, out, header_class)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def clause_parse_title1(node, div, title, _out, header_class = {})
|
33
|
+
depth = clause_title_depth(node, title)
|
34
|
+
div.send "h#{depth}", **attr_code(header_class) do |h|
|
35
|
+
title&.children&.each { |c2| parse(c2, h) }
|
36
|
+
clause_parse_subtitle(title, h)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def clause_title_depth(node, title)
|
41
|
+
depth = node.ancestors("clause, annex, terms, references, "\
|
42
|
+
"definitions, acknowledgements, introduction, "\
|
43
|
+
"foreword").size + 1
|
44
|
+
depth = title["depth"] if title && title["depth"]
|
45
|
+
depth
|
46
|
+
end
|
47
|
+
|
48
|
+
def clause_parse_subtitle(title, heading)
|
49
|
+
if var = title&.at("./following-sibling::xmlns:variant-title"\
|
50
|
+
"[@type = 'sub']")&.remove
|
51
|
+
heading.br nil
|
52
|
+
heading.br nil
|
53
|
+
var.children.each { |c2| parse(c2, heading) }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def clause_name(_num, title, div, header_class)
|
58
|
+
header_class = {} if header_class.nil?
|
59
|
+
div.h1 **attr_code(header_class) do |h1|
|
60
|
+
if title.is_a?(String)
|
61
|
+
h1 << title
|
62
|
+
else
|
63
|
+
title&.children&.each { |c2| parse(c2, h1) }
|
64
|
+
clause_parse_subtitle(title, h1)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
div.parent.at(".//h1")
|
68
|
+
end
|
69
|
+
|
70
|
+
def annex_name(_annex, name, div)
|
71
|
+
return if name.nil?
|
72
|
+
|
73
|
+
div.h1 **{ class: "Annex" } do |t|
|
74
|
+
name.children.each { |c2| parse(c2, t) }
|
75
|
+
clause_parse_subtitle(name, t)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def variant_title(_node, _out); end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|