isodoc 3.1.12 → 3.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ce8e37bf69e8622cfac604ad54ea06088dea5c9eec91226d8d9e3f3761693c4
4
- data.tar.gz: 033de119ca1a8300891954739f892434955f9830ac3becdd0d87f479b8914ba2
3
+ metadata.gz: a1528432b5d869e42077b250498452e276bd3c774dbe55adbb375157c4c61f87
4
+ data.tar.gz: 16608e9fd9e1d2dd682667db8455bf63737d79e346f689c49c11628519f661e2
5
5
  SHA512:
6
- metadata.gz: 4d7bf496ad23e75d105f5bdacf73f0d21e537f0d559f53914e78b3da631044500c5887f544290003b3d2508f7926f860ff846857b8ca0a434f23b3f6143033e5
7
- data.tar.gz: 6644b38d8a81476e6ac6e11b7884685f2942c0b7ee69d5078ee48276eaba30c3e901fcf112594c8202a6fd41bb81e4e7d149e14de9c59350a1fa0b312344580f
6
+ metadata.gz: 8c230460e11f2d68b5a844629947e8ee4fbdc4b23dd58d0ecbac85b2adaebeedf4fbde0b5eb434e51717449e3835cd202fefe5c7edfe217724cd5b41683e190b
7
+ data.tar.gz: 98fc8b60f2d0ebeddf9a2040fedba22b592e4af190cb055bb58c88fca0107daecfe9833c7552f76365a532591ea0e007ee6a228bbd41af21e25b9d5b5546871a
data/isodoc.gemspec CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.add_dependency "base64"
32
32
  spec.add_dependency "bigdecimal"
33
- spec.add_dependency "html2doc", "~> 1.9.0"
33
+ spec.add_dependency "html2doc", "~> 1.10.0"
34
34
  # spec.add_dependency "isodoc-i18n", "~> 1.1.0" # already in relaton-render and mn-requirements
35
35
  # spec.add_dependency "relaton-cli"
36
36
  # spec.add_dependency "metanorma-utils", "~> 1.5.0" # already in isodoc-i18n
@@ -105,9 +105,9 @@ module IsoDoc
105
105
  table.at(".//tr").xpath("./td | ./th").each do |td|
106
106
  cols += (td["colspan"] ? td["colspan"].to_i : 1)
107
107
  end
