isodoc 1.0.20 → 1.0.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0713e025f733621ae715be8cbc85d8d0af3a03cc86331204dca8185f1d7eff67
4
- data.tar.gz: b2f421c4a76ca3b70781604ff47de87962ea658ba13860651a9349160508efbe
3
+ metadata.gz: 6ced8fa4ff249bf78fce24da52269e4745261f432e59c7a18fddfaf4ecc01d8f
4
+ data.tar.gz: 39f693b7397daa3ad71af07fa7133ec086aab0f39a2e090e79537be6091736d7
5
5
  SHA512:
6
- metadata.gz: 696c6c79ee5da9240f6ee1834267f7f540edd3512c7961c4e7c3a1e8f30804966225433d14a4d9a91608421a00dbd119a5ad983fb4c7498a716a602de432ae0e
7
- data.tar.gz: f40f777f6566e4efdc8c7c65cd56003d1edfc04a27a33004223b679e5083e8af7a165117577c4a25188ff6d9dd2fd56ac35f5492abb67b2793445a8da7397e4a
6
+ metadata.gz: 9d2086e3ca34a2478c59550edb4a76371e4e8fa46c92fc5b988c35ff8efc25ddffa2674861eed07bcea3f7bbe352bf2cdeee69ff1a5b67d50bdd76291d3c2fda
7
+ data.tar.gz: e0228c717670ed147bdaa4f0300274d51d127c28029b7c004961e258567ec293eb145accf70993fde00cc21ab6c67bffc70d140eb987309c99545061f7b43b37
@@ -124,3 +124,6 @@ b, strong {
124
124
  font-weight: bold;
125
125
  }
126
126
 
127
+ div.document-stage-band, div.document-type-band {
128
+ background-color: #FFFFFF;
129
+ }
@@ -1,3 +1,5 @@
1
+ require_relative "blocks_example"
2
+
1
3
  module IsoDoc::Function
2
4
  module Blocks
3
5
  @annotation = false
@@ -51,7 +53,7 @@ module IsoDoc::Function
51
53
  end
52
54
 
53
55
  def figure_key(out)
54
- out.p do |p|
56
+ out.p **{ style: "page-break-after:avoid;"} do |p|
55
57
  p.b { |b| b << @key_lbl }
56
58
  end
57
59
  end
@@ -80,56 +82,6 @@ module IsoDoc::Function
80
82
  @in_figure = false
81
83
  end
82
84
 
