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
@@ -0,0 +1,128 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Plurimath
|
4
|
+
module Math
|
5
|
+
module Function
|
6
|
+
class Nary < Core
|
7
|
+
attr_accessor :parameter_one, :parameter_two, :parameter_three, :parameter_four, :options
|
8
|
+
|
9
|
+
def initialize(parameter_one = nil,
|
10
|
+
parameter_two = nil,
|
11
|
+
parameter_three = nil,
|
12
|
+
parameter_four = nil,
|
13
|
+
options = {})
|
14
|
+
@parameter_one = parameter_one
|
15
|
+
@parameter_two = parameter_two
|
16
|
+
@parameter_three = parameter_three
|
17
|
+
@parameter_four = parameter_four
|
18
|
+
@options = options
|
19
|
+
Utility.validate_left_right([parameter_one, parameter_two, parameter_three, parameter_four])
|
20
|
+
end
|
21
|
+
|
22
|
+
def ==(object)
|
23
|
+
self.class == object.class &&
|
24
|
+
object.parameter_one == parameter_one &&
|
25
|
+
object.parameter_two == parameter_two &&
|
26
|
+
object.parameter_three == parameter_three &&
|
27
|
+
object.parameter_four == parameter_four &&
|
28
|
+
object.options == options
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_asciimath
|
32
|
+
first_value = parameter_one&.to_asciimath || "int"
|
33
|
+
second_value = "_#{parameter_two.to_asciimath}" if parameter_two
|
34
|
+
third_value = "^#{parameter_three.to_asciimath}" if parameter_three
|
35
|
+
fourth_value = " #{parameter_four.to_asciimath}" if parameter_four
|
36
|
+
"#{first_value}#{second_value}#{third_value}#{fourth_value}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_latex
|
40
|
+
first_value = parameter_one&.to_latex || "\\int"
|
41
|
+
second_value = "_#{parameter_two.to_latex}" if parameter_two
|
42
|
+
third_value = "^#{parameter_three.to_latex}" if parameter_three
|
43
|
+
fourth_value = "{#{parameter_four.to_latex}}" if parameter_four
|
44
|
+
"#{first_value}#{second_value}#{third_value}#{fourth_value}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_mathml_without_math_tag
|
48
|
+
tag_name = options[:type] == "undOvr" ? "munderover" : "msubsup"
|
49
|
+
subsup_tag = ox_element(tag_name)
|
50
|
+
new_arr = [
|
51
|
+
validate_mathml_fields(parameter_one),
|
52
|
+
validate_mathml_fields(parameter_two),
|
53
|
+
validate_mathml_fields(parameter_three),
|
54
|
+
]
|
55
|
+
Utility.update_nodes(subsup_tag, new_arr)
|
56
|
+
return subsup_tag unless parameter_four
|
57
|
+
|
58
|
+
Utility.update_nodes(
|
59
|
+
ox_element("mrow"),
|
60
|
+
[
|
61
|
+
subsup_tag,
|
62
|
+
parameter_four&.to_mathml_without_math_tag,
|
63
|
+
],
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
def to_omml_without_math_tag(display_style)
|
68
|
+
nary_element = Utility.ox_element("nary", namespace: "m")
|
69
|
+
Utility.update_nodes(nary_element, omml_nary_tag(display_style))
|
70
|
+
Array(nary_element)
|
71
|
+
end
|
72
|
+
|
73
|
+
def line_breaking(obj)
|
74
|
+
parameter_one&.line_breaking(obj)
|
75
|
+
if obj.value_exist?
|
76
|
+
obj.update(self.class.new(Utility.filter_values(obj.value), self.parameter_two, self.parameter_three, self.parameter_four))
|
77
|
+
self.parameter_two = nil
|
78
|
+
self.parameter_three = nil
|
79
|
+
self.parameter_four = nil
|
80
|
+
return
|
81
|
+
end
|
82
|
+
|
83
|
+
parameter_two&.line_breaking(obj)
|
84
|
+
if obj.value_exist?
|
85
|
+
obj.update(self.class.new(nil, Utility.filter_values(obj.value), self.parameter_three, self.parameter_four))
|
86
|
+
self.parameter_three = nil
|
87
|
+
self.parameter_four = nil
|
88
|
+
return
|
89
|
+
end
|
90
|
+
|
91
|
+
parameter_four&.line_breaking(obj)
|
92
|
+
if obj.value_exist?
|
93
|
+
obj.update(Utility.filter_values(obj.value))
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
protected
|
98
|
+
|
99
|
+
def chr_value(narypr)
|
100
|
+
first_value = Utility.html_entity_to_unicode(parameter_one&.nary_attr_value)
|
101
|
+
narypr << Utility.ox_element("chr", namespace: "m", attributes: { "m:val": first_value }) unless first_value == "∫"
|
102
|
+
|
103
|
+
narypr << Utility.ox_element("limLoc", namespace: "m", attributes: { "m:val": options[:type].to_s })
|
104
|
+
hide_tags(narypr, parameter_two, "sub")
|
105
|
+
hide_tags(narypr, parameter_three, "sup")
|
106
|
+
narypr
|
107
|
+
end
|
108
|
+
|
109
|
+
def hide_tags(nar, field, tag_prefix)
|
110
|
+
return nar unless field.nil?
|
111
|
+
|
112
|
+
nar << Utility.ox_element("#{tag_prefix}Hide", namespace: "m", attributes: { "m:val": "1" })
|
113
|
+
end
|
114
|
+
|
115
|
+
def omml_nary_tag(display_style)
|
116
|
+
narypr = Utility.ox_element("naryPr", namespace: "m")
|
117
|
+
chr_value(narypr)
|
118
|
+
[
|
119
|
+
(narypr << Utility.pr_element("ctrl", true, namespace: "m")),
|
120
|
+
omml_parameter(parameter_two, display_style, tag_name: "sub"),
|
121
|
+
omml_parameter(parameter_three, display_style, tag_name: "sup"),
|
122
|
+
omml_parameter(parameter_four, display_style, tag_name: "e"),
|
123
|
+
]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -6,6 +6,8 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Norm < UnaryFunction
|
9
|
+
attr_accessor :open_paren, :close_paren
|
10
|
+
|
9
11
|
def to_asciimath
|
10
12
|
parameter_one.is_a?(Table) ? "norm#{parameter_one.to_asciimath}" : super
|
11
13
|
end
|
@@ -15,24 +17,31 @@ module Plurimath
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def to_mathml_without_math_tag
|
18
|
-
first_value = parameter_one&.to_mathml_without_math_tag
|
19
|
-
norm =
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
norm,
|
24
|
-
first_value,
|
25
|
-
norm,
|
26
|
-
],
|
27
|
-
)
|
20
|
+
first_value = Array(parameter_one&.to_mathml_without_math_tag)
|
21
|
+
norm = ox_element("mo") << "∥"
|
22
|
+
first_value = first_value.insert(0, norm) unless open_paren
|
23
|
+
first_value = first_value << norm unless close_paren
|
24
|
+
Utility.update_nodes(ox_element("mrow"), first_value)
|
28
25
|
end
|
29
26
|
|
30
27
|
def to_omml_without_math_tag(display_style)
|
31
|
-
[
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
array = []
|
29
|
+
array << r_element("∥") unless open_paren
|
30
|
+
array += Array(omml_value(display_style))
|
31
|
+
array << r_element("∥") unless close_paren
|
32
|
+
array
|
33
|
+
end
|
34
|
+
|
35
|
+
def line_breaking(obj)
|
36
|
+
parameter_one.line_breaking(obj)
|
37
|
+
if obj.value_exist?
|
38
|
+
norm_object = self.class.new(Utility.filter_values(obj.value))
|
39
|
+
norm_object.open_paren = true
|
40
|
+
norm_object.close_paren = false
|
41
|
+
obj.update(norm_object)
|
42
|
+
self.close_paren = true
|
43
|
+
self.open_paren = false unless open_paren
|
44
|
+
end
|
36
45
|
end
|
37
46
|
end
|
38
47
|
end
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Oint < TernaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "contour integral",
|
11
|
+
first_value: "subscript",
|
12
|
+
second_value: "supscript",
|
13
|
+
}
|
14
|
+
|
9
15
|
def to_asciimath
|
10
16
|
first_value = "_#{wrapped(parameter_one)}" if parameter_one
|
11
17
|
second_value = "^#{wrapped(parameter_two)}" if parameter_two
|
@@ -19,28 +25,33 @@ module Plurimath
|
|
19
25
|
end
|
20
26
|
|
21
27
|
def to_mathml_without_math_tag
|
22
|
-
mo_tag =
|
28
|
+
mo_tag = ox_element("mo")
|
29
|
+
mo_tag << invert_unicode_symbols.to_s unless hide_function_name
|
23
30
|
return mo_tag unless all_values_exist?
|
24
31
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
if parameter_one || parameter_two
|
33
|
+
value_array = [
|
34
|
+
mo_tag,
|
35
|
+
parameter_one&.to_mathml_without_math_tag,
|
36
|
+
parameter_two&.to_mathml_without_math_tag,
|
37
|
+
]
|
38
|
+
tag_name = if parameter_one && parameter_two
|
39
|
+
"subsup"
|
40
|
+
else
|
41
|
+
parameter_one ? "sub" : "sup"
|
42
|
+
end
|
43
|
+
msubsup_tag = ox_element("m#{tag_name}")
|
44
|
+
Utility.update_nodes(msubsup_tag, value_array)
|
45
|
+
return msubsup_tag unless parameter_three
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
47
|
+
Utility.update_nodes(
|
48
|
+
ox_element("mrow"),
|
49
|
+
[
|
50
|
+
msubsup_tag,
|
51
|
+
parameter_three&.to_mathml_without_math_tag,
|
52
|
+
],
|
53
|
+
)
|
54
|
+
end
|
44
55
|
end
|
45
56
|
|
46
57
|
def to_omml_without_math_tag(display_style)
|
@@ -49,7 +60,7 @@ module Plurimath
|
|
49
60
|
Utility.update_nodes(
|
50
61
|
nary,
|
51
62
|
[
|
52
|
-
narypr("∮", function_type: "subSup"),
|
63
|
+
narypr((hide_function_name ? "" : "∮"), function_type: "subSup"),
|
53
64
|
omml_parameter(parameter_one, display_style, tag_name: "sub"),
|
54
65
|
omml_parameter(parameter_two, display_style, tag_name: "sup"),
|
55
66
|
omml_parameter(parameter_three, display_style, tag_name: "e"),
|
@@ -63,6 +74,23 @@ module Plurimath
|
|
63
74
|
[r_tag]
|
64
75
|
end
|
65
76
|
end
|
77
|
+
|
78
|
+
def line_breaking(obj)
|
79
|
+
parameter_one&.line_breaking(obj)
|
80
|
+
if obj.value_exist?
|
81
|
+
oint = self.class.new(Utility.filter_values(obj.value), parameter_two, parameter_three)
|
82
|
+
oint.hide_function_name = true
|
83
|
+
obj.update(oint)
|
84
|
+
self.parameter_two = nil
|
85
|
+
self.parameter_three = nil
|
86
|
+
return
|
87
|
+
end
|
88
|
+
|
89
|
+
parameter_three&.line_breaking(obj)
|
90
|
+
if obj.value_exist?
|
91
|
+
obj.update(Utility.filter_values(obj.value))
|
92
|
+
end
|
93
|
+
end
|
66
94
|
end
|
67
95
|
end
|
68
96
|
end
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Over < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "over",
|
11
|
+
first_value: "numerator",
|
12
|
+
second_value: "denominator",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_asciimath
|
10
16
|
first_value = wrapped(parameter_one)
|
11
17
|
second_value = wrapped(parameter_two)
|
@@ -13,16 +19,12 @@ module Plurimath
|
|
13
19
|
end
|
14
20
|
|
15
21
|
def to_mathml_without_math_tag
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
first_value,
|
23
|
-
second_value,
|
24
|
-
],
|
25
|
-
)
|
22
|
+
tag_name = hide_function_name ? "mrow" : "mfrac"
|
23
|
+
mathml_value = [
|
24
|
+
parameter_one&.to_mathml_without_math_tag,
|
25
|
+
parameter_two&.to_mathml_without_math_tag,
|
26
|
+
]
|
27
|
+
Utility.update_nodes(ox_element(tag_name), mathml_value)
|
26
28
|
end
|
27
29
|
|
28
30
|
def to_latex
|
@@ -44,6 +46,23 @@ module Plurimath
|
|
44
46
|
)
|
45
47
|
[f_element]
|
46
48
|
end
|
49
|
+
|
50
|
+
def line_breaking(obj)
|
51
|
+
parameter_one&.line_breaking(obj)
|
52
|
+
if obj.value_exist?
|
53
|
+
obj.update(self.class.new(Utility.filter_values(obj.value), parameter_two))
|
54
|
+
self.parameter_two = nil
|
55
|
+
self.hide_function_name = true
|
56
|
+
return
|
57
|
+
end
|
58
|
+
|
59
|
+
parameter_two&.line_breaking(obj)
|
60
|
+
if obj.value_exist?
|
61
|
+
over = self.class.new(nil, Utility.filter_values(obj.value))
|
62
|
+
over.hide_function_name = true
|
63
|
+
obj.update(over)
|
64
|
+
end
|
65
|
+
end
|
47
66
|
end
|
48
67
|
end
|
49
68
|
end
|
@@ -6,17 +6,18 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Overset < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "overset",
|
11
|
+
first_value: "base",
|
12
|
+
second_value: "supscript",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_mathml_without_math_tag
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
[
|
16
|
-
second_value,
|
17
|
-
first_value,
|
18
|
-
],
|
19
|
-
)
|
16
|
+
value_array = [
|
17
|
+
validate_mathml_fields(parameter_two),
|
18
|
+
validate_mathml_fields(parameter_one),
|
19
|
+
]
|
20
|
+
Utility.update_nodes(ox_element("mover"), value_array)
|
20
21
|
end
|
21
22
|
|
22
23
|
def to_omml_without_math_tag(display_style)
|
@@ -38,6 +39,14 @@ module Plurimath
|
|
38
39
|
)
|
39
40
|
[limupp]
|
40
41
|
end
|
42
|
+
|
43
|
+
def line_breaking(obj)
|
44
|
+
parameter_two&.line_breaking(obj)
|
45
|
+
if obj.value_exist?
|
46
|
+
obj.update(self.class.new(parameter_one, Utility.filter_values(obj.value)))
|
47
|
+
self.parameter_one = nil
|
48
|
+
end
|
49
|
+
end
|
41
50
|
end
|
42
51
|
end
|
43
52
|
end
|
@@ -7,24 +7,42 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Phantom < UnaryFunction
|
9
9
|
def to_asciimath
|
10
|
-
"#{Array.new(
|
10
|
+
"#{Array.new(asciimath_value&.length, '\ ').join}"
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_html
|
14
|
-
"<i>#{
|
14
|
+
"<i style='visibility: hidden;'>#{parameter_one&.to_html}</i>"
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_latex
|
18
|
-
|
18
|
+
"\\#{class_name}{#{latex_value}}"
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_mathml_without_math_tag
|
22
|
-
phantom = Utility.ox_element("mphantom")
|
23
22
|
Utility.update_nodes(
|
24
|
-
|
25
|
-
|
23
|
+
Utility.ox_element("mphantom"),
|
24
|
+
Array(mathml_value),
|
26
25
|
)
|
27
26
|
end
|
27
|
+
|
28
|
+
def to_omml_without_math_tag(display_style)
|
29
|
+
phant = Utility.ox_element("phant", namespace: "m")
|
30
|
+
e_tag = Utility.ox_element("e", namespace: "m")
|
31
|
+
Utility.update_nodes(e_tag, Array(omml_value(display_style)))
|
32
|
+
Utility.update_nodes(phant, [phant_pr, e_tag])
|
33
|
+
end
|
34
|
+
|
35
|
+
def line_breaking(obj)
|
36
|
+
custom_array_line_breaking(obj)
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def phant_pr
|
42
|
+
attributes = { val: "m:off" }
|
43
|
+
phant = Utility.ox_element("phant", namespace: "m")
|
44
|
+
phant << Utility.ox_element("show", namespace: "m", attributes: attributes)
|
45
|
+
end
|
28
46
|
end
|
29
47
|
end
|
30
48
|
end
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Power < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "superscript",
|
11
|
+
first_value: "base",
|
12
|
+
second_value: "script",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_asciimath
|
10
16
|
second_value = "^#{wrapped(parameter_two)}" if parameter_two
|
11
17
|
"#{parameter_one.to_asciimath}#{second_value}"
|
@@ -13,10 +19,11 @@ module Plurimath
|
|
13
19
|
|
14
20
|
def to_mathml_without_math_tag
|
15
21
|
tag_name = (["ubrace", "obrace"].include?(parameter_one&.class_name) ? "over" : "sup")
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
value_array = [
|
23
|
+
validate_mathml_fields(parameter_one),
|
24
|
+
validate_mathml_fields(parameter_two),
|
25
|
+
]
|
26
|
+
Utility.update_nodes(ox_element("m#{tag_name}"), value_array)
|
20
27
|
end
|
21
28
|
|
22
29
|
def to_latex
|
@@ -45,6 +52,14 @@ module Plurimath
|
|
45
52
|
)
|
46
53
|
[ssup_element]
|
47
54
|
end
|
55
|
+
|
56
|
+
def line_breaking(obj)
|
57
|
+
parameter_one&.line_breaking(obj)
|
58
|
+
if obj.value_exist?
|
59
|
+
obj.update(self.class.new(Utility.filter_values(obj.value), parameter_two))
|
60
|
+
self.parameter_two = nil
|
61
|
+
end
|
62
|
+
end
|
48
63
|
end
|
49
64
|
end
|
50
65
|
end
|
@@ -6,12 +6,21 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class PowerBase < TernaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "subsup",
|
11
|
+
first_value: "base",
|
12
|
+
second_value: "subscript",
|
13
|
+
third_value: "supscript",
|
14
|
+
}.freeze
|
15
|
+
|
9
16
|
def to_mathml_without_math_tag
|
10
|
-
|
11
|
-
|
12
|
-
new_arr
|
13
|
-
|
14
|
-
|
17
|
+
tag_name = parameter_one&.tag_name || "subsup"
|
18
|
+
subsup_tag = ox_element("m#{tag_name}")
|
19
|
+
new_arr = [
|
20
|
+
validate_mathml_fields(parameter_one),
|
21
|
+
validate_mathml_fields(parameter_two),
|
22
|
+
validate_mathml_fields(parameter_three),
|
23
|
+
]
|
15
24
|
Utility.update_nodes(subsup_tag, new_arr)
|
16
25
|
end
|
17
26
|
|
@@ -29,25 +38,8 @@ module Plurimath
|
|
29
38
|
"#{first_value}#{second_value}#{third_value}"
|
30
39
|
end
|
31
40
|
|
32
|
-
def omml_nary_tag(display_style)
|
33
|
-
narypr = Utility.ox_element("naryPr", namespace: "m")
|
34
|
-
chr_value(narypr)
|
35
|
-
narypr << Utility.ox_element(
|
36
|
-
"limLoc",
|
37
|
-
namespace: "m",
|
38
|
-
attributes: { "m:val": parameter_one.omml_tag_name },
|
39
|
-
)
|
40
|
-
hide_tags(narypr)
|
41
|
-
narypr << Utility.pr_element("ctrl", true, namespace: "m")
|
42
|
-
[
|
43
|
-
narypr,
|
44
|
-
omml_parameter(parameter_two, display_style, tag_name: "sub"),
|
45
|
-
omml_parameter(parameter_three, display_style, tag_name: "sup"),
|
46
|
-
]
|
47
|
-
end
|
48
|
-
|
49
41
|
def to_omml_without_math_tag(display_style)
|
50
|
-
return underover(display_style) if parameter_one
|
42
|
+
return underover(display_style) if parameter_one&.omml_tag_name == "undOvr"
|
51
43
|
|
52
44
|
ssubsup = Utility.ox_element("sSubSup", namespace: "m")
|
53
45
|
ssubsuppr = Utility.ox_element("sSubSupPr", namespace: "m")
|
@@ -66,19 +58,28 @@ module Plurimath
|
|
66
58
|
[ssubsup]
|
67
59
|
end
|
68
60
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
61
|
+
def line_breaking(obj)
|
62
|
+
parameter_one&.line_breaking(obj)
|
63
|
+
if obj.value_exist?
|
64
|
+
obj.update(
|
65
|
+
self.class.new(Utility.filter_values(obj.value), parameter_two, parameter_three)
|
66
|
+
)
|
67
|
+
self.parameter_two = nil
|
68
|
+
self.parameter_three = nil
|
69
|
+
return
|
70
|
+
end
|
74
71
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
72
|
+
parameter_two.line_breaking(obj)
|
73
|
+
if obj.value_exist?
|
74
|
+
obj.update(
|
75
|
+
self.class.new(nil, Utility.filter_values(obj.value), parameter_three)
|
76
|
+
)
|
77
|
+
self.parameter_three = nil
|
78
|
+
end
|
80
79
|
end
|
81
80
|
|
81
|
+
protected
|
82
|
+
|
82
83
|
def hide_tags(nar)
|
83
84
|
attr = { "m:val": "1" }
|
84
85
|
if parameter_two.nil?
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Prod < TernaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "prod",
|
11
|
+
first_value: "subscript",
|
12
|
+
second_value: "supscript",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_asciimath
|
10
16
|
first_value = "_#{wrapped(parameter_one)}" if parameter_one
|
11
17
|
second_value = "^#{wrapped(parameter_two)}" if parameter_two
|
@@ -19,17 +25,20 @@ module Plurimath
|
|
19
25
|
end
|
20
26
|
|
21
27
|
def to_mathml_without_math_tag
|
22
|
-
first_value =
|
28
|
+
first_value = ox_element("mo")
|
29
|
+
first_value << invert_unicode_symbols.to_s unless hide_function_name
|
23
30
|
if parameter_one || parameter_two
|
24
|
-
value_array = [first_value]
|
25
|
-
value_array << parameter_one&.to_mathml_without_math_tag
|
26
|
-
value_array << parameter_two&.to_mathml_without_math_tag
|
27
31
|
tag_name = if parameter_two && parameter_one
|
28
32
|
"underover"
|
29
33
|
else
|
30
34
|
parameter_one ? "under" : "over"
|
31
35
|
end
|
32
|
-
|
36
|
+
value_array = [
|
37
|
+
first_value,
|
38
|
+
parameter_one&.to_mathml_without_math_tag,
|
39
|
+
parameter_two&.to_mathml_without_math_tag,
|
40
|
+
]
|
41
|
+
munderover_tag = ox_element("m#{tag_name}")
|
33
42
|
Utility.update_nodes(
|
34
43
|
munderover_tag,
|
35
44
|
value_array,
|
@@ -55,29 +64,40 @@ module Plurimath
|
|
55
64
|
end
|
56
65
|
|
57
66
|
def to_omml_without_math_tag(display_style)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
t_tag = Utility.ox_element("t", namespace: "m")
|
73
|
-
r_tag << (t_tag << "∏")
|
74
|
-
[r_tag]
|
75
|
-
end
|
67
|
+
return r_element("∏", rpr_tag: false) unless all_values_exist?
|
68
|
+
|
69
|
+
nary = Utility.ox_element("nary", namespace: "m")
|
70
|
+
Utility.update_nodes(nary, nary_values(display_style))
|
71
|
+
[nary]
|
72
|
+
end
|
73
|
+
|
74
|
+
def nary_values(display_style)
|
75
|
+
[
|
76
|
+
narypr(hide_function_name ? "" : nary_attr_value),
|
77
|
+
omml_parameter(parameter_one, display_style, tag_name: "sub"),
|
78
|
+
omml_parameter(parameter_two, display_style, tag_name: "sup"),
|
79
|
+
omml_parameter(parameter_three, display_style, tag_name: "e"),
|
80
|
+
]
|
76
81
|
end
|
77
82
|
|
78
83
|
def nary_attr_value
|
79
84
|
"∏"
|
80
85
|
end
|
86
|
+
|
87
|
+
def line_breaking(obj)
|
88
|
+
parameter_one&.line_breaking(obj)
|
89
|
+
if obj.value_exist?
|
90
|
+
prod = self.class.new(Utility.filter_values(obj.value), parameter_two, parameter_three)
|
91
|
+
prod.hide_function_name = true
|
92
|
+
obj.update(prod)
|
93
|
+
return
|
94
|
+
end
|
95
|
+
|
96
|
+
parameter_three&.line_breaking(obj)
|
97
|
+
if obj.value_exist?
|
98
|
+
obj.update(Utility.filter_values(obj.value))
|
99
|
+
end
|
100
|
+
end
|
81
101
|
end
|
82
102
|
end
|
83
103
|
end
|