108
- style =
109
- %{border-top:0pt;border-bottom:#{IsoDoc::Function::Table::SW} 1.5pt;}
110
- tfoot.add_child("<tr><td colspan='#{cols}' style='#{style}'/></tr>")
108
+ table["class"].nil? or # = plain table
109
+ s = "style='border-top:0pt;border-bottom:#{IsoDoc::Function::Table::SW} 1.5pt;'"
110
+ tfoot.add_child("<tr><td colspan='#{cols}' #{s}/></tr>")
111
111
  tfoot.xpath(".//td").last
112
112
  end
113
113
 
@@ -58,7 +58,7 @@ module IsoDoc
58
58
  end
59
59
  end
60
60
 
61
- def fmt_review_body_parse(node, out); end
61
+ def fmt_annotation_body_parse(node, out); end
62
62
  end
63
63
  end
64
64
  end
@@ -226,11 +226,11 @@ module IsoDoc
226
226
  children_parse(node, out)
227
227
  end
228
228
 
229
- def fmt_review_start_parse(node, out)
229
+ def fmt_annotation_start_parse(node, out)
230
230
  children_parse(node, out)
231
231
  end
232
232
 
233
- def fmt_review_end_parse(node, out)
233
+ def fmt_annotation_end_parse(node, out)
234
234
  children_parse(node, out)
235
235
  end
236
236
  end
@@ -96,7 +96,7 @@ module IsoDoc
96
96
  def svgmap_parse(node, out); end
97
97
  def amend_parse(node, out); end
98
98
  def semx_sourcecode_parse(node, out); end
99
- def review_note_parse(node, out); end
99
+ def annotation_note_parse(node, out); end
100
100
  def semx_source_parse(node, out); end
101
101
  end
102
102
  end
@@ -37,6 +37,7 @@ module IsoDoc
37
37
  def ol_attrs(node)
38
38
  { # type: node["type"] ? ol_style(node["type"].to_sym) : ol_depth(node),
39
39
  type: ol_style(node["type"]&.to_sym),
40
+ start: node["start"],
40
41
  id: node["id"], style: keep_style(node) }
41
42
  end
42
43
 
@@ -40,22 +40,32 @@ module IsoDoc
40
40
  end
41
41
  end
42
42
 
43
+ def bordered_table_style(node, klass)
44
+ bordered = "border-width:1px;border-spacing:0;"
45
+ (node["plain"] != "true" && (%w(modspec).include?(klass) || !klass)) or
46
+ bordered = ""
47
+ bordered
48
+ end
49
+
43
50
  def table_attrs(node)
44
- width = node["width"] ? "width:#{node['width']};" : nil
45
51
  c = node["class"]
46
- bordered = "border-width:1px;border-spacing:0;"
47
- (%w(modspec).include?(c) || !c) or bordered = ""
48
- attr_code(
49
- id: node["id"],
50
- class: c || "MsoISOTable",
51
- style: "#{bordered}#{width}#{keep_style(node)}",
52
- title: node["alt"],
53
- )
52
+ style = table_attrs_style(node, c)
53
+ attr_code(id: node["id"],
54
+ class: node["plain"] == "true" ? nil : (c || "MsoISOTable"),
55
+ style: style, title: node["alt"])
54
56
  end
55
57
 
56
- def tcaption(node, table)
57
- return unless node["summary"]
58
+ def table_attrs_style(node, klass)
59
+ width = node["width"] ? "width:#{node['width']};" : nil
60
+ bordered = bordered_table_style(node, klass)
61
+ style = node["style"] ? "" : "#{bordered}#{width}"
62
+ style += keep_style(node) || ""
63
+ style.empty? and style = nil
64
+ style
65
+ end
58
66
 
67
+ def tcaption(node, table)
68
+ node["summary"] or return
59
69
  table.caption do |c|
60
70
  c.span style: "display:none" do |s|
61
71
  s << node["summary"]
@@ -127,6 +137,7 @@ module IsoDoc
127
137
  end
128
138
 
129
139
  def table_bordered?(node)
140
+ node.parent.parent["plain"] == "true" and return false
130
141
  c = node.parent.parent["class"]
131
142
  %w(modspec).include?(c) || !c
132
143
  end
@@ -157,7 +157,7 @@ module IsoDoc
157
157
  when "fmt-source" then source_parse(node, out)
158
158
  when "tr" then tr_parse(node, out)
159
159
  when "note" then note_parse(node, out)
160
- when "review" then review_note_parse(node, out)
160
+ when "annotation" then annotation_note_parse(node, out)
161
161
  when "admonition" then admonition_parse(node, out)
162
162
  when "formula" then formula_parse(node, out)
163
163
  when "table" then table_parse(node, out)
@@ -237,9 +237,9 @@ module IsoDoc
237
237
  when "fmt-fn-body" then fmt_fn_body_parse(node, out)
238
238
  when "fmt-fn-label" then fmt_fn_label_parse(node, out)
239
239
  when "fmt-footnote-container" then fmt_footnote_container_parse(node, out)
240
- when "fmt-review-start" then fmt_review_start_parse(node, out)
241
- when "fmt-review-end" then fmt_review_end_parse(node, out)
242
- when "fmt-review-body" then fmt_review_body_parse(node, out)
240
+ when "fmt-annotation-start" then fmt_annotation_start_parse(node, out)
241
+ when "fmt-annotation-end" then fmt_annotation_end_parse(node, out)
242
+ when "fmt-annotation-body" then fmt_annotation_body_parse(node, out)
243
243
  else error_parse(node, out)
244
244
  end
245
245
  end
@@ -1,5 +1,4 @@
1
1
  require "metanorma-utils"
2
- require_relative "../../nokogiri/xml/node"
3
2
 
4
3
  module IsoDoc
5
4
  module Function
@@ -96,7 +96,10 @@ module IsoDoc
96
96
 
97
97
  def table_attrs(node)
98
98
  ret = super
99
- node.at(ns("./colgroup")) and ret[:style] += "table-layout:fixed;"
99
+ if node.at(ns("./colgroup"))
100
+ ret[:style] ||= ""
101
+ ret[:style] += "table-layout:fixed;"
102
+ end
100
103
  ret
101
104
  end
102
105
 
@@ -102,9 +102,30 @@ module IsoDoc
102
102
  set(:agency, agency)
103
103
  set(:publisher, connectives_strip(@i18n.boolean_conj(publisher, "and")))
104
104
  set(:copublisher_logos, logos)
105
+ set(:copublisher_logo_attrs, copublisher_logo_attrs(xml))
105
106
  agency_addr(xml)
106
107
  end
107
108
 
109
+ def copublisher_logo_attrs(xml)
110
+ xml.xpath(ns("//metanorma-extension/presentation-metadata/*"))
111
+ .each_with_object([]) do |x, m|
112
+ copublisher_logo_attr?(x) or next
113
+ p = x.name.split(/[_-]/)
114
+ idx = (p[4] || "1").to_i - 1
115
+ m[idx] ||= {}
116
+ m[idx][p[2]] ||= {}
117
+ m[idx][p[2]][p[3]] = x.text
118
+ end
119
+ end
120
+
121
+ def copublisher_logo_attr?(elem)
122
+ elem.name.start_with?("logo-publisher-") or return false
123
+ p = elem.name.split(/[_-]/)
124
+ %w(doc html).include?(p[2]) &&
125
+ %w(height width).include?(p[3]) &&
126
+ (!p[4] || /^\d+/.match?(p[4]))
127
+ end
128
+
108
129
  def agency_addr(xml)
109
130
  a = xml.at(ns("//bibdata/contributor[xmlns:role/@type = 'publisher'][1]/" \
110
131
  "organization")) or return
@@ -1,7 +1,7 @@
1
1
  module IsoDoc
2
2
  class PresentationXMLConvert < ::IsoDoc::Convert
3
3
  def prefix_name(node, delims, label, elem)
4
- label, delims = prefix_name_defaults(node, delims, label)
4
+ label, delims = prefix_name_defaults(node, delims, label, elem)
5
5
  name, ins, ids, number = prefix_name_prep(node, elem)
6
6
  ins.next = fmt_xref_label(label, number, ids)
7
7
  # autonum can be empty, e.g single note in clause: "NOTE []"
@@ -11,8 +11,11 @@ module IsoDoc
11
11
  prefix_name_postprocess(node, elem)
12
12
  end
13
13
 
14
- def prefix_name_defaults(_node, delims, label)
14
+ def prefix_name_defaults(node, delims, label, elem)
15
15
  label&.empty? and label = nil
16
+ node["unnumbered"] == "true" && !node.at(ns("./#{elem}")) &&
17
+ node.name != "admonition" and label = nil
18
+ # do not caption unnumbered uncaptioned blocks, other than admonitions
16
19
  delims.nil? and delims = {}
17
20
  [label, delims]
18
21
  end
@@ -27,7 +30,7 @@ module IsoDoc
27
30
  end
28
31
 
29
32
  def prefix_name_labels(node)
30
- @new_ids ||= {}
33
+ #@new_ids ||= {}
31
34
  id = "_#{UUIDTools::UUID.random_create}"
32
35
  @new_ids[id] = nil
33
36
  { elem: node["id"], name: id }
@@ -112,7 +112,7 @@ module IsoDoc
112
112
 
113
113
  def table_css(elem)
114
114
  parser = IsoDoc::CssBorderParser::BorderParser.new
115
- elem.xpath(ns(".//tr | .//th | .//td")).each do |n|
115
+ elem.xpath(ns(".//tr | .//th | .//td | .//table")).each do |n|
116
116
  n["style"] or next
117
117
  parsed_properties = parser.parse_declaration(n["style"])
118
118
  new_style = parser.to_css_string(parsed_properties)
@@ -0,0 +1,23 @@
1
+ module IsoDoc
2
+ class PresentationXMLConvert < ::IsoDoc::Convert
3
+ def cleanup(docxml)
4
+ docxml["type"] = "presentation"
5
+ empty_elements_remove(docxml)
6
+ end
7
+
8
+ # allow fmt-link to be empty
9
+ def empty_elements_remove(docxml)
10
+ %w(fmt-name fmt-xref-label fmt-source fmt-xref fmt-eref fmt-origin
11
+ fmt-concept fmt-related fmt-preferred fmt-deprecates
12
+ fmt-admitted fmt-termsource fmt-definition fmt-footnote-container
13
+ fmt-fn-body fmt-fn-label fmt-annotation-body fmt-provision
14
+ fmt-identifier fmt-date).each do |e|
15
+ docxml.xpath(ns("//#{e}")).each do |n|
16
+ n.text.strip.empty? or next
17
+ n.elements.empty? or next
18
+ n.remove
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -193,8 +193,7 @@ module IsoDoc
193
193
  out = desgn.parent.at(ns("./fmt-#{desgn.name}"))
194
194
  d1 = semx_fmt_dup(desgn)
195
195
  s = d1.at(ns("./source"))
196
- s0 = desgn.at(ns("./source"))
197
- modification_dup_align(s0, s)
196
+ modification_dup_align(desgn.at(ns("./source")), s)
198
197
  name = d1.at(ns("./expression/name | ./letter-symbol/name | " \
199
198
  "./graphical-symbol")) or return
200
199
  designation_annotate(d1, name, desgn)
@@ -227,9 +226,8 @@ module IsoDoc
227
226
 
228
227
  def designation_grammar(desgn, name)
229
228
  g = desgn.at(ns("./expression/grammar")) or return
230
- ret = []
231
- g.xpath(ns("./gender | ./number")).each do |x|
232
- ret << @i18n.grammar_abbrevs[x.text]
229
+ ret = g.xpath(ns("./gender | ./number")).each_with_object([]) do |x, m|
230
+ m << @i18n.grammar_abbrevs[x.text]
233
231
  end
234
232
  %w(isPreposition isParticiple isAdjective isVerb isAdverb isNoun)
235
233
  .each do |x|
@@ -252,9 +250,7 @@ module IsoDoc
252
250
  end
253
251
 
254
252
  def designation_bookmarks(desgn, name)
255
- desgn.xpath(ns(".//bookmark")).each do |b|
256
- name << b.remove
257
- end
253
+ desgn.xpath(ns(".//bookmark")).each { |b| name << b.remove }
258
254
  end
259
255
  end
260
256
  end
@@ -139,14 +139,22 @@ module IsoDoc
139
139
  end
140
140
 
141
141
  def comments(docxml)
142
- docxml.xpath(ns("//review")).each do |c|
142
+ global_display = display_comments_global?(docxml)
143
+ docxml.xpath(ns("//annotation")).each do |c|
144
+ global_display || display_comment_override?(c) or next
143
145
  c1 = comment_body(c)
144
146
  comment_bookmarks(c1)
145
147
  end
146
148
  end
147
149
 
150
+ # if false, then decision on displaying comment is only dependent on
151
+ # display_comments_global? . display_comment_override? overrides that
152
+ def display_comment_override?(_comment)
153
+ false
154
+ end
155
+
148
156
  def comment_body(elem)
149
- c1 = elem.after("<fmt-review-body/>").next
157
+ c1 = elem.after("<fmt-annotation-body/>").next
150
158
  elem.attributes.each_key { |k| k == "id" or c1[k] = elem[k] }
151
159
  add_id(c1)
152
160
  c1 << semx_fmt_dup(elem)
@@ -162,7 +170,7 @@ module IsoDoc
162
170
 
163
171
  # Do not insert a comment bookmark inside another comment bookmark
164
172
  AVOID_COMMENT_BOOKMARKS = <<~XPATH.freeze
165
- [not(ancestor::xmlns:fmt-review-start)][not(ancestor::xmlns:fmt-review-end)]
173
+ [not(ancestor::xmlns:fmt-annotation-start)][not(ancestor::xmlns:fmt-annotation-end)]
166
174
  XPATH
167
175
 
168
176
  def comment_bookmarks_locate(elem)
@@ -181,7 +189,7 @@ module IsoDoc
181
189
  end
182
190
 
183
191
  def comment_bookmark_start(from, elem)
184
- ret = from.before("<fmt-review-start/>").previous
192
+ ret = from.before("<fmt-annotation-start/>").previous
185
193
  add_id(ret)
186
194
  ret["source"] = elem["from"]
187
195
  comment_to_bookmark_attrs(elem, ret, start: true)
@@ -190,7 +198,7 @@ module IsoDoc
190
198
  end
191
199
 
192
200
  def comment_bookmark_end(to, elem)
193
- ret = to.after("<fmt-review-end/>").next
201
+ ret = to.after("<fmt-annotation-end/>").next
194
202
  add_id(ret)
195
203
  ret["source"] = elem["to"]
196
204
  comment_to_bookmark_attrs(elem, ret, start: false)
@@ -205,5 +213,11 @@ module IsoDoc
205
213
  def comment_bookmark_end_label(_elem)
206
214
  ""
207
215
  end
216
+
217
+ def display_comments_global?(docxml)
218
+ m = docxml.at(ns("//presentation-metadata/render-document-annotations"))
219
+ m&.text and return m.text != "false"
220
+ @meta.get[:unpublished]
221
+ end
208
222
  end
209
223
  end
@@ -77,7 +77,6 @@ module IsoDoc
77
77
  end
78
78
 
79
79
  def provide_ids(docxml)
80
- @new_ids = {} # guids assigned within Presentation XML
81
80
  anchor_sanitise(docxml)
82
81
  populate_id(docxml)
83
82
  add_missing_id(docxml)
@@ -100,7 +99,7 @@ module IsoDoc
100
99
 
101
100
  def add_missing_id(docxml)
102
101
  docxml.xpath(ns("//source | //modification | //erefstack | //fn | " \
103
- "//review | //floating-title | //li | //executivesummary | " \
102
+ "//annotation | //floating-title | //li | //executivesummary | " \
104
103
  "//preface/abstract | //foreword | //introduction | //annex | " \
105
104
  "//acknowledgements | //clause | //references | //terms | " \
106
105
  "//preferred | //deprecates | //admitted | //related")).each do |s|
@@ -120,10 +119,12 @@ module IsoDoc
120
119
  end
121
120
 
122
121
  def add_new_contenthash_id(docxml, ids)
122
+ suffix = "" # for disambiguation in Metanorma Collections
123
+ docxml["document_suffix"] and suffix = "_#{docxml['document_suffix']}"
123
124
  %w(original-id id).each do |k|
124
125
  docxml.xpath("//*[@#{k}]").each do |x|
125
126
  ids.has_key?(x[k]) or next
126
- new_id = contenthash(x)
127
+ new_id = Metanorma::Utils::contenthash(x) + suffix
127
128
  ids[x[k]] = new_id
128
129
  x[k] = new_id
129
130
  end
@@ -134,17 +135,10 @@ module IsoDoc
134
135
  Metanorma::Utils::anchor_attributes(presxml: true).each do |e|
135
136
  docxml.xpath("//xmlns:#{e[0]}[@#{e[1]}]").each do |x|
136
137
  ids.has_key?(x[e[1]]) or next
137
- #require "debug"; binding.b unless ids[x[e[1]]]
138
138
  ids[x[e[1]]] or next
139
139
  x[e[1]] = ids[x[e[1]]]
140
140
  end
141
141
  end
142
142
  end
143
-
144
- # TODO duplicate of standoc
145
- def contenthash(elem)
146
- Digest::MD5.hexdigest("#{elem.path}////#{elem.text}")
147
- .sub(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "_\\1-\\2-\\3-\\4-\\5")
148
- end
149
143
  end
150
144
  end
@@ -219,7 +219,7 @@ module IsoDoc
219
219
  end
220
220
 
221
221
  def ruby1(elem)
222
- v = elem.at(ns("./pronunciation | ./annotation")).remove
222
+ v = elem.at(ns("./ruby-pronunciation | ./ruby-annotation")).remove
223
223
  elem.xpath(ns("./ruby")).each do |r|
224
224
  ruby1(r)
225
225
  end
@@ -1,14 +1,41 @@
1
1
  module IsoDoc
2
2
  class PresentationXMLConvert < ::IsoDoc::Convert
3
3
  def metadata(docxml)
4
+ preprocess_metadata(docxml)
4
5
  toc_metadata(docxml)
5
6
  fonts_metadata(docxml)
6
7
  attachments_extract(docxml)
7
- localized_strings(docxml)
8
8
  a = docxml.at(ns("//metanorma-extension")) or return
9
9
  a.elements.empty? and a.remove
10
10
  end
11
11
 
12
+ def preprocess_metadata(docxml)
13
+ localized_strings(docxml)
14
+ logo_expand_pres_metadata(docxml)
15
+ end
16
+
17
+ # logo-{role}-{format}-{height/width}-{number}
18
+ def logo_expand_pres_metadata(docxml)
19
+ docxml.xpath(ns("//metanorma-extension/presentation-metadata/*"))
20
+ .each do |x|
21
+ logo_size_pres_metadata_incomplete?(x) or next
22
+ parts = x.name.split("-")
23
+ @output_formats.each_key do |f|
24
+ tagname = "logo-#{parts[1]}-#{f}-#{parts[2..].join('-')}"
25
+ x.parent.next = <<~XML
26
+ <presentation-metadata><#{tagname}>#{x.text}</#{tagname}></presentation-metadata>
27
+ XML
28
+ end
29
+ end
30
+ end
31
+
32
+ def logo_size_pres_metadata_incomplete?(elem)
33
+ parts = elem.name.split("-")
34
+ elem.name.start_with?("logo-") &&
35
+ %w(author editor publisher authorizer distrbutor).include?(parts[1]) &&
36
+ %w(height width).include?(parts[2])
37
+ end
38
+
12
39
  def localized_strings(docxml)
13
40
  a = docxml.at(ns("//bibdata")) or return
14
41
  a.next =
@@ -68,9 +68,9 @@ module IsoDoc
68
68
  end
69
69
 
70
70
  def annotations(elem, fmt_elem)
71
- elem.at(ns("./annotation")) or return
71
+ elem.at(ns("./callout-annotation")) or return
72
72
  ret = ""
73
- elem.xpath(ns("./annotation")).each do |a|
73
+ elem.xpath(ns("./callout-annotation")).each do |a|
74
74
  id = a["original-id"]
75
75
  dd = semx_fmt_dup(a)
76
76
  dd["source"] = a["id"]
@@ -79,7 +79,7 @@ module IsoDoc
79
79
  <dd>#{to_xml dd}</dd>
80
80
  OUT
81
81
  end
82
- fmt_elem.xpath(ns("./annotation")).each(&:remove)
82
+ fmt_elem.xpath(ns("./callout-annotation")).each(&:remove)
83
83
  fmt_elem << "<dl><name>#{@i18n.key}</name>#{ret}</dl>"
84
84
  end
85
85
 
@@ -104,7 +104,7 @@ module IsoDoc
104
104
  end
105
105
 
106
106
  def source_remove_annotations(ret, elem)
107
- ret[:ann] = elem.xpath(ns("./annotation")).each(&:remove)
107
+ ret[:ann] = elem.xpath(ns("./callout-annotation")).each(&:remove)
108
108
  ret[:call] = elem.xpath(ns("./callout")).each_with_object([]) do |c, m|
109
109
  m << { xml: c.remove, line: c.line - elem.line }
110
110
  end
@@ -13,20 +13,22 @@ require_relative "presentation_function/bibdata"
13
13
  require_relative "presentation_function/metadata"
14
14
  require_relative "presentation_function/footnotes"
15
15
  require_relative "presentation_function/ids"
16
+ require_relative "presentation_function/cleanup"
16
17
 
17
18
  module IsoDoc
18
19
  class PresentationXMLConvert < ::IsoDoc::Convert
19
20
  def initialize(options)
20
21
  @format = :presentation
21
22
  @suffix = "presentation.xml"
23
+ @new_ids = {} # guids assigned within Presentation XML
22
24
  super
23
25
  end
24
26
 
25
27
  def convert1(docxml, filename, dir)
26
28
  presxml_convert_init(docxml, filename, dir)
27
29
  conversions(docxml)
28
- docxml.root["type"] = "presentation"
29
- id_validate(docxml.root)
30
+ cleanup(docxml.root)
31
+ validate(docxml.root)
30
32
  docxml.to_xml.gsub("&lt;", "&#x3c;").gsub("&gt;", "&#x3e;")
31
33
  end
32
34
 
@@ -44,6 +46,10 @@ module IsoDoc
44
46
  counter_init
45
47
  end
46
48
 
49
+ def validate(docxml)
50
+ id_validate(docxml)
51
+ end
52
+
47
53
  def bibitem_lookup(docxml)
48
54
  @bibitem_lookup ||= docxml.xpath(ns("//references/bibitem"))
49
55
  .each_with_object({}) do |b, m|
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "3.1.12".freeze
2
+ VERSION = "3.2.1".freeze
3
3
  end
@@ -2,7 +2,7 @@ module IsoDoc
2
2
  module WordFunction
3
3
  module Comments
4
4
  def comments(docxml, out)
5
- c = docxml.xpath(ns("//fmt-review-body"))
5
+ c = docxml.xpath(ns("//fmt-annotation-body"))
6
6
  c.empty? and return
7
7
  out.div style: "mso-element:comment-list" do |div|
8
8
  @in_comment = true
@@ -17,7 +17,7 @@ module IsoDoc
17
17
  to: node["end"] }