83
- def example_label(node, div, name)
84
- n = get_anchors[node["id"]]
85
- div.p **{ class: "example-title" } do |p|
86
- lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @example_lbl :
87
- l10n("#{@example_lbl} #{n[:label]}")
88
- p << lbl
89
- name and !lbl.nil? and p << "&nbsp;&mdash; "
90
- name and name.children.each { |n| parse(n, div) }
91
- end
92
- end
93
-
94
- EXAMPLE_TBL_ATTR =
95
- { class: "example_label", style: "width:82.8pt;padding:0 0 0 0;\
96
- margin-left:0pt;vertical-align:top;" }.freeze
97
-
98
- # used if we are boxing examples
99
- def example_div_parse(node, out)
100
- out.div **attr_code(id: node["id"], class: "example") do |div|
101
- example_label(node, div, node.at(ns("./name")))
102
- node.children.each do |n|
103
- parse(n, div) unless n.name == "name"
104
- end
105
- end
106
- end
107
-
108
- def example_table_attr(node)
109
- attr_code(id: node["id"], class: "example",
110
- style: "border-collapse:collapse;border-spacing:0;" )
111
- end
112
-
113
- EXAMPLE_TD_ATTR =
114
- { style: "vertical-align:top;padding:0;", class: "example" }.freeze
115
-
116
- def example_table_parse(node, out)
117
- out.table **example_table_attr(node) do |t|
118
- t.tr do |tr|
119
- tr.td **EXAMPLE_TBL_ATTR do |td|
120
- example_label(node, td, node.at(ns("./name")))
121
- end
122
- tr.td **EXAMPLE_TD_ATTR do |td|
123
- node.children.each { |n| parse(n, td) unless n.name == "name" }
124
- end
125
- end
126
- end
127
- end
128
-
129
- def example_parse(node, out)
130
- example_div_parse(node, out)
131
- end
132
-
133
85
  def sourcecode_name_parse(node, div, name)
134
86
  lbl = anchor(node['id'], :label, false)
135
87
  lbl = nil if labelled_ancestor(node)
@@ -197,8 +149,11 @@ module IsoDoc::Function
197
149
 
198
150
  def formula_where(dl, out)
199
151
  return unless dl
200
- out.p { |p| p << @where_lbl }
152
+ out.p **{ style: "page-break-after:avoid;"} do |p|
153
+ p << @where_lbl
154
+ end
201
155
  parse(dl, out)
156
+ out.parent.at("./dl")["class"] = "formula_dl"
202
157
  end
203
158
 
204
159
  def formula_parse1(node, out)
@@ -0,0 +1,53 @@
1
+ module IsoDoc::Function
2
+ module Blocks
3
+ def example_label(node, div, name)
4
+ n = get_anchors[node["id"]]
5
+ div.p **{ class: "example-title" } do |p|
6
+ lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @example_lbl :
7
+ l10n("#{@example_lbl} #{n[:label]}")
8
+ p << lbl
9
+ name and !lbl.nil? and p << "&nbsp;&mdash; "
10
+ name and name.children.each { |n| parse(n, div) }
11
+ end
12
+ end
13
+
14
+ EXAMPLE_TBL_ATTR =
15
+ { class: "example_label", style: "width:82.8pt;padding:0 0 0 0;\
16
+ margin-left:0pt;vertical-align:top;" }.freeze
17
+
18
+ # used if we are boxing examples
19
+ def example_div_parse(node, out)
20
+ out.div **attr_code(id: node["id"], class: "example") do |div|
21
+ example_label(node, div, node.at(ns("./name")))
22
+ node.children.each do |n|
23
+ parse(n, div) unless n.name == "name"
24
+ end
25
+ end
26
+ end
27
+
28
+ def example_table_attr(node)
29
+ attr_code(id: node["id"], class: "example",
30
+ style: "border-collapse:collapse;border-spacing:0;" )
31
+ end
32
+
33
+ EXAMPLE_TD_ATTR =
34
+ { style: "vertical-align:top;padding:0;", class: "example" }.freeze
35
+
36
+ def example_table_parse(node, out)
37
+ out.table **example_table_attr(node) do |t|
38
+ t.tr do |tr|
39
+ tr.td **EXAMPLE_TBL_ATTR do |td|
40
+ example_label(node, td, node.at(ns("./name")))
41
+ end
42
+ tr.td **EXAMPLE_TD_ATTR do |td|
43
+ node.children.each { |n| parse(n, td) unless n.name == "name" }
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ def example_parse(node, out)
50
+ example_div_parse(node, out)
51
+ end
52
+ end
53
+ end
@@ -19,6 +19,33 @@ module IsoDoc::Function
19
19
  admonition_cleanup(docxml)
20
20
  end
21
21
 
22
+ def table_long_strings_cleanup(docxml)
23
+ docxml.xpath("//td | //th").each do |d|
24
+ d.traverse do |n|
25
+ next unless n.text?
26
+ n.replace(break_up_long_strings(n.text))
27
+ end
28
+ end
29
+ end
30
+
31
+ def break_up_long_strings(t)
32
+ t.split(/(?=\s)/).map do |w|
33
+ (/^\s*$/.match(t) or w.size < 30) ? w :
34
+ w.scan(/.{,30}/).map do |w1|
35
+ (w1.size < 30) ? w1 : break_up_long_strings1(w1)
36
+ end.join
37
+ end.join
38
+ end
39
+
40
+ def break_up_long_strings1(w1)
41
+ s = w1.split(%r{(?<=[,.?+;/=])})
42
+ if s.size == 1 then w1 + " "
43
+ else
44
+ s[-1] = " " + s[-1]
45
+ s.join
46
+ end
47
+ end
48
+
22
49
  def admonition_cleanup(docxml)
23
50
  docxml.xpath("//div[@class = 'Admonition'][title]").each do |d|
24
51
  title = d.at("./title")
@@ -65,6 +92,7 @@ module IsoDoc::Function
65
92
  # since it is in diagram
66
93
  def figure_cleanup(docxml)
67
94
  docxml.xpath(FIGURE_WITH_FOOTNOTES).each do |f|
95
+ next unless f.at(".//aside[not(ancestor::p[@class = 'FigureTitle'])]")
68
96
  key = figure_get_or_make_dl(f)
69
97
  f.xpath(".//aside").each do |aside|
70
98
  figure_aside_process(f, aside, key)
@@ -156,6 +184,7 @@ module IsoDoc::Function
156
184
  def table_cleanup(docxml)
157
185
  table_footnote_cleanup(docxml)
158
186
  table_note_cleanup(docxml)
187
+ table_long_strings_cleanup(docxml)
159
188
  docxml
160
189
  end
161
190
 
@@ -43,6 +43,11 @@ module IsoDoc::Function
43
43
 
44
44
  def li_parse(node, out)
45
45
  out.li **attr_code(id: node["id"]) do |li|
46
+ if node["uncheckedcheckbox"] == "true"
47
+ li << '<span class="zzMoveToFollowing"><input type="checkbox" checked="checked"/></span>'
48
+ elsif node["checkedcheckbox"] == "true"
49
+ li << '<span class="zzMoveToFollowing"><input type="checkbox"/></span>'
50
+ end
46
51
  node.children.each { |n| parse(n, li) }
47
52
  end
48
53
  end
@@ -131,13 +131,13 @@ module IsoDoc::Function
131
131
 
132
132
  def biblio_list(f, div, biblio)
133
133
  i = 0
134
- f.xpath(ns("./bibitem | ./note")).each do |b|
135
- next if implicit_reference(b)
136
- i += 1 if b.name == "bibitem"
137
- if b.name == "note" then note_parse(b, div)
138
- elsif(is_standard(b)) then std_bibitem_entry(div, b, i, biblio)
134
+ f.children.each do |b|
135
+ if b.name == "bibitem"
136
+ i += 1
137
+ (is_standard(b)) ? std_bibitem_entry(div, b, i, biblio) :
138
+ nonstd_bibitem(div, b, i, biblio)
139
139
  else
140
- nonstd_bibitem(div, b, i, biblio)
140
+ parse(b, div) unless %w(title).include? b.name
141
141
  end
142
142
  end
143
143
  end
@@ -149,9 +149,6 @@ module IsoDoc::Function
149
149
  out.div do |div|
150
150
  num = num + 1
151
151
  clause_name(num, @normref_lbl, div, nil)
152
- f.elements.reject do |e|
153
- %w(reference title bibitem note).include? e.name
154
- end.each { |e| parse(e, div) }
155
152
  biblio_list(f, div, false)
156
153
  end
157
154
  num
@@ -165,9 +162,6 @@ module IsoDoc::Function
165
162
  page_break(out)
166
163
  out.div do |div|
167
164
  div.h1 @bibliography_lbl, **{ class: "Section3" }
168
- f.elements.reject do |e|
169
- %w(reference title bibitem note).include? e.name
170
- end.each { |e| parse(e, div) }
171
165
  biblio_list(f, div, true)
172
166
  end
173
167
  end
@@ -178,9 +172,6 @@ module IsoDoc::Function
178
172
  anchor(node['id'], :label, false) and
179
173
  clause_parse_title(node, div, node.at(ns("./title")), out) or
180
174
  div.h2 title, **{ class: "Section3" }
181
- node.elements.reject do |e|
182
- %w(reference title bibitem note).include? e.name
183
- end.each { |e| parse(e, div) }
184
175
  biblio_list(node, div, true)
185
176
  end
186
177
  end
@@ -20,6 +20,7 @@ module IsoDoc::Function
20
20
  end
21
21
  end
22
22
 
23
+ # used for subclauses
23
24
  def clause_parse_title(node, div, c1, out)
24
25
  if node["inline-header"] == "true"
25
26
  inline_header_title(out, node, c1)
@@ -33,6 +34,7 @@ module IsoDoc::Function
33
34
  end
34
35
  end
35
36
 
37
+ # used for subclauses
36
38
  def clause_parse(node, out)
37
39
  out.div **attr_code(id: node["id"]) do |div|
38
40
  clause_parse_title(node, div, node.at(ns("./title")), out)
@@ -84,6 +86,7 @@ module IsoDoc::Function
84
86
  isoxml.xpath(ns("//annex")).each do |c|
85
87
  page_break(out)
86
88
  out.div **attr_code(id: c["id"], class: "Section3") do |s|
89
+ annex_name(c, nil, s) unless c.at(ns("./title"))
87
90
  c.elements.each do |c1|
88
91
  if c1.name == "title" then annex_name(c, c1, s)
89
92
  else
@@ -45,10 +45,11 @@ module IsoDoc::Function
45
45
  end
46
46
 
47
47
  def make_table_attr(node)
48
+ width = node["width"] ? "width:#{node['width']};" : nil
48
49
  attr_code(
49
50
  id: node["id"],
50
51
  class: "MsoISOTable",
51
- style: "border-width:1px;border-spacing:0;",
52
+ style: "border-width:1px;border-spacing:0;#{width}",
52
53
  title: node["alt"]
53
54
  )
54
55
  end
@@ -1,5 +1,6 @@
1
1
  require_relative "xref_counter"
2
2
  require_relative "xref_anchor"
3
+ require_relative "xref_gen_seq"
3
4
 
4
5
  module IsoDoc::Function
5
6
  module XrefGen
@@ -124,138 +125,5 @@ module IsoDoc::Function
124
125
  example_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
125
126
  list_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
126
127
  end
127
-
128
- def sequential_figure_names(clause)
129
- c = Counter.new
130
- j = 0
131
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).each do |t|
132
- if t.parent.name == "figure" then j += 1
133
- else
134
- j = 0
135
- c.increment(t)
136
- end
137
- label = c.print + (j.zero? ? "" : "-#{j}")
138
- next if t["id"].nil? || t["id"].empty?
139
- @anchors[t["id"]] =
140
- anchor_struct(label, nil, @figure_lbl, "figure", t["unnumbered"])
141
- end
142
- end
143
-
144
- def sequential_table_names(clause)
145
- c = Counter.new
146
- clause.xpath(ns(".//table")).each do |t|
147
- next if t["id"].nil? || t["id"].empty?
148
- @anchors[t["id"]] = anchor_struct(c.increment(t).print, nil,
149
- @table_lbl, "table", t["unnumbered"])
150
- end
151
- end
152
-
153
- def sequential_formula_names(clause)
154
- c = Counter.new
155
- clause.xpath(ns(".//formula")).each do |t|
156
- next if t["id"].nil? || t["id"].empty?
157
- @anchors[t["id"]] =
158
- anchor_struct(c.increment(t).print, t,
159
- t["inequality"] ? @inequality_lbl : @formula_lbl,
160
- "formula", t["unnumbered"])
161
- end
162
- end
163
-
164
- FIRST_LVL_REQ = "[not(ancestor::permission or ancestor::requirement or "\
165
- "ancestor::recommendation)]".freeze
166
-
167
- def sequential_permission_names(clause, klass, label)
168
- c = Counter.new
169
- clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}")).each do |t|
170
- next if t["id"].nil? || t["id"].empty?
171
- id = c.increment(t).print
172
- @anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
173
- sequential_permission_names2(t, id)
174
- end
175
- end
176
-
177
- def sequential_permission_names2(t, id)
178
- sequential_permission_names1(t, id, "permission", @permission_lbl)
179
- sequential_permission_names1(t, id, "requirement", @requirement_lbl)
180
- sequential_permission_names1(t, id, "recommendation", @recommendation_lbl)
181
- end
182
-
183
- def sequential_permission_names1(block, lbl, klass, label)
184
- c = Counter.new
185
- block.xpath(ns("./#{klass}")).each do |t|
186
- next if t["id"].nil? || t["id"].empty?
187
- id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
188
- @anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
189
- sequential_permission_names2(t, id)
190
- end
191
- end
192
-
193
- def sequential_asset_names(clause)
194
- sequential_table_names(clause)
195
- sequential_figure_names(clause)
196
- sequential_formula_names(clause)
197
- sequential_permission_names(clause, "permission", @permission_lbl)
198
- sequential_permission_names(clause, "requirement", @requirement_lbl)
199
- sequential_permission_names(clause, "recommendation", @recommendation_lbl)
200
- end
201
-
202
- def hierarchical_figure_names(clause, num)
203
- c = Counter.new
204
- j = 0
205
- clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).each do |t|
206
- if t.parent.name == "figure" then j += 1
207
- else
208
- j = 0
209
- c.increment(t)
210
- end
211
- label = "#{num}#{hiersep}#{c.print}" +
212
- (j.zero? ? "" : "#{hierfigsep}#{j}")
213
- next if t["id"].nil? || t["id"].empty?
214
- @anchors[t["id"]] = anchor_struct(label, nil, @figure_lbl, "figure",
215
- t["unnumbered"])
216
- end
217
- end
218
-
219
- def hierarchical_table_names(clause, num)
220
- c = Counter.new
221
- clause.xpath(ns(".//table")).each do |t|
222
- next if t["id"].nil? || t["id"].empty?
223
- @anchors[t["id"]] =
224
- anchor_struct("#{num}#{hiersep}#{c.increment(t).print}",
225
- nil, @table_lbl, "table", t["unnumbered"])
226
- end
227
- end
228
-
229
- def hierarchical_asset_names(clause, num)
230
- hierarchical_table_names(clause, num)
231
- hierarchical_figure_names(clause, num)
232
- hierarchical_formula_names(clause, num)
233
- hierarchical_permission_names(clause, num, "permission", @permission_lbl)
234
- hierarchical_permission_names(clause, num, "requirement",
235
- @requirement_lbl)
236
- hierarchical_permission_names(clause, num, "recommendation",
237
- @recommendation_lbl)
238
- end
239
-
240
- def hierarchical_formula_names(clause, num)
241
- c = Counter.new
242
- clause.xpath(ns(".//formula")).each do |t|
243
- next if t["id"].nil? || t["id"].empty?
244
- @anchors[t["id"]] =
245
- anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", t,
246
- t["inequality"] ? @inequality_lbl : @formula_lbl,
247
- "formula", t["unnumbered"])
248
- end
249
- end
250
-
251
- def hierarchical_permission_names(clause, num, klass, label)
252
- c = Counter.new
253
- clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}")).each do |t|
254
- next if t["id"].nil? || t["id"].empty?
255
- id = "#{num}#{hiersep}#{c.increment(t).print}"
256
- @anchors[t["id"]] = anchor_struct(id, t, label, klass, t["unnumbered"])
257
- sequential_permission_names2(t, id)
258
- end
259
- end
260
128
  end
261
129
  end