plurimath 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.rspec +3 -0
- data/.rspec-opal +11 -0
- data/Gemfile +4 -0
- data/Rakefile +11 -0
- data/lib/plurimath/asciimath/parse.rb +3 -2
- data/lib/plurimath/asciimath/transform.rb +47 -5
- data/lib/plurimath/latex/constants.rb +5 -1
- data/lib/plurimath/latex/parse.rb +20 -11
- data/lib/plurimath/latex/transform.rb +32 -14
- data/lib/plurimath/math/core.rb +212 -10
- data/lib/plurimath/math/formula.rb +154 -40
- data/lib/plurimath/math/function/abs.rb +28 -15
- data/lib/plurimath/math/function/bar.rb +5 -0
- data/lib/plurimath/math/function/base.rb +22 -2
- data/lib/plurimath/math/function/binary_function.rb +38 -12
- data/lib/plurimath/math/function/ceil.rb +24 -9
- data/lib/plurimath/math/function/color.rb +14 -0
- data/lib/plurimath/math/function/ddot.rb +6 -1
- data/lib/plurimath/math/function/deg.rb +4 -1
- data/lib/plurimath/math/function/det.rb +4 -1
- data/lib/plurimath/math/function/dim.rb +4 -1
- data/lib/plurimath/math/function/dot.rb +5 -0
- data/lib/plurimath/math/function/exp.rb +4 -1
- data/lib/plurimath/math/function/fenced.rb +51 -15
- data/lib/plurimath/math/function/floor.rb +24 -14
- data/lib/plurimath/math/function/font_style.rb +63 -8
- data/lib/plurimath/math/function/frac.rb +38 -18
- data/lib/plurimath/math/function/gcd.rb +4 -1
- data/lib/plurimath/math/function/glb.rb +8 -1
- data/lib/plurimath/math/function/hat.rb +16 -5
- data/lib/plurimath/math/function/hom.rb +4 -1
- data/lib/plurimath/math/function/inf.rb +16 -0
- data/lib/plurimath/math/function/int.rb +35 -9
- data/lib/plurimath/math/function/ker.rb +4 -1
- data/lib/plurimath/math/function/lcm.rb +17 -1
- data/lib/plurimath/math/function/left.rb +20 -2
- data/lib/plurimath/math/function/lg.rb +4 -1
- data/lib/plurimath/math/function/lim.rb +16 -0
- data/lib/plurimath/math/function/liminf.rb +4 -1
- data/lib/plurimath/math/function/limits.rb +29 -9
- data/lib/plurimath/math/function/limsup.rb +4 -1
- data/lib/plurimath/math/function/linebreak.rb +95 -0
- data/lib/plurimath/math/function/ln.rb +4 -1
- data/lib/plurimath/math/function/log.rb +27 -12
- data/lib/plurimath/math/function/longdiv.rb +19 -0
- data/lib/plurimath/math/function/lub.rb +4 -1
- data/lib/plurimath/math/function/max.rb +4 -1
- data/lib/plurimath/math/function/mbox.rb +8 -7
- data/lib/plurimath/math/function/menclose.rb +6 -0
- data/lib/plurimath/math/function/merror.rb +12 -3
- data/lib/plurimath/math/function/min.rb +4 -1
- data/lib/plurimath/math/function/mod.rb +48 -15
- data/lib/plurimath/math/function/msgroup.rb +32 -0
- data/lib/plurimath/math/function/msline.rb +10 -0
- data/lib/plurimath/math/function/multiscript.rb +27 -0
- data/lib/plurimath/math/function/nary.rb +128 -0
- data/lib/plurimath/math/function/norm.rb +24 -15
- data/lib/plurimath/math/function/obrace.rb +5 -0
- data/lib/plurimath/math/function/oint.rb +48 -20
- data/lib/plurimath/math/function/over.rb +29 -10
- data/lib/plurimath/math/function/overset.rb +19 -10
- data/lib/plurimath/math/function/phantom.rb +24 -6
- data/lib/plurimath/math/function/power.rb +19 -4
- data/lib/plurimath/math/function/power_base.rb +34 -33
- data/lib/plurimath/math/function/prod.rb +43 -23
- data/lib/plurimath/math/function/right.rb +20 -2
- data/lib/plurimath/math/function/root.rb +6 -0
- data/lib/plurimath/math/function/rule.rb +8 -1
- data/lib/plurimath/math/function/scarries.rb +14 -0
- data/lib/plurimath/math/function/semantics.rb +15 -0
- data/lib/plurimath/math/function/sqrt.rb +5 -0
- data/lib/plurimath/math/function/stackrel.rb +14 -0
- data/lib/plurimath/math/function/substack.rb +18 -51
- data/lib/plurimath/math/function/sum.rb +36 -12
- data/lib/plurimath/math/function/sup.rb +11 -2
- data/lib/plurimath/math/function/table/array.rb +1 -1
- data/lib/plurimath/math/function/table/matrix.rb +4 -0
- data/lib/plurimath/math/function/table.rb +62 -26
- data/lib/plurimath/math/function/td.rb +42 -4
- data/lib/plurimath/math/function/ternary_function.rb +48 -10
- data/lib/plurimath/math/function/text.rb +25 -3
- data/lib/plurimath/math/function/tilde.rb +5 -0
- data/lib/plurimath/math/function/tr.rb +29 -1
- data/lib/plurimath/math/function/ubrace.rb +5 -0
- data/lib/plurimath/math/function/unary_function.rb +115 -29
- data/lib/plurimath/math/function/underover.rb +27 -58
- data/lib/plurimath/math/function/underset.rb +25 -9
- data/lib/plurimath/math/function/vec.rb +45 -0
- data/lib/plurimath/math/function.rb +7 -5
- data/lib/plurimath/math/number.rb +12 -8
- data/lib/plurimath/math/symbol.rb +25 -13
- data/lib/plurimath/math.rb +1 -3
- data/lib/plurimath/mathml/parser.rb +6 -4
- data/lib/plurimath/mathml/transform.rb +26 -19
- data/lib/plurimath/omml/parser.rb +3 -3
- data/lib/plurimath/omml/transform.rb +34 -21
- data/lib/plurimath/setup/oga.rb +5 -0
- data/lib/plurimath/setup/opal.rb.erb +8 -0
- data/lib/plurimath/setup/ox.rb +5 -0
- data/lib/plurimath/unitsml.rb +2 -1
- data/lib/plurimath/utility.rb +77 -41
- data/lib/plurimath/version.rb +1 -1
- data/lib/plurimath/xml_engine/oga.rb +246 -0
- data/lib/plurimath/xml_engine/ox.rb +29 -0
- data/lib/plurimath/xml_engine.rb +6 -0
- data/lib/plurimath.rb +12 -2
- metadata +12 -3
- data/lib/plurimath/math/function/scarry.rb +0 -12
@@ -5,6 +5,13 @@ module Plurimath
|
|
5
5
|
class Formula < Core
|
6
6
|
attr_accessor :value, :left_right_wrapper, :displaystyle, :input_string
|
7
7
|
|
8
|
+
MATH_ZONE_TYPES = %i[
|
9
|
+
omml
|
10
|
+
latex
|
11
|
+
mathml
|
12
|
+
asciimath
|
13
|
+
].freeze
|
14
|
+
|
8
15
|
def initialize(
|
9
16
|
value = [],
|
10
17
|
left_right_wrapper = true,
|
@@ -18,7 +25,9 @@ module Plurimath
|
|
18
25
|
end
|
19
26
|
|
20
27
|
def ==(object)
|
21
|
-
object.value
|
28
|
+
object.respond_to?(:value) &&
|
29
|
+
object.respond_to?(:left_right_wrapper) &&
|
30
|
+
object.value == value &&
|
22
31
|
object.left_right_wrapper == left_right_wrapper
|
23
32
|
end
|
24
33
|
|
@@ -28,21 +37,29 @@ module Plurimath
|
|
28
37
|
parse_error!(:asciimath)
|
29
38
|
end
|
30
39
|
|
31
|
-
def to_mathml(display_style: displaystyle)
|
40
|
+
def to_mathml(display_style: displaystyle, split_on_linebreak: false)
|
41
|
+
return line_breaked_mathml(display_style) if split_on_linebreak
|
42
|
+
|
32
43
|
math_attrs = {
|
33
44
|
xmlns: "http://www.w3.org/1998/Math/MathML",
|
34
45
|
display: "block",
|
35
46
|
}
|
36
47
|
style_attrs = { displaystyle: boolean_display_style(display_style) }
|
37
|
-
math =
|
38
|
-
style =
|
48
|
+
math = ox_element("math", attributes: math_attrs)
|
49
|
+
style = ox_element("mstyle", attributes: style_attrs)
|
39
50
|
Utility.update_nodes(style, mathml_content)
|
40
51
|
Utility.update_nodes(math, [style])
|
41
|
-
|
52
|
+
dump_nodes(math, indent: 2)
|
42
53
|
rescue
|
43
54
|
parse_error!(:mathml)
|
44
55
|
end
|
45
56
|
|
57
|
+
def line_breaked_mathml(display_style)
|
58
|
+
new_line_support.map do |formula|
|
59
|
+
formula.to_mathml(display_style: display_style)
|
60
|
+
end.join
|
61
|
+
end
|
62
|
+
|
46
63
|
def to_mathml_without_math_tag
|
47
64
|
return mathml_content unless left_right_wrapper
|
48
65
|
|
@@ -68,7 +85,7 @@ module Plurimath
|
|
68
85
|
parse_error!(:html)
|
69
86
|
end
|
70
87
|
|
71
|
-
def
|
88
|
+
def omml_attrs
|
72
89
|
{
|
73
90
|
"xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
74
91
|
"xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
@@ -91,16 +108,20 @@ module Plurimath
|
|
91
108
|
}
|
92
109
|
end
|
93
110
|
|
94
|
-
def to_omml(display_style: displaystyle)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
111
|
+
def to_omml(display_style: displaystyle, split_on_linebreak: false)
|
112
|
+
objects = split_on_linebreak ? new_line_support : [self]
|
113
|
+
|
114
|
+
para_element = Utility.ox_element("oMathPara", attributes: omml_attrs, namespace: "m")
|
115
|
+
objects.each.with_index(1) do |object, index|
|
116
|
+
para_element << Utility.update_nodes(
|
117
|
+
Utility.ox_element("oMath", namespace: "m"),
|
118
|
+
object.omml_content(boolean_display_style(display_style)),
|
119
|
+
)
|
120
|
+
next if objects.length == index
|
121
|
+
|
122
|
+
para_element << omml_br_tag
|
123
|
+
end
|
124
|
+
dump_nodes(para_element, indent: 2)
|
104
125
|
rescue
|
105
126
|
parse_error!(:omml)
|
106
127
|
end
|
@@ -110,24 +131,58 @@ module Plurimath
|
|
110
131
|
end
|
111
132
|
|
112
133
|
def to_omml_without_math_tag(display_style)
|
113
|
-
return nary_tag(display_style) if nary_tag_able?(display_style)
|
114
|
-
|
115
134
|
omml_content(display_style)
|
116
135
|
end
|
117
136
|
|
118
|
-
def
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
137
|
+
def to_display(type = nil)
|
138
|
+
return type_error! unless MATH_ZONE_TYPES.include?(type.downcase.to_sym)
|
139
|
+
|
140
|
+
math_zone = case type
|
141
|
+
when :asciimath
|
142
|
+
" |_ \"#{to_asciimath}\"\n#{to_asciimath_math_zone(" ").join}"
|
143
|
+
when :latex
|
144
|
+
" |_ \"#{to_latex}\"\n#{to_latex_math_zone(" ").join}"
|
145
|
+
when :mathml
|
146
|
+
" |_ \"#{to_mathml.gsub(/\n\s*/, "")}\"\n#{to_mathml_math_zone(" ").join}"
|
147
|
+
when :omml
|
148
|
+
" |_ \"#{to_omml.gsub(/\n\s*/, "")}\"\n#{to_omml_math_zone(" ", display_style: displaystyle).join}"
|
149
|
+
end
|
150
|
+
<<~MATHZONE.sub(/\n$/, "")
|
151
|
+
|_ Math zone
|
152
|
+
#{math_zone}
|
153
|
+
MATHZONE
|
127
154
|
end
|
128
155
|
|
129
|
-
def
|
130
|
-
|
156
|
+
def to_asciimath_math_zone(spacing = "", last = false, indent = true)
|
157
|
+
filtered_values(value).map.with_index(1) do |object, index|
|
158
|
+
last = index == @values.length
|
159
|
+
object.to_asciimath_math_zone(new_space(spacing, indent), last, indent)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def to_latex_math_zone(spacing = "", last = false, indent = true)
|
164
|
+
filtered_values(value).map.with_index(1) do |object, index|
|
165
|
+
last = index == @values.length
|
166
|
+
object.to_latex_math_zone(new_space(spacing, indent), last, indent)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def to_mathml_math_zone(spacing = "", last = false, indent = true)
|
171
|
+
filtered_values(value).map.with_index(1) do |object, index|
|
172
|
+
last = index == @values.length
|
173
|
+
object.to_mathml_math_zone(new_space(spacing, indent), last, indent)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def to_omml_math_zone(spacing = "", last = false, indent = true, display_style:)
|
178
|
+
filtered_values(value).map.with_index(1) do |object, index|
|
179
|
+
last = index == @values.length
|
180
|
+
object.to_omml_math_zone(new_space(spacing, indent), last, indent, display_style: display_style)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def extract_class_name_from_text
|
185
|
+
return unless value.length < 2 && value.first.is_a?(Function::Text)
|
131
186
|
|
132
187
|
value.first.parameter_one
|
133
188
|
end
|
@@ -136,29 +191,88 @@ module Plurimath
|
|
136
191
|
value.first.nary_attr_value
|
137
192
|
end
|
138
193
|
|
139
|
-
def nary_tag_able?(display_style)
|
140
|
-
value.length == 2 &&
|
141
|
-
["underover", "powerbase"].include?(value&.first&.class_name) &&
|
142
|
-
!value.first.parameter_one.is_a?(Function::FontStyle) &&
|
143
|
-
(
|
144
|
-
value&.first&.parameter_one&.to_omml_without_math_tag(display_style)&.length == 1 ||
|
145
|
-
value&.first&.parameter_one.to_omml_without_math_tag(display_style).match?(/^&#x\w*\d*;$/)
|
146
|
-
)
|
147
|
-
end
|
148
|
-
|
149
194
|
def validate_function_formula
|
150
195
|
(value.none?(Function::Left) || value.none?(Function::Right))
|
151
196
|
end
|
152
197
|
|
198
|
+
def value_exist?
|
199
|
+
value && !value.empty?
|
200
|
+
end
|
201
|
+
|
202
|
+
def update(object)
|
203
|
+
self.value = Array(object)
|
204
|
+
end
|
205
|
+
|
206
|
+
def cloned_objects
|
207
|
+
cloned_obj = value.map(&:cloned_objects)
|
208
|
+
formula = self.class.new(cloned_obj)
|
209
|
+
formula.left_right_wrapper = @left_right_wrapper
|
210
|
+
formula
|
211
|
+
end
|
212
|
+
|
213
|
+
def new_line_support(array = [])
|
214
|
+
cloned = cloned_objects
|
215
|
+
obj = self.class.new
|
216
|
+
cloned.line_breaking(obj)
|
217
|
+
array << cloned
|
218
|
+
obj.value_exist? ? obj.new_line_support(array) : array
|
219
|
+
end
|
220
|
+
|
221
|
+
def line_breaking(obj)
|
222
|
+
if result.size > 1
|
223
|
+
breaked_result = result.first.last.omml_line_break(result)
|
224
|
+
update(Array(breaked_result.shift))
|
225
|
+
obj.update(breaked_result.flatten)
|
226
|
+
reprocess_value(obj)
|
227
|
+
return
|
228
|
+
end
|
229
|
+
|
230
|
+
value.each.with_index(1) do |object, index|
|
231
|
+
object.line_breaking(obj)
|
232
|
+
break obj.insert(value.slice!(index..value.size)) if obj.value_exist?
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def reprocess_value(obj)
|
237
|
+
new_obj = self.class.new([])
|
238
|
+
self.line_breaking(new_obj)
|
239
|
+
if new_obj.value_exist?
|
240
|
+
obj.value.insert(0, Function::Linebreak.new)
|
241
|
+
obj.value.insert(0, self.class.new(new_obj.value))
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def insert(values)
|
246
|
+
update(Array(value) + values)
|
247
|
+
end
|
248
|
+
|
249
|
+
|
153
250
|
protected
|
154
251
|
|
155
252
|
def boolean_display_style(display_style = displaystyle)
|
156
|
-
YAML.
|
253
|
+
YAML.safe_load(display_style.to_s)
|
254
|
+
end
|
255
|
+
|
256
|
+
def new_space(spacing, indent)
|
257
|
+
if value.any? { |val| val.class_name == "left" } && value.any? { |val| val.class_name == "right" }
|
258
|
+
return spacing
|
259
|
+
end
|
260
|
+
|
261
|
+
(indent && wrapable?(spacing)) ? spacing + "|_ " : spacing
|
262
|
+
end
|
263
|
+
|
264
|
+
def wrapable?(spacing)
|
265
|
+
left_right_wrapper && !spacing.end_with?("|_ ")
|
157
266
|
end
|
158
267
|
|
159
268
|
def parse_error!(type)
|
160
269
|
Math.parse_error!(input_string, type)
|
161
270
|
end
|
271
|
+
|
272
|
+
def omml_br_tag
|
273
|
+
r_tag = ox_element("r", namespace: "m")
|
274
|
+
r_tag << ox_element("br")
|
275
|
+
end
|
162
276
|
end
|
163
277
|
end
|
164
278
|
end
|
@@ -6,32 +6,45 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Abs < UnaryFunction
|
9
|
+
attr_accessor :open_paren, :close_paren
|
10
|
+
|
9
11
|
def to_mathml_without_math_tag
|
10
12
|
symbol = Utility.ox_element("mo") << "|"
|
11
|
-
first_value = mathml_value
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
)
|
13
|
+
first_value = mathml_value
|
14
|
+
first_value = first_value&.insert(0, symbol) unless open_paren
|
15
|
+
first_value << symbol unless close_paren
|
16
|
+
Utility.update_nodes(ox_element("mrow"), first_value)
|
16
17
|
end
|
17
18
|
|
18
19
|
def to_omml_without_math_tag(display_style)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
Array(
|
21
|
+
md_tag << omml_parameter(parameter_one, display_style, tag_name: "e"),
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def line_breaking(obj)
|
26
|
+
parameter_one.line_breaking(obj)
|
27
|
+
if obj.value_exist?
|
28
|
+
ceil_object = self.class.new(Utility.filter_values(obj.value))
|
29
|
+
ceil_object.open_paren = true
|
30
|
+
ceil_object.close_paren = false
|
31
|
+
obj.update(ceil_object)
|
32
|
+
self.close_paren = true
|
33
|
+
self.open_paren = false unless open_paren
|
34
|
+
end
|
24
35
|
end
|
25
36
|
|
26
37
|
protected
|
27
38
|
|
28
|
-
def
|
39
|
+
def md_tag
|
29
40
|
attribute = { "m:val": "|" }
|
41
|
+
sepchr_attr = { "m:val": "" }
|
30
42
|
mdpr = Utility.pr_element("d", namespace: "m")
|
31
|
-
mdpr <<
|
32
|
-
mdpr <<
|
33
|
-
mdpr <<
|
34
|
-
mdpr <<
|
43
|
+
mdpr << ox_element("begChr", namespace: "m", attributes: attribute) unless open_paren
|
44
|
+
mdpr << ox_element("endChr", namespace: "m", attributes: attribute) unless close_paren
|
45
|
+
mdpr << ox_element("sepChr", namespace: "m", attributes: sepchr_attr)
|
46
|
+
mdpr << ox_element("grow", namespace: "m")
|
47
|
+
ox_element("d", namespace: "m") << mdpr
|
35
48
|
end
|
36
49
|
end
|
37
50
|
end
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Base < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "subscript",
|
11
|
+
first_value: "base",
|
12
|
+
second_value: "script",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_asciimath
|
10
16
|
first_value = parameter_one.to_asciimath if parameter_one
|
11
17
|
second_value = "_#{wrapped(parameter_two)}" if parameter_two
|
@@ -16,8 +22,8 @@ module Plurimath
|
|
16
22
|
tag_name = (Utility::MUNDER_CLASSES.include?(parameter_one&.class_name) ? "under" : "sub")
|
17
23
|
sub_tag = Utility.ox_element("m#{tag_name}")
|
18
24
|
mathml_value = []
|
19
|
-
mathml_value << parameter_one
|
20
|
-
mathml_value << parameter_two
|
25
|
+
mathml_value << validate_mathml_fields(parameter_one)
|
26
|
+
mathml_value << validate_mathml_fields(parameter_two)
|
21
27
|
Utility.update_nodes(sub_tag, mathml_value)
|
22
28
|
end
|
23
29
|
|
@@ -48,6 +54,20 @@ module Plurimath
|
|
48
54
|
)
|
49
55
|
[ssub_element]
|
50
56
|
end
|
57
|
+
|
58
|
+
def line_breaking(obj)
|
59
|
+
parameter_one&.line_breaking(obj)
|
60
|
+
if obj.value_exist?
|
61
|
+
obj.update(self.class.new(Utility.filter_values(obj.value), parameter_two))
|
62
|
+
self.parameter_two = nil
|
63
|
+
return
|
64
|
+
end
|
65
|
+
|
66
|
+
parameter_two&.line_breaking(obj)
|
67
|
+
if obj.value_exist?
|
68
|
+
obj.update(self.class.new(nil, Utility.filter_values(obj.value)))
|
69
|
+
end
|
70
|
+
end
|
51
71
|
end
|
52
72
|
end
|
53
73
|
end
|
@@ -4,12 +4,12 @@ module Plurimath
|
|
4
4
|
module Math
|
5
5
|
module Function
|
6
6
|
class BinaryFunction < Core
|
7
|
-
attr_accessor :parameter_one, :parameter_two
|
7
|
+
attr_accessor :parameter_one, :parameter_two, :hide_function_name
|
8
8
|
|
9
9
|
def initialize(parameter_one = nil, parameter_two = nil)
|
10
10
|
@parameter_one = parameter_one
|
11
11
|
@parameter_two = parameter_two
|
12
|
-
Utility.validate_left_right(
|
12
|
+
Utility.validate_left_right(variables.map { |var| get(var) })
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_asciimath
|
@@ -64,6 +64,42 @@ module Plurimath
|
|
64
64
|
!(parameter_one.nil? && parameter_two.nil?)
|
65
65
|
end
|
66
66
|
|
67
|
+
def to_asciimath_math_zone(spacing, last = false, _)
|
68
|
+
parameters = self.class::FUNCTION
|
69
|
+
new_spacing = gsub_spacing(spacing, last)
|
70
|
+
new_arr = ["#{spacing}\"#{to_asciimath}\" #{parameters[:name]}\n"]
|
71
|
+
ascii_fields_to_print(parameter_one, { spacing: new_spacing, field_name: parameters[:first_value], additional_space: "| |_ " , array: new_arr })
|
72
|
+
ascii_fields_to_print(parameter_two, { spacing: new_spacing, field_name: parameters[:second_value], additional_space: " |_ " , array: new_arr })
|
73
|
+
new_arr
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_latex_math_zone(spacing, last = false, _)
|
77
|
+
parameters = self.class::FUNCTION
|
78
|
+
new_spacing = gsub_spacing(spacing, last)
|
79
|
+
new_arr = ["#{spacing}\"#{to_latex}\" #{parameters[:name]}\n"]
|
80
|
+
latex_fields_to_print(parameter_one, { spacing: new_spacing, field_name: parameters[:first_value], additional_space: "| |_ " , array: new_arr })
|
81
|
+
latex_fields_to_print(parameter_two, { spacing: new_spacing, field_name: parameters[:second_value], additional_space: " |_ " , array: new_arr })
|
82
|
+
new_arr
|
83
|
+
end
|
84
|
+
|
85
|
+
def to_mathml_math_zone(spacing, last = false, _)
|
86
|
+
parameters = self.class::FUNCTION
|
87
|
+
new_spacing = gsub_spacing(spacing, last)
|
88
|
+
new_arr = ["#{spacing}\"#{dump_mathml(self)}\" #{parameters[:name]}\n"]
|
89
|
+
mathml_fields_to_print(parameter_one, { spacing: new_spacing, field_name: parameters[:first_value], additional_space: "| |_ ", array: new_arr })
|
90
|
+
mathml_fields_to_print(parameter_two, { spacing: new_spacing, field_name: parameters[:second_value], additional_space: " |_ ", array: new_arr })
|
91
|
+
new_arr
|
92
|
+
end
|
93
|
+
|
94
|
+
def to_omml_math_zone(spacing, last = false, _, display_style:)
|
95
|
+
parameters = self.class::FUNCTION
|
96
|
+
new_spacing = gsub_spacing(spacing, last)
|
97
|
+
new_arr = ["#{spacing}\"#{dump_omml(self, display_style)}\" #{parameters[:name]}\n"]
|
98
|
+
omml_fields_to_print(parameter_one, { spacing: new_spacing, field_name: parameters[:first_value], additional_space: "| |_ ", array: new_arr, display_style: display_style })
|
99
|
+
omml_fields_to_print(parameter_two, { spacing: new_spacing, field_name: parameters[:second_value], additional_space: " |_ ", array: new_arr, display_style: display_style })
|
100
|
+
new_arr
|
101
|
+
end
|
102
|
+
|
67
103
|
protected
|
68
104
|
|
69
105
|
def latex_wrapped(field)
|
@@ -80,16 +116,6 @@ module Plurimath
|
|
80
116
|
"(#{field.to_asciimath})"
|
81
117
|
end
|
82
118
|
|
83
|
-
def invert_unicode_symbols
|
84
|
-
Mathml::Constants::UNICODE_SYMBOLS.invert[class_name] || class_name
|
85
|
-
end
|
86
|
-
|
87
|
-
def empty_tag(wrapper_tag)
|
88
|
-
r_tag = Utility.ox_element("r", namespace: "m")
|
89
|
-
r_tag << (Utility.ox_element("t", namespace: "m") << "​")
|
90
|
-
wrapper_tag << r_tag
|
91
|
-
end
|
92
|
-
|
93
119
|
def underover(display_style)
|
94
120
|
return r_element(class_name, rpr_tag: false) unless all_values_exist?
|
95
121
|
|
@@ -6,23 +6,22 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Ceil < UnaryFunction
|
9
|
+
attr_accessor :open_paren, :close_paren
|
10
|
+
|
9
11
|
def to_latex
|
10
12
|
"{\\lceil #{latex_value} \\rceil}"
|
11
13
|
end
|
12
14
|
|
13
15
|
def to_mathml_without_math_tag
|
14
|
-
|
15
|
-
first_value =
|
16
|
-
|
17
|
-
Utility.update_nodes(
|
18
|
-
Utility.ox_element("mrow"),
|
19
|
-
first_value << right_value,
|
20
|
-
)
|
16
|
+
first_value = mathml_value
|
17
|
+
first_value = first_value&.insert(0, paren_node("⌈")) unless open_paren
|
18
|
+
first_value = first_value << paren_node("⌉") unless close_paren
|
19
|
+
Utility.update_nodes(ox_element("mrow"), first_value)
|
21
20
|
end
|
22
21
|
|
23
22
|
def to_omml_without_math_tag(display_style)
|
24
|
-
lceil = Symbol.new("⌈")
|
25
|
-
rceil = Symbol.new("⌉")
|
23
|
+
lceil = Symbol.new("⌈") unless open_paren
|
24
|
+
rceil = Symbol.new("⌉") unless close_paren
|
26
25
|
fenced = Fenced.new(lceil, Array(parameter_one), rceil)
|
27
26
|
Array(fenced.to_omml_without_math_tag(display_style))
|
28
27
|
end
|
@@ -31,6 +30,22 @@ module Plurimath
|
|
31
30
|
first_value = "<i>#{parameter_one.to_html}</i>" if parameter_one
|
32
31
|
"<i>⌈</i>#{first_value}<i>⌉</i>"
|
33
32
|
end
|
33
|
+
|
34
|
+
def line_breaking(obj)
|
35
|
+
parameter_one.line_breaking(obj)
|
36
|
+
if obj.value_exist?
|
37
|
+
ceil_object = self.class.new(Utility.filter_values(obj.value))
|
38
|
+
ceil_object.open_paren = true
|
39
|
+
ceil_object.close_paren = false
|
40
|
+
obj.update(ceil_object)
|
41
|
+
self.close_paren = true
|
42
|
+
self.open_paren = false unless open_paren
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def paren_node(value)
|
47
|
+
ox_element("mo") << value
|
48
|
+
end
|
34
49
|
end
|
35
50
|
end
|
36
51
|
end
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Color < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "color",
|
11
|
+
first_value: "mathcolor",
|
12
|
+
second_value: "text",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_asciimath
|
10
16
|
first_value = "(#{parameter_one&.to_asciimath&.gsub(/\s/, '')})"
|
11
17
|
second_value = "(#{parameter_two&.to_asciimath})"
|
@@ -31,6 +37,14 @@ module Plurimath
|
|
31
37
|
def to_omml_without_math_tag(display_style)
|
32
38
|
Array(parameter_two.insert_t_tag(display_style))
|
33
39
|
end
|
40
|
+
|
41
|
+
def to_omml_math_zone(spacing, last = false, _, display_style:)
|
42
|
+
parameters = self.class::FUNCTION
|
43
|
+
new_spacing = gsub_spacing(spacing, last)
|
44
|
+
new_arr = ["#{spacing}\"#{dump_omml(self, display_style)}\" #{parameters[:name]}\n"]
|
45
|
+
omml_fields_to_print(parameter_two, { spacing: new_spacing, field_name: "text", additional_space: "| |_ ", array: new_arr, display_style: display_style })
|
46
|
+
new_arr
|
47
|
+
end
|
34
48
|
end
|
35
49
|
end
|
36
50
|
end
|
@@ -21,7 +21,7 @@ module Plurimath
|
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
24
|
-
def to_omml_without_math_tag(
|
24
|
+
def to_omml_without_math_tag(_)
|
25
25
|
return r_element("..", rpr_tag: false) unless parameter_one
|
26
26
|
|
27
27
|
symbol = Symbol.new("..")
|
@@ -32,6 +32,11 @@ module Plurimath
|
|
32
32
|
first_value = "<i>#{parameter_one.to_html}</i>" if parameter_one
|
33
33
|
"#{first_value}<i>..</i>"
|
34
34
|
end
|
35
|
+
|
36
|
+
def line_breaking(obj)
|
37
|
+
parameter_one&.line_breaking(obj)
|
38
|
+
obj.update(Utility.filter_values(obj.value)) if obj.value_exist?
|
39
|
+
end
|
35
40
|
end
|
36
41
|
end
|
37
42
|
end
|
@@ -11,7 +11,10 @@ module Plurimath
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_omml_without_math_tag(display_style)
|
14
|
-
|
14
|
+
array = []
|
15
|
+
array << r_element("deg", rpr_tag: false) unless hide_function_name
|
16
|
+
array += Array(omml_value(display_style))
|
17
|
+
array
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -11,7 +11,10 @@ module Plurimath
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_omml_without_math_tag(display_style)
|
14
|
-
|
14
|
+
array = []
|
15
|
+
array << r_element("det", rpr_tag: false) unless hide_function_name
|
16
|
+
array += Array(omml_value(display_style))
|
17
|
+
array
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -11,7 +11,10 @@ module Plurimath
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_omml_without_math_tag(display_style)
|
14
|
-
|
14
|
+
array = []
|
15
|
+
array << r_element("dim", rpr_tag: false) unless hide_function_name
|
16
|
+
array += Array(omml_value(display_style))
|
17
|
+
array
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -11,7 +11,10 @@ module Plurimath
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_omml_without_math_tag(display_style)
|
14
|
-
|
14
|
+
array = []
|
15
|
+
array << r_element("exp", rpr_tag: false) unless hide_function_name
|
16
|
+
array += Array(omml_value(display_style))
|
17
|
+
array
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|