18
18
  end
19
19
 
20
- def fmt_review_start_parse(node, out)
20
+ def fmt_annotation_start_parse(node, out)
21
21
  make_comment_link(out, node["target"], node)
22
22
  end
23
23
 
@@ -42,7 +42,7 @@ module IsoDoc
42
42
  end
43
43
  end
44
44
 
45
- def fmt_review_body_parse(node, out)
45
+ def fmt_annotation_body_parse(node, out)
46
46
  out.div style: "mso-element:comment", id: node["id"] do |div|
47
47
  div.span style: %{mso-comment-author:"#{node['reviewer']}"}
48
48
  make_comment_target(div)
@@ -61,10 +61,15 @@ module IsoDoc
61
61
  ddef.children[1..].each { |n| parse(n, out) }
62
62
  end
63
63
 
64
+ def dl_table_attrs(node)
65
+ { id: node["id"],
66
+ align: node["class"] == "formula_dl" ? "left" : nil,
67
+ class: node["class"] || "dl" }
68
+ end
69
+
64
70
  def dl_parse_table(node, out)
65
71
  list_title_parse(node, out)
66
- out.table **attr_code(id: node["id"],
67
- class: node["class"] || "dl") do |v|
72
+ out.table **attr_code(dl_table_attrs(node)) do |v|
68
73
  node.elements.select { |n| dt_dd?(n) }
