uniword 1.7.11 → 1.7.12
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/cli/main.rb +2 -2
- data/lib/uniword/converter/plain_text.rb +40 -41
- data/lib/uniword/converter.rb +1 -1
- data/lib/uniword/docx/reconciler/parts.rb +8 -4
- data/lib/uniword/version.rb +1 -1
- data/lib/uniword.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a9f29c7a4853ed4ac6fe6dfae3669e23a2f95191081ea62c7bc61c308a0b11d2
|
|
4
|
+
data.tar.gz: 05abdcfa08c7b73f12932da578566733cc1d0fc57c78a87894d02928d0a12b0a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1bc8db91e9c8706a652f16757368e3352019dc420ddecfd398dad3b98c516ba0523d239d0c91799ee4bbaa59f8e7b4e62604224d8c1a9b48bca7f32fcf641ff3
|
|
7
|
+
data.tar.gz: a5a11680364937d9142f5c1f9b5ca26bb21fe49fe6bb6e234832891fdaa834830e0d32af4561493034d5d7e1a704b716fab99aab084bdd14b13d3d29796fc5b2
|
data/lib/uniword/cli/main.rb
CHANGED
|
@@ -539,7 +539,7 @@ module Uniword
|
|
|
539
539
|
desc "to md|adoc INPUT", "Convert a DOCX to Markdown or AsciiDoc"
|
|
540
540
|
long_desc <<~DESC
|
|
541
541
|
Convert a Word document to a plain-text editing format -- Markdown
|
|
542
|
-
or AsciiDoc -- through the
|
|
542
|
+
or AsciiDoc -- through the Ceradoc CoreModel bridge.
|
|
543
543
|
|
|
544
544
|
Carried: headings h1-h6, paragraphs, bold/italic/underline/
|
|
545
545
|
strikethrough, lists, tables with header rows, links, bookmarks.
|
|
@@ -578,7 +578,7 @@ module Uniword
|
|
|
578
578
|
desc "from md|adoc INPUT", "Convert Markdown or AsciiDoc to a DOCX"
|
|
579
579
|
long_desc <<~DESC
|
|
580
580
|
Convert a Markdown or AsciiDoc file to a Word document through
|
|
581
|
-
the
|
|
581
|
+
the Ceradoc CoreModel bridge. Headings become Heading styles,
|
|
582
582
|
lists get numbering, tables keep their header rows, and
|
|
583
583
|
AsciiDoc links become real hyperlinks.
|
|
584
584
|
|
|
@@ -5,15 +5,15 @@ module Uniword
|
|
|
5
5
|
# Plain-text editing round trip for Word documents (issue #80).
|
|
6
6
|
#
|
|
7
7
|
# Bridges Uniword::Wordprocessingml::DocumentRoot to Markdown and
|
|
8
|
-
# AsciiDoc through
|
|
8
|
+
# AsciiDoc through Ceradoc's hub-and-spoke CoreModel:
|
|
9
9
|
#
|
|
10
|
-
# DocumentRoot ->
|
|
11
|
-
# -> (
|
|
10
|
+
# DocumentRoot -> Ceradoc::Docx.parse_to_core -> core
|
|
11
|
+
# -> (Ceradoc::Markdown | Ceradoc::AsciiDoc) writer
|
|
12
12
|
#
|
|
13
|
-
# (
|
|
14
|
-
# ->
|
|
13
|
+
# (Ceradoc::Markdown | Ceradoc::AsciiDoc) parser -> core
|
|
14
|
+
# -> Ceradoc::Docx.serialize -> DocumentRoot
|
|
15
15
|
#
|
|
16
|
-
# The
|
|
16
|
+
# The ceradoc gems are OPTIONAL runtime dependencies: they are
|
|
17
17
|
# required lazily inside the conversion methods, never at file
|
|
18
18
|
# load. When missing, a DependencyError with an install hint is
|
|
19
19
|
# raised.
|
|
@@ -27,7 +27,7 @@ module Uniword
|
|
|
27
27
|
# * tables with a header row
|
|
28
28
|
# * links (bridge resolves relationship ids to target URLs)
|
|
29
29
|
# * bookmarks (heading/paragraph anchor id propagation)
|
|
30
|
-
# * footnotes (
|
|
30
|
+
# * footnotes (ceradoc-docx 0.1.6 carries them into the core
|
|
31
31
|
# model; to md/adoc emits GFM [^id] + definitions)
|
|
32
32
|
#
|
|
33
33
|
# Dropped or degraded (recorded on PlainTextResult, warned about;
|
|
@@ -38,18 +38,17 @@ module Uniword
|
|
|
38
38
|
# * tracked changes (w:ins/w:del)
|
|
39
39
|
# * structured document tags (content survives, wrapper unwrapped)
|
|
40
40
|
# * math (OMML)
|
|
41
|
-
# * images (docx extractor does not carry drawings;
|
|
41
|
+
# * images (docx extractor does not carry drawings; ceradoc#322)
|
|
42
42
|
#
|
|
43
43
|
# Never carried by any plain-text format (not detected per document):
|
|
44
44
|
# themes, settings, font table, and other package-level parts.
|
|
45
45
|
#
|
|
46
46
|
# From the plain-text side, links written to DOCX resolve to real
|
|
47
|
-
# External relationships on save
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
# literal text (definitions do convert, coradoc#320).
|
|
47
|
+
# External relationships on save, and from_markdown builds real
|
|
48
|
+
# hyperlinks from inline Markdown links (ceradoc-markdown fixed the
|
|
49
|
+
# literal-text flattening, ceradoc#320). Upstream flattening that
|
|
50
|
+
# remains: from_markdown footnote REFERENCES stay literal text
|
|
51
|
+
# (definitions do convert, ceradoc#320).
|
|
53
52
|
#
|
|
54
53
|
# @example Document to Markdown
|
|
55
54
|
# md = Uniword::Converter::PlainText.new.to_markdown(document)
|
|
@@ -57,7 +56,7 @@ module Uniword
|
|
|
57
56
|
# @example Markdown to a DocumentRoot
|
|
58
57
|
# doc = Uniword::Converter::PlainText.new.from_markdown(md_text)
|
|
59
58
|
class PlainText
|
|
60
|
-
GEMS_HINT = "
|
|
59
|
+
GEMS_HINT = "ceradoc-docx ceradoc-markdown ceradoc-adoc"
|
|
61
60
|
|
|
62
61
|
# Convert a document to Markdown.
|
|
63
62
|
#
|
|
@@ -78,15 +77,15 @@ module Uniword
|
|
|
78
77
|
# @return [PlainTextResult]
|
|
79
78
|
# @raise [FidelityError] in strict mode with dropped features
|
|
80
79
|
def to_markdown_result(document, strict: false)
|
|
81
|
-
require_gems!("
|
|
80
|
+
require_gems!("ceradoc/docx", "ceradoc/markdown")
|
|
82
81
|
drops = detect_dropped_features(document)
|
|
83
82
|
assert_strict!(drops, :markdown) if strict
|
|
84
83
|
core = with_conversion_guards(document, drops) do
|
|
85
|
-
::
|
|
84
|
+
::Ceradoc::Docx.parse_to_core(document)
|
|
86
85
|
end
|
|
87
86
|
build_result(format: :markdown, direction: :docx_to_markdown,
|
|
88
87
|
core: core, drops: drops, text:
|
|
89
|
-
::
|
|
88
|
+
::Ceradoc::Markdown.serialize(core))
|
|
90
89
|
end
|
|
91
90
|
|
|
92
91
|
# Parse Markdown into a document model.
|
|
@@ -106,8 +105,8 @@ module Uniword
|
|
|
106
105
|
# @param strict [Boolean] raise when features would be dropped
|
|
107
106
|
# @return [PlainTextResult]
|
|
108
107
|
def from_markdown_result(text, strict: false)
|
|
109
|
-
require_gems!("
|
|
110
|
-
core = ::
|
|
108
|
+
require_gems!("ceradoc/docx", "ceradoc/markdown")
|
|
109
|
+
core = ::Ceradoc::Markdown.parse_to_core(text)
|
|
111
110
|
finish_from_core(format: :markdown,
|
|
112
111
|
direction: :markdown_to_docx,
|
|
113
112
|
core: core, strict: strict)
|
|
@@ -132,13 +131,13 @@ module Uniword
|
|
|
132
131
|
# @return [PlainTextResult]
|
|
133
132
|
# @raise [FidelityError] in strict mode with dropped features
|
|
134
133
|
def to_asciidoc_result(document, strict: false)
|
|
135
|
-
require_gems!("
|
|
134
|
+
require_gems!("ceradoc/docx", "ceradoc/asciidoc")
|
|
136
135
|
drops = detect_dropped_features(document)
|
|
137
136
|
assert_strict!(drops, :asciidoc) if strict
|
|
138
137
|
core = with_conversion_guards(document, drops) do
|
|
139
|
-
::
|
|
138
|
+
::Ceradoc::Docx.parse_to_core(document)
|
|
140
139
|
end
|
|
141
|
-
adoc_model = ::
|
|
140
|
+
adoc_model = ::Ceradoc::AsciiDoc::Transform::FromCoreModel
|
|
142
141
|
.transform(core)
|
|
143
142
|
normalize_emphasis_constraint!(adoc_model)
|
|
144
143
|
build_result(format: :asciidoc, direction: :docx_to_asciidoc,
|
|
@@ -155,8 +154,8 @@ module Uniword
|
|
|
155
154
|
def normalize_emphasis_constraint!(model)
|
|
156
155
|
model.visit do |element, _phase|
|
|
157
156
|
element.unconstrained = true if element.is_a?(
|
|
158
|
-
::
|
|
159
|
-
) || element.is_a?(::
|
|
157
|
+
::Ceradoc::AsciiDoc::Model::Inline::Bold,
|
|
158
|
+
) || element.is_a?(::Ceradoc::AsciiDoc::Model::Inline::Italic)
|
|
160
159
|
element
|
|
161
160
|
end
|
|
162
161
|
model
|
|
@@ -179,8 +178,8 @@ module Uniword
|
|
|
179
178
|
# @param strict [Boolean] raise when features would be dropped
|
|
180
179
|
# @return [PlainTextResult]
|
|
181
180
|
def from_asciidoc_result(text, strict: false)
|
|
182
|
-
require_gems!("
|
|
183
|
-
core = ::
|
|
181
|
+
require_gems!("ceradoc/docx", "ceradoc/asciidoc")
|
|
182
|
+
core = ::Ceradoc::AsciiDoc.parse_to_core(text)
|
|
184
183
|
finish_from_core(format: :asciidoc,
|
|
185
184
|
direction: :asciidoc_to_docx,
|
|
186
185
|
core: core, strict: strict)
|
|
@@ -188,7 +187,7 @@ module Uniword
|
|
|
188
187
|
|
|
189
188
|
private
|
|
190
189
|
|
|
191
|
-
# Lazily load the
|
|
190
|
+
# Lazily load the ceradoc gems; raise a DependencyError with an
|
|
192
191
|
# install hint when any is missing.
|
|
193
192
|
def require_gems!(*libs)
|
|
194
193
|
libs.each { |lib| require lib }
|
|
@@ -224,7 +223,7 @@ module Uniword
|
|
|
224
223
|
raise FidelityError.new(format, drops)
|
|
225
224
|
end
|
|
226
225
|
|
|
227
|
-
# Rewrite hyperlink rIds to their target URLs so
|
|
226
|
+
# Rewrite hyperlink rIds to their target URLs so ceradoc's
|
|
228
227
|
# writers emit real links; every mutation is restored after the
|
|
229
228
|
# conversion.
|
|
230
229
|
def with_conversion_guards(document, _drops)
|
|
@@ -233,7 +232,7 @@ module Uniword
|
|
|
233
232
|
end
|
|
234
233
|
|
|
235
234
|
# Rewrite w:hyperlink r:id attributes to their relationship
|
|
236
|
-
# targets so
|
|
235
|
+
# targets so ceradoc's writers emit real URLs instead of "rId1".
|
|
237
236
|
# Relationships live in document.xml.rels on loaded documents
|
|
238
237
|
# and in the IdAllocator on builder-built ones; both sources are
|
|
239
238
|
# consulted. Returns the rewrite log for restoration.
|
|
@@ -287,7 +286,7 @@ module Uniword
|
|
|
287
286
|
# Serialize the CoreModel into a DocumentRoot and wrap both in a
|
|
288
287
|
# result (from_* direction).
|
|
289
288
|
def finish_from_core(format:, direction:, core:, strict:)
|
|
290
|
-
document = ::
|
|
289
|
+
document = ::Ceradoc::Docx.serialize(core)
|
|
291
290
|
build_result(format: format, direction: direction, core: core,
|
|
292
291
|
drops: [], document: document).tap do |result|
|
|
293
292
|
assert_strict!(result.dropped_features, format) if strict
|
|
@@ -311,15 +310,15 @@ module Uniword
|
|
|
311
310
|
Array(core).each do |root|
|
|
312
311
|
walk_core(root, skip_self: true) do |node|
|
|
313
312
|
case node
|
|
314
|
-
when ::
|
|
313
|
+
when ::Ceradoc::CoreModel::StructuralElement
|
|
315
314
|
counts[:headings] += 1 if heading?(node)
|
|
316
|
-
when ::
|
|
315
|
+
when ::Ceradoc::CoreModel::Block
|
|
317
316
|
counts[:paragraphs] += 1
|
|
318
|
-
when ::
|
|
317
|
+
when ::Ceradoc::CoreModel::ListBlock
|
|
319
318
|
counts[:lists] += 1
|
|
320
|
-
when ::
|
|
319
|
+
when ::Ceradoc::CoreModel::Table
|
|
321
320
|
counts[:tables] += 1
|
|
322
|
-
when ::
|
|
321
|
+
when ::Ceradoc::CoreModel::InlineElement
|
|
323
322
|
counts[:links] += 1 if link?(node)
|
|
324
323
|
end
|
|
325
324
|
end
|
|
@@ -342,14 +341,14 @@ module Uniword
|
|
|
342
341
|
|
|
343
342
|
def children_of(node)
|
|
344
343
|
case node
|
|
345
|
-
when ::
|
|
344
|
+
when ::Ceradoc::CoreModel::StructuralElement
|
|
346
345
|
Array(node.children)
|
|
347
|
-
when ::
|
|
346
|
+
when ::Ceradoc::CoreModel::Block
|
|
348
347
|
content = node.renderable_content
|
|
349
|
-
content.is_a?(Array) ? content.grep(::
|
|
350
|
-
when ::
|
|
348
|
+
content.is_a?(Array) ? content.grep(::Ceradoc::CoreModel::Base) : []
|
|
349
|
+
when ::Ceradoc::CoreModel::ListBlock
|
|
351
350
|
Array(node.items)
|
|
352
|
-
when ::
|
|
351
|
+
when ::Ceradoc::CoreModel::Table
|
|
353
352
|
Array(node.rows).flat_map { |row| Array(row.cells) }
|
|
354
353
|
else
|
|
355
354
|
[]
|
data/lib/uniword/converter.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Uniword
|
|
4
4
|
# Format converters beyond the docx/mhtml/html paths handled by
|
|
5
5
|
# FormatConverter. Currently hosts the plain-text editing round
|
|
6
|
-
# trip (Markdown / AsciiDoc) built on the optional
|
|
6
|
+
# trip (Markdown / AsciiDoc) built on the optional Ceradoc gems.
|
|
7
7
|
module Converter
|
|
8
8
|
autoload :PlainText, "uniword/converter/plain_text"
|
|
9
9
|
autoload :PlainTextResult, "uniword/converter/plain_text_result"
|
|
@@ -50,10 +50,14 @@ module Uniword
|
|
|
50
50
|
val: profile.list_separator,
|
|
51
51
|
)
|
|
52
52
|
|
|
53
|
-
# CT_Settings
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
|
|
53
|
+
# CT_Settings sequence: ... compat, docVars, rsids, m:mathPr ...
|
|
54
|
+
# Fixtures carrying rsids last serialize it after the appended
|
|
55
|
+
# siblings and fail strict sequence validation, but anchoring it
|
|
56
|
+
# on compat unconditionally pushed rsids ahead of a parsed
|
|
57
|
+
# w:docVars block (template settings carry one), breaking the
|
|
58
|
+
# sequence the other way. Anchor on docVars when present.
|
|
59
|
+
rsids_anchor = settings.doc_vars ? "docVars" : "compat"
|
|
60
|
+
Ooxml::ElementOrder.move_once(settings, "rsids", after: rsids_anchor)
|
|
57
61
|
|
|
58
62
|
# w:updateFields set by the user/API: ensure it serializes —
|
|
59
63
|
# parsed settings carry a stored element_order that lacks it.
|
data/lib/uniword/version.rb
CHANGED
data/lib/uniword.rb
CHANGED
|
@@ -210,8 +210,8 @@ module Uniword
|
|
|
210
210
|
# Plugin system (validators, transformers, CLI commands).
|
|
211
211
|
autoload :Plugin, "uniword/plugin"
|
|
212
212
|
|
|
213
|
-
# Plain-text (Markdown / AsciiDoc) conversion via
|
|
214
|
-
#
|
|
213
|
+
# Plain-text (Markdown / AsciiDoc) conversion via Ceradoc. The
|
|
214
|
+
# ceradoc gems are optional at runtime and lazily required.
|
|
215
215
|
autoload :Converter, "uniword/converter"
|
|
216
216
|
|
|
217
217
|
# CLI
|
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.12
|
|
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-12-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: leptris
|