plurimath 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +13 -0
- data/.github/workflows/release.yml +22 -0
- data/.gitignore +1 -0
- data/.hound.yml +5 -0
- data/.rubocop.yml +8 -0
- data/AsciiMath-Supported-Data.adoc +2000 -0
- data/Gemfile +3 -0
- data/Latex-Supported-Data.adoc +1879 -0
- data/MathML-Supported-Data.adoc +287 -0
- data/README.adoc +96 -0
- data/lib/plurimath/asciimath/constants.rb +267 -229
- data/lib/plurimath/asciimath/parse.rb +125 -26
- data/lib/plurimath/asciimath/parser.rb +6 -3
- data/lib/plurimath/asciimath/transform.rb +1135 -208
- data/lib/plurimath/asciimath.rb +1 -1
- data/lib/plurimath/html/constants.rb +50 -0
- data/lib/plurimath/html/parse.rb +149 -0
- data/lib/plurimath/html/parser.rb +26 -0
- data/lib/plurimath/html/transform.rb +363 -0
- data/lib/plurimath/html.rb +1 -1
- data/lib/plurimath/latex/constants.rb +3729 -1906
- data/lib/plurimath/latex/parse.rb +167 -51
- data/lib/plurimath/latex/parser.rb +12 -4
- data/lib/plurimath/latex/transform.rb +598 -183
- data/lib/plurimath/math/base.rb +15 -0
- data/lib/plurimath/math/formula.rb +96 -11
- data/lib/plurimath/math/function/bar.rb +34 -0
- data/lib/plurimath/math/function/base.rb +32 -5
- data/lib/plurimath/math/function/binary_function.rb +104 -17
- data/lib/plurimath/math/function/cancel.rb +8 -0
- data/lib/plurimath/math/function/ceil.rb +3 -0
- data/lib/plurimath/math/function/color.rb +16 -6
- data/lib/plurimath/math/function/f.rb +8 -0
- data/lib/plurimath/math/function/fenced.rb +95 -3
- data/lib/plurimath/math/function/floor.rb +15 -0
- data/lib/plurimath/math/function/font_style/bold.rb +37 -0
- data/lib/plurimath/math/function/font_style/double_struck.rb +37 -0
- data/lib/plurimath/math/function/font_style/fraktur.rb +37 -0
- data/lib/plurimath/math/function/font_style/italic.rb +37 -0
- data/lib/plurimath/math/function/font_style/monospace.rb +37 -0
- data/lib/plurimath/math/function/font_style/normal.rb +37 -0
- data/lib/plurimath/math/function/font_style/sans-serif.rb +37 -0
- data/lib/plurimath/math/function/font_style/script.rb +37 -0
- data/lib/plurimath/math/function/font_style.rb +18 -25
- data/lib/plurimath/math/function/frac.rb +35 -5
- data/lib/plurimath/math/function/g.rb +7 -0
- data/lib/plurimath/math/function/hat.rb +12 -0
- data/lib/plurimath/math/function/inf.rb +21 -1
- data/lib/plurimath/math/function/int.rb +23 -2
- data/lib/plurimath/math/function/left.rb +25 -4
- data/lib/plurimath/math/function/lim.rb +40 -2
- data/lib/plurimath/math/function/limits.rb +8 -0
- data/lib/plurimath/math/function/log.rb +61 -4
- data/lib/plurimath/math/function/longdiv.rb +12 -0
- data/lib/plurimath/math/function/mbox.rb +31 -0
- data/lib/plurimath/math/function/menclose.rb +46 -0
- data/lib/plurimath/math/function/merror.rb +12 -0
- data/lib/plurimath/math/function/mod.rb +25 -4
- data/lib/plurimath/math/function/msgroup.rb +37 -0
- data/lib/plurimath/math/function/msline.rb +12 -0
- data/lib/plurimath/math/function/multiscript.rb +30 -0
- data/lib/plurimath/math/function/norm.rb +18 -1
- data/lib/plurimath/math/function/obrace.rb +17 -0
- data/lib/plurimath/math/function/oint.rb +2 -2
- data/lib/plurimath/math/function/over.rb +36 -0
- data/lib/plurimath/math/function/overset.rb +36 -7
- data/lib/plurimath/math/function/phantom.rb +28 -0
- data/lib/plurimath/math/function/power.rb +33 -9
- data/lib/plurimath/math/function/power_base.rb +110 -5
- data/lib/plurimath/math/function/prod.rb +29 -2
- data/lib/plurimath/math/function/right.rb +44 -0
- data/lib/plurimath/math/function/root.rb +27 -4
- data/lib/plurimath/math/function/rule.rb +33 -0
- data/lib/plurimath/math/function/scarries.rb +12 -0
- data/lib/plurimath/math/function/scarry.rb +12 -0
- data/lib/plurimath/math/function/sqrt.rb +24 -2
- data/lib/plurimath/math/function/stackrel.rb +27 -0
- data/lib/plurimath/math/function/substack.rb +7 -1
- data/lib/plurimath/math/function/sum.rb +56 -2
- data/lib/plurimath/math/function/sup.rb +3 -0
- data/lib/plurimath/math/function/table/align.rb +24 -0
- data/lib/plurimath/math/function/table/array.rb +44 -0
- data/lib/plurimath/math/function/table/bmatrix.rb +37 -0
- data/lib/plurimath/math/function/table/matrix.rb +32 -0
- data/lib/plurimath/math/function/table/multline.rb +24 -0
- data/lib/plurimath/math/function/table/pmatrix.rb +24 -0
- data/lib/plurimath/math/function/table/split.rb +24 -0
- data/lib/plurimath/math/function/table/vmatrix.rb +24 -0
- data/lib/plurimath/math/function/table.rb +190 -20
- data/lib/plurimath/math/function/td.rb +27 -9
- data/lib/plurimath/math/function/ternary_function.rb +83 -8
- data/lib/plurimath/math/function/text.rb +45 -8
- data/lib/plurimath/math/function/tr.rb +28 -4
- data/lib/plurimath/math/function/ubrace.rb +17 -0
- data/lib/plurimath/math/function/ul.rb +29 -0
- data/lib/plurimath/math/function/unary_function.rb +85 -7
- data/lib/plurimath/math/function/underline.rb +12 -0
- data/lib/plurimath/math/function/underover.rb +107 -0
- data/lib/plurimath/math/function/underset.rb +39 -0
- data/lib/plurimath/math/function/vec.rb +10 -0
- data/lib/plurimath/math/function.rb +13 -2
- data/lib/plurimath/math/number.rb +11 -3
- data/lib/plurimath/math/symbol.rb +57 -9
- data/lib/plurimath/math/unicode.rb +11 -0
- data/lib/plurimath/math.rb +15 -6
- data/lib/plurimath/mathml/constants.rb +224 -179
- data/lib/plurimath/mathml/parser.rb +24 -7
- data/lib/plurimath/mathml/transform.rb +249 -148
- data/lib/plurimath/mathml.rb +1 -1
- data/lib/plurimath/omml/parser.rb +42 -0
- data/lib/plurimath/omml/transform.rb +278 -0
- data/lib/plurimath/omml.rb +1 -1
- data/lib/plurimath/unitsml.rb +4 -0
- data/lib/plurimath/utility.rb +395 -0
- data/lib/plurimath/version.rb +1 -1
- data/plurimath.gemspec +1 -0
- metadata +66 -9
- data/.github/workflows/test.yml +0 -36
- data/README.md +0 -40
- data/lib/plurimath/mathml/parse.rb +0 -63
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "binary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Menclose < BinaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
parameter_two&.to_asciimath
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_mathml_without_math_tag
|
14
|
+
attributes = { notation: parameter_one }
|
15
|
+
menclose = Utility.ox_element("menclose", attributes: attributes)
|
16
|
+
menclose << parameter_two.to_mathml_without_math_tag if parameter_two
|
17
|
+
menclose
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_latex
|
21
|
+
parameter_two&.to_latex
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_html
|
25
|
+
second_value = parameter_two&.to_html
|
26
|
+
"<menclose notation=\"#{parameter_one}\">#{second_value}</menclose>"
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_omml_without_math_tag
|
30
|
+
borderbox = Utility.ox_element("borderBox", namespace: "m")
|
31
|
+
borderpr = Utility.ox_element("borderBoxPr", namespace: "m")
|
32
|
+
borderpr << Utility.pr_element("ctrl", true, namespace: "m")
|
33
|
+
me = Utility.ox_element("e", namespace: "m")
|
34
|
+
me << parameter_two.to_omml_without_math_tag if parameter_two
|
35
|
+
Utility.update_nodes(
|
36
|
+
borderbox,
|
37
|
+
[
|
38
|
+
borderpr,
|
39
|
+
me,
|
40
|
+
],
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -7,15 +7,36 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Mod < BinaryFunction
|
9
9
|
def to_asciimath
|
10
|
-
first_value =
|
11
|
-
second_value =
|
12
|
-
"#{first_value}mod#{second_value}"
|
10
|
+
first_value = parameter_one&.to_asciimath
|
11
|
+
second_value = parameter_two&.to_asciimath
|
12
|
+
"#{first_value} mod #{second_value}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_mathml_without_math_tag
|
16
|
+
mrow_tag = Utility.ox_element("mrow")
|
17
|
+
mo_tag = Utility.ox_element("mi") << "mod"
|
18
|
+
first_value = parameter_one&.to_mathml_without_math_tag if parameter_one
|
19
|
+
second_value = parameter_two&.to_mathml_without_math_tag if parameter_two
|
20
|
+
Utility.update_nodes(
|
21
|
+
mrow_tag,
|
22
|
+
[
|
23
|
+
first_value,
|
24
|
+
mo_tag,
|
25
|
+
second_value,
|
26
|
+
],
|
27
|
+
)
|
13
28
|
end
|
14
29
|
|
15
30
|
def to_latex
|
16
31
|
first_value = "{#{parameter_one.to_latex}}" if parameter_one
|
17
32
|
second_value = "{#{parameter_two.to_latex}}" if parameter_two
|
18
|
-
"#{first_value}\\
|
33
|
+
"#{first_value} \\mod #{second_value}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_html
|
37
|
+
first_value = "<i>#{parameter_one.to_html}</i>" if parameter_one
|
38
|
+
second_value = "<i>#{parameter_two.to_html}</i>" if parameter_two
|
39
|
+
"#{first_value}<i>mod</i>#{second_value}"
|
19
40
|
end
|
20
41
|
end
|
21
42
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "unary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Msgroup < UnaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
parameter_one.map(&:to_asciimath).join
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_latex
|
14
|
+
parameter_one.map(&:to_latex).join
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_mathml_without_math_tag
|
18
|
+
Utility.update_nodes(
|
19
|
+
Utility.ox_element("msgroup"),
|
20
|
+
parameter_one.map(&:to_mathml_without_math_tag),
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_omml_without_math_tag
|
25
|
+
Utility.update_nodes(
|
26
|
+
Utility.ox_element("msgroup"),
|
27
|
+
parameter_one&.map(&:to_omml_without_math_tag),
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_html
|
32
|
+
"<i>#{parameter_one.map(&:to_html).join}</i>"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "ternary_function"
|
4
|
+
module Plurimath
|
5
|
+
module Math
|
6
|
+
module Function
|
7
|
+
class Multiscript < TernaryFunction
|
8
|
+
def to_omml_without_math_tag
|
9
|
+
pre_element = Utility.ox_element("sPre", namespace: "m")
|
10
|
+
pr_element = Utility.ox_element("sPrePr", namespace: "m")
|
11
|
+
sub_element = Utility.ox_element("sub", namespace: "m")
|
12
|
+
sub_element << parameter_two.to_omml_without_math_tag if parameter_two
|
13
|
+
sup_element = Utility.ox_element("sup", namespace: "m")
|
14
|
+
sup_element << parameter_three.to_omml_without_math_tag if parameter_three
|
15
|
+
e_element = Utility.ox_element("e", namespace: "m")
|
16
|
+
e_element << parameter_one.to_omml_without_math_tag if parameter_one
|
17
|
+
Utility.update_nodes(
|
18
|
+
pre_element,
|
19
|
+
[
|
20
|
+
pr_element << Utility.pr_element("ctrl", true, namespace: "m"),
|
21
|
+
sub_element,
|
22
|
+
sup_element,
|
23
|
+
e_element,
|
24
|
+
],
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -6,8 +6,25 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Norm < UnaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
parameter_one.is_a?(Table) ? "norm#{parameter_one.to_asciimath}" : super
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_latex
|
14
|
+
"{\\lVert #{parameter_one&.to_latex} \\lVert}"
|
15
|
+
end
|
16
|
+
|
9
17
|
def to_mathml_without_math_tag
|
10
|
-
|
18
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
19
|
+
norm = Utility.ox_element("mo") << "∥"
|
20
|
+
Utility.update_nodes(
|
21
|
+
Utility.ox_element("mrow"),
|
22
|
+
[
|
23
|
+
norm,
|
24
|
+
first_value,
|
25
|
+
norm,
|
26
|
+
],
|
27
|
+
)
|
11
28
|
end
|
12
29
|
end
|
13
30
|
end
|
@@ -6,7 +6,24 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Obrace < UnaryFunction
|
9
|
+
def to_latex
|
10
|
+
first_value = "{#{parameter_one.to_latex}}" if parameter_one
|
11
|
+
"\\overbrace#{first_value}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_mathml_without_math_tag
|
15
|
+
mo_tag = (Utility.ox_element("mo") << "⏞")
|
16
|
+
if parameter_one
|
17
|
+
over_tag = Utility.ox_element("mover")
|
18
|
+
arr_value = mathml_value
|
19
|
+
Utility.update_nodes(over_tag, (arr_value << mo_tag))
|
20
|
+
else
|
21
|
+
mo_tag
|
22
|
+
end
|
23
|
+
end
|
9
24
|
end
|
25
|
+
|
26
|
+
Overbrace = Obrace
|
10
27
|
end
|
11
28
|
end
|
12
29
|
end
|
@@ -7,8 +7,8 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Oint < BinaryFunction
|
9
9
|
def to_asciimath
|
10
|
-
first_value = "_
|
11
|
-
second_value = "
|
10
|
+
first_value = "_#{wrapped(parameter_one)}" if parameter_one
|
11
|
+
second_value = "^#{wrapped(parameter_two)}" if parameter_two
|
12
12
|
"oint#{first_value}#{second_value}"
|
13
13
|
end
|
14
14
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "binary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Over < BinaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
first_value = wrapped(parameter_one)
|
11
|
+
second_value = wrapped(parameter_two)
|
12
|
+
"overset#{first_value}#{second_value}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_mathml_without_math_tag
|
16
|
+
mover_tag = Utility.ox_element("mfrac")
|
17
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
18
|
+
second_value = parameter_two&.to_mathml_without_math_tag
|
19
|
+
Utility.update_nodes(
|
20
|
+
mover_tag,
|
21
|
+
[
|
22
|
+
first_value,
|
23
|
+
second_value,
|
24
|
+
],
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_latex
|
29
|
+
first_value = parameter_one&.to_latex
|
30
|
+
two_value = parameter_two&.to_latex
|
31
|
+
"{#{first_value} \\over #{two_value}}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -7,15 +7,44 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Overset < BinaryFunction
|
9
9
|
def to_mathml_without_math_tag
|
10
|
-
first_value = parameter_one
|
11
|
-
second_value = parameter_two
|
12
|
-
"
|
10
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
11
|
+
second_value = parameter_two&.to_mathml_without_math_tag
|
12
|
+
over_tag = Utility.ox_element("mover")
|
13
|
+
Utility.update_nodes(
|
14
|
+
over_tag,
|
15
|
+
[
|
16
|
+
second_value,
|
17
|
+
first_value,
|
18
|
+
],
|
19
|
+
)
|
13
20
|
end
|
14
21
|
|
15
|
-
def
|
16
|
-
first_value
|
17
|
-
|
18
|
-
|
22
|
+
def to_omml_without_math_tag
|
23
|
+
first_value = if parameter_one.is_a?(Math::Symbol)
|
24
|
+
mt = Utility.ox_element("t", namespace: "m")
|
25
|
+
mt << parameter_one.to_omml_without_math_tag
|
26
|
+
else
|
27
|
+
parameter_one.to_omml_without_math_tag
|
28
|
+
end
|
29
|
+
second_value = if parameter_two.is_a?(Math::Symbol)
|
30
|
+
mt = Utility.ox_element("t", namespace: "m")
|
31
|
+
mt << parameter_two.to_omml_without_math_tag
|
32
|
+
else
|
33
|
+
parameter_two.to_omml_without_math_tag
|
34
|
+
end
|
35
|
+
limupp = Utility.ox_element("limUpp", namespace: "m")
|
36
|
+
limupppr = Utility.ox_element("limUppPr", namespace: "m")
|
37
|
+
limupppr << Utility.pr_element("ctrl", true, namespace: "m")
|
38
|
+
me = (Utility.ox_element("e", namespace: "m") << first_value)
|
39
|
+
lim = (Utility.ox_element("lim", namespace: "m") << second_value)
|
40
|
+
Utility.update_nodes(
|
41
|
+
limupp,
|
42
|
+
[
|
43
|
+
limupppr,
|
44
|
+
me,
|
45
|
+
lim,
|
46
|
+
],
|
47
|
+
)
|
19
48
|
end
|
20
49
|
end
|
21
50
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "unary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Phantom < UnaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
"\"#{Array.new(parameter_one&.length, ' ').join}\""
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_html
|
14
|
+
"<i>#{Array.new(parameter_one&.length, ' ').join}</i>"
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_latex
|
18
|
+
"<i>#{Array.new(parameter_one&.length, '\\ ').join}</i>"
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_mathml_without_math_tag
|
22
|
+
mi_tag_value = Array.new(parameter_one&.length, " ").join
|
23
|
+
Utility.ox_element("mi") << mi_tag_value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -7,23 +7,47 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Power < BinaryFunction
|
9
9
|
def to_asciimath
|
10
|
-
|
11
|
-
|
12
|
-
"#{first_value}#{second_value}"
|
10
|
+
second_value = "^#{wrapped(parameter_two)}" if parameter_two
|
11
|
+
"#{parameter_one.to_asciimath}#{second_value}"
|
13
12
|
end
|
14
13
|
|
15
14
|
def to_mathml_without_math_tag
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
tag_name = (["ubrace", "obrace"].include?(parameter_one&.class_name) ? "over" : "sup")
|
16
|
+
sup_tag = Utility.ox_element("m#{tag_name}")
|
17
|
+
mathml_value = [parameter_one.to_mathml_without_math_tag]
|
18
|
+
mathml_value << parameter_two&.to_mathml_without_math_tag
|
19
|
+
Utility.update_nodes(sup_tag, mathml_value)
|
19
20
|
end
|
20
21
|
|
21
22
|
def to_latex
|
22
|
-
first_value
|
23
|
-
|
24
|
-
second_value = parameter_two.to_latex
|
23
|
+
first_value = parameter_one.to_latex
|
24
|
+
second_value = parameter_two.to_latex if parameter_two
|
25
25
|
"#{first_value}^{#{second_value}}"
|
26
26
|
end
|
27
|
+
|
28
|
+
def to_html
|
29
|
+
first_value = "<i>#{parameter_one.to_html}</i>" if parameter_one
|
30
|
+
second_value = "<sup>#{parameter_two.to_html}</sup>" if parameter_two
|
31
|
+
"#{first_value}#{second_value}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_omml_without_math_tag
|
35
|
+
ssup_element = Utility.ox_element("sSup", namespace: "m")
|
36
|
+
suppr_element = Utility.ox_element("sSupPr", namespace: "m")
|
37
|
+
sup_element = Utility.ox_element("sup", namespace: "m")
|
38
|
+
e_element = Utility.ox_element("e", namespace: "m")
|
39
|
+
e_element << parameter_one.to_omml_without_math_tag if parameter_one
|
40
|
+
sup_element << parameter_two.to_omml_without_math_tag if parameter_two
|
41
|
+
Utility.update_nodes(
|
42
|
+
ssup_element,
|
43
|
+
[
|
44
|
+
suppr_element << Utility.pr_element("ctrl", true, namespace: "m"),
|
45
|
+
e_element,
|
46
|
+
sup_element,
|
47
|
+
],
|
48
|
+
)
|
49
|
+
ssup_element
|
50
|
+
end
|
27
51
|
end
|
28
52
|
end
|
29
53
|
end
|
@@ -7,19 +7,124 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class PowerBase < TernaryFunction
|
9
9
|
def to_mathml_without_math_tag
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
tag_name = (["ubrace", "obrace"].include?(parameter_one&.class_name) ? "underover" : "subsup")
|
11
|
+
subsup_tag = Utility.ox_element("m#{tag_name}")
|
12
|
+
new_arr = []
|
13
|
+
new_arr << parameter_one.to_mathml_without_math_tag
|
14
|
+
new_arr << parameter_two&.to_mathml_without_math_tag
|
15
|
+
new_arr << parameter_three&.to_mathml_without_math_tag
|
16
|
+
Utility.update_nodes(
|
17
|
+
subsup_tag,
|
18
|
+
new_arr,
|
19
|
+
)
|
14
20
|
end
|
15
21
|
|
16
22
|
def to_latex
|
17
23
|
first_value = parameter_one.to_latex if parameter_one
|
18
24
|
second_value = parameter_two.to_latex if parameter_two
|
19
25
|
third_value = parameter_three.to_latex if parameter_three
|
20
|
-
first_value = "{#{first_value}}" if parameter_one.is_a?(Math::Formula)
|
21
26
|
"#{first_value}_{#{second_value}}^{#{third_value}}"
|
22
27
|
end
|
28
|
+
|
29
|
+
def to_html
|
30
|
+
first_value = "<i>#{parameter_one.to_html}</i>" if parameter_one
|
31
|
+
second_value = "<sub>#{parameter_two.to_html}</sub>" if parameter_two
|
32
|
+
third_value = "<sup>#{parameter_three.to_html}</sup>" if parameter_three
|
33
|
+
"#{first_value}#{second_value}#{third_value}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def omml_nary_tag
|
37
|
+
narypr = Utility.ox_element("naryPr", namespace: "m")
|
38
|
+
chr_value(narypr)
|
39
|
+
narypr << Utility.ox_element(
|
40
|
+
"limLoc",
|
41
|
+
namespace: "m",
|
42
|
+
attributes: { "m:val": "subSup" },
|
43
|
+
)
|
44
|
+
hide_tags(narypr)
|
45
|
+
narypr << Utility.pr_element("ctrl", true, namespace: "m")
|
46
|
+
[
|
47
|
+
narypr,
|
48
|
+
sub_element,
|
49
|
+
sup_element,
|
50
|
+
]
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_omml_without_math_tag
|
54
|
+
ssubsup = Utility.ox_element("sSubSup", namespace: "m")
|
55
|
+
ssubsuppr = Utility.ox_element("sSubSupPr", namespace: "m")
|
56
|
+
ssubsuppr << hide_tags(
|
57
|
+
Utility.pr_element("ctrl", true, namespace: "m"),
|
58
|
+
)
|
59
|
+
Utility.update_nodes(
|
60
|
+
ssubsup,
|
61
|
+
[
|
62
|
+
ssubsuppr,
|
63
|
+
e_element,
|
64
|
+
sub_element,
|
65
|
+
sup_element,
|
66
|
+
],
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
protected
|
71
|
+
|
72
|
+
def chr_value(narypr)
|
73
|
+
first_value = parameter_one.to_omml_without_math_tag
|
74
|
+
return narypr if first_value == "∫"
|
75
|
+
|
76
|
+
narypr << Utility.ox_element(
|
77
|
+
"chr",
|
78
|
+
namespace: "m",
|
79
|
+
attributes: { "m:val": first_value },
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
def e_element
|
84
|
+
elemnet = Utility.ox_element("e", namespace: "m")
|
85
|
+
if parameter_one
|
86
|
+
elemnet << parameter_one&.to_omml_without_math_tag
|
87
|
+
else
|
88
|
+
elemnet
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def sub_element
|
93
|
+
elemnet = Utility.ox_element("sub", namespace: "m")
|
94
|
+
if parameter_two
|
95
|
+
elemnet << parameter_two&.to_omml_without_math_tag
|
96
|
+
else
|
97
|
+
elemnet
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def sup_element
|
102
|
+
elemnet = Utility.ox_element("sup", namespace: "m")
|
103
|
+
if parameter_three
|
104
|
+
elemnet << parameter_three&.to_omml_without_math_tag
|
105
|
+
else
|
106
|
+
elemnet
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def hide_tags(nar)
|
111
|
+
attr = { "m:val": "1" }
|
112
|
+
if parameter_two.nil?
|
113
|
+
nar << Utility.ox_element(
|
114
|
+
"subHide",
|
115
|
+
namespace: "m",
|
116
|
+
attributes: attr,
|
117
|
+
)
|
118
|
+
end
|
119
|
+
if parameter_three.nil?
|
120
|
+
nar << Utility.ox_element(
|
121
|
+
"supHide",
|
122
|
+
namespace: "m",
|
123
|
+
attributes: attr,
|
124
|
+
)
|
125
|
+
end
|
126
|
+
nar
|
127
|
+
end
|
23
128
|
end
|
24
129
|
end
|
25
130
|
end
|
@@ -7,8 +7,8 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Prod < BinaryFunction
|
9
9
|
def to_asciimath
|
10
|
-
first_value = "_
|
11
|
-
second_value = "
|
10
|
+
first_value = "_#{wrapped(parameter_one)}" if parameter_one
|
11
|
+
second_value = "^#{wrapped(parameter_two)}" if parameter_two
|
12
12
|
"prod#{first_value}#{second_value}"
|
13
13
|
end
|
14
14
|
|
@@ -17,6 +17,33 @@ module Plurimath
|
|
17
17
|
second_value = "^{#{parameter_two.to_latex}}" if parameter_two
|
18
18
|
"\\prod#{first_value}#{second_value}"
|
19
19
|
end
|
20
|
+
|
21
|
+
def to_mathml_without_math_tag
|
22
|
+
first_value = Utility.ox_element("mo") << invert_unicode_symbols.to_s
|
23
|
+
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
|
+
tag_name = if parameter_two && parameter_one
|
28
|
+
"underover"
|
29
|
+
else
|
30
|
+
parameter_one ? "under" : "over"
|
31
|
+
end
|
32
|
+
munderover_tag = Utility.ox_element("m#{tag_name}")
|
33
|
+
Utility.update_nodes(
|
34
|
+
munderover_tag,
|
35
|
+
value_array,
|
36
|
+
)
|
37
|
+
else
|
38
|
+
first_value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_html
|
43
|
+
first_value = "<sub>#{parameter_one.to_html}</sub>" if parameter_one
|
44
|
+
second_value = "<sup>#{parameter_two.to_html}</sup>" if parameter_two
|
45
|
+
"<i>∏</i>#{first_value}#{second_value}"
|
46
|
+
end
|
20
47
|
end
|
21
48
|
end
|
22
49
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "unary_function"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Right < UnaryFunction
|
9
|
+
def to_asciimath
|
10
|
+
"right#{parameter_one}"
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_mathml_without_math_tag
|
14
|
+
mo = Utility.ox_element("mo")
|
15
|
+
mo << right_paren if parameter_one
|
16
|
+
mo
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_omml_without_math_tag
|
20
|
+
mt = Utility.ox_element("m:t")
|
21
|
+
mt << parameter_one if parameter_one
|
22
|
+
mt
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_html
|
26
|
+
"<i>#{parameter_one}</i>"
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_latex
|
30
|
+
prefix = "\\" if parameter_one == "}"
|
31
|
+
"\\right #{prefix}#{parameter_one}"
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def right_paren
|
37
|
+
return "}" if parameter_one == "\\}"
|
38
|
+
|
39
|
+
parameter_one
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|