69
74
  .each_slice(2) do |dt, dd|
70
75
  dl_parse_table1(v, dt, dd)
@@ -15,9 +15,10 @@ module IsoDoc
15
15
  table.at(".//tr").xpath("./td | ./th").each do |td|
16
16
  cols += (td["colspan"] ? td["colspan"].to_i : 1)
17
17
  end
18
- style = "border-top:0pt;mso-border-top-alt:0pt;" \
19
- "border-bottom:#{SW1} 1.5pt;mso-border-bottom-alt:#{SW1} 1.5pt;"
20
- tfoot.add_child("<tr><td colspan='#{cols}' style='#{style}'/></tr>")
18
+ table["plain"] == "true" or
19
+ s = "style='border-top:0pt;mso-border-top-alt:0pt;" \
20
+ "border-bottom:#{SW1} 1.5pt;mso-border-bottom-alt:#{SW1} 1.5pt;'"
21
+ tfoot.add_child("<tr><td colspan='#{cols}' #{s}/></tr>")
21
22
  tfoot.xpath(".//td").last
22
23
  end
23
24
 
@@ -39,7 +40,7 @@ module IsoDoc
39
40
  border-top:#{top}mso-border-top-alt:#{top}
40
41
  border-bottom:#{bottom}mso-border-bottom-alt:#{bottom}
