uniword 1.5.3 → 1.6.0
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/exe/uniword +8 -0
- data/lib/uniword/builder/image_builder.rb +1 -1
- data/lib/uniword/docx/package_defaults.rb +1 -1
- data/lib/uniword/docx/package_serialization.rb +1 -1
- data/lib/uniword/docx/reconciler/helpers.rb +1 -1
- data/lib/uniword/docx/reconciler/referential_integrity.rb +1 -1
- data/lib/uniword/find_replace/scope.rb +9 -11
- data/lib/uniword/ooxml/package_file.rb +1 -1
- data/lib/uniword/picture/fill_rect.rb +2 -2
- data/lib/uniword/picture/picture_source_rect.rb +3 -2
- data/lib/uniword/picture/picture_stretch.rb +3 -2
- data/lib/uniword/picture/tile.rb +3 -2
- data/lib/uniword/properties/word2010_id_value.rb +2 -2
- data/lib/uniword/version.rb +1 -1
- data/lib/uniword/wordprocessingml/body.rb +54 -6
- data/lib/uniword/wordprocessingml/styles_configuration.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1153bb3528efaa764919405fb7e3ac11e0e9aedcaae81e6dd0b692293e3876a2
|
|
4
|
+
data.tar.gz: 0e59bf185f59fc2377dc56c1dd1bfacbc773814d47dcef9f19bb6f855cf0298c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 540da6a280c292c6563daf77a1c024fefbc1266048d7fab197cff2e7bb7d0529d2953e1cc596d8b426668702adc03a3b1821645a8bd028fc6d71cfe937862a0c
|
|
7
|
+
data.tar.gz: 9543bd3d00ce96e4d47480f5db92a05ab60a7fc1a6e85cf60037ace089106f703f30d6be825dcaa939319c5fe559d5e35b9669f8103a6c9cabd8c5c4415552f1
|
data/exe/uniword
CHANGED
|
@@ -2,5 +2,13 @@
|
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
require "bundler/setup"
|
|
5
|
+
|
|
6
|
+
# Hydration-heavy workloads run ~1.75x under YJIT (measured on the
|
|
7
|
+
# 608KB corpus). Opt out with UNIWORD_DISABLE_YJIT=1.
|
|
8
|
+
if defined?(RubyVM::YJIT) && !RubyVM::YJIT.enabled? &&
|
|
9
|
+
ENV["UNIWORD_DISABLE_YJIT"] != "1"
|
|
10
|
+
RubyVM::YJIT.enable
|
|
11
|
+
end
|
|
12
|
+
|
|
5
13
|
require "uniword"
|
|
6
14
|
Uniword::CLI.start(ARGV)
|
|
@@ -302,7 +302,7 @@ alt_text: nil)
|
|
|
302
302
|
|
|
303
303
|
# Non-visual properties
|
|
304
304
|
pic.nv_pic_pr = Picture::NonVisualPictureProperties.new
|
|
305
|
-
pic.nv_pic_pr.c_nv_pr =
|
|
305
|
+
pic.nv_pic_pr.c_nv_pr = Picture::NonVisualDrawingProperties.new(
|
|
306
306
|
id: deterministic_id("pic", r_id),
|
|
307
307
|
name: "Picture",
|
|
308
308
|
)
|
|
@@ -112,7 +112,7 @@ module Uniword
|
|
|
112
112
|
rels = Ooxml::Relationships::PackageRelationships.new
|
|
113
113
|
rels.relationships = part_keys.each_with_index.map do |key, idx|
|
|
114
114
|
defn = Ooxml::PartRegistry.find_by_key(key)
|
|
115
|
-
Ooxml::Relationships::
|
|
115
|
+
Ooxml::Relationships::PackageRelationship.new(
|
|
116
116
|
id: "rId#{idx + 1}",
|
|
117
117
|
type: defn.rel_type,
|
|
118
118
|
target: defn.target,
|
|
@@ -260,7 +260,7 @@ document_rels)
|
|
|
260
260
|
|
|
261
261
|
# The reconciler runs before injection; register the rId with
|
|
262
262
|
# the allocator (single authority) and append the rel here.
|
|
263
|
-
package_rels.relationships << Ooxml::Relationships::
|
|
263
|
+
package_rels.relationships << Ooxml::Relationships::PackageRelationship.new(
|
|
264
264
|
id: allocator.alloc_rid(target: definition.target,
|
|
265
265
|
type: definition.rel_type,
|
|
266
266
|
scope: :package),
|
|
@@ -236,7 +236,7 @@ module Uniword
|
|
|
236
236
|
def build_rel(id, type, target, target_mode: nil)
|
|
237
237
|
attrs = { id: id, type: type, target: target }
|
|
238
238
|
attrs[:target_mode] = target_mode if target_mode
|
|
239
|
-
Ooxml::Relationships::
|
|
239
|
+
Ooxml::Relationships::PackageRelationship.new(**attrs)
|
|
240
240
|
end
|
|
241
241
|
|
|
242
242
|
def run_properties_match?(a, b)
|
|
@@ -317,7 +317,7 @@ module Uniword
|
|
|
317
317
|
new_rid = allocator.alloc_rid(target: url, type: rel_type,
|
|
318
318
|
target_mode: "External")
|
|
319
319
|
unless valid_rids.include?(new_rid)
|
|
320
|
-
rels.relationships << Ooxml::Relationships::
|
|
320
|
+
rels.relationships << Ooxml::Relationships::PackageRelationship.new(
|
|
321
321
|
id: new_rid,
|
|
322
322
|
type: rel_type,
|
|
323
323
|
target: url,
|
|
@@ -38,9 +38,8 @@ module Uniword
|
|
|
38
38
|
protected
|
|
39
39
|
|
|
40
40
|
# Yield every Text element inside a run. A run carries its
|
|
41
|
-
# `<w:t>` Text
|
|
42
|
-
#
|
|
43
|
-
# declared as a collection).
|
|
41
|
+
# `<w:t>` Text elements on the `text` accessor (declared as a
|
|
42
|
+
# collection; lutaml-model 0.8.32+ returns an Array).
|
|
44
43
|
#
|
|
45
44
|
# @param run [Wordprocessingml::Run, nil]
|
|
46
45
|
# @yieldparam text_element [Wordprocessingml::Text]
|
|
@@ -49,14 +48,13 @@ module Uniword
|
|
|
49
48
|
def each_text_in_run(run)
|
|
50
49
|
return unless run
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
yield text_element, accessor
|
|
51
|
+
run.text&.each do |text_element|
|
|
52
|
+
accessor = TextAccessor.new(
|
|
53
|
+
-> { text_element.content },
|
|
54
|
+
->(value) { text_element.content = value },
|
|
55
|
+
)
|
|
56
|
+
yield text_element, accessor
|
|
57
|
+
end
|
|
60
58
|
end
|
|
61
59
|
|
|
62
60
|
# Walk every paragraph in `containers` and yield each run's
|
|
@@ -86,7 +86,7 @@ module Uniword
|
|
|
86
86
|
# Ensure output directory exists
|
|
87
87
|
FileUtils.mkdir_p(File.dirname(output_path))
|
|
88
88
|
|
|
89
|
-
Zip::File.open(output_path,
|
|
89
|
+
Zip::File.open(output_path, create: true) do |zipfile|
|
|
90
90
|
Dir.glob(File.join(@extracted_dir, "**", "*")).each do |file_path|
|
|
91
91
|
next if File.directory?(file_path)
|
|
92
92
|
|
|
@@ -7,7 +7,7 @@ module Uniword
|
|
|
7
7
|
# Fill rectangle insets
|
|
8
8
|
#
|
|
9
9
|
# Generated from OOXML schema: picture.yml
|
|
10
|
-
# Element: <
|
|
10
|
+
# Element: <a:fillRect> (child of a:stretch in CT_BlipFillProperties)
|
|
11
11
|
class FillRect < Lutaml::Model::Serializable
|
|
12
12
|
attribute :l, :integer
|
|
13
13
|
attribute :t, :integer
|
|
@@ -16,7 +16,7 @@ module Uniword
|
|
|
16
16
|
|
|
17
17
|
xml do
|
|
18
18
|
element "fillRect"
|
|
19
|
-
namespace Uniword::Ooxml::Namespaces::
|
|
19
|
+
namespace Uniword::Ooxml::Namespaces::DrawingML
|
|
20
20
|
|
|
21
21
|
map_attribute "l", to: :l
|
|
22
22
|
map_attribute "t", to: :t
|
|
@@ -7,7 +7,8 @@ module Uniword
|
|
|
7
7
|
# Source rectangle for picture cropping
|
|
8
8
|
#
|
|
9
9
|
# Generated from OOXML schema: picture.yml
|
|
10
|
-
# Element: <
|
|
10
|
+
# Element: <a:srcRect> (CT_BlipFillProperties reuses DrawingML
|
|
11
|
+
# children inside pic:blipFill)
|
|
11
12
|
class PictureSourceRect < Lutaml::Model::Serializable
|
|
12
13
|
attribute :l, :integer
|
|
13
14
|
attribute :t, :integer
|
|
@@ -16,7 +17,7 @@ module Uniword
|
|
|
16
17
|
|
|
17
18
|
xml do
|
|
18
19
|
element "srcRect"
|
|
19
|
-
namespace Uniword::Ooxml::Namespaces::
|
|
20
|
+
namespace Uniword::Ooxml::Namespaces::DrawingML
|
|
20
21
|
|
|
21
22
|
map_attribute "l", to: :l
|
|
22
23
|
map_attribute "t", to: :t
|
|
@@ -7,13 +7,14 @@ module Uniword
|
|
|
7
7
|
# Stretch fill properties
|
|
8
8
|
#
|
|
9
9
|
# Generated from OOXML schema: picture.yml
|
|
10
|
-
# Element: <
|
|
10
|
+
# Element: <a:stretch> (CT_BlipFillProperties reuses DrawingML
|
|
11
|
+
# children inside pic:blipFill)
|
|
11
12
|
class PictureStretch < Lutaml::Model::Serializable
|
|
12
13
|
attribute :fill_rect, FillRect
|
|
13
14
|
|
|
14
15
|
xml do
|
|
15
16
|
element "stretch"
|
|
16
|
-
namespace Uniword::Ooxml::Namespaces::
|
|
17
|
+
namespace Uniword::Ooxml::Namespaces::DrawingML
|
|
17
18
|
mixed_content
|
|
18
19
|
|
|
19
20
|
map_element "fillRect", to: :fill_rect, render_nil: false
|
data/lib/uniword/picture/tile.rb
CHANGED
|
@@ -7,7 +7,8 @@ module Uniword
|
|
|
7
7
|
# Tile properties for picture fill
|
|
8
8
|
#
|
|
9
9
|
# Generated from OOXML schema: picture.yml
|
|
10
|
-
# Element: <
|
|
10
|
+
# Element: <a:tile> (CT_BlipFillProperties reuses DrawingML
|
|
11
|
+
# children inside pic:blipFill)
|
|
11
12
|
class Tile < Lutaml::Model::Serializable
|
|
12
13
|
attribute :tx, :integer
|
|
13
14
|
attribute :ty, :integer
|
|
@@ -17,7 +18,7 @@ module Uniword
|
|
|
17
18
|
|
|
18
19
|
xml do
|
|
19
20
|
element "tile"
|
|
20
|
-
namespace Uniword::Ooxml::Namespaces::
|
|
21
|
+
namespace Uniword::Ooxml::Namespaces::DrawingML
|
|
21
22
|
|
|
22
23
|
map_attribute "tx", to: :tx
|
|
23
24
|
map_attribute "ty", to: :ty
|
|
@@ -4,13 +4,13 @@ require "lutaml/model"
|
|
|
4
4
|
|
|
5
5
|
module Uniword
|
|
6
6
|
module Properties
|
|
7
|
-
# Namespaced custom type for Word 2010 (wp14) attributes
|
|
7
|
+
# Namespaced custom type for Word 2010 Drawing (wp14) attributes
|
|
8
8
|
# Used for wp14:anchorId and wp14:editId attributes
|
|
9
9
|
class Word2010IdValue < Lutaml::Model::Type::String
|
|
10
10
|
include Lutaml::Xml::Type::Configurable
|
|
11
11
|
|
|
12
12
|
xml do
|
|
13
|
-
namespace Uniword::Ooxml::Namespaces::
|
|
13
|
+
namespace Uniword::Ooxml::Namespaces::Word2010Drawing
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
end
|
data/lib/uniword/version.rb
CHANGED
|
@@ -32,15 +32,54 @@ module Uniword
|
|
|
32
32
|
map_element "bookmarkEnd", to: :bookmark_ends, render_nil: false
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
# Get all elements in body
|
|
35
|
+
# Get all elements in body, in document order.
|
|
36
36
|
#
|
|
37
|
-
#
|
|
37
|
+
# Walks `element_order` (populated by lutaml-model when mixed_content
|
|
38
|
+
# is parsed) and dispatches each tag to its typed collection —
|
|
39
|
+
# `p` -> paragraphs, `tbl` -> tables, `sdt` -> structured_document_tags,
|
|
40
|
+
# `bookmarkStart` -> bookmark_starts, `bookmarkEnd` -> bookmark_ends,
|
|
41
|
+
# `sectPr` -> section_properties. Whitespace/comment entries are
|
|
42
|
+
# skipped. Elements not represented in `element_order` are appended
|
|
43
|
+
# at the end in collection order (the only order available when
|
|
44
|
+
# `element_order` is empty or nil).
|
|
45
|
+
#
|
|
46
|
+
# @return [Array] Block-level content in document order
|
|
38
47
|
def elements
|
|
48
|
+
return concatenate_typed_collections if element_order.nil? || element_order.empty?
|
|
49
|
+
|
|
39
50
|
result = []
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
counters = Hash.new(0)
|
|
52
|
+
sectpr_seen = false
|
|
53
|
+
collections = {
|
|
54
|
+
"p" => paragraphs,
|
|
55
|
+
"tbl" => tables,
|
|
56
|
+
"sdt" => structured_document_tags,
|
|
57
|
+
"bookmarkStart" => bookmark_starts,
|
|
58
|
+
"bookmarkEnd" => bookmark_ends,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
element_order.each do |entry|
|
|
62
|
+
name = entry.name
|
|
63
|
+
if collections.key?(name)
|
|
64
|
+
collection = collections[name]
|
|
65
|
+
index = counters[name]
|
|
66
|
+
if collection && index < collection.size
|
|
67
|
+
result << collection[index]
|
|
68
|
+
counters[name] = index + 1
|
|
69
|
+
end
|
|
70
|
+
elsif name == "sectPr"
|
|
71
|
+
sectpr_seen = true
|
|
72
|
+
result << section_properties if section_properties
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
collections.each do |name, collection|
|
|
77
|
+
next unless collection && counters[name] < collection.size
|
|
78
|
+
|
|
79
|
+
result.concat(collection[counters[name]..])
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
result << section_properties if section_properties && !sectpr_seen
|
|
44
83
|
result
|
|
45
84
|
end
|
|
46
85
|
|
|
@@ -80,6 +119,15 @@ module Uniword
|
|
|
80
119
|
|
|
81
120
|
private
|
|
82
121
|
|
|
122
|
+
def concatenate_typed_collections
|
|
123
|
+
result = []
|
|
124
|
+
result.concat(paragraphs || [])
|
|
125
|
+
result.concat(structured_document_tags || [])
|
|
126
|
+
result.concat(tables || [])
|
|
127
|
+
result << section_properties if section_properties
|
|
128
|
+
result
|
|
129
|
+
end
|
|
130
|
+
|
|
83
131
|
def sync_element_order
|
|
84
132
|
return if element_order.nil? || element_order.empty?
|
|
85
133
|
|
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.
|
|
4
|
+
version: 1.6.0
|
|
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
|
+
date: 2026-09-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: logger
|
|
@@ -92,14 +92,14 @@ dependencies:
|
|
|
92
92
|
requirements:
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: '
|
|
95
|
+
version: '3.4'
|
|
96
96
|
type: :runtime
|
|
97
97
|
prerelease: false
|
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
|
99
99
|
requirements:
|
|
100
100
|
- - "~>"
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: '
|
|
102
|
+
version: '3.4'
|
|
103
103
|
- !ruby/object:Gem::Dependency
|
|
104
104
|
name: thor
|
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|