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,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../font_style"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class FontStyle
|
9
|
+
class Fraktur < FontStyle
|
10
|
+
def initialize(parameter_one,
|
11
|
+
parameter_two = "fraktur")
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_asciimath
|
16
|
+
"mathfrak(#{parameter_one.to_asciimath})"
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_latex
|
20
|
+
first_value = parameter_one.to_latex if parameter_one
|
21
|
+
"\\mathfrak{#{first_value}}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_mathml_without_math_tag
|
25
|
+
Utility.update_nodes(
|
26
|
+
Utility.ox_element(
|
27
|
+
"mstyle",
|
28
|
+
attributes: { mathvariant: "fraktur" },
|
29
|
+
),
|
30
|
+
[parameter_one.to_mathml_without_math_tag],
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../font_style"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class FontStyle
|
9
|
+
class Italic < FontStyle
|
10
|
+
def initialize(parameter_one,
|
11
|
+
parameter_two = "italic")
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_asciimath
|
16
|
+
"ii(#{parameter_one.to_asciimath})"
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_latex
|
20
|
+
first_value = parameter_one.to_latex if parameter_one
|
21
|
+
"\\mathit{#{first_value}}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_mathml_without_math_tag
|
25
|
+
Utility.update_nodes(
|
26
|
+
Utility.ox_element(
|
27
|
+
"mstyle",
|
28
|
+
attributes: { mathvariant: "italic" },
|
29
|
+
),
|
30
|
+
[parameter_one.to_mathml_without_math_tag],
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../font_style"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class FontStyle
|
9
|
+
class Monospace < FontStyle
|
10
|
+
def initialize(parameter_one,
|
11
|
+
parameter_two = "monospace")
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_asciimath
|
16
|
+
"mathtt(#{parameter_one.to_asciimath})"
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_latex
|
20
|
+
first_value = parameter_one.to_latex if parameter_one
|
21
|
+
"\\mathtt{#{first_value}}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_mathml_without_math_tag
|
25
|
+
Utility.update_nodes(
|
26
|
+
Utility.ox_element(
|
27
|
+
"mstyle",
|
28
|
+
attributes: { mathvariant: "monospace" },
|
29
|
+
),
|
30
|
+
[parameter_one.to_mathml_without_math_tag],
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../font_style"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class FontStyle
|
9
|
+
class Normal < FontStyle
|
10
|
+
def initialize(parameter_one,
|
11
|
+
parameter_two = "rm")
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_asciimath
|
16
|
+
"rm(#{parameter_one.to_asciimath})"
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_latex
|
20
|
+
first_value = parameter_one.to_latex if parameter_one
|
21
|
+
"\\mathrm{#{first_value}}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_mathml_without_math_tag
|
25
|
+
Utility.update_nodes(
|
26
|
+
Utility.ox_element(
|
27
|
+
"mstyle",
|
28
|
+
attributes: { mathvariant: "normal" },
|
29
|
+
),
|
30
|
+
[parameter_one.to_mathml_without_math_tag],
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../font_style"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class FontStyle
|
9
|
+
class SansSerif < FontStyle
|
10
|
+
def initialize(parameter_one,
|
11
|
+
parameter_two = "sans-serif")
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_asciimath
|
16
|
+
"mathsf(#{parameter_one.to_asciimath})"
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_latex
|
20
|
+
first_value = parameter_one.to_latex if parameter_one
|
21
|
+
"\\mathsf{#{first_value}}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_mathml_without_math_tag
|
25
|
+
Utility.update_nodes(
|
26
|
+
Utility.ox_element(
|
27
|
+
"mstyle",
|
28
|
+
attributes: { mathvariant: "sans-serif" },
|
29
|
+
),
|
30
|
+
[parameter_one.to_mathml_without_math_tag],
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../font_style"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class FontStyle
|
9
|
+
class Script < FontStyle
|
10
|
+
def initialize(parameter_one,
|
11
|
+
parameter_two = "script")
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_asciimath
|
16
|
+
"mathcal(#{parameter_one.to_asciimath})"
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_latex
|
20
|
+
first_value = parameter_one.to_latex if parameter_one
|
21
|
+
"\\mathcal{#{first_value}}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_mathml_without_math_tag
|
25
|
+
Utility.update_nodes(
|
26
|
+
Utility.ox_element(
|
27
|
+
"mstyle",
|
28
|
+
attributes: { mathvariant: "script" },
|
29
|
+
),
|
30
|
+
[parameter_one.to_mathml_without_math_tag],
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -6,38 +6,31 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class FontStyle < BinaryFunction
|
9
|
-
FONT_TYPES = {
|
10
|
-
mathfrak: "fraktur",
|
11
|
-
mathcal: "script",
|
12
|
-
mathbb: "double-struck",
|
13
|
-
mathsf: "sans-serif",
|
14
|
-
mathtt: "monospace",
|
15
|
-
mathbf: "bold",
|
16
|
-
bbb: "double-struck",
|
17
|
-
bb: "bold",
|
18
|
-
fr: "fraktur",
|
19
|
-
cc: "script",
|
20
|
-
sf: "sans-serif",
|
21
|
-
tt: "monospace",
|
22
|
-
}.freeze
|
23
|
-
|
24
9
|
def to_asciimath
|
25
|
-
|
26
|
-
"#{parameter_two}(#{parameter_one.to_asciimath})"
|
27
|
-
else
|
28
|
-
parameter_one.to_asciimath
|
29
|
-
end
|
10
|
+
parameter_one&.to_asciimath
|
30
11
|
end
|
31
12
|
|
32
13
|
def to_mathml_without_math_tag
|
33
|
-
|
34
|
-
|
35
|
-
|
14
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
15
|
+
Utility.update_nodes(
|
16
|
+
Utility.ox_element(
|
17
|
+
"mstyle",
|
18
|
+
attributes: { mathvariant: parameter_two },
|
19
|
+
),
|
20
|
+
[first_value],
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_omml_without_math_tag
|
25
|
+
parameter_one&.to_omml_without_math_tag
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_html
|
29
|
+
parameter_one&.to_html
|
36
30
|
end
|
37
31
|
|
38
32
|
def to_latex
|
39
|
-
|
40
|
-
"\\#{parameter_two}{#{first_value}}"
|
33
|
+
parameter_one&.to_latex
|
41
34
|
end
|
42
35
|
end
|
43
36
|
end
|
@@ -6,17 +6,47 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Frac < 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
|
+
"frac#{first_value}#{second_value}"
|
13
|
+
end
|
14
|
+
|
9
15
|
def to_mathml_without_math_tag
|
10
|
-
|
11
|
-
|
12
|
-
|
16
|
+
frac_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
|
+
frac_tag,
|
21
|
+
[
|
22
|
+
first_value,
|
23
|
+
second_value,
|
24
|
+
].flatten,
|
25
|
+
)
|
13
26
|
end
|
14
27
|
|
15
28
|
def to_latex
|
16
|
-
first_value = parameter_one
|
17
|
-
two_value = parameter_two
|
29
|
+
first_value = parameter_one&.to_latex
|
30
|
+
two_value = parameter_two&.to_latex
|
18
31
|
"\\frac{#{first_value}}{#{two_value}}"
|
19
32
|
end
|
33
|
+
|
34
|
+
def to_omml_without_math_tag
|
35
|
+
f_element = Utility.ox_element("f", namespace: "m")
|
36
|
+
fpr_element = Utility.ox_element("fPr", namespace: "m")
|
37
|
+
num_element = Utility.ox_element("num", namespace: "m")
|
38
|
+
num_element << parameter_one.to_omml_without_math_tag if parameter_one
|
39
|
+
den_element = Utility.ox_element("den", namespace: "m")
|
40
|
+
den_element << parameter_two.to_omml_without_math_tag if parameter_two
|
41
|
+
Utility.update_nodes(
|
42
|
+
f_element,
|
43
|
+
[
|
44
|
+
fpr_element << Utility.pr_element("ctrl", true, namespace: "m"),
|
45
|
+
num_element,
|
46
|
+
den_element,
|
47
|
+
],
|
48
|
+
)
|
49
|
+
end
|
20
50
|
end
|
21
51
|
end
|
22
52
|
end
|
@@ -6,6 +6,18 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Hat < UnaryFunction
|
9
|
+
def to_mathml_without_math_tag
|
10
|
+
mover_tag = Utility.ox_element("mover")
|
11
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
12
|
+
second_value = (Utility.ox_element("mo") << "^")
|
13
|
+
Utility.update_nodes(
|
14
|
+
mover_tag,
|
15
|
+
[
|
16
|
+
first_value,
|
17
|
+
second_value,
|
18
|
+
],
|
19
|
+
)
|
20
|
+
end
|
9
21
|
end
|
10
22
|
end
|
11
23
|
end
|
@@ -6,12 +6,32 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Inf < BinaryFunction
|
9
|
-
|
10
9
|
def to_latex
|
11
10
|
first_value = "_{#{parameter_one.to_latex}}" if parameter_one
|
12
11
|
second_value = "^{#{parameter_two.to_latex}}" if parameter_two
|
13
12
|
"\\#{class_name}#{first_value}#{second_value}"
|
14
13
|
end
|
14
|
+
|
15
|
+
def to_mathml_without_math_tag
|
16
|
+
first_value = Utility.ox_element("mo") << class_name
|
17
|
+
if parameter_one || parameter_two
|
18
|
+
value_array = [first_value]
|
19
|
+
value_array << parameter_one&.to_mathml_without_math_tag
|
20
|
+
value_array << parameter_two&.to_mathml_without_math_tag
|
21
|
+
tag_name = if parameter_two && parameter_one
|
22
|
+
"underover"
|
23
|
+
else
|
24
|
+
parameter_one ? "under" : "over"
|
25
|
+
end
|
26
|
+
munderover_tag = Utility.ox_element("m#{tag_name}")
|
27
|
+
Utility.update_nodes(
|
28
|
+
munderover_tag,
|
29
|
+
value_array,
|
30
|
+
)
|
31
|
+
else
|
32
|
+
first_value
|
33
|
+
end
|
34
|
+
end
|
15
35
|
end
|
16
36
|
end
|
17
37
|
end
|
@@ -7,10 +7,31 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Int < 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
|
"int#{first_value}#{second_value}"
|
13
13
|
end
|
14
|
+
|
15
|
+
def to_latex
|
16
|
+
first_value = "_#{latex_wrapped(parameter_one)}" if parameter_one
|
17
|
+
second_value = "^#{latex_wrapped(parameter_two)}" if parameter_two
|
18
|
+
"\\#{class_name}#{first_value}#{second_value}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_mathml_without_math_tag
|
22
|
+
mrow_tag = Utility.ox_element("msubsup")
|
23
|
+
mo_tag = Utility.ox_element("mo") << invert_unicode_symbols.to_s
|
24
|
+
first_value = parameter_one&.to_mathml_without_math_tag if parameter_one
|
25
|
+
second_value = parameter_two&.to_mathml_without_math_tag if parameter_two
|
26
|
+
Utility.update_nodes(
|
27
|
+
mrow_tag,
|
28
|
+
[
|
29
|
+
mo_tag,
|
30
|
+
first_value,
|
31
|
+
second_value,
|
32
|
+
],
|
33
|
+
)
|
34
|
+
end
|
14
35
|
end
|
15
36
|
end
|
16
37
|
end
|
@@ -7,15 +7,36 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Left < UnaryFunction
|
9
9
|
def to_asciimath
|
10
|
-
"left#{
|
10
|
+
"left#{parameter_one}"
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
"
|
13
|
+
def to_mathml_without_math_tag
|
14
|
+
mo = Utility.ox_element("mo")
|
15
|
+
mo << left_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>"
|
15
27
|
end
|
16
28
|
|
17
29
|
def to_latex
|
18
|
-
"\\
|
30
|
+
prefix = "\\" if parameter_one == "{"
|
31
|
+
"\\left #{prefix}#{parameter_one}"
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def left_paren
|
37
|
+
return "{" if parameter_one == "\\{"
|
38
|
+
|
39
|
+
parameter_one
|
19
40
|
end
|
20
41
|
end
|
21
42
|
end
|
@@ -7,8 +7,8 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Lim < 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
|
"lim#{first_value}#{second_value}"
|
13
13
|
end
|
14
14
|
|
@@ -17,6 +17,44 @@ module Plurimath
|
|
17
17
|
second_value = "^{#{parameter_two.to_latex}}" if parameter_two
|
18
18
|
"\\#{class_name}#{first_value}#{second_value}"
|
19
19
|
end
|
20
|
+
|
21
|
+
def to_mathml_without_math_tag
|
22
|
+
first_value = (Utility.ox_element("mo") << "lim")
|
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_omml_without_math_tag
|
43
|
+
limupp = Utility.ox_element("limUpp", namespace: "m")
|
44
|
+
limpr = Utility.ox_element("limUppPr", namespace: "m")
|
45
|
+
limpr << Utility.pr_element("ctrl", namespace: "m")
|
46
|
+
e_tag = Utility.ox_element("e", namespace: "m")
|
47
|
+
e_tag << parameter_one&.to_omml_without_math_tag
|
48
|
+
lim = Utility.ox_element("lim", namespace: "m")
|
49
|
+
lim << parameter_two&.to_omml_without_math_tag if parameter_two
|
50
|
+
Utility.update_nodes(
|
51
|
+
limupp,
|
52
|
+
[
|
53
|
+
e_tag,
|
54
|
+
lim,
|
55
|
+
],
|
56
|
+
)
|
57
|
+
end
|
20
58
|
end
|
21
59
|
end
|
22
60
|
end
|
@@ -6,6 +6,14 @@ module Plurimath
|
|
6
6
|
module Math
|
7
7
|
module Function
|
8
8
|
class Limits < TernaryFunction
|
9
|
+
def to_mathml_without_math_tag
|
10
|
+
underover = Utility.ox_element("munderover")
|
11
|
+
value_array = []
|
12
|
+
value_array << parameter_one&.to_mathml_without_math_tag
|
13
|
+
value_array << parameter_two&.to_mathml_without_math_tag
|
14
|
+
value_array << parameter_three&.to_mathml_without_math_tag
|
15
|
+
Utility.update_nodes(underover, value_array)
|
16
|
+
end
|
9
17
|
|
10
18
|
def to_latex
|
11
19
|
first_value = parameter_one&.to_latex
|
@@ -7,16 +7,73 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Log < 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
|
"log#{first_value}#{second_value}"
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_latex
|
16
|
-
first_value = "_
|
17
|
-
second_value = "
|
16
|
+
first_value = "_#{latex_wrapped(parameter_one)}" if parameter_one
|
17
|
+
second_value = "^#{latex_wrapped(parameter_two)}" if parameter_two
|
18
18
|
"\\log#{first_value}#{second_value}"
|
19
19
|
end
|
20
|
+
|
21
|
+
def to_html
|
22
|
+
first_value = "<sub>#{parameter_one.to_html}</sub>" if parameter_one
|
23
|
+
second_value = "<sup>#{parameter_two.to_html}</sup>" if parameter_two
|
24
|
+
"<i>log</i>#{first_value}#{second_value}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_omml_without_math_tag
|
28
|
+
func = Utility.ox_element("func", namespace: "m")
|
29
|
+
funcpr = Utility.ox_element("funcPr", namespace: "m")
|
30
|
+
funcpr << Utility.pr_element("ctrl", true, namespace: "m")
|
31
|
+
fname = Utility.ox_element("fName", namespace: "m")
|
32
|
+
mr = Utility.ox_element("r", namespace: "m")
|
33
|
+
rpr = Utility.rpr_element
|
34
|
+
mt = Utility.ox_element("t", namespace: "m") << class_name
|
35
|
+
fname << Utility.update_nodes(mr, [rpr, mt])
|
36
|
+
log_values = [first_value, second_value].flatten.compact
|
37
|
+
Utility.update_nodes(
|
38
|
+
func,
|
39
|
+
[
|
40
|
+
funcpr,
|
41
|
+
fname,
|
42
|
+
] + log_values,
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_mathml_without_math_tag
|
47
|
+
subsup_tag = Utility.ox_element("msubsup")
|
48
|
+
first_value = (Utility.ox_element("mi") << "log")
|
49
|
+
if parameter_one || parameter_two
|
50
|
+
new_arr = [first_value]
|
51
|
+
new_arr << parameter_one&.to_mathml_without_math_tag
|
52
|
+
new_arr << parameter_two&.to_mathml_without_math_tag
|
53
|
+
Utility.update_nodes(
|
54
|
+
subsup_tag,
|
55
|
+
new_arr,
|
56
|
+
)
|
57
|
+
else
|
58
|
+
first_value
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
|
64
|
+
def first_value
|
65
|
+
return nil if parameter_one.nil?
|
66
|
+
|
67
|
+
first_value = parameter_one.to_omml_without_math_tag
|
68
|
+
Utility.ox_element("e", namespace: "m") << first_value
|
69
|
+
end
|
70
|
+
|
71
|
+
def second_value
|
72
|
+
return nil if parameter_two.nil?
|
73
|
+
|
74
|
+
second_value = parameter_two.to_omml_without_math_tag
|
75
|
+
Utility.ox_element("e", namespace: "m") << second_value
|
76
|
+
end
|
20
77
|
end
|
21
78
|
end
|
22
79
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "unary_function"
|
4
|
+
module Plurimath
|
5
|
+
module Math
|
6
|
+
module Function
|
7
|
+
class Mbox < UnaryFunction
|
8
|
+
def to_mathml_without_math_tag
|
9
|
+
text = Utility.ox_element("mtext")
|
10
|
+
text << (parameter_one.to_mathml_without_math_tag) if parameter_one
|
11
|
+
text
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_latex
|
15
|
+
first_value = parameter_one&.to_latex
|
16
|
+
"\\mbox{#{first_value}}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_html
|
20
|
+
parameter_one&.to_html
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_omml_without_math_tag
|
24
|
+
text = Utility.ox_element("t", namespace: "m")
|
25
|
+
text << parameter_one.to_omml_without_math_tag if parameter_one
|
26
|
+
text
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|