41
42
  STYLE
42
- opt[:bordered] or ret = ""
43
+ opt[:bordered] && !cell["style"] or ret = ""
43
44
  pb = keep_rows_together(cell, rowmax, totalrows, opt) ? "avoid" : "auto"
44
45
  "#{ret}page-break-after:#{pb};"
45
46
  end
@@ -72,15 +73,14 @@ module IsoDoc
72
73
 
73
74
  def table_attrs(node)
74
75
  c = node["class"]
75
- bordered = "border-spacing:0;border-width:1px;"
76
- (%w(modspec).include?(c) || !c) or bordered = nil
77
- ret = {
78
- summary: node["summary"], width: node["width"],
79
- style: "mso-table-anchor-horizontal:column;mso-table-overlap:never;" \
80
- "#{bordered}#{keep_style(node)}",
81
- class: (node.text.length > 4000 ? "MsoISOTableBig" : "MsoISOTable")
82
- }
83
- bordered or ret.delete(:class)
76
+ style = node["style"] || node["plain"] == "true" ? "" : "border-spacing:0;border-width:1px;"
77
+ (%w(modspec).include?(c) || !c) or style = nil
78
+ ret =
79
+ { summary: node["summary"], width: node["width"],
80
+ style: "mso-table-anchor-horizontal:column;mso-table-overlap:never;" \
81
+ "#{style}#{keep_style(node)}",
82
+ class: (node.text.length > 4000 ? "MsoISOTableBig" : "MsoISOTable") }
83
+ style or ret.delete(:class)
84
84
  super.merge(attr_code(ret))
