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
@@ -39,26 +39,52 @@ module Plurimath
|
|
39
39
|
def to_omml_without_math_tag(display_style)
|
40
40
|
d = Utility.ox_element("d", namespace: "m")
|
41
41
|
dpr = Utility.ox_element("dPr", namespace: "m")
|
42
|
-
|
43
|
-
|
42
|
+
parameter = Formula.new(Array(parameter_two))
|
43
|
+
open_paren(dpr)
|
44
|
+
close_paren(dpr)
|
45
|
+
fenced_value = omml_parameter(parameter, display_style, tag_name: "e")
|
44
46
|
dpr << Utility.pr_element("ctrl", true, namespace: "m")
|
45
|
-
Utility.update_nodes(
|
46
|
-
d,
|
47
|
-
[
|
48
|
-
dpr,
|
49
|
-
omml_parameter(
|
50
|
-
Formula.new(Array(parameter_two)),
|
51
|
-
display_style,
|
52
|
-
tag_name: "e",
|
53
|
-
),
|
54
|
-
],
|
55
|
-
)
|
47
|
+
Utility.update_nodes(d, [dpr, fenced_value])
|
56
48
|
[d]
|
57
49
|
end
|
58
50
|
|
51
|
+
def to_asciimath_math_zone(spacing, last = false, indent = true)
|
52
|
+
filtered_values(parameter_two).map.with_index(1) do |object, index|
|
53
|
+
last = index == @values.length
|
54
|
+
object.to_asciimath_math_zone(spacing, last, indent)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_latex_math_zone(spacing, last = false, indent = true)
|
59
|
+
filtered_values(parameter_two).map.with_index(1) do |object, index|
|
60
|
+
last = index == @values.length
|
61
|
+
object.to_latex_math_zone(spacing, last, indent)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def to_mathml_math_zone(spacing, last = false, indent = true)
|
66
|
+
filtered_values(parameter_two).map.with_index(1) do |object, index|
|
67
|
+
last = index == @values.length
|
68
|
+
object.to_mathml_math_zone(spacing, last, indent)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def to_omml_math_zone(spacing, last = false, indent = true, display_style:)
|
73
|
+
filtered_values(parameter_two).map do |object|
|
74
|
+
object.to_omml_math_zone(spacing, last, !indent, display_style: display_style)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def line_breaking(obj)
|
79
|
+
field_values = result(Array(parameter_two))
|
80
|
+
return unless field_values.length > 1
|
81
|
+
|
82
|
+
obj.update(value_split(obj, field_values))
|
83
|
+
end
|
84
|
+
|
59
85
|
protected
|
60
86
|
|
61
|
-
def
|
87
|
+
def open_paren(dpr)
|
62
88
|
first_value = parameter_one&.value
|
63
89
|
return dpr if first_value.nil? || first_value.empty?
|
64
90
|
|
@@ -70,7 +96,7 @@ module Plurimath
|
|
70
96
|
)
|
71
97
|
end
|
72
98
|
|
73
|
-
def
|
99
|
+
def close_paren(dpr)
|
74
100
|
third_value = parameter_three&.value
|
75
101
|
return dpr if third_value.nil? || third_value.empty?
|
76
102
|
|
@@ -96,6 +122,16 @@ module Plurimath
|
|
96
122
|
|
97
123
|
field&.value
|
98
124
|
end
|
125
|
+
|
126
|
+
def value_split(obj, field_value)
|
127
|
+
object = cloned_objects
|
128
|
+
breaked_result = field_value.first.last.omml_line_break(field_value)
|
129
|
+
self.parameter_two = Array(breaked_result.shift)
|
130
|
+
object.parameter_one = nil
|
131
|
+
object.parameter_two = breaked_result.flatten
|
132
|
+
self.parameter_three = nil
|
133
|
+
object
|
134
|
+
end
|
99
135
|
end
|
100
136
|
end
|
101
137
|
end
|
@@ -6,28 +6,38 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Floor < UnaryFunction
|
9
|
+
attr_accessor :open_paren, :close_paren
|
10
|
+
|
9
11
|
def to_latex
|
10
|
-
"\\lfloor #{parameter_one.to_latex} \\rfloor"
|
12
|
+
"{\\lfloor #{parameter_one.to_latex} \\rfloor}"
|
11
13
|
end
|
12
14
|
|
13
15
|
def to_mathml_without_math_tag
|
14
16
|
first_value = parameter_one&.to_mathml_without_math_tag
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
first_value,
|
20
|
-
Utility.ox_element("mo") << "⌋",
|
21
|
-
],
|
22
|
-
)
|
17
|
+
value_array = [first_value]
|
18
|
+
value_array.insert(0, (ox_element("mo") << "⌊")) unless open_paren
|
19
|
+
value_array << (ox_element("mo") << "⌋") unless close_paren
|
20
|
+
Utility.update_nodes(ox_element("mrow"), value_array)
|
23
21
|
end
|
24
22
|
|
25
23
|
def to_omml_without_math_tag(display_style)
|
26
|
-
[
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
array = []
|
25
|
+
array << r_element("⌊") unless open_paren
|
26
|
+
array += Array(omml_value(display_style))
|
27
|
+
array << r_element("⌋") unless close_paren
|
28
|
+
array
|
29
|
+
end
|
30
|
+
|
31
|
+
def line_breaking(obj)
|
32
|
+
parameter_one.line_breaking(obj)
|
33
|
+
if obj.value_exist?
|
34
|
+
ceil_object = self.class.new(Utility.filter_values(obj.value))
|
35
|
+
ceil_object.open_paren = true
|
36
|
+
ceil_object.close_paren = false
|
37
|
+
obj.update(ceil_object)
|
38
|
+
self.close_paren = true
|
39
|
+
self.open_paren = false unless open_paren
|
40
|
+
end
|
31
41
|
end
|
32
42
|
end
|
33
43
|
end
|
@@ -37,7 +37,7 @@ module Plurimath
|
|
37
37
|
true
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
40
|
+
def extract_class_name_from_text
|
41
41
|
parameter_one.parameter_one if parameter_one.is_a?(Text)
|
42
42
|
parameter_one.class_name
|
43
43
|
end
|
@@ -47,18 +47,73 @@ module Plurimath
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def font_styles(display_style, sty: "p", scr: nil)
|
50
|
-
r_tag
|
50
|
+
r_tag = Utility.ox_element("r", namespace: "m")
|
51
51
|
rpr_tag = Utility.ox_element("rPr", namespace: "m")
|
52
|
-
|
53
|
-
|
54
|
-
fonts << Utility.ox_element("sty", namespace: "m", attributes: { "m:val": sty }) if sty
|
55
|
-
r_tag << Utility.update_nodes(rpr_tag, fonts)
|
52
|
+
rpr_tag << Utility.ox_element("scr", namespace: "m", attributes: { "m:val": scr }) if scr
|
53
|
+
rpr_tag << Utility.ox_element("sty", namespace: "m", attributes: { "m:val": sty }) if sty
|
56
54
|
Utility.update_nodes(
|
57
|
-
r_tag,
|
58
|
-
Array(parameter_one
|
55
|
+
(r_tag << rpr_tag),
|
56
|
+
Array(parameter_one&.font_style_t_tag(display_style)),
|
59
57
|
)
|
60
58
|
[r_tag]
|
61
59
|
end
|
60
|
+
|
61
|
+
def to_asciimath_math_zone(spacing, last = false, _)
|
62
|
+
new_spacing = gsub_spacing(spacing, last)
|
63
|
+
new_arr = [
|
64
|
+
"#{spacing}\"#{to_asciimath}\" function apply\n",
|
65
|
+
"#{new_spacing}|_ \"#{parameter_two}\" font family\n",
|
66
|
+
]
|
67
|
+
ascii_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ " , array: new_arr })
|
68
|
+
new_arr
|
69
|
+
end
|
70
|
+
|
71
|
+
def to_latex_math_zone(spacing, last = false, _)
|
72
|
+
new_spacing = gsub_spacing(spacing, last)
|
73
|
+
new_arr = [
|
74
|
+
"#{spacing}\"#{to_latex}\" function apply\n",
|
75
|
+
"#{new_spacing}|_ \"#{parameter_two}\" font family\n",
|
76
|
+
]
|
77
|
+
latex_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ " , array: new_arr })
|
78
|
+
new_arr
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_mathml_math_zone(spacing, last = false, _)
|
82
|
+
new_spacing = gsub_spacing(spacing, last)
|
83
|
+
new_arr = [
|
84
|
+
"#{spacing}\"#{dump_mathml(self)}\" function apply\n",
|
85
|
+
"#{new_spacing}|_ \"#{omml_and_mathml_font_family}\" font family\n",
|
86
|
+
]
|
87
|
+
mathml_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ ", array: new_arr })
|
88
|
+
new_arr
|
89
|
+
end
|
90
|
+
|
91
|
+
def to_omml_math_zone(spacing, last = false, _, display_style:)
|
92
|
+
new_spacing = gsub_spacing(spacing, last)
|
93
|
+
new_arr = [
|
94
|
+
"#{spacing}\"#{dump_omml(self, display_style)}\" function apply\n",
|
95
|
+
"#{new_spacing}|_ \"#{omml_and_mathml_font_family}\" font family\n",
|
96
|
+
]
|
97
|
+
omml_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ ", array: new_arr, display_style: display_style })
|
98
|
+
new_arr
|
99
|
+
end
|
100
|
+
|
101
|
+
def omml_and_mathml_font_family
|
102
|
+
fonts = Utility::FONT_STYLES.select { |_font, font_class| font_class == self.class }.keys.map(&:to_s)
|
103
|
+
Omml::Parser::SUPPORTED_FONTS.values.find { |value| fonts.include?(value) }
|
104
|
+
end
|
105
|
+
|
106
|
+
def line_breaking(obj)
|
107
|
+
parameter_one&.line_breaking(obj)
|
108
|
+
return unless obj.value_exist?
|
109
|
+
|
110
|
+
obj.update(
|
111
|
+
self.class.new(
|
112
|
+
Utility.filter_values(obj.value),
|
113
|
+
self.parameter_two,
|
114
|
+
)
|
115
|
+
)
|
116
|
+
end
|
62
117
|
end
|
63
118
|
end
|
64
119
|
end
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Frac < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "fraction",
|
11
|
+
first_value: "numerator",
|
12
|
+
second_value: "denominator",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_asciimath
|
10
16
|
first_value = "(#{parameter_one&.to_asciimath})" if parameter_one
|
11
17
|
second_value = "(#{parameter_two&.to_asciimath})" if 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
|
-
].flatten,
|
25
|
-
)
|
22
|
+
tag_name = hide_function_name ? "mfrac" : "mrow"
|
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("mfrac"), mathml_value)
|
26
28
|
end
|
27
29
|
|
28
30
|
def to_latex
|
@@ -35,15 +37,33 @@ module Plurimath
|
|
35
37
|
f_element = Utility.ox_element("f", namespace: "m")
|
36
38
|
fpr_element = Utility.ox_element("fPr", namespace: "m")
|
37
39
|
fpr_element << Utility.pr_element("ctrl", true, namespace: "m")
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
Array(
|
41
|
+
Utility.update_nodes(
|
42
|
+
f_element,
|
43
|
+
[
|
44
|
+
fpr_element,
|
45
|
+
omml_parameter(parameter_one, display_style, tag_name: "num"),
|
46
|
+
omml_parameter(parameter_two, display_style, tag_name: "den"),
|
47
|
+
],
|
48
|
+
),
|
45
49
|
)
|
46
|
-
|
50
|
+
end
|
51
|
+
|
52
|
+
def line_breaking(obj)
|
53
|
+
parameter_one&.line_breaking(obj)
|
54
|
+
if obj.value_exist?
|
55
|
+
obj.update(self.class.new(Utility.filter_values(obj.value), parameter_two))
|
56
|
+
self.parameter_two = nil
|
57
|
+
self.hide_function_name = true
|
58
|
+
return
|
59
|
+
end
|
60
|
+
|
61
|
+
parameter_two&.line_breaking(obj)
|
62
|
+
if obj.value_exist?
|
63
|
+
frac = self.class.new(nil, Utility.filter_values(obj.value))
|
64
|
+
frac.hide_function_name = true
|
65
|
+
obj.update(frac)
|
66
|
+
end
|
47
67
|
end
|
48
68
|
end
|
49
69
|
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("gcd", 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
|
@@ -10,8 +10,15 @@ module Plurimath
|
|
10
10
|
false
|
11
11
|
end
|
12
12
|
|
13
|
+
def to_latex
|
14
|
+
"glb{#{latex_value}}"
|
15
|
+
end
|
16
|
+
|
13
17
|
def to_omml_without_math_tag(display_style)
|
14
|
-
|
18
|
+
array = []
|
19
|
+
array << r_element("glb", rpr_tag: false) unless hide_function_name
|
20
|
+
array += Array(omml_value(display_style))
|
21
|
+
array
|
15
22
|
end
|
16
23
|
end
|
17
24
|
end
|
@@ -43,22 +43,33 @@ module Plurimath
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def to_omml_without_math_tag(display_style)
|
46
|
-
return r_element("^", rpr_tag: false)
|
46
|
+
return r_element("^", rpr_tag: false) unless parameter_one
|
47
|
+
return omml_value(display_style) if hide_function_name
|
47
48
|
|
48
49
|
if attributes && attributes[:accent]
|
49
50
|
accent_tag(display_style)
|
50
51
|
else
|
51
|
-
symbol = Symbol.new("̂")
|
52
|
-
Overset.new(parameter_one, symbol).to_omml_without_math_tag(
|
52
|
+
symbol = Symbol.new("̂") unless hide_function_name
|
53
|
+
Overset.new(parameter_one, symbol).to_omml_without_math_tag(display_style)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def line_breaking(obj)
|
58
|
+
parameter_one&.line_breaking(obj)
|
59
|
+
if obj.value_exist?
|
60
|
+
obj.update(
|
61
|
+
Overset.new(Utility.filter_values(obj.value), nil),
|
62
|
+
)
|
53
63
|
end
|
54
64
|
end
|
55
65
|
|
56
66
|
protected
|
57
67
|
|
58
68
|
def accent_tag(display_style)
|
59
|
-
|
69
|
+
symbol = "̂" unless hide_function_name
|
70
|
+
acc_tag = Utility.ox_element("acc", namespace: "m")
|
60
71
|
acc_pr_tag = Utility.ox_element("accPr", namespace: "m")
|
61
|
-
acc_pr_tag << (Utility.ox_element("chr", namespace: "m", attributes: { "m:val":
|
72
|
+
acc_pr_tag << (Utility.ox_element("chr", namespace: "m", attributes: { "m:val": symbol }))
|
62
73
|
Utility.update_nodes(
|
63
74
|
acc_tag,
|
64
75
|
[
|
@@ -7,7 +7,10 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Hom < UnaryFunction
|
9
9
|
def to_omml_without_math_tag(display_style)
|
10
|
-
|
10
|
+
array = []
|
11
|
+
array << r_element("hom", rpr_tag: false) unless hide_function_name
|
12
|
+
array += Array(omml_value(display_style))
|
13
|
+
array
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Inf < BinaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
first_value = "_(#{parameter_one.to_asciimath})" if parameter_one
|
11
|
+
second_value = "^(#{parameter_two.to_asciimath})" if parameter_two
|
12
|
+
"#{class_name}#{first_value}#{second_value}"
|
13
|
+
end
|
14
|
+
|
9
15
|
def to_latex
|
10
16
|
first_value = "_{#{parameter_one.to_latex}}" if parameter_one
|
11
17
|
second_value = "^{#{parameter_two.to_latex}}" if parameter_two
|
@@ -33,6 +39,16 @@ module Plurimath
|
|
33
39
|
def to_omml_without_math_tag(display_style)
|
34
40
|
underover(display_style)
|
35
41
|
end
|
42
|
+
|
43
|
+
def line_breaking(obj)
|
44
|
+
parameter_one.line_breaking(obj)
|
45
|
+
if obj.value_exist?
|
46
|
+
obj.update(
|
47
|
+
Underover.new(nil, Utility.filter_values(obj.value), parameter_two)
|
48
|
+
)
|
49
|
+
self.parameter_two = nil
|
50
|
+
end
|
51
|
+
end
|
36
52
|
end
|
37
53
|
end
|
38
54
|
end
|
@@ -6,6 +6,13 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Int < TernaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "integral",
|
11
|
+
first_value: "lower limit",
|
12
|
+
second_value: "upper limit",
|
13
|
+
third_value: "integrand"
|
14
|
+
}
|
15
|
+
|
9
16
|
def to_asciimath
|
10
17
|
first_value = "_#{wrapped(parameter_one)}" if parameter_one
|
11
18
|
second_value = "^#{wrapped(parameter_two)}" if parameter_two
|
@@ -45,15 +52,7 @@ module Plurimath
|
|
45
52
|
def to_omml_without_math_tag(display_style)
|
46
53
|
if all_values_exist?
|
47
54
|
nary = Utility.ox_element("nary", namespace: "m")
|
48
|
-
Utility.update_nodes(
|
49
|
-
nary,
|
50
|
-
[
|
51
|
-
narypr("∫", function_type: "subSup"),
|
52
|
-
omml_parameter(parameter_one, display_style, tag_name: "sub"),
|
53
|
-
omml_parameter(parameter_two, display_style, tag_name: "sup"),
|
54
|
-
omml_parameter(parameter_three, display_style, tag_name: "e"),
|
55
|
-
],
|
56
|
-
)
|
55
|
+
Utility.update_nodes(nary, nary_array(display_style))
|
57
56
|
[nary]
|
58
57
|
else
|
59
58
|
r_tag = Utility.ox_element("r", namespace: "m")
|
@@ -62,6 +61,33 @@ module Plurimath
|
|
62
61
|
[r_tag]
|
63
62
|
end
|
64
63
|
end
|
64
|
+
|
65
|
+
def line_breaking(obj)
|
66
|
+
parameter_one&.line_breaking(obj)
|
67
|
+
if obj.value_exist?
|
68
|
+
int = Int.new(Utility.filter_values(obj.value), parameter_two, parameter_three)
|
69
|
+
int.hide_function_name = true
|
70
|
+
obj.update(int)
|
71
|
+
self.parameter_two = nil
|
72
|
+
self.parameter_three = nil
|
73
|
+
return
|
74
|
+
end
|
75
|
+
|
76
|
+
parameter_three&.line_breaking(obj)
|
77
|
+
if obj.value_exist?
|
78
|
+
obj.update(Utility.filter_values(obj.value))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def nary_array(display_style)
|
83
|
+
symbol = hide_function_name ? "" : "∫"
|
84
|
+
[
|
85
|
+
narypr(symbol, function_type: "subSup"),
|
86
|
+
omml_parameter(parameter_one, display_style, tag_name: "sub"),
|
87
|
+
omml_parameter(parameter_two, display_style, tag_name: "sup"),
|
88
|
+
omml_parameter(parameter_three, display_style, tag_name: "e"),
|
89
|
+
]
|
90
|
+
end
|
65
91
|
end
|
66
92
|
end
|
67
93
|
end
|
@@ -7,7 +7,10 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Ker < UnaryFunction
|
9
9
|
def to_omml_without_math_tag(display_style)
|
10
|
-
|
10
|
+
array = []
|
11
|
+
array << r_element("ker", rpr_tag: false) unless hide_function_name
|
12
|
+
array += Array(omml_value(display_style))
|
13
|
+
array
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
@@ -6,8 +6,24 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Lcm < UnaryFunction
|
9
|
+
def validate_function_formula
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_asciimath
|
14
|
+
first_value = " #{asciimath_value}" if parameter_one
|
15
|
+
"lcm#{first_value}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_latex
|
19
|
+
"lcm{#{latex_value}}"
|
20
|
+
end
|
21
|
+
|
9
22
|
def to_omml_without_math_tag(display_style)
|
10
|
-
|
23
|
+
array = []
|
24
|
+
array << r_element("lcm", rpr_tag: false) unless hide_function_name
|
25
|
+
array += Array(omml_value(display_style))
|
26
|
+
array
|
11
27
|
end
|
12
28
|
end
|
13
29
|
end
|
@@ -16,7 +16,7 @@ module Plurimath
|
|
16
16
|
mo
|
17
17
|
end
|
18
18
|
|
19
|
-
def to_omml_without_math_tag(
|
19
|
+
def to_omml_without_math_tag(_)
|
20
20
|
mr = Utility.ox_element("m:r")
|
21
21
|
if parameter_one
|
22
22
|
mt = Utility.ox_element("m:t")
|
@@ -30,13 +30,31 @@ module Plurimath
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def to_latex
|
33
|
-
"\\left #{
|
33
|
+
"\\left #{latex_paren}"
|
34
34
|
end
|
35
35
|
|
36
36
|
def validate_function_formula
|
37
37
|
false
|
38
38
|
end
|
39
39
|
|
40
|
+
def to_asciimath_math_zone(spacing = "", _, _)
|
41
|
+
"#{spacing}\"#{latex_paren}\" left\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_latex_math_zone(spacing = "", _, _)
|
45
|
+
"#{spacing}\"#{latex_paren}\" left\n"
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_mathml_math_zone(spacing = "", _, _)
|
49
|
+
mo_tag = (Utility.ox_element("mo") << left_paren)
|
50
|
+
"#{spacing}\"#{dump_ox_nodes(mo_tag).gsub(/\s+/, "")}\" left\n"
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_omml_math_zone(spacing = "", _, _, display_style:)
|
54
|
+
t_tag = (Utility.ox_element("t", namespace: "m") << left_paren)
|
55
|
+
"#{spacing}\"#{dump_ox_nodes(t_tag).gsub(/\s+/, "")}\" left\n"
|
56
|
+
end
|
57
|
+
|
40
58
|
protected
|
41
59
|
|
42
60
|
def left_paren
|
@@ -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("lg", 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
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Lim < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "limit",
|
11
|
+
first_value: "limit subscript",
|
12
|
+
second_value: "limit 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
|
@@ -42,6 +48,16 @@ module Plurimath
|
|
42
48
|
def to_omml_without_math_tag(display_style)
|
43
49
|
underover(display_style)
|
44
50
|
end
|
51
|
+
|
52
|
+
def line_breaking(obj)
|
53
|
+
parameter_one.line_breaking(obj)
|
54
|
+
if obj.value_exist?
|
55
|
+
obj.update(
|
56
|
+
Underover.new(nil, Utility.filter_values(obj.value), parameter_two)
|
57
|
+
)
|
58
|
+
self.parameter_two = nil
|
59
|
+
end
|
60
|
+
end
|
45
61
|
end
|
46
62
|
end
|
47
63
|
end
|
@@ -7,7 +7,10 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Liminf < UnaryFunction
|
9
9
|
def to_omml_without_math_tag(display_style)
|
10
|
-
|
10
|
+
array = []
|
11
|
+
array << r_element("liminf", rpr_tag: false) unless hide_function_name
|
12
|
+
array += Array(omml_value(display_style))
|
13
|
+
array
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|