omml 0.2.2 → 0.2.3
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/.gitignore +1 -0
- data/.rubocop_todo.yml +12 -6
- data/Gemfile +0 -3
- data/lib/omml/models/ct_br.rb +1 -1
- data/lib/omml/models/ct_r.rb +2 -0
- data/lib/omml/models/ct_wordprocessing_empty.rb +24 -0
- data/lib/omml/models/ct_wordprocessing_text.rb +26 -0
- data/lib/omml/models/groups/eg_run_inner_content.rb +4 -65
- data/lib/omml/models/groups/eg_word_run_inner_content.rb +91 -0
- data/lib/omml/models.rb +6 -0
- data/lib/omml/namespace.rb +2 -0
- data/lib/omml/version.rb +1 -1
- data/lib/omml/wordprocessing_namespace.rb +2 -0
- data/reference-docs/shared-math.xsd +1528 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6940ed4402f47df60c0de9c7768720da480a64725187434630c836bd77d31e66
|
|
4
|
+
data.tar.gz: 73f8119d2186095dfd4d061db0c2d096b7412ca984c713ed2b2933a6bb32e011
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4545f65afd76963f930e49396b165e183e1b6b440edfcfb80c7c2b2cc80a6df7531589b2071fdcb61990c65265394ca66432f29b632f0837ea86446f1cee7c32
|
|
7
|
+
data.tar.gz: 5cb71bf1eef0b864459dd7bce5ef5f9aabcf1a3132c3dacbc1aeb3e940cfd0becce3ee5c444dc8f54f859403c37ae3bc37100a62ab7a57da91c116fafec11bd2
|
data/.gitignore
CHANGED
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2026-
|
|
3
|
+
# on 2026-07-15 04:20:07 UTC using RuboCop version 1.86.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
@@ -12,8 +12,14 @@ Metrics/AbcSize:
|
|
|
12
12
|
Exclude:
|
|
13
13
|
- 'spec/omml_fixture_round_trip_spec.rb'
|
|
14
14
|
|
|
15
|
-
# Offense count:
|
|
16
|
-
# Configuration parameters: .
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
# Offense count: 2
|
|
16
|
+
# Configuration parameters: IgnoredMetadata.
|
|
17
|
+
RSpec/DescribeClass:
|
|
18
|
+
Exclude:
|
|
19
|
+
- '**/spec/features/**/*'
|
|
20
|
+
- '**/spec/requests/**/*'
|
|
21
|
+
- '**/spec/routing/**/*'
|
|
22
|
+
- '**/spec/system/**/*'
|
|
23
|
+
- '**/spec/views/**/*'
|
|
24
|
+
- 'spec/omml/qualified_namespace_spec.rb'
|
|
25
|
+
- 'spec/omml/wordprocessing_in_math_spec.rb'
|
data/Gemfile
CHANGED
|
@@ -5,9 +5,6 @@ source "https://rubygems.org"
|
|
|
5
5
|
gemspec
|
|
6
6
|
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
7
7
|
|
|
8
|
-
# TODO: remove this override once lutaml-model 0.8.0 is released.
|
|
9
|
-
gem "lutaml-model", github: "lutaml/lutaml-model", branch: "main"
|
|
10
|
-
|
|
11
8
|
gem "pry"
|
|
12
9
|
gem "rake", "~> 12.0"
|
|
13
10
|
gem "rspec", "~> 3.0"
|
data/lib/omml/models/ct_br.rb
CHANGED
data/lib/omml/models/ct_r.rb
CHANGED
|
@@ -6,6 +6,7 @@ module Omml
|
|
|
6
6
|
attribute :r_pr, :ct_rpr, collection: 0..1
|
|
7
7
|
import_model_attributes :eg_word_r_pr
|
|
8
8
|
choice(min: 0, max: Float::INFINITY) do
|
|
9
|
+
import_model_attributes :eg_word_run_inner_content
|
|
9
10
|
import_model_attributes :eg_run_inner_content
|
|
10
11
|
end
|
|
11
12
|
|
|
@@ -17,6 +18,7 @@ module Omml
|
|
|
17
18
|
sequence do
|
|
18
19
|
map_element :rPr, to: :r_pr
|
|
19
20
|
import_model_mappings :eg_word_r_pr
|
|
21
|
+
import_model_mappings :eg_word_run_inner_content
|
|
20
22
|
import_model_mappings :eg_run_inner_content
|
|
21
23
|
end
|
|
22
24
|
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Omml
|
|
4
|
+
module Models
|
|
5
|
+
# WordprocessingML empty marker type, parallel to CTEmpty (math).
|
|
6
|
+
# Per OOXML schema, several elements inside a math run (`<m:r>`) are
|
|
7
|
+
# WordprocessingML primitives with empty content model: `<w:cr/>`,
|
|
8
|
+
# `<w:tab/>`, `<w:noBreakHyphen/>`, `<w:pgNum/>`, etc. These resolve
|
|
9
|
+
# to the wordprocessing `CT_Empty`, not the math one.
|
|
10
|
+
#
|
|
11
|
+
# The container class (`EGWordRunInnerContent`) already declares the
|
|
12
|
+
# wordprocessing namespace, but lutaml-model matches elements by the
|
|
13
|
+
# TYPE's namespace during parsing. Without this parallel type,
|
|
14
|
+
# math-namespaced CTEmpty won't match `<w:cr/>` and the element is
|
|
15
|
+
# silently dropped.
|
|
16
|
+
class CTWordprocessingEmpty < Base
|
|
17
|
+
xml do
|
|
18
|
+
element "CT_Empty"
|
|
19
|
+
|
|
20
|
+
namespace Omml::WordprocessingNamespace
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Omml
|
|
4
|
+
module Models
|
|
5
|
+
# WordprocessingML text type, parallel to CTText (math).
|
|
6
|
+
# Per OOXML schema, `<w:delText>`, `<w:instrText>`, and
|
|
7
|
+
# `<w:delInstrText>` inside a math run (`<m:r>`) resolve to the
|
|
8
|
+
# wordprocessing `CT_Text`, not the math one (`<m:t>`).
|
|
9
|
+
#
|
|
10
|
+
# Behavior is identical to CTText (string content + `xml:space`
|
|
11
|
+
# attribute); only the XML namespace differs.
|
|
12
|
+
class CTWordprocessingText < Base
|
|
13
|
+
attribute :content, :st_string
|
|
14
|
+
attribute :space, ::Lutaml::Xml::W3c::XmlSpaceType
|
|
15
|
+
|
|
16
|
+
xml do
|
|
17
|
+
element "CT_Text"
|
|
18
|
+
|
|
19
|
+
namespace Omml::WordprocessingNamespace
|
|
20
|
+
|
|
21
|
+
map_content to: :content
|
|
22
|
+
map_attribute :space, to: :space
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -2,79 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
module Omml
|
|
4
4
|
module Models
|
|
5
|
+
# Math run inner content. Per shared-math.xsd CT_R, the math schema
|
|
6
|
+
# contributes only the `t` element (CT_Text) inside a math run; all
|
|
7
|
+
# other run inner content (br, cr, tab, delText, etc.) belongs to
|
|
8
|
+
# the WordprocessingML namespace via EGWordRunInnerContent.
|
|
5
9
|
class EGRunInnerContent < Base
|
|
6
10
|
choice(min: 1, max: 1) do
|
|
7
|
-
attribute :br, :string
|
|
8
11
|
attribute :t, :ct_text
|
|
9
|
-
attribute :del_text, :ct_text
|
|
10
|
-
attribute :instr_text, :ct_text
|
|
11
|
-
attribute :del_instr_text, :ct_text
|
|
12
|
-
attribute :no_break_hyphen, :ct_empty
|
|
13
|
-
attribute :soft_hyphen, :ct_empty, collection: 0..1
|
|
14
|
-
attribute :day_short, :ct_empty, collection: 0..1
|
|
15
|
-
attribute :month_short, :ct_empty, collection: 0..1
|
|
16
|
-
attribute :year_short, :ct_empty, collection: 0..1
|
|
17
|
-
attribute :day_long, :ct_empty, collection: 0..1
|
|
18
|
-
attribute :month_long, :ct_empty, collection: 0..1
|
|
19
|
-
attribute :year_long, :ct_empty, collection: 0..1
|
|
20
|
-
attribute :annotation_ref, :ct_empty, collection: 0..1
|
|
21
|
-
attribute :footnote_ref, :ct_empty, collection: 0..1
|
|
22
|
-
attribute :endnote_ref, :ct_empty, collection: 0..1
|
|
23
|
-
attribute :separator, :ct_empty, collection: 0..1
|
|
24
|
-
attribute :continuation_separator, :ct_empty, collection: 0..1
|
|
25
|
-
attribute :sym, :ct_sym, collection: 0..1
|
|
26
|
-
attribute :pg_num, :ct_empty, collection: 0..1
|
|
27
|
-
attribute :cr, :ct_empty, collection: 0..1
|
|
28
|
-
attribute :tab, :ct_empty, collection: 0..1
|
|
29
|
-
attribute :object, :ct_object
|
|
30
|
-
attribute :pict, :ct_picture
|
|
31
|
-
attribute :fld_char, :ct_fld_char
|
|
32
|
-
attribute :ruby, :ct_ruby
|
|
33
|
-
attribute :footnote_reference, :ct_ftn_edn_ref
|
|
34
|
-
attribute :endnote_reference, :ct_ftn_edn_ref
|
|
35
|
-
attribute :comment_reference, :ct_markup
|
|
36
|
-
attribute :drawing, :ct_drawing
|
|
37
|
-
attribute :ptab, :ct_p_tab, collection: 0..1
|
|
38
|
-
attribute :last_rendered_page_break, :ct_empty, collection: 0..1
|
|
39
12
|
end
|
|
40
13
|
|
|
41
14
|
xml do
|
|
42
15
|
type_name "EG_RunInnerContent"
|
|
43
|
-
map_element :br, to: :br, render_empty: true, namespace: nil
|
|
44
16
|
map_element :t, to: :t, render_empty: true
|
|
45
|
-
map_element :delText, to: :del_text, render_empty: true
|
|
46
|
-
map_element :instrText, to: :instr_text, render_empty: true
|
|
47
|
-
map_element :delInstrText, to: :del_instr_text, render_empty: true
|
|
48
|
-
map_element :noBreakHyphen, to: :no_break_hyphen, render_empty: true
|
|
49
|
-
map_element :softHyphen, to: :soft_hyphen
|
|
50
|
-
map_element :dayShort, to: :day_short
|
|
51
|
-
map_element :monthShort, to: :month_short
|
|
52
|
-
map_element :yearShort, to: :year_short
|
|
53
|
-
map_element :dayLong, to: :day_long
|
|
54
|
-
map_element :monthLong, to: :month_long
|
|
55
|
-
map_element :yearLong, to: :year_long
|
|
56
|
-
map_element :annotationRef, to: :annotation_ref
|
|
57
|
-
map_element :footnoteRef, to: :footnote_ref
|
|
58
|
-
map_element :endnoteRef, to: :endnote_ref
|
|
59
|
-
map_element :separator, to: :separator
|
|
60
|
-
map_element :continuationSeparator, to: :continuation_separator
|
|
61
|
-
map_element :sym, to: :sym
|
|
62
|
-
map_element :pgNum, to: :pg_num
|
|
63
|
-
map_element :cr, to: :cr
|
|
64
|
-
map_element :tab, to: :tab
|
|
65
|
-
map_element :object, to: :object, render_empty: true
|
|
66
|
-
map_element :pict, to: :pict, render_empty: true
|
|
67
|
-
map_element :fldChar, to: :fld_char, render_empty: true
|
|
68
|
-
map_element :ruby, to: :ruby, render_empty: true
|
|
69
|
-
map_element :footnoteReference, to: :footnote_reference,
|
|
70
|
-
render_empty: true
|
|
71
|
-
map_element :endnoteReference, to: :endnote_reference,
|
|
72
|
-
render_empty: true
|
|
73
|
-
map_element :commentReference, to: :comment_reference,
|
|
74
|
-
render_empty: true
|
|
75
|
-
map_element :drawing, to: :drawing, render_empty: true
|
|
76
|
-
map_element :ptab, to: :ptab
|
|
77
|
-
map_element :lastRenderedPageBreak, to: :last_rendered_page_break
|
|
78
17
|
end
|
|
79
18
|
end
|
|
80
19
|
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Omml
|
|
4
|
+
module Models
|
|
5
|
+
# WordprocessingML run inner content elements referenced from CT_R via
|
|
6
|
+
# <xsd:group ref="w:EG_RunInnerContent" /> in shared-math.xsd.
|
|
7
|
+
#
|
|
8
|
+
# Every element here belongs to the WordprocessingML namespace regardless
|
|
9
|
+
# of its containing parent. Per the global rule "define your own types",
|
|
10
|
+
# Omml owns these wordprocessing stubs so the gem is self-contained;
|
|
11
|
+
# consumers (e.g. Uniword) substitute their own wordprocessing classes
|
|
12
|
+
# via the register substitution mechanism.
|
|
13
|
+
class EGWordRunInnerContent < Base
|
|
14
|
+
choice(min: 1, max: 1) do
|
|
15
|
+
attribute :br, :ct_br
|
|
16
|
+
attribute :del_text, :ct_wordprocessing_text
|
|
17
|
+
attribute :instr_text, :ct_wordprocessing_text
|
|
18
|
+
attribute :del_instr_text, :ct_wordprocessing_text
|
|
19
|
+
attribute :no_break_hyphen, :ct_wordprocessing_empty
|
|
20
|
+
attribute :soft_hyphen, :ct_wordprocessing_empty, collection: 0..1
|
|
21
|
+
attribute :day_short, :ct_wordprocessing_empty, collection: 0..1
|
|
22
|
+
attribute :month_short, :ct_wordprocessing_empty, collection: 0..1
|
|
23
|
+
attribute :year_short, :ct_wordprocessing_empty, collection: 0..1
|
|
24
|
+
attribute :day_long, :ct_wordprocessing_empty, collection: 0..1
|
|
25
|
+
attribute :month_long, :ct_wordprocessing_empty, collection: 0..1
|
|
26
|
+
attribute :year_long, :ct_wordprocessing_empty, collection: 0..1
|
|
27
|
+
attribute :annotation_ref, :ct_wordprocessing_empty, collection: 0..1
|
|
28
|
+
attribute :footnote_ref, :ct_wordprocessing_empty, collection: 0..1
|
|
29
|
+
attribute :endnote_ref, :ct_wordprocessing_empty, collection: 0..1
|
|
30
|
+
attribute :separator, :ct_wordprocessing_empty, collection: 0..1
|
|
31
|
+
attribute :continuation_separator, :ct_wordprocessing_empty,
|
|
32
|
+
collection: 0..1
|
|
33
|
+
attribute :sym, :ct_sym, collection: 0..1
|
|
34
|
+
attribute :pg_num, :ct_wordprocessing_empty, collection: 0..1
|
|
35
|
+
attribute :cr, :ct_wordprocessing_empty, collection: 0..1
|
|
36
|
+
attribute :tab, :ct_wordprocessing_empty, collection: 0..1
|
|
37
|
+
attribute :object, :ct_object
|
|
38
|
+
attribute :pict, :ct_picture
|
|
39
|
+
attribute :fld_char, :ct_fld_char
|
|
40
|
+
attribute :ruby, :ct_ruby
|
|
41
|
+
attribute :footnote_reference, :ct_ftn_edn_ref
|
|
42
|
+
attribute :endnote_reference, :ct_ftn_edn_ref
|
|
43
|
+
attribute :comment_reference, :ct_markup
|
|
44
|
+
attribute :drawing, :ct_drawing
|
|
45
|
+
attribute :ptab, :ct_p_tab, collection: 0..1
|
|
46
|
+
attribute :last_rendered_page_break, :ct_wordprocessing_empty,
|
|
47
|
+
collection: 0..1
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
xml do
|
|
51
|
+
type_name "EG_WordRunInnerContent"
|
|
52
|
+
namespace Omml::WordprocessingNamespace
|
|
53
|
+
|
|
54
|
+
map_element :br, to: :br, render_empty: true
|
|
55
|
+
map_element :delText, to: :del_text, render_empty: true
|
|
56
|
+
map_element :instrText, to: :instr_text, render_empty: true
|
|
57
|
+
map_element :delInstrText, to: :del_instr_text, render_empty: true
|
|
58
|
+
map_element :noBreakHyphen, to: :no_break_hyphen, render_empty: true
|
|
59
|
+
map_element :softHyphen, to: :soft_hyphen
|
|
60
|
+
map_element :dayShort, to: :day_short
|
|
61
|
+
map_element :monthShort, to: :month_short
|
|
62
|
+
map_element :yearShort, to: :year_short
|
|
63
|
+
map_element :dayLong, to: :day_long
|
|
64
|
+
map_element :monthLong, to: :month_long
|
|
65
|
+
map_element :yearLong, to: :year_long
|
|
66
|
+
map_element :annotationRef, to: :annotation_ref
|
|
67
|
+
map_element :footnoteRef, to: :footnote_ref
|
|
68
|
+
map_element :endnoteRef, to: :endnote_ref
|
|
69
|
+
map_element :separator, to: :separator
|
|
70
|
+
map_element :continuationSeparator, to: :continuation_separator
|
|
71
|
+
map_element :sym, to: :sym
|
|
72
|
+
map_element :pgNum, to: :pg_num
|
|
73
|
+
map_element :cr, to: :cr
|
|
74
|
+
map_element :tab, to: :tab
|
|
75
|
+
map_element :object, to: :object, render_empty: true
|
|
76
|
+
map_element :pict, to: :pict, render_empty: true
|
|
77
|
+
map_element :fldChar, to: :fld_char, render_empty: true
|
|
78
|
+
map_element :ruby, to: :ruby, render_empty: true
|
|
79
|
+
map_element :footnoteReference, to: :footnote_reference,
|
|
80
|
+
render_empty: true
|
|
81
|
+
map_element :endnoteReference, to: :endnote_reference,
|
|
82
|
+
render_empty: true
|
|
83
|
+
map_element :commentReference, to: :comment_reference,
|
|
84
|
+
render_empty: true
|
|
85
|
+
map_element :drawing, to: :drawing, render_empty: true
|
|
86
|
+
map_element :ptab, to: :ptab
|
|
87
|
+
map_element :lastRenderedPageBreak, to: :last_rendered_page_break
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
data/lib/omml/models.rb
CHANGED
|
@@ -180,6 +180,10 @@ module Omml
|
|
|
180
180
|
autoload :CTWrapTopBottom, "omml/models/ct_wrap_top_bottom"
|
|
181
181
|
autoload :CTXAlign, "omml/models/ct_x_align"
|
|
182
182
|
autoload :CTYAlign, "omml/models/ct_y_align"
|
|
183
|
+
autoload :CTWordprocessingEmpty,
|
|
184
|
+
"omml/models/ct_wordprocessing_empty"
|
|
185
|
+
autoload :CTWordprocessingText,
|
|
186
|
+
"omml/models/ct_wordprocessing_text"
|
|
183
187
|
|
|
184
188
|
autoload :OMath, "omml/models/o_math"
|
|
185
189
|
autoload :OMathPara, "omml/models/o_math_para"
|
|
@@ -202,6 +206,8 @@ module Omml
|
|
|
202
206
|
autoload :EGRunLevelElts, "omml/models/groups/eg_run_level_elts"
|
|
203
207
|
autoload :EGScriptStyle, "omml/models/groups/eg_script_style"
|
|
204
208
|
autoload :EGWordRPr, "omml/models/groups/eg_word_r_pr"
|
|
209
|
+
autoload :EGWordRunInnerContent,
|
|
210
|
+
"omml/models/groups/eg_word_run_inner_content"
|
|
205
211
|
autoload :EGWrapType, "omml/models/groups/eg_wrap_type"
|
|
206
212
|
|
|
207
213
|
autoload :EnumString, "omml/models/simple_types/enum_string"
|
data/lib/omml/namespace.rb
CHANGED
|
@@ -4,6 +4,8 @@ module Omml
|
|
|
4
4
|
class Namespace < Lutaml::Xml::W3c::XmlNamespace
|
|
5
5
|
uri "http://schemas.openxmlformats.org/officeDocument/2006/math"
|
|
6
6
|
prefix_default "m"
|
|
7
|
+
# Per shared-math.xsd: elementFormDefault="qualified"
|
|
8
|
+
element_form_default :qualified
|
|
7
9
|
attribute_form_default :qualified
|
|
8
10
|
end
|
|
9
11
|
end
|
data/lib/omml/version.rb
CHANGED
|
@@ -4,6 +4,8 @@ module Omml
|
|
|
4
4
|
class WordprocessingNamespace < Lutaml::Xml::W3c::XmlNamespace
|
|
5
5
|
uri "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
|
|
6
6
|
prefix_default "w"
|
|
7
|
+
# Per wml.xsd: elementFormDefault="qualified"
|
|
8
|
+
element_form_default :qualified
|
|
7
9
|
attribute_form_default :qualified
|
|
8
10
|
end
|
|
9
11
|
end
|