uniword 1.7.4 → 1.7.6
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/lib/uniword/builder/paragraph_builder.rb +4 -1
- data/lib/uniword/builder/style_builder.rb +3 -1
- data/lib/uniword/math/plurimath_adapter.rb +1 -1
- data/lib/uniword/review/review_manager.rb +6 -1
- data/lib/uniword/transformation/ooxml_to_mhtml_converter.rb +46 -7
- data/lib/uniword/version.rb +1 -1
- data/lib/uniword/wordprocessingml/drawing.rb +6 -5
- data/lib/uniword/wordprocessingml/paragraph_properties.rb +8 -1
- data/lib/uniword/wordprocessingml/run_properties/conversion.rb +38 -26
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1f78e4ec92cc4ea7740d9e2ec0d3b2acf76ef1851331be34219795c902ebf090
|
|
4
|
+
data.tar.gz: e722b7c3c0b32d87477e727f4f6eeea54c3a766d5d9593d18b6f3698949fc4f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c34a8c5593579f138e64e36ee04f7cd4e8a0fcd6088c7f4d522bc9efdffb6f22c3ceb89d44a0b5e7d64508fad54df2ac856dbd220b8fb989fef3ed635d43b0d
|
|
7
|
+
data.tar.gz: 2eba230eaeffd07d2c30227c81fe4263dabff15f0802df553c42da0062a865283fe8a33fc0ba777b574aa9e5f454a59c3f06323f6a9953994117cc573b578e3e
|
|
@@ -102,7 +102,10 @@ module Uniword
|
|
|
102
102
|
before: before, after: after, line: line, line_rule: rule
|
|
103
103
|
}.select { |_, value| value }
|
|
104
104
|
sp = ensure_properties.ensure_spacing(*written.keys)
|
|
105
|
-
|
|
105
|
+
sp.before = before if before
|
|
106
|
+
sp.after = after if after
|
|
107
|
+
sp.line = line if line
|
|
108
|
+
sp.line_rule = rule if rule
|
|
106
109
|
self
|
|
107
110
|
end
|
|
108
111
|
|
|
@@ -106,7 +106,9 @@ module Uniword
|
|
|
106
106
|
before: before, after: after, line: line
|
|
107
107
|
}.select { |_, value| value }
|
|
108
108
|
sp = ensure_para_props.ensure_spacing(*written.keys)
|
|
109
|
-
|
|
109
|
+
sp.before = before if before
|
|
110
|
+
sp.after = after if after
|
|
111
|
+
sp.line = line if line
|
|
110
112
|
self
|
|
111
113
|
end
|
|
112
114
|
|
|
@@ -158,7 +158,7 @@ module Uniword
|
|
|
158
158
|
# Extract alignment (m:jc)
|
|
159
159
|
jc_node = para_props.at_xpath(".//m:jc", "m" => OMML_NAMESPACE)
|
|
160
160
|
if jc_node
|
|
161
|
-
jc_val = jc_node
|
|
161
|
+
jc_val = jc_node["m:val"]
|
|
162
162
|
properties[:alignment] = normalize_alignment(jc_val)
|
|
163
163
|
end
|
|
164
164
|
end
|
|
@@ -367,7 +367,12 @@ module Uniword
|
|
|
367
367
|
# @return [void]
|
|
368
368
|
def remove_anchored_elements(paragraph, collection_name, tag,
|
|
369
369
|
comment_id)
|
|
370
|
-
collection =
|
|
370
|
+
collection = case collection_name
|
|
371
|
+
when :comment_range_starts
|
|
372
|
+
paragraph.comment_range_starts
|
|
373
|
+
when :comment_range_ends
|
|
374
|
+
paragraph.comment_range_ends
|
|
375
|
+
end
|
|
371
376
|
matching = collection.select { |element| element.id.to_s == comment_id }
|
|
372
377
|
matching.each do |element|
|
|
373
378
|
index = collection.index(element)
|
|
@@ -270,16 +270,55 @@ document_name = nil)
|
|
|
270
270
|
# Build HTML body content from sections array.
|
|
271
271
|
# Each section is wrapped in a <div class=WordSectionN> with <br> between them.
|
|
272
272
|
def build_sections_html(sections)
|
|
273
|
-
return
|
|
273
|
+
return footnote_list_html if sections.empty?
|
|
274
|
+
|
|
275
|
+
body = if sections.size == 1
|
|
276
|
+
elements_html = sections.first.map do |element|
|
|
277
|
+
@element_renderer.element_to_html(element)
|
|
278
|
+
end.join("\n")
|
|
279
|
+
"<div class=WordSection1>\n\n#{elements_html}\n\n</div>"
|
|
280
|
+
else
|
|
281
|
+
section_divs(sections)
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
body + footnote_list_html
|
|
285
|
+
end
|
|
274
286
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
287
|
+
# Word MHTML carries footnote bodies at the end of the document body,
|
|
288
|
+
# wrapped in a footnote-list container; the in-text footnote
|
|
289
|
+
# references point at these blocks. Without this section the MHTML
|
|
290
|
+
# output silently loses every footnote body that the DOCX output
|
|
291
|
+
# keeps in word/footnotes.xml.
|
|
292
|
+
def footnote_list_html
|
|
293
|
+
entries = footnote_entries
|
|
294
|
+
return "" if entries.empty?
|
|
295
|
+
|
|
296
|
+
blocks = entries.map { |entry| footnote_entry_to_html(entry) }
|
|
297
|
+
"<div style='mso-element:footnote-list'>\n#{blocks.join("\n")}\n</div>"
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
# User footnote entries, in document order. The separator and
|
|
301
|
+
# continuationSeparator entries are Word plumbing, not content.
|
|
302
|
+
def footnote_entries
|
|
303
|
+
footnotes = @document.footnotes
|
|
304
|
+
return [] unless footnotes.is_a?(Uniword::Wordprocessingml::Footnotes)
|
|
305
|
+
|
|
306
|
+
footnotes.footnote_entries.reject do |entry|
|
|
307
|
+
entry.type == "separator" || entry.type == "continuationSeparator"
|
|
281
308
|
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def footnote_entry_to_html(entry)
|
|
312
|
+
html = Array(entry.paragraphs).map do |paragraph|
|
|
313
|
+
@element_renderer.paragraph_to_html(paragraph)
|
|
314
|
+
end.join("\n")
|
|
315
|
+
|
|
316
|
+
"<div style='mso-element:footnote' id=\"ftn#{entry.id}\">\n#{html}\n</div>"
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
private
|
|
282
320
|
|
|
321
|
+
def section_divs(sections)
|
|
283
322
|
section_divs = sections.each_with_index.map do |section_elements, idx|
|
|
284
323
|
elements_html = section_elements.map do |element|
|
|
285
324
|
@element_renderer.element_to_html(element)
|
data/lib/uniword/version.rb
CHANGED
|
@@ -36,7 +36,7 @@ module Uniword
|
|
|
36
36
|
#
|
|
37
37
|
# @return [String, nil] Alternative text, or nil when absent
|
|
38
38
|
def alt_text
|
|
39
|
-
first_non_blank(
|
|
39
|
+
first_non_blank(&:descr)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
# Set the alternative text on whichever frame this drawing carries.
|
|
@@ -57,16 +57,17 @@ module Uniword
|
|
|
57
57
|
#
|
|
58
58
|
# @return [String, nil] Title, or nil when absent
|
|
59
59
|
def alt_title
|
|
60
|
-
first_non_blank(
|
|
60
|
+
first_non_blank(&:title)
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
private
|
|
64
64
|
|
|
65
|
-
# @param attribute [
|
|
65
|
+
# @param attribute [#call] reader called on each frame's docPr
|
|
66
66
|
# @return [String, nil] First non-blank value across the frames
|
|
67
|
-
def first_non_blank(attribute)
|
|
67
|
+
def first_non_blank(&attribute)
|
|
68
68
|
[inline, anchor]
|
|
69
|
-
.filter_map { |frame| frame&.doc_properties
|
|
69
|
+
.filter_map { |frame| frame&.doc_properties }
|
|
70
|
+
.filter_map(&attribute)
|
|
70
71
|
.map(&:strip)
|
|
71
72
|
.find { |text| !text.empty? }
|
|
72
73
|
end
|
|
@@ -381,7 +381,14 @@ module Uniword
|
|
|
381
381
|
end
|
|
382
382
|
|
|
383
383
|
entries.drop(1).each do |stale|
|
|
384
|
-
clearing.each
|
|
384
|
+
clearing.each do |field|
|
|
385
|
+
case field
|
|
386
|
+
when :before then stale.before = nil
|
|
387
|
+
when :after then stale.after = nil
|
|
388
|
+
when :line then stale.line = nil
|
|
389
|
+
when :line_rule then stale.line_rule = nil
|
|
390
|
+
end
|
|
391
|
+
end
|
|
385
392
|
end
|
|
386
393
|
|
|
387
394
|
entries.first
|
|
@@ -9,25 +9,6 @@ module Uniword
|
|
|
9
9
|
# (e.g., RunProperties.new(bold: true)) and the wrapper
|
|
10
10
|
# objects (e.g., Properties::Bold) required by lutaml-model.
|
|
11
11
|
module Conversion
|
|
12
|
-
# Every rPr attribute whose value is an ST_OnOff toggle element.
|
|
13
|
-
BOOLEAN_WRAPPERS = {
|
|
14
|
-
bold: Properties::Bold,
|
|
15
|
-
bold_cs: Properties::BoldCs,
|
|
16
|
-
italic: Properties::Italic,
|
|
17
|
-
italic_cs: Properties::ItalicCs,
|
|
18
|
-
strike: Properties::Strike,
|
|
19
|
-
double_strike: Properties::DoubleStrike,
|
|
20
|
-
small_caps: Properties::SmallCaps,
|
|
21
|
-
caps: Properties::Caps,
|
|
22
|
-
hidden: Properties::Vanish,
|
|
23
|
-
no_proof: Properties::NoProof,
|
|
24
|
-
web_hidden: Properties::WebHidden,
|
|
25
|
-
shadow: Properties::Shadow,
|
|
26
|
-
emboss: Properties::Emboss,
|
|
27
|
-
imprint: Properties::Imprint,
|
|
28
|
-
outline: Properties::Outline,
|
|
29
|
-
}.freeze
|
|
30
|
-
|
|
31
12
|
def initialize(attrs = {})
|
|
32
13
|
# Extract flat convenience keys before super (lutaml-model ignores
|
|
33
14
|
# unknown keys). These are converted to proper wrapper objects below.
|
|
@@ -118,15 +99,46 @@ module Uniword
|
|
|
118
99
|
# Wrap every ST_OnOff toggle handed in as a primitive.
|
|
119
100
|
#
|
|
120
101
|
# `false` is a value, not an absence: testing truthiness here left a
|
|
121
|
-
# raw Ruby false on the attribute and to_xml then died on it.
|
|
102
|
+
# raw Ruby false on the attribute and to_xml then died on it. Each
|
|
103
|
+
# toggle is named explicitly so a new one cannot silently skip
|
|
104
|
+
# conversion; boolean_element_spec asserts the full set converts.
|
|
122
105
|
def convert_boolean_attrs!
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
106
|
+
self.bold = Properties::Bold.new(val: bold) if wrap_needed?(bold, Properties::Bold)
|
|
107
|
+
self.bold_cs = Properties::BoldCs.new(val: bold_cs) if
|
|
108
|
+
wrap_needed?(bold_cs, Properties::BoldCs)
|
|
109
|
+
self.italic = Properties::Italic.new(val: italic) if
|
|
110
|
+
wrap_needed?(italic, Properties::Italic)
|
|
111
|
+
self.italic_cs = Properties::ItalicCs.new(val: italic_cs) if
|
|
112
|
+
wrap_needed?(italic_cs, Properties::ItalicCs)
|
|
113
|
+
self.strike = Properties::Strike.new(val: strike) if
|
|
114
|
+
wrap_needed?(strike, Properties::Strike)
|
|
115
|
+
self.double_strike = Properties::DoubleStrike.new(val: double_strike) if
|
|
116
|
+
wrap_needed?(double_strike, Properties::DoubleStrike)
|
|
117
|
+
self.small_caps = Properties::SmallCaps.new(val: small_caps) if
|
|
118
|
+
wrap_needed?(small_caps, Properties::SmallCaps)
|
|
119
|
+
self.caps = Properties::Caps.new(val: caps) if
|
|
120
|
+
wrap_needed?(caps, Properties::Caps)
|
|
121
|
+
self.hidden = Properties::Vanish.new(val: hidden) if
|
|
122
|
+
wrap_needed?(hidden, Properties::Vanish)
|
|
123
|
+
self.no_proof = Properties::NoProof.new(val: no_proof) if
|
|
124
|
+
wrap_needed?(no_proof, Properties::NoProof)
|
|
125
|
+
self.web_hidden = Properties::WebHidden.new(val: web_hidden) if
|
|
126
|
+
wrap_needed?(web_hidden, Properties::WebHidden)
|
|
127
|
+
self.shadow = Properties::Shadow.new(val: shadow) if
|
|
128
|
+
wrap_needed?(shadow, Properties::Shadow)
|
|
129
|
+
self.emboss = Properties::Emboss.new(val: emboss) if
|
|
130
|
+
wrap_needed?(emboss, Properties::Emboss)
|
|
131
|
+
self.imprint = Properties::Imprint.new(val: imprint) if
|
|
132
|
+
wrap_needed?(imprint, Properties::Imprint)
|
|
133
|
+
self.outline = Properties::Outline.new(val: outline) if
|
|
134
|
+
wrap_needed?(outline, Properties::Outline)
|
|
135
|
+
end
|
|
127
136
|
|
|
128
|
-
|
|
129
|
-
|
|
137
|
+
private
|
|
138
|
+
|
|
139
|
+
def wrap_needed?(value, klass)
|
|
140
|
+
!value.nil? && !value.is_a?(klass) &&
|
|
141
|
+
!Lutaml::Model::Utils.uninitialized?(value)
|
|
130
142
|
end
|
|
131
143
|
|
|
132
144
|
def convert_style_attr!
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: uniword
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.7.
|
|
4
|
+
version: 1.7.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: logger
|
|
@@ -30,28 +30,28 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.9.
|
|
33
|
+
version: 1.9.414
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.9.
|
|
40
|
+
version: 1.9.414
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: lutaml-model
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 0.8.
|
|
47
|
+
version: 0.8.171
|
|
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: 0.8.
|
|
54
|
+
version: 0.8.171
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: omml
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|