plurimath 0.4.4 → 0.6.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 +3 -0
- data/Rakefile +11 -0
- data/lib/plurimath/asciimath/transform.rb +15 -0
- data/lib/plurimath/latex/constants.rb +3 -0
- data/lib/plurimath/latex/parse.rb +20 -11
- data/lib/plurimath/latex/transform.rb +24 -2
- data/lib/plurimath/math/core.rb +88 -0
- data/lib/plurimath/math/formula.rb +68 -24
- data/lib/plurimath/math/function/base.rb +8 -2
- data/lib/plurimath/math/function/binary_function.rb +36 -4
- data/lib/plurimath/math/function/color.rb +14 -0
- data/lib/plurimath/math/function/fenced.rb +27 -0
- data/lib/plurimath/math/function/floor.rb +1 -1
- data/lib/plurimath/math/function/font_style.rb +46 -0
- data/lib/plurimath/math/function/frac.rb +6 -0
- data/lib/plurimath/math/function/int.rb +7 -0
- data/lib/plurimath/math/function/left.rb +19 -1
- data/lib/plurimath/math/function/lim.rb +6 -0
- data/lib/plurimath/math/function/limits.rb +7 -0
- data/lib/plurimath/math/function/log.rb +6 -0
- data/lib/plurimath/math/function/menclose.rb +6 -0
- data/lib/plurimath/math/function/mod.rb +6 -0
- data/lib/plurimath/math/function/msgroup.rb +28 -0
- data/lib/plurimath/math/function/multiscript.rb +7 -0
- data/lib/plurimath/math/function/nary.rb +94 -0
- data/lib/plurimath/math/function/oint.rb +6 -0
- data/lib/plurimath/math/function/over.rb +6 -0
- data/lib/plurimath/math/function/overset.rb +6 -0
- data/lib/plurimath/math/function/power.rb +8 -2
- data/lib/plurimath/math/function/power_base.rb +10 -31
- data/lib/plurimath/math/function/prod.rb +19 -18
- data/lib/plurimath/math/function/right.rb +19 -1
- data/lib/plurimath/math/function/root.rb +6 -0
- data/lib/plurimath/math/function/rule.rb +7 -0
- data/lib/plurimath/math/function/semantics.rb +6 -0
- data/lib/plurimath/math/function/stackrel.rb +6 -0
- data/lib/plurimath/math/function/substack.rb +6 -0
- data/lib/plurimath/math/function/sum.rb +26 -25
- data/lib/plurimath/math/function/table.rb +52 -24
- data/lib/plurimath/math/function/td.rb +28 -0
- data/lib/plurimath/math/function/ternary_function.rb +44 -4
- data/lib/plurimath/math/function/text.rb +25 -3
- data/lib/plurimath/math/function/tr.rb +28 -0
- data/lib/plurimath/math/function/unary_function.rb +43 -3
- data/lib/plurimath/math/function/underover.rb +7 -55
- data/lib/plurimath/math/function/underset.rb +6 -0
- data/lib/plurimath/math/function/vec.rb +40 -0
- data/lib/plurimath/math/function.rb +7 -5
- data/lib/plurimath/math/number.rb +9 -5
- data/lib/plurimath/math/symbol.rb +13 -9
- data/lib/plurimath/math.rb +1 -3
- data/lib/plurimath/mathml/parser.rb +4 -4
- data/lib/plurimath/mathml/transform.rb +3 -4
- data/lib/plurimath/omml/parser.rb +19 -3
- data/lib/plurimath/omml/transform.rb +19 -14
- 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/utility.rb +60 -34
- 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 +11 -2
@@ -57,6 +57,52 @@ module Plurimath
|
|
57
57
|
r_tag,
|
58
58
|
Array(parameter_one.font_style_t_tag(display_style)),
|
59
59
|
)
|
60
|
+
[r_tag]
|
61
|
+
end
|
62
|
+
|
63
|
+
def to_asciimath_math_zone(spacing, last = false, _)
|
64
|
+
new_spacing = gsub_spacing(spacing, last)
|
65
|
+
new_arr = [
|
66
|
+
"#{spacing}\"#{to_asciimath}\" function apply\n",
|
67
|
+
"#{new_spacing}|_ \"#{parameter_two}\" font family\n",
|
68
|
+
]
|
69
|
+
ascii_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ " , array: new_arr })
|
70
|
+
new_arr
|
71
|
+
end
|
72
|
+
|
73
|
+
def to_latex_math_zone(spacing, last = false, _)
|
74
|
+
new_spacing = gsub_spacing(spacing, last)
|
75
|
+
new_arr = [
|
76
|
+
"#{spacing}\"#{to_latex}\" function apply\n",
|
77
|
+
"#{new_spacing}|_ \"#{parameter_two}\" font family\n",
|
78
|
+
]
|
79
|
+
latex_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ " , array: new_arr })
|
80
|
+
new_arr
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_mathml_math_zone(spacing, last = false, _)
|
84
|
+
new_spacing = gsub_spacing(spacing, last)
|
85
|
+
new_arr = [
|
86
|
+
"#{spacing}\"#{dump_mathml(self)}\" function apply\n",
|
87
|
+
"#{new_spacing}|_ \"#{omml_and_mathml_font_family}\" font family\n",
|
88
|
+
]
|
89
|
+
mathml_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ ", array: new_arr })
|
90
|
+
new_arr
|
91
|
+
end
|
92
|
+
|
93
|
+
def to_omml_math_zone(spacing, last = false, _, display_style:)
|
94
|
+
new_spacing = gsub_spacing(spacing, last)
|
95
|
+
new_arr = [
|
96
|
+
"#{spacing}\"#{dump_omml(self, display_style)}\" function apply\n",
|
97
|
+
"#{new_spacing}|_ \"#{omml_and_mathml_font_family}\" font family\n",
|
98
|
+
]
|
99
|
+
omml_fields_to_print(parameter_one, { spacing: new_spacing, field_name: "argument", additional_space: "| |_ ", array: new_arr, display_style: display_style })
|
100
|
+
new_arr
|
101
|
+
end
|
102
|
+
|
103
|
+
def omml_and_mathml_font_family
|
104
|
+
fonts = Utility::FONT_STYLES.select { |_font, font_class| font_class == self.class }.keys.map(&:to_s)
|
105
|
+
Omml::Parser::SUPPORTED_FONTS.values.find { |value| fonts.include?(value) }
|
60
106
|
end
|
61
107
|
end
|
62
108
|
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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -6,6 +6,13 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Limits < TernaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "function apply",
|
11
|
+
first_value: "base",
|
12
|
+
second_value: "subscript",
|
13
|
+
third_value: "supscript",
|
14
|
+
}.freeze
|
15
|
+
|
9
16
|
def to_mathml_without_math_tag
|
10
17
|
underover = Utility.ox_element("munderover")
|
11
18
|
value_array = []
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Log < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "function apply",
|
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
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Menclose < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "enclosure",
|
11
|
+
first_value: "enclosure type",
|
12
|
+
second_value: "expression",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_asciimath
|
10
16
|
parameter_two&.to_asciimath
|
11
17
|
end
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Mod < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "mod",
|
11
|
+
first_value: "base",
|
12
|
+
second_value: "argument",
|
13
|
+
}
|
14
|
+
|
9
15
|
def to_asciimath
|
10
16
|
first_value = parameter_one&.to_asciimath
|
11
17
|
second_value = parameter_two&.to_asciimath
|
@@ -28,6 +28,34 @@ module Plurimath
|
|
28
28
|
def to_html
|
29
29
|
"<i>#{parameter_one.map(&:to_html).join}</i>"
|
30
30
|
end
|
31
|
+
|
32
|
+
def to_asciimath_math_zone(spacing, last = false, _indent = true)
|
33
|
+
[
|
34
|
+
"#{spacing}\"msgroup\" function apply\n",
|
35
|
+
Formula.new(parameter_one).to_asciimath_math_zone(gsub_spacing(spacing, last)),
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_latex_math_zone(spacing, last = false, indent = true)
|
40
|
+
[
|
41
|
+
"#{spacing}\"msgroup\" function apply\n",
|
42
|
+
Formula.new(parameter_one).to_latex_math_zone(gsub_spacing(spacing, last), last, indent),
|
43
|
+
]
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_mathml_math_zone(spacing, last = false, indent = true)
|
47
|
+
[
|
48
|
+
"#{spacing}\"msgroup\" function apply\n",
|
49
|
+
Formula.new(parameter_one).to_mathml_math_zone(gsub_spacing(spacing, last), last, indent),
|
50
|
+
]
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_omml_math_zone(spacing, last = false, indent = true, display_style:)
|
54
|
+
[
|
55
|
+
"#{spacing}\"msgroup\" function apply\n",
|
56
|
+
Formula.new(parameter_one).to_omml_math_zone(gsub_spacing(spacing, last), last, indent, display_style: display_style),
|
57
|
+
]
|
58
|
+
end
|
31
59
|
end
|
32
60
|
end
|
33
61
|
end
|
@@ -5,6 +5,13 @@ module Plurimath
|
|
5
5
|
module Math
|
6
6
|
module Function
|
7
7
|
class Multiscript < TernaryFunction
|
8
|
+
FUNCTION = {
|
9
|
+
name: "multiscript",
|
10
|
+
first_value: "base",
|
11
|
+
second_value: "subscript",
|
12
|
+
third_value: "supscript",
|
13
|
+
}.freeze
|
14
|
+
|
8
15
|
def to_omml_without_math_tag(display_style)
|
9
16
|
pre_element = Utility.ox_element("sPre", namespace: "m")
|
10
17
|
pr_element = Utility.ox_element("sPrePr", namespace: "m")
|
@@ -0,0 +1,94 @@
|
|
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 = Utility.ox_element(tag_name)
|
50
|
+
new_arr = []
|
51
|
+
new_arr << validate_mathml_fields(parameter_one)
|
52
|
+
new_arr << validate_mathml_fields(parameter_two)
|
53
|
+
new_arr << validate_mathml_fields(parameter_three)
|
54
|
+
Utility.update_nodes(subsup_tag, new_arr)
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_omml_without_math_tag(display_style)
|
58
|
+
nary_element = Utility.ox_element("nary", namespace: "m")
|
59
|
+
Utility.update_nodes(nary_element, omml_nary_tag(display_style))
|
60
|
+
Array(nary_element)
|
61
|
+
end
|
62
|
+
|
63
|
+
protected
|
64
|
+
|
65
|
+
def chr_value(narypr)
|
66
|
+
first_value = Utility.html_entity_to_unicode(parameter_one&.nary_attr_value)
|
67
|
+
narypr << Utility.ox_element("chr", namespace: "m", attributes: { "m:val": first_value }) unless first_value == "∫"
|
68
|
+
|
69
|
+
narypr << Utility.ox_element("limLoc", namespace: "m", attributes: { "m:val": options[:type].to_s })
|
70
|
+
hide_tags(narypr, parameter_two, "sub")
|
71
|
+
hide_tags(narypr, parameter_three, "sup")
|
72
|
+
narypr
|
73
|
+
end
|
74
|
+
|
75
|
+
def hide_tags(nar, field, tag_prefix)
|
76
|
+
return nar unless field.nil?
|
77
|
+
|
78
|
+
nar << Utility.ox_element("#{tag_prefix}Hide", namespace: "m", attributes: { "m:val": "1" })
|
79
|
+
end
|
80
|
+
|
81
|
+
def omml_nary_tag(display_style)
|
82
|
+
narypr = Utility.ox_element("naryPr", namespace: "m")
|
83
|
+
chr_value(narypr)
|
84
|
+
[
|
85
|
+
(narypr << Utility.pr_element("ctrl", true, namespace: "m")),
|
86
|
+
omml_parameter(parameter_two, display_style, tag_name: "sub"),
|
87
|
+
omml_parameter(parameter_three, display_style, tag_name: "sup"),
|
88
|
+
omml_parameter(parameter_four, display_style, tag_name: "e"),
|
89
|
+
]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
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
|
@@ -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)
|
@@ -6,6 +6,12 @@ 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
16
|
first_value = parameter_one&.to_mathml_without_math_tag
|
11
17
|
second_value = parameter_two&.to_mathml_without_math_tag
|
@@ -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}"
|
@@ -14,8 +20,8 @@ module Plurimath
|
|
14
20
|
def to_mathml_without_math_tag
|
15
21
|
tag_name = (["ubrace", "obrace"].include?(parameter_one&.class_name) ? "over" : "sup")
|
16
22
|
sup_tag = Utility.ox_element("m#{tag_name}")
|
17
|
-
mathml_value = [parameter_one
|
18
|
-
mathml_value << parameter_two
|
23
|
+
mathml_value = [validate_mathml_fields(parameter_one)]
|
24
|
+
mathml_value << validate_mathml_fields(parameter_two)
|
19
25
|
Utility.update_nodes(sup_tag, mathml_value)
|
20
26
|
end
|
21
27
|
|
@@ -6,12 +6,19 @@ 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
17
|
subsup_tag = Utility.ox_element("m#{parameter_one.tag_name}")
|
11
18
|
new_arr = []
|
12
|
-
new_arr << parameter_one
|
13
|
-
new_arr << parameter_two
|
14
|
-
new_arr << parameter_three
|
19
|
+
new_arr << validate_mathml_fields(parameter_one)
|
20
|
+
new_arr << validate_mathml_fields(parameter_two)
|
21
|
+
new_arr << validate_mathml_fields(parameter_three)
|
15
22
|
Utility.update_nodes(subsup_tag, new_arr)
|
16
23
|
end
|
17
24
|
|
@@ -29,23 +36,6 @@ module Plurimath
|
|
29
36
|
"#{first_value}#{second_value}#{third_value}"
|
30
37
|
end
|
31
38
|
|
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
39
|
def to_omml_without_math_tag(display_style)
|
50
40
|
return underover(display_style) if parameter_one.omml_tag_name == "undOvr"
|
51
41
|
|
@@ -68,17 +58,6 @@ module Plurimath
|
|
68
58
|
|
69
59
|
protected
|
70
60
|
|
71
|
-
def chr_value(narypr)
|
72
|
-
first_value = Utility.html_entity_to_unicode(parameter_one&.nary_attr_value)
|
73
|
-
return narypr if first_value == "∫"
|
74
|
-
|
75
|
-
narypr << Utility.ox_element(
|
76
|
-
"chr",
|
77
|
-
namespace: "m",
|
78
|
-
attributes: { "m:val": first_value },
|
79
|
-
)
|
80
|
-
end
|
81
|
-
|
82
61
|
def hide_tags(nar)
|
83
62
|
attr = { "m:val": "1" }
|
84
63
|
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
|
@@ -55,24 +61,19 @@ module Plurimath
|
|
55
61
|
end
|
56
62
|
|
57
63
|
def to_omml_without_math_tag(display_style)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
r_tag = Utility.ox_element("r", namespace: "m")
|
72
|
-
t_tag = Utility.ox_element("t", namespace: "m")
|
73
|
-
r_tag << (t_tag << "∏")
|
74
|
-
[r_tag]
|
75
|
-
end
|
64
|
+
return r_element("∏", rpr_tag: false) unless all_values_exist?
|
65
|
+
|
66
|
+
nary = Utility.ox_element("nary", namespace: "m")
|
67
|
+
Utility.update_nodes(
|
68
|
+
nary,
|
69
|
+
[
|
70
|
+
narypr("∏"),
|
71
|
+
omml_parameter(parameter_one, display_style, tag_name: "sub"),
|
72
|
+
omml_parameter(parameter_two, display_style, tag_name: "sup"),
|
73
|
+
omml_parameter(parameter_three, display_style, tag_name: "e"),
|
74
|
+
],
|
75
|
+
)
|
76
|
+
[nary]
|
76
77
|
end
|
77
78
|
|
78
79
|
def nary_attr_value
|
@@ -30,13 +30,31 @@ module Plurimath
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def to_latex
|
33
|
-
"\\right #{
|
33
|
+
"\\right #{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}\" right\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_latex_math_zone(spacing = "", _, _)
|
45
|
+
"#{spacing}\"#{latex_paren}\" right\n"
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_mathml_math_zone(spacing = "", _, _)
|
49
|
+
mo_tag = (Utility.ox_element("mo") << right_paren)
|
50
|
+
"#{spacing}\"#{dump_ox_nodes(mo_tag).gsub(/\s+/, "")}\" right\n"
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_omml_math_zone(spacing = "", _, _, display_style:)
|
54
|
+
t_tag = (Utility.ox_element("t", namespace: "m") << right_paren)
|
55
|
+
"#{spacing}\"#{dump_ox_nodes(t_tag).gsub(/\s+/, "")}\" right\n"
|
56
|
+
end
|
57
|
+
|
40
58
|
protected
|
41
59
|
|
42
60
|
def right_paren
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Root < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "root",
|
11
|
+
first_value: "radicand",
|
12
|
+
second_value: "index",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_mathml_without_math_tag
|
10
16
|
first_value = parameter_one&.to_mathml_without_math_tag
|
11
17
|
second_value = parameter_two&.to_mathml_without_math_tag
|
@@ -5,6 +5,13 @@ module Plurimath
|
|
5
5
|
module Math
|
6
6
|
module Function
|
7
7
|
class Rule < TernaryFunction
|
8
|
+
FUNCTION = {
|
9
|
+
name: "rule",
|
10
|
+
first_value: "first argument",
|
11
|
+
second_value: "second argument",
|
12
|
+
third_value: "third argument",
|
13
|
+
}.freeze
|
14
|
+
|
8
15
|
def to_asciimath
|
9
16
|
""
|
10
17
|
end
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Semantics < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "semantics",
|
11
|
+
first_value: "first argument",
|
12
|
+
second_value: "second argument",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_mathml_without_math_tag
|
10
16
|
first_value = parameter_one&.to_mathml_without_math_tag
|
11
17
|
second_value = other_tags(parameter_two)
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Stackrel < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "stackrel",
|
11
|
+
first_value: "above",
|
12
|
+
second_value: "below",
|
13
|
+
}.freeze
|
14
|
+
|
9
15
|
def to_asciimath
|
10
16
|
first_value = wrapped(parameter_one)
|
11
17
|
second_value = wrapped(parameter_two)
|
@@ -6,6 +6,12 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Substack < BinaryFunction
|
9
|
+
FUNCTION = {
|
10
|
+
name: "substack",
|
11
|
+
first_value: "above",
|
12
|
+
second_value: "below",
|
13
|
+
}.freeze
|
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
|