isodoc 2.5.8 → 2.5.10

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: 69483536ae8b9bb773ddbb3e3d38660784c9e01ad1eb810ecfc045b721bcd3c3
4
- data.tar.gz: 43212277b0d8b7fec3551bf234ff31288eaf2f1fe63e494ed82ab7438d3a8c3c
3
+ metadata.gz: a73625d6e0b342e44b34e2c93ef6df6126e1694dbcd9475cc52168da86a8cb8b
4
+ data.tar.gz: 58bed9e6bd9f0a5812a6e7ee46e90ea2c4e2dc4bf1592a66db4302dd4d579f5c
5
5
  SHA512:
6
- metadata.gz: 230b47645cebcda1c1d56df140a8a1aced48807e0188270bbc25034c91ea3b612cbd004000bef00a7e81ca0de57b63463665d5679cb5de3ef14ed264ed971f46
7
- data.tar.gz: 50f2cf4ca7215a501b9999601aec898b4c4006f468ceba9481b9ad5d7820481650dd21ddb68da3fe632571e4bde708a5d1877598b20ba484ceff72c768672247
6
+ metadata.gz: 28274dab0c28284a969ae3caf93e2065447c8b70b9166385e972b610014eb6bdeea8de3ec25273dfa1aea7fb78eaea463e894a0feeef18b82f0be3f2f479ff7c
7
+ data.tar.gz: 87c56a3f6c1aefd791ae520d2e3c1e0c7d7060b5d81aca3e64096294cd3c5de28cd71d70ad04db8823457bc90773a8f6b1d427a43e1cdd3ed067b5ab72099c29
@@ -90,7 +90,7 @@ h1, h2, h3, h4, h5, h6 {
90
90
 
91
91
  blockquote, q {
92
92
  quotes: none; }
93
- blockquote:before, blockquote:after, q:before, q:after {
93
+ blockquote::before, blockquote::after, q::before, q::after {
94
94
  content: '';
95
95
  content: none; }
96
96
 
@@ -113,14 +113,18 @@ b, strong {
113
113
  div.document-stage-band, div.document-type-band {
114
114
  background-color: #333333; }
115
115
 
116
- a.FootnoteRef + a.FootnoteRef:before {
116
+ a.FootnoteRef + a.FootnoteRef::before {
117
117
  content: ", ";
118
118
  vertical-align: super; }
119
119
 
120
- a.TableFootnoteRef + a.TableFootnoteRef:before {
120
+ a.TableFootnoteRef + a.TableFootnoteRef::before {
121
121
  content: ", ";
122
122
  vertical-align: super; }
123
123
 
124
+ a.TableFootnoteRef, span.TableFootnoteRef,
125
+ a.FootnoteRef, span.FootnoteRef {
126
+ vertical-align: super; }
127
+
124
128
  .addition {
125
129
  color: blue; }
126
130
 
@@ -90,7 +90,7 @@ h1, h2, h3, h4, h5, h6 {
90
90
 
91
91
  blockquote, q {
92
92
  quotes: none; }
93
- blockquote:before, blockquote:after, q:before, q:after {
93
+ blockquote::before, blockquote::after, q::before, q::after {
94
94
  content: '';
95
95
  content: none; }
96
96
 
@@ -113,14 +113,18 @@ b, strong {
113
113
  div.document-stage-band, div.document-type-band {
114
114
  background-color: #333333; }
115
115
 
116
- a.FootnoteRef + a.FootnoteRef:before {
116
+ a.FootnoteRef + a.FootnoteRef::before {
117
117
  content: ", ";
118
118
  vertical-align: super; }
119
119
 
120
- a.TableFootnoteRef + a.TableFootnoteRef:before {
120
+ a.TableFootnoteRef + a.TableFootnoteRef::before {
121
121
  content: ", ";
122
122
  vertical-align: super; }
123
123
 
124
+ a.TableFootnoteRef, span.TableFootnoteRef,
125
+ a.FootnoteRef, span.FootnoteRef {
126
+ vertical-align: super; }
127
+
124
128
  .addition {
125
129
  color: blue; }
126
130
 
@@ -102,7 +102,7 @@ h1, h2, h3, h4, h5, h6 {
102
102
  blockquote, q {
103
103
  quotes: none;
104
104
 
105
- &:before, &:after {
105
+ &::before, &::after {
106
106
  content: '';
107
107
  content: none;
108
108
  }
@@ -139,16 +139,20 @@ div.document-stage-band, div.document-type-band {
139
139
  background-color: #333333;
140
140
  }
141
141
 
142
- a.FootnoteRef + a.FootnoteRef:before {
142
+ a.FootnoteRef + a.FootnoteRef::before {
143
143
  content: ", ";
144
144
  vertical-align: super;
145
145
  }
146
146
 
147
- a.TableFootnoteRef + a.TableFootnoteRef:before {
147
+ a.TableFootnoteRef + a.TableFootnoteRef::before {
148
148
  content: ", ";
149
149
  vertical-align: super;
150
150
  }
151
151
 
152
+ a.TableFootnoteRef, span.TableFootnoteRef,
153
+ a.FootnoteRef, span.FootnoteRef {
154
+ vertical-align: super;
155
+ }
152
156
 
153
157
  .addition {
154
158
  color: blue;
@@ -25,47 +25,6 @@ module IsoDoc
25
25
  admonition_cleanup(docxml)
26
26
  end
27
27
 
28
- def table_long_strings_cleanup(docxml)
29
- return unless @break_up_urls_in_tables
30
-
31
- docxml.xpath("//td | //th").each do |d|
32
- d.traverse do |n|
33
- n.text? or next
34
- ret = break_up_long_str(n.text)
35
- n.content = ret
36
- end
37
- end
38
- end
39
-
40
- LONGSTR_THRESHOLD = 10
41
- LONGSTR_NOPUNCT = 2
42
-
43
- def break_up_long_str(text)
44
- /^\s*$/.match?(text) and return text
45
- text.split(/(?=\s)/).map do |w|
46
- if /^\s*$/.match(text) || (w.size < LONGSTR_THRESHOLD) then w
47
- else
48
- w.scan(/.{,#{LONGSTR_THRESHOLD}}/o).map.with_index do |w1, i|
49
- w1.size < LONGSTR_THRESHOLD ? w1 : break_up_long_str1(w1, i + 1)
50
- end.join
51
- end
52
- end.join
53
- end
54
-
55
- # break on punct every LONGSTRING_THRESHOLD chars
56
- # break regardless every LONGSTRING_THRESHOLD * LONGSTR_NOPUNCT
57
- def break_up_long_str1(text, iteration)
58
- s = text.split(%r{(?<=[,.?+;/=(\[])})
59
- if s.size == 1
60
- (iteration % LONGSTR_NOPUNCT).zero? and
61
- text += "\u200b"
62
- text
63
- else
64
- s[-1] = "\u200b#{s[-1]}"
65
- s.join
66
- end
67
- end
68
-
69
28
  def admonition_cleanup(docxml)
70
29
  docxml.xpath("//div[@class = 'Admonition'][title]").each do |d|
71
30
  title = d.at("./title")
@@ -214,7 +173,6 @@ module IsoDoc
214
173
  def table_cleanup(docxml)
215
174
  table_footnote_cleanup(docxml)
216
175
  table_note_cleanup(docxml)
217
- table_long_strings_cleanup(docxml)
218
176
  docxml
219
177
  end
220
178
 
@@ -96,6 +96,10 @@ module IsoDoc
96
96
  dl_parse1(v, dt, dd)
97
97
  end
98
98
  end
99
+ dl_parse_notes(node, out)
100
+ end
101
+
102
+ def dl_parse_notes(node, out)
99
103
  node.elements.reject { |n| dt_dd?(n) || n.name == "name" }
100
104
  .each { |n| parse(n, out) }
101
105
  end
@@ -1,4 +1,4 @@
1
- require_relative "./section_titles"
1
+ require_relative "section_titles"
2
2
 
3
3
  module IsoDoc
4
4
  module Function
@@ -20,7 +20,7 @@ module IsoDoc
20
20
  def clause(isoxml, out)
21
21
  isoxml.xpath(ns(middle_clause(isoxml))).each do |c|
22
22
  out.div **attr_code(clause_attrs(c)) do |s|
23
- clause_name(c, c&.at(ns("./title")), s, nil)
23
+ clause_name(c, c.at(ns("./title")), s, nil)
24
24
  c.elements.reject { |c1| c1.name == "title" }.each do |c1|
25
25
  parse(c1, s)
26
26
  end
@@ -64,7 +64,7 @@ module IsoDoc
64
64
  f = isoxml.at(ns(TERM_CLAUSE)) or return num
65
65
  out.div **attr_code(id: f["id"]) do |div|
66
66
  num = num + 1
67
- clause_name(f, f&.at(ns("./title")), div, nil)
67
+ clause_name(f, f.at(ns("./title")), div, nil)
68
68
  f.elements.each do |e|
69
69
  parse(e, div) unless %w{title source}.include? e.name
70
70
  end
@@ -60,7 +60,7 @@ module IsoDoc
60
60
 
61
61
  def to_xhtml_prep(xml)
62
62
  xml.gsub!(/<\?xml[^>]*>/, "")
63
- /<!DOCTYPE /.match(xml) || (xml = DOCTYPE_HDR + xml)
63
+ xml.include?("<!DOCTYPE ") || (xml = DOCTYPE_HDR + xml)
64
64
  numeric_escapes(xml)
65
65
  end
66
66
 
@@ -130,7 +130,7 @@ module IsoDoc
130
130
  .gsub(%r{</?p(\s[^>]+)?>}, "")
131
131
  .gsub(/<\/?h[123456][^>]*>/, "").gsub(/<\/?b[^>]*>/, "").dup)
132
132
  h1.traverse do |x|
133
- if x.name == "span" && /mso-tab-count/.match(x["style"])
133
+ if x.name == "span" && x["style"]&.include?("mso-tab-count")
134
134
  x.replace(" ")
135
135
  elsif header_strip_elem?(x) then x.remove
136
136
  elsif x.name == "a" then x.replace(x.children)
@@ -143,7 +143,7 @@ module IsoDoc
143
143
  elem.name == "img" ||
144
144
  (elem.name == "span" && elem["class"] == "MsoCommentReference") ||
145
145
  (elem.name == "a" && elem["class"] == "FootnoteRef") ||
146
- (elem.name == "span" && /mso-bookmark/.match(elem["style"]))
146
+ (elem.name == "span" && elem["style"]&.include?("mso-bookmark"))
147
147
  end
148
148
 
149
149
  def liquid(doc)
@@ -202,9 +202,15 @@ module IsoDoc
202
202
  end
203
203
  end
204
204
 
205
- def labelled_ancestor(node)
206
- !node.ancestors("example, requirement, recommendation, permission, " \
207
- "note, table, figure, sourcecode").empty?
205
+ LABELLED_ANCESTOR_ELEMENTS =
206
+ %w(example requirement recommendation permission
207
+ note table figure sourcecode).freeze
208
+
209
+ def labelled_ancestor(elem)
210
+ #require "debug"; binding.b
211
+ #!elem.path.gsub(/\[\d+\]/, "").split(%r{/})[1..-1]
212
+ !elem.ancestors.map(&:name)
213
+ .intersection(LABELLED_ANCESTOR_ELEMENTS).empty?
208
214
  end
209
215
 
210
216
  def emf?(type)
@@ -1,12 +1,11 @@
1
- require_relative "./image"
2
- require_relative "./sourcecode"
1
+ require_relative "image"
2
+ require_relative "sourcecode"
3
3
  require "rouge"
4
4
 
5
5
  module IsoDoc
6
6
  class PresentationXMLConvert < ::IsoDoc::Convert
7
7
  def lower2cap(text)
8
- return text if /^[[:upper:]][[:upper:]]/.match?(text)
9
-
8
+ /^[[:upper:]][[:upper:]]/.match?(text) and return text
10
9
  text.capitalize
11
10
  end
12
11
 
@@ -89,31 +88,8 @@ module IsoDoc
89
88
  prefix_name(elem, block_delim, l10n("#{@i18n.box} #{n}"), "name")
90
89
  end
91
90
 
92
- def recommendation(docxml)
93
- docxml.xpath(ns("//recommendation")).each do |f|
94
- recommendation1(f, lower2cap(@i18n.recommendation))
95
- end
96
- end
97
-
98
- def requirement(docxml)
99
- docxml.xpath(ns("//requirement")).each do |f|
100
- recommendation1(f, lower2cap(@i18n.requirement))
101
- end
102
- end
103
-
104
- def permission(docxml)
105
- docxml.xpath(ns("//permission")).each do |f|
106
- recommendation1(f, lower2cap(@i18n.permission))
107
- end
108
- end
109
-
110
- def recommendation1(elem, type)
111
- lbl = @reqt_models.model(elem["model"])
112
- .recommendation_label(elem, type, xrefs)
113
- prefix_name(elem, "", l10n(lbl), "name")
114
- end
115
-
116
91
  def table(docxml)
92
+ table_long_strings_cleanup(docxml)
117
93
  docxml.xpath(ns("//table")).each { |f| table1(f) }
118
94
  end
119
95
 
@@ -125,6 +101,74 @@ module IsoDoc
125
101
  "name")
126
102
  end
127
103
 
104
+ def table_long_strings_cleanup(docxml)
105
+ @break_up_urls_in_tables or return
106
+ docxml.xpath(ns("//td | //th")).each do |d|
107
+ d.traverse do |n|
108
+ n.text? or next
109
+ ret = break_up_long_str(n.text)
110
+ n.content = ret
111
+ end
112
+ end
113
+ end
114
+
115
+ LONGSTR_THRESHOLD = 10
116
+ LONGSTR_NOPUNCT = 2
117
+
118
+ def break_up_long_str(text)
119
+ /^\s*$/.match?(text) and return text
120
+ text.split(/(?=\s)/).map do |w|
121
+ if /^\s*$/.match(text) || (w.size < LONGSTR_THRESHOLD) then w
122
+ else
123
+ w.scan(/.{,#{LONGSTR_THRESHOLD}}/o).map.with_index do |w1, i|
124
+ w1.size < LONGSTR_THRESHOLD ? w1 : break_up_long_str1(w1, i + 1)
125
+ end.join
126
+ end
127
+ end.join
128
+ end
129
+
130
+ STR_BREAKUP_RE = %r{
131
+ (?<=[=_—–\u2009→?+;]) | # break after any of these
132
+ (?<=[,.:])(?!\d) | # break on punct only if not preceding digit
133
+ (?<=[>])(?![>]) | # > not >->
134
+ (?<=[\]])(?![\]]) | # ] not ]-]
135
+ (?<=//) | # //
136
+ (?<=[/])(?![/]) | # / not /-/
137
+ (?<![<])(?=[<]) | # < not <-<
138
+ (?<=\p{L})(?=[(\{\[]\p{L}) # letter and bracket, followed by letter
139
+ }x.freeze
140
+
141
+
142
+ CAMEL_CASE_RE = %r{
143
+ (?<=\p{Ll}\p{Ll})(?=\p{Lu}\p{Ll}\p{Ll}) # 2 lowerc / upperc, 2 lowerc
144
+ }x.freeze
145
+
146
+ # break on punct every LONGSTRING_THRESHOLD chars, with zero width space
147
+ # if punct fails, try break on camel case, with soft hyphen
148
+ # break regardless every LONGSTRING_THRESHOLD * LONGSTR_NOPUNCT,
149
+ # with soft hyphen
150
+ def break_up_long_str1(text, iteration)
151
+ s, separator = break_up_long_str2(text)
152
+ if s.size == 1 # could not break up
153
+ (iteration % LONGSTR_NOPUNCT).zero? and
154
+ text += "\u00ad" # force soft hyphen
155
+ text
156
+ else
157
+ s[-1] = "#{separator}#{s[-1]}"
158
+ s.join
159
+ end
160
+ end
161
+
162
+ def break_up_long_str2(text)
163
+ s = text.split(STR_BREAKUP_RE, -1)
164
+ separator = "\u200b"
165
+ if s.size == 1
166
+ s = text.split(CAMEL_CASE_RE)
167
+ separator = "\u00ad"
168
+ end
169
+ [s, separator]
170
+ end
171
+
128
172
  # we use this to eliminate the semantic amend blocks from rendering
129
173
  def amend(docxml)
130
174
  docxml.xpath(ns("//amend")).each { |f| amend1(f) }
@@ -167,26 +211,6 @@ module IsoDoc
167
211
  elem["label"] = @xrefs.anchor(elem["id"], :label, false)
168
212
  end
169
213
 
170
- def requirement_render_preprocessing(docxml); end
171
-
172
- REQS = %w(requirement recommendation permission).freeze
173
-
174
- def requirement_render(docxml)
175
- requirement_render_preprocessing(docxml)
176
- REQS.each do |x|
177
- REQS.each do |y|
178
- docxml.xpath(ns("//#{x}//#{y}")).each { |r| requirement_render1(r) }
179
- end
180
- end
181
- docxml.xpath(ns("//requirement | //recommendation | //permission"))
182
- .each { |r| requirement_render1(r) }
183
- end
184
-
185
- def requirement_render1(node)
186
- node.replace(@reqt_models.model(node["model"])
187
- .requirement_render1(node))
188
- end
189
-
190
214
  def source(docxml)
191
215
  docxml.xpath(ns("//source/modification")).each do |f|
192
216
  source_modification(f)
@@ -0,0 +1,47 @@
1
+ module IsoDoc
2
+ class PresentationXMLConvert < ::IsoDoc::Convert
3
+ def recommendation(docxml)
4
+ docxml.xpath(ns("//recommendation")).each do |f|
5
+ recommendation1(f, lower2cap(@i18n.recommendation))
6
+ end
7
+ end
8
+
9
+ def requirement(docxml)
10
+ docxml.xpath(ns("//requirement")).each do |f|
11
+ recommendation1(f, lower2cap(@i18n.requirement))
12
+ end
13
+ end
14
+
15
+ def permission(docxml)
16
+ docxml.xpath(ns("//permission")).each do |f|
17
+ recommendation1(f, lower2cap(@i18n.permission))
18
+ end
19
+ end
20
+
21
+ def recommendation1(elem, type)
22
+ lbl = @reqt_models.model(elem["model"])
23
+ .recommendation_label(elem, type, xrefs)
24
+ prefix_name(elem, "", l10n(lbl), "name")
25
+ end
26
+
27
+ def requirement_render_preprocessing(docxml); end
28
+
29
+ REQS = %w(requirement recommendation permission).freeze
30
+
31
+ def requirement_render(docxml)
32
+ requirement_render_preprocessing(docxml)
33
+ REQS.each do |x|
34
+ REQS.each do |y|
35
+ docxml.xpath(ns("//#{x}//#{y}")).each { |r| requirement_render1(r) }
36
+ end
37
+ end
38
+ docxml.xpath(ns("//requirement | //recommendation | //permission"))
39
+ .each { |r| requirement_render1(r) }
40
+ end
41
+
42
+ def requirement_render1(node)
43
+ node.replace(@reqt_models.model(node["model"])
44
+ .requirement_render1(node))
45
+ end
46
+ end
47
+ end
@@ -1,4 +1,5 @@
1
1
  require_relative "presentation_function/block"
2
+ require_relative "presentation_function/reqt"
2
3
  require_relative "presentation_function/concepts"
3
4
  require_relative "presentation_function/terms"
4
5
  require_relative "presentation_function/xrefs"
@@ -22,7 +23,7 @@ module IsoDoc
22
23
  info docxml, nil
23
24
  conversions(docxml)
24
25
  docxml.root["type"] = "presentation"
25
- docxml.to_xml.gsub(/&lt;/, "&#x3c;").gsub(/&gt;/, "&#x3e;")
26
+ docxml.to_xml.gsub("&lt;", "&#x3c;").gsub("&gt;", "&#x3e;")
26
27
  end
27
28
 
28
29
  def bibitem_lookup(docxml)
@@ -125,7 +126,7 @@ module IsoDoc
125
126
  .sub(/ xmlns=['"][^"']+['"]/, "") # root XMLNS
126
127
  .split(/(?=[<> \t\r\n\f\v])/).map do |x|
127
128
  case x
128
- when /^<[^:]+:/ then x.sub(/:/, ":semantic__")
129
+ when /^<[^:]+:/ then x.sub(":", ":semantic__")
129
130
  when /^<[^:]+$/ then x.sub(%r{(</?)([[:alpha:]])},
130
131
  "\\1semantic__\\2")
131
132
  else x end
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.5.8".freeze
2
+ VERSION = "2.5.10".freeze
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require_relative "./table"
2
2
  require_relative "./inline"
3
+ require_relative "./lists"
3
4
 
4
5
  module IsoDoc
5
6
  module WordFunction
@@ -42,12 +43,6 @@ module IsoDoc
42
43
  end
43
44
  end
44
45
 
45
- def insert_tab(out, count)
46
- out.span **attr_code(style: "mso-tab-count:#{count}") do |span|
47
- [1..count].each { span << "&#xA0; " }
48
- end
49
- end
50
-
51
46
  def para_class(_node)
52
47
  return "Sourcecode" if @annotation
53
48
  return "MsoCommentText" if @in_comment
@@ -67,58 +62,6 @@ module IsoDoc
67
62
  node.xpath(ns("./note")).each { |n| parse(n, out) }
68
63
  end
69
64
 
70
- WORD_DT_ATTRS = { class: @note ? "Note" : nil, align: "left",
71
- style: "margin-left:0pt;text-align:left;" }.freeze
72
-
73
- def dt_parse(dterm, term)
74
- term.p **attr_code(WORD_DT_ATTRS) do |p|
75
- if dterm.elements.empty?
76
- p << dterm.text
77
- else
78
- dterm.children.each { |n| parse(n, p) }
79
- end
80
- end
81
- end
82
-
83
- def dl_parse(node, out)
84
- return super unless node.ancestors("table, dl").empty?
85
-
86
- dl_parse_table(node, out)
87
- end
88
-
89
- def dl_parse_table(node, out)
90
- list_title_parse(node, out)
91
- out.table class: (node["class"] || "dl") do |v|
92
- node.elements.select { |n| dt_dd?(n) }
93
- .each_slice(2) do |dt, dd|
94
- dl_parse_table1(v, dt, dd)
95
- end
96
- dl_parse_notes(node, v)
97
- end
98
- end
99
-
100
- def dl_parse_table1(table, dterm, ddefn)
101
- table.tr do |tr|
102
- tr.td valign: "top", align: "left" do |term|
103
- dt_parse(dterm, term)
104
- end
105
- tr.td valign: "top" do |listitem|
106
- ddefn.children.each { |n| parse(n, listitem) }
107
- end
108
- end
109
- end
110
-
111
- def dl_parse_notes(node, out)
112
- remainder = node.elements.reject { |n| dt_dd?(n) || n.name == "name" }
113
- return if remainder.empty?
114
-
115
- out.tr do |tr|
116
- tr.td colspan: 2 do |td|
117
- remainder.each { |n| parse(n, td) }
118
- end
119
- end
120
- end
121
-
122
65
  def figure_get_or_make_dl(node)
123
66
  dl = node.at(".//table[@class = 'dl']")
124
67
  if dl.nil?
@@ -130,7 +73,7 @@ module IsoDoc
130
73
 
131
74
  # get rid of footnote link, it is in diagram
132
75
  def figure_aside_process(fig, aside, key)
133
- fig&.at("./a[@class='TableFootnoteRef']")&.remove
76
+ fig.at("./a[@class='TableFootnoteRef']")&.remove
134
77
  fnref = fig.at(".//span[@class='TableFootnoteRef']/..")
135
78
  tr = key.add_child("<tr></tr>").first
136
79
  dt = tr.add_child("<td valign='top' align='left'></td>").first
@@ -143,7 +86,7 @@ module IsoDoc
143
86
  end
144
87
 
145
88
  def note_p_parse(node, div)
146
- name = node&.at(ns("./name"))&.remove
89
+ name = node.at(ns("./name"))&.remove
147
90
  div.p class: "Note" do |p|
148
91
  p.span class: "note_label" do |s|
149
92
  name&.children&.each { |n| parse(n, s) }
@@ -155,7 +98,7 @@ module IsoDoc
155
98
  end
156
99
 
157
100
  def note_parse1(node, div)
158
- name = node&.at(ns("./name"))&.remove
101
+ name = node.at(ns("./name"))&.remove
159
102
  div.p class: "Note" do |p|
160
103
  p.span class: "note_label" do |s|
161
104
  name&.children&.each { |n| parse(n, s) }
@@ -211,30 +154,12 @@ module IsoDoc
211
154
  end
212
155
  end
213
156
 
214
- def li_parse(node, out)
215
- out.li **attr_code(id: node["id"]) do |li|
216
- if node["uncheckedcheckbox"] == "true"
217
- li << '<span class="zzMoveToFollowing">&#x2610; </span>'
218
- elsif node["checkedcheckbox"] == "true"
219
- li << '<span class="zzMoveToFollowing">&#x2611; </span>'
220
- end
221
- node.children.each { |n| parse(n, li) }
222
- end
223
- end
224
-
225
- def suffix_url(url)
226
- return url if url.nil? || %r{^https?://|^#}.match?(url)
227
- return url unless File.extname(url).empty?
228
-
229
- url.sub(/#{File.extname(url)}$/, ".doc")
230
- end
231
-
232
- def info(isoxml, out)
157
+ def info(xml, out)
233
158
  @tocfigurestitle =
234
- isoxml.at(ns("//metanorma-extension/toc[@type = 'figure']/title"))&.text
159
+ xml.at(ns("//metanorma-extension/toc[@type = 'figure']/title"))&.text
235
160
  @toctablestitle =
236
- isoxml.at(ns("//metanorma-extension/toc[@type = 'table']/title"))&.text
237
- @tocrecommendationstitle = isoxml
161
+ xml.at(ns("//metanorma-extension/toc[@type = 'table']/title"))&.text
162
+ @tocrecommendationstitle = xml
238
163
  .at(ns("//metanorma-extension/toc[@type = 'recommendation']/title"))&.text
239
164
  super
240
165
  end
@@ -1,22 +1,28 @@
1
1
  module IsoDoc
2
2
  module WordFunction
3
3
  module Body
4
+ def insert_tab(out, count)
5
+ out.span **attr_code(style: "mso-tab-count:#{count}") do |span|
6
+ [1..count].each { span << "&#xA0; " }
7
+ end
8
+ end
9
+
4
10
  def section_break(body, continuous: false)
5
11
  body.p do |p|
6
12
  if continuous
7
- p.br **{ clear: "all", style: "page-break-before:auto;"\
8
- "mso-break-type:section-break" }
13
+ p.br clear: "all", style: "page-break-before:auto;" \
14
+ "mso-break-type:section-break"
9
15
  else
10
- p.br **{ clear: "all", class: "section" }
16
+ p.br clear: "all", class: "section"
11
17
  end
12
18
  end
13
19
  end
14
20
 
15
21
  def page_break(out)
16
22
  out.p do |p|
17
- p.br **{ clear: "all",
18
- style: "mso-special-character:line-break;"\
19
- "page-break-before:always" }
23
+ p.br clear: "all",
24
+ style: "mso-special-character:line-break;" \
25
+ "page-break-before:always"
20
26
  end
21
27
  end
22
28
 
@@ -24,8 +30,8 @@ module IsoDoc
24
30
  return page_break(out) if node["orientation"].nil?
25
31
 
26
32
  out.p do |p|
27
- p.br **{ clear: "all", class: "section",
28
- orientation: node["orientation"] }
33
+ p.br clear: "all", class: "section",
34
+ orientation: node["orientation"]
29
35
  end
30
36
  end
31
37
 
@@ -56,10 +62,17 @@ module IsoDoc
56
62
  else
57
63
  "##{node['target']}"
58
64
  end
59
- out.a(**{ href: target }) do |l|
65
+ out.a(href: target) do |l|
60
66
  node.children.each { |n| parse(n, l) }
61
67
  end
62
68
  end
69
+
70
+ def suffix_url(url)
71
+ return url if url.nil? || %r{^https?://|^#}.match?(url)
72
+ return url unless File.extname(url).empty?
73
+
74
+ url.sub(/#{File.extname(url)}$/, ".doc")
75
+ end
63
76
  end
64
77
  end
65
78
  end
@@ -0,0 +1,107 @@
1
+ require_relative "./table"
2
+ require_relative "./inline"
3
+
4
+ module IsoDoc
5
+ module WordFunction
6
+ module Body
7
+ WORD_DT_ATTRS = { class: @note ? "Note" : nil, align: "left",
8
+ style: "margin-left:0pt;text-align:left;" }.freeze
9
+
10
+ def dt_parse(dterm, term)
11
+ term.p **attr_code(WORD_DT_ATTRS) do |p|
12
+ if dterm.elements.empty?
13
+ p << dterm.text
14
+ else
15
+ dterm.children.each { |n| parse(n, p) }
16
+ end
17
+ end
18
+ end
19
+
20
+ def dl_parse(node, out)
21
+ node.ancestors("table, dl").empty? or
22
+ return dl_parse_nontable(node, out)
23
+ dl_parse_table(node, out)
24
+ end
25
+
26
+ def dl_parse_nontable(node, out)
27
+ node["id"] and bookmark_parse(node, out)
28
+ list_title_parse(node, out)
29
+ node.elements.select { |n| dt_dd?(n) }
30
+ .each_slice(2) do |dt, dd|
31
+ dl_parse_nontable1(out, dt, dd)
32
+ end
33
+ dl_parse_notes(node, out)
34
+ end
35
+
36
+ WORD_EMBED_DL_ATTRS =
37
+ "text-indent: -2.0cm; margin-left: 2.0cm; tab-stops: 2.0cm;".freeze
38
+
39
+ def dl_parse_nontable1(out, dterm, ddef)
40
+ out.p **attr_code(style: WORD_EMBED_DL_ATTRS, id: dterm["id"]) do |p|
41
+ dterm.children.each { |n| parse(n, p) }
42
+ insert_tab(p, 1)
43
+ ddef["id"] and bookmark_parse(ddef, out)
44
+ ddef_first_para(out, ddef)
45
+ end
46
+ ddef_other_paras(out, ddef)
47
+ end
48
+
49
+ def ddef_first_para(out, ddef)
50
+ if ddef.elements&.first&.name == "p"
51
+ ddef.children.first.children.each { |n| parse(n, out) }
52
+ else
53
+ ddef.children.each { |n| parse(n, out) }
54
+ end
55
+ end
56
+
57
+ def ddef_other_paras(out, ddef)
58
+ ddef.elements&.first&.name == "p" or return
59
+ ddef.children[1..-1].each { |n| parse(n, out) }
60
+ end
61
+
62
+ def dl_parse_table(node, out)
63
+ list_title_parse(node, out)
64
+ out.table **attr_code(id: node["id"],
65
+ class: (node["class"] || "dl")) do |v|
66
+ node.elements.select { |n| dt_dd?(n) }
67
+ .each_slice(2) do |dt, dd|
68
+ dl_parse_table1(v, dt, dd)
69
+ end
70
+ dl_parse_table_notes(node, v)
71
+ end
72
+ end
73
+
74
+ def dl_parse_table1(table, dterm, ddefn)
75
+ table.tr do |tr|
76
+ tr.td valign: "top", align: "left" do |term|
77
+ dt_parse(dterm, term)
78
+ end
79
+ tr.td valign: "top" do |listitem|
80
+ ddefn.children.each { |n| parse(n, listitem) }
81
+ end
82
+ end
83
+ end
84
+
85
+ def dl_parse_table_notes(node, out)
86
+ remainder = node.elements.reject { |n| dt_dd?(n) || n.name == "name" }
87
+ remainder.empty? and return
88
+ out.tr do |tr|
89
+ tr.td colspan: 2 do |td|
90
+ remainder.each { |n| parse(n, td) }
91
+ end
92
+ end
93
+ end
94
+
95
+ def li_parse(node, out)
96
+ out.li **attr_code(id: node["id"]) do |li|
97
+ if node["uncheckedcheckbox"] == "true"
98
+ li << '<span class="zzMoveToFollowing">&#x2610; </span>'
99
+ elsif node["checkedcheckbox"] == "true"
100
+ li << '<span class="zzMoveToFollowing">&#x2611; </span>'
101
+ end
102
+ node.children.each { |n| parse(n, li) }
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -17,6 +17,7 @@ bibliography: بيبليوغرافيا
17
17
  clause: فقرة
18
18
  annex: ملحق
19
19
  appendix: تذييل
20
+ continued: واصلت
20
21
  no_terms_boilerplate: |
21
22
  <p>لم يتم سرد أي مصطلحات وتعريفات في هذا المستند.</p>
22
23
  internal_terms_boilerplate: |
@@ -17,6 +17,7 @@ bibliography: Bibliographie
17
17
  clause: Klausel
18
18
  annex: Anhang
19
19
  appendix: Appendix
20
+ continued: Fortsetzung
20
21
  no_terms_boilerplate: |
21
22
  <p>In diesem Dokument sind keine Begriffe und Definitionen aufgeführt.</p>
22
23
  internal_terms_boilerplate: |
@@ -18,6 +18,7 @@ preface: Preface
18
18
  clause: Clause
19
19
  annex: Annex
20
20
  appendix: Appendix
21
+ continued: continued
21
22
  no_terms_boilerplate: |
22
23
  <p>No terms and definitions are listed in this document.</p>
23
24
  internal_terms_boilerplate: |
@@ -17,6 +17,7 @@ bibliography: Bibliografía
17
17
  clause: Cláusula
18
18
  annex: Anexo
19
19
  appendix: Apéndice
20
+ continued: continuación
20
21
  no_terms_boilerplate: |
21
22
  <p>En este documento no se enumeran términos ni definiciones.</p>
22
23
  internal_terms_boilerplate: |
@@ -18,6 +18,7 @@ preface: Préface
18
18
  clause: Article
19
19
  annex: Annexe
20
20
  appendix: Appendice
21
+ continued: continué
21
22
  no_terms_boilerplate: |
22
23
  <p>Aucun terme n’est défini dans le présent document.</p>
23
24
  internal_terms_boilerplate: |
@@ -18,6 +18,7 @@ preface: Preface
18
18
  clause: 箇条
19
19
  annex: 附属書
20
20
  appendix: Appendix
21
+ continued: 続き
21
22
  no_terms_boilerplate: |
22
23
  <p>この規格には,定義する用語はない。</p>
23
24
  internal_terms_boilerplate: |
@@ -17,6 +17,7 @@ bibliography: Библиография
17
17
  clause: Пункт
18
18
  annex: Дополнение
19
19
  appendix: Приложение
20
+ continued: продолжение
20
21
  no_terms_boilerplate: |
21
22
  <p>Термины и определения не перечислены в этом документе.</p>
22
23
  internal_terms_boilerplate: |
@@ -18,6 +18,7 @@ preface: 序言
18
18
  clause: 条
19
19
  annex: 附件
20
20
  appendix: 附录
21
+ continued: 继续
21
22
  no_terms_boilerplate: |
22
23
  <p>本文件不提供术语和定义。</p>
23
24
  internal_terms_boilerplate: |
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: 2.5.8
4
+ version: 2.5.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-06 00:00:00.000000000 Z
11
+ date: 2023-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html2doc
@@ -439,6 +439,7 @@ files:
439
439
  - lib/isodoc/presentation_function/inline.rb
440
440
  - lib/isodoc/presentation_function/math.rb
441
441
  - lib/isodoc/presentation_function/refs.rb
442
+ - lib/isodoc/presentation_function/reqt.rb
442
443
  - lib/isodoc/presentation_function/section.rb
443
444
  - lib/isodoc/presentation_function/sourcecode.rb
444
445
  - lib/isodoc/presentation_function/terms.rb
@@ -452,6 +453,7 @@ files:
452
453
  - lib/isodoc/word_function/comments.rb
453
454
  - lib/isodoc/word_function/footnotes.rb
454
455
  - lib/isodoc/word_function/inline.rb
456
+ - lib/isodoc/word_function/lists.rb
455
457
  - lib/isodoc/word_function/postprocess.rb
456
458
  - lib/isodoc/word_function/postprocess_cover.rb
457
459
  - lib/isodoc/word_function/postprocess_table.rb