85
85
  end
86
86
 
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.12
4
+ version: 3.2.1
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-06-23 00:00:00.000000000 Z
11
+ date: 2025-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.9.0
47
+ version: 1.10.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.9.0
54
+ version: 1.10.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mn2pdf
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -438,6 +438,7 @@ files:
438
438
  - lib/isodoc/presentation_function/autonum.rb
439
439
  - lib/isodoc/presentation_function/bibdata.rb
440
440
  - lib/isodoc/presentation_function/block.rb
441
+ - lib/isodoc/presentation_function/cleanup.rb
441
442
  - lib/isodoc/presentation_function/concepts.rb
442
443
  - lib/isodoc/presentation_function/docid.rb
443
444
  - lib/isodoc/presentation_function/erefs.rb
@@ -487,7 +488,6 @@ files:
487
488
  - lib/metanorma/output/base.rb
488
489
  - lib/metanorma/output/utils.rb
489
490
  - lib/metanorma/output/xslfo.rb
490
- - lib/nokogiri/xml/node.rb
491
491
  - lib/relaton/render-isodoc/config.yml
492
492
  - lib/relaton/render-isodoc/general.rb
493
493
  homepage: https://github.com/metanorma/isodoc
@@ -1,14 +0,0 @@
1
- module Nokogiri
2
- module XML
3
- class Node
4
- def add_first_child(content)
5
- if children.empty?
6
- add_child(content)
7
- else
8
- children.first.previous = content
9
- end
10
- self
11
- end
12
- end
13
- end
14
- end