plurimath 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +8 -11
- data/.gitignore +1 -0
- data/AsciiMath-Supported-Data.adoc +280 -0
- data/Gemfile +1 -0
- data/Latex-Supported-Data.adoc +1872 -0
- data/MathML-Supported-Data.adoc +270 -0
- data/README.adoc +94 -0
- data/lib/plurimath/asciimath/constants.rb +215 -222
- data/lib/plurimath/asciimath/parse.rb +45 -11
- data/lib/plurimath/asciimath/parser.rb +4 -3
- data/lib/plurimath/asciimath/transform.rb +222 -131
- 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 +1885 -1858
- data/lib/plurimath/latex/parse.rb +127 -34
- data/lib/plurimath/latex/parser.rb +5 -4
- data/lib/plurimath/latex/transform.rb +324 -164
- data/lib/plurimath/math/formula.rb +9 -1
- data/lib/plurimath/math/function/bar.rb +1 -1
- data/lib/plurimath/math/function/base.rb +7 -1
- data/lib/plurimath/math/function/binary_function.rb +10 -5
- data/lib/plurimath/math/function/color.rb +4 -4
- data/lib/plurimath/math/function/fenced.rb +7 -2
- data/lib/plurimath/math/function/font_style/bold.rb +18 -0
- data/lib/plurimath/math/function/font_style/double_struck.rb +18 -0
- data/lib/plurimath/math/function/font_style/fraktur.rb +18 -0
- data/lib/plurimath/math/function/font_style/monospace.rb +18 -0
- data/lib/plurimath/math/function/font_style/sans-serif.rb +18 -0
- data/lib/plurimath/math/function/font_style/script.rb +18 -0
- data/lib/plurimath/math/function/font_style.rb +2 -22
- data/lib/plurimath/math/function/frac.rb +4 -4
- data/lib/plurimath/math/function/inf.rb +0 -1
- data/lib/plurimath/math/function/left.rb +3 -6
- data/lib/plurimath/math/function/limits.rb +0 -1
- data/lib/plurimath/math/function/log.rb +6 -0
- data/lib/plurimath/math/function/mod.rb +6 -0
- data/lib/plurimath/math/function/multiscript.rb +11 -0
- data/lib/plurimath/math/function/norm.rb +2 -1
- data/lib/plurimath/math/function/over.rb +29 -0
- data/lib/plurimath/math/function/overset.rb +2 -2
- data/lib/plurimath/math/function/power.rb +7 -1
- data/lib/plurimath/math/function/power_base.rb +14 -7
- data/lib/plurimath/math/function/prod.rb +6 -0
- data/lib/plurimath/math/function/right.rb +24 -0
- data/lib/plurimath/math/function/root.rb +5 -4
- data/lib/plurimath/math/function/sqrt.rb +1 -1
- data/lib/plurimath/math/function/substack.rb +0 -1
- data/lib/plurimath/math/function/sum.rb +6 -0
- data/lib/plurimath/math/function/table/align.rb +24 -0
- data/lib/plurimath/math/function/table/array.rb +25 -0
- data/lib/plurimath/math/function/table/bmatrix.rb +26 -0
- data/lib/plurimath/math/function/table/matrix.rb +24 -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 +25 -0
- data/lib/plurimath/math/function/table.rb +17 -5
- data/lib/plurimath/math/function/td.rb +6 -1
- data/lib/plurimath/math/function/ternary_function.rb +16 -6
- data/lib/plurimath/math/function/text.rb +19 -7
- data/lib/plurimath/math/function/tr.rb +6 -1
- data/lib/plurimath/math/function/unary_function.rb +5 -0
- data/lib/plurimath/math/function/vec.rb +4 -0
- data/lib/plurimath/math/function.rb +13 -2
- data/lib/plurimath/math/number.rb +8 -0
- data/lib/plurimath/math/symbol.rb +12 -3
- data/lib/plurimath/math.rb +9 -4
- data/lib/plurimath/mathml/constants.rb +2 -34
- data/lib/plurimath/mathml/parse.rb +7 -2
- data/lib/plurimath/mathml/parser.rb +2 -1
- data/lib/plurimath/mathml/transform.rb +73 -68
- data/lib/plurimath/mathml.rb +1 -1
- data/lib/plurimath/omml/constants.rb +154 -0
- data/lib/plurimath/omml/parser.rb +22 -0
- data/lib/plurimath/omml/transform.rb +216 -0
- data/lib/plurimath/omml.rb +1 -1
- data/lib/plurimath/unitsml.rb +4 -0
- data/lib/plurimath/utility.rb +73 -0
- data/lib/plurimath/version.rb +1 -1
- data/plurimath.gemspec +1 -0
- metadata +49 -7
- data/README.md +0 -40
@@ -28,14 +28,13 @@ module Plurimath
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def to_mathml_without_math_tag
|
31
|
-
first_value = parameter_one
|
32
|
-
second_value = parameter_two
|
33
|
-
|
34
|
-
"<mo>#{third_value}</mo>#{first_value}#{second_value}"
|
31
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
32
|
+
second_value = parameter_two&.to_mathml_without_math_tag
|
33
|
+
"<mo>#{invert_unicode_symbols}</mo>#{first_value}#{second_value}"
|
35
34
|
end
|
36
35
|
|
37
36
|
def invert_unicode_symbols
|
38
|
-
Mathml::Constants::UNICODE_SYMBOLS.invert[class_name]
|
37
|
+
Mathml::Constants::UNICODE_SYMBOLS.invert[class_name] || class_name
|
39
38
|
end
|
40
39
|
|
41
40
|
def to_latex
|
@@ -44,6 +43,12 @@ module Plurimath
|
|
44
43
|
"\\#{class_name}#{first_value}#{second_value}"
|
45
44
|
end
|
46
45
|
|
46
|
+
def to_html
|
47
|
+
first_value = "<i>#{parameter_one.to_latex}</i>" if parameter_one
|
48
|
+
second_value = "<i>#{parameter_two.to_latex}</i>" if parameter_two
|
49
|
+
"<i>#{class_name}</i>#{first_value}#{second_value}"
|
50
|
+
end
|
51
|
+
|
47
52
|
def class_name
|
48
53
|
self.class.name.split("::").last.downcase
|
49
54
|
end
|
@@ -7,14 +7,14 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Color < BinaryFunction
|
9
9
|
def to_mathml_without_math_tag
|
10
|
-
first_value = parameter_one
|
11
|
-
second_value = parameter_two
|
10
|
+
first_value = parameter_one&.value
|
11
|
+
second_value = parameter_two&.to_mathml_without_math_tag
|
12
12
|
"<mstyle mathcolor='#{first_value}'>#{second_value}</mstyle>"
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_latex
|
16
|
-
first_value = parameter_one
|
17
|
-
second_value = parameter_two
|
16
|
+
first_value = parameter_one&.to_latex
|
17
|
+
second_value = parameter_two&.to_latex
|
18
18
|
"\\#{class_name}{#{first_value}}#{second_value}"
|
19
19
|
end
|
20
20
|
end
|
@@ -8,13 +8,18 @@ module Plurimath
|
|
8
8
|
class Fenced < TernaryFunction
|
9
9
|
def to_asciimath
|
10
10
|
first_value = parameter_one ? parameter_one.to_asciimath : "("
|
11
|
-
second_value = parameter_two
|
11
|
+
second_value = parameter_two&.map(&:to_asciimath)&.join(",")
|
12
12
|
third_value = parameter_three ? parameter_three.to_asciimath : ")"
|
13
13
|
"#{first_value}#{second_value}#{third_value}"
|
14
14
|
end
|
15
15
|
|
16
16
|
def to_mathml_without_math_tag
|
17
|
-
|
17
|
+
first_value = parameter_one.value
|
18
|
+
second_value = parameter_two.map(&:to_mathml_without_math_tag).join
|
19
|
+
third_value = parameter_three.value
|
20
|
+
"<mfenced open='#{first_value}' close='#{third_value}'>"\
|
21
|
+
"#{second_value}"\
|
22
|
+
"</mfenced>"
|
18
23
|
end
|
19
24
|
end
|
20
25
|
end
|
@@ -0,0 +1,18 @@
|
|
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 Bold < FontStyle
|
10
|
+
def initialize(parameter_one,
|
11
|
+
parameter_two = "bold")
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
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 DoubleStruck < FontStyle
|
10
|
+
def initialize(parameter_one,
|
11
|
+
parameter_two = "double-struck")
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
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
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
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
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
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
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
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
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -6,33 +6,13 @@ 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_two}(#{parameter_one.to_asciimath})"
|
30
11
|
end
|
31
12
|
|
32
13
|
def to_mathml_without_math_tag
|
33
|
-
type = FONT_TYPES[parameter_two.to_sym]
|
34
14
|
first_value = parameter_one.to_mathml_without_math_tag
|
35
|
-
"<mstyle mathvariant='#{
|
15
|
+
"<mstyle mathvariant='#{parameter_two}'>#{first_value}</mstyle>"
|
36
16
|
end
|
37
17
|
|
38
18
|
def to_latex
|
@@ -7,14 +7,14 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Frac < BinaryFunction
|
9
9
|
def to_mathml_without_math_tag
|
10
|
-
first_value = parameter_one
|
11
|
-
two_value = parameter_two
|
10
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
11
|
+
two_value = parameter_two&.to_mathml_without_math_tag
|
12
12
|
"<mfrac>#{first_value}#{two_value}</mfrac>"
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_latex
|
16
|
-
first_value = parameter_one
|
17
|
-
two_value = parameter_two
|
16
|
+
first_value = parameter_one&.to_latex
|
17
|
+
two_value = parameter_two&.to_latex
|
18
18
|
"\\frac{#{first_value}}{#{two_value}}"
|
19
19
|
end
|
20
20
|
end
|
@@ -7,15 +7,12 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Left < UnaryFunction
|
9
9
|
def to_asciimath
|
10
|
-
"left#{
|
11
|
-
end
|
12
|
-
|
13
|
-
def value_to_asciimath
|
14
|
-
"(#{parameter_one.to_asciimath}right)" if parameter_one
|
10
|
+
"left#{parameter_one}"
|
15
11
|
end
|
16
12
|
|
17
13
|
def to_latex
|
18
|
-
"\\
|
14
|
+
prefix = "\\" if parameter_one == "{"
|
15
|
+
"\\left#{prefix}#{parameter_one}"
|
19
16
|
end
|
20
17
|
end
|
21
18
|
end
|
@@ -17,6 +17,12 @@ module Plurimath
|
|
17
17
|
second_value = "^{#{parameter_two.to_latex}}" 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
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -17,6 +17,12 @@ module Plurimath
|
|
17
17
|
second_value = "{#{parameter_two.to_latex}}" if parameter_two
|
18
18
|
"#{first_value}\\pmod#{second_value}"
|
19
19
|
end
|
20
|
+
|
21
|
+
def to_html
|
22
|
+
first_value = "<i>#{parameter_one.to_html}</i>" if parameter_one
|
23
|
+
second_value = "<i>#{parameter_two.to_html}</i>" if parameter_two
|
24
|
+
"#{first_value}<i>mod</i>#{second_value}"
|
25
|
+
end
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -7,7 +7,8 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Norm < UnaryFunction
|
9
9
|
def to_mathml_without_math_tag
|
10
|
-
|
10
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
11
|
+
"<mo>∥</mo>#{first_value}<mo>∥</mo>"
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -0,0 +1,29 @@
|
|
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 = "(#{parameter_one.to_asciimath})" if parameter_one
|
11
|
+
second_value = "(#{parameter_two.to_asciimath})" if parameter_two
|
12
|
+
"overset#{first_value}#{second_value}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_mathml_without_math_tag
|
16
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
17
|
+
two_value = parameter_two&.to_mathml_without_math_tag
|
18
|
+
"<mover>#{first_value}#{two_value}</mover>"
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_latex
|
22
|
+
first_value = parameter_one&.to_latex
|
23
|
+
two_value = parameter_two&.to_latex
|
24
|
+
"{#{first_value} \\over #{two_value}}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -7,8 +7,8 @@ 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
|
10
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
11
|
+
second_value = parameter_two&.to_mathml_without_math_tag
|
12
12
|
"<mover>#{second_value}#{first_value}</mover>"
|
13
13
|
end
|
14
14
|
|
@@ -20,10 +20,16 @@ module Plurimath
|
|
20
20
|
|
21
21
|
def to_latex
|
22
22
|
first_value = parameter_one.to_latex if parameter_one
|
23
|
-
first_value = "{#{first_value}}" if parameter_one.is_a?(
|
23
|
+
first_value = "{#{first_value}}" if parameter_one.is_a?(Formula)
|
24
24
|
second_value = parameter_two.to_latex
|
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
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
@@ -7,19 +7,26 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class PowerBase < TernaryFunction
|
9
9
|
def to_mathml_without_math_tag
|
10
|
-
first_value = parameter_one
|
11
|
-
second_value = parameter_two
|
12
|
-
third_value = parameter_three
|
10
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
11
|
+
second_value = parameter_two&.to_mathml_without_math_tag
|
12
|
+
third_value = parameter_three&.to_mathml_without_math_tag
|
13
13
|
"<msubsup>#{first_value}#{second_value}#{third_value}</msubsup>"
|
14
14
|
end
|
15
15
|
|
16
16
|
def to_latex
|
17
|
-
first_value = parameter_one
|
18
|
-
second_value = parameter_two
|
19
|
-
third_value = parameter_three
|
20
|
-
first_value = "{#{first_value}}" if parameter_one.is_a?(
|
17
|
+
first_value = parameter_one&.to_latex
|
18
|
+
second_value = parameter_two&.to_latex
|
19
|
+
third_value = parameter_three&.to_latex
|
20
|
+
first_value = "{#{first_value}}" if parameter_one.is_a?(Formula)
|
21
21
|
"#{first_value}_{#{second_value}}^{#{third_value}}"
|
22
22
|
end
|
23
|
+
|
24
|
+
def to_html
|
25
|
+
first_value = "<i>#{parameter_one.to_html}</i>"
|
26
|
+
second_value = "<sub>#{parameter_two.to_html}</sub>"
|
27
|
+
third_value = "<sup>#{parameter_three.to_html}</sup>"
|
28
|
+
"#{first_value}#{second_value}#{third_value}"
|
29
|
+
end
|
23
30
|
end
|
24
31
|
end
|
25
32
|
end
|
@@ -17,6 +17,12 @@ 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_html
|
22
|
+
first_value = "<sub>#{parameter_one.to_latex}</sub>" if parameter_one
|
23
|
+
second_value = "<sup>#{parameter_two.to_latex}</sup>" if parameter_two
|
24
|
+
"<i>∏</i>#{first_value}#{second_value}"
|
25
|
+
end
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -0,0 +1,24 @@
|
|
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
|
+
"<mi>#{parameter_one}</mi>"
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_latex
|
18
|
+
prefix = "\\" if parameter_one == "}"
|
19
|
+
"\\right#{prefix}#{parameter_one}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -7,13 +7,14 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Root < BinaryFunction
|
9
9
|
def to_mathml_without_math_tag
|
10
|
-
first_value = parameter_one
|
11
|
-
|
10
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
11
|
+
second_value = parameter_two&.to_mathml_without_math_tag
|
12
|
+
"<mroot>#{first_value}#{second_value}</mroot>"
|
12
13
|
end
|
13
14
|
|
14
15
|
def to_latex
|
15
|
-
first_value = parameter_one
|
16
|
-
second_value = parameter_two
|
16
|
+
first_value = parameter_one&.to_latex
|
17
|
+
second_value = parameter_two&.to_latex
|
17
18
|
"\\sqrt[#{first_value}]{#{second_value}}"
|
18
19
|
end
|
19
20
|
end
|
@@ -7,7 +7,7 @@ module Plurimath
|
|
7
7
|
module Function
|
8
8
|
class Sqrt < UnaryFunction
|
9
9
|
def to_mathml_without_math_tag
|
10
|
-
first_value = parameter_one
|
10
|
+
first_value = parameter_one&.to_mathml_without_math_tag
|
11
11
|
"<msqrt>#{first_value}</msqrt>"
|
12
12
|
end
|
13
13
|
end
|
@@ -17,6 +17,12 @@ module Plurimath
|
|
17
17
|
second_value = "^{#{parameter_two.to_latex}}" if parameter_two
|
18
18
|
"\\sum#{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>∑</i>#{first_value}#{second_value}"
|
25
|
+
end
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../table"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Table
|
9
|
+
class Align < Table
|
10
|
+
def initialize(parameter_one,
|
11
|
+
parameter_two = "[",
|
12
|
+
parameter_three = "]")
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_latex
|
17
|
+
first_value = parameter_one&.map(&:to_latex)&.join("\\\\")
|
18
|
+
"\\begin{align}#{first_value}\\end{align}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../table"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Table
|
9
|
+
class Array < Table
|
10
|
+
def initialize(parameter_one = [],
|
11
|
+
parameter_two = "[",
|
12
|
+
parameter_three = "]")
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_latex
|
17
|
+
divider = "{#{parameter_three.map(&:to_latex).join}}"
|
18
|
+
first_value = parameter_one&.map(&:to_latex)&.join("\\\\")
|
19
|
+
"\\begin{array}#{divider}#{first_value}\\end{array}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../table"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Table
|
9
|
+
class Bmatrix < Table
|
10
|
+
def initialize(parameter_one,
|
11
|
+
parameter_two = "[",
|
12
|
+
parameter_three = "]")
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_latex
|
17
|
+
first_value = parameter_one&.map(&:to_latex)&.join("\\\\")
|
18
|
+
matrices = Latex::Constants::MATRICES.invert
|
19
|
+
environment = matrices[parameter_two].to_s
|
20
|
+
"\\begin{#{environment}}#{first_value}\\end{#{environment}}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../table"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Table
|
9
|
+
class Matrix < Table
|
10
|
+
def initialize(parameter_one = [],
|
11
|
+
parameter_two = "(",
|
12
|
+
parameter_three = ")")
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_latex
|
17
|
+
first_value = parameter_one&.map(&:to_latex)&.join("\\\\")
|
18
|
+
"\\begin{matrix}#{first_value}\\end{matrix}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../table"
|
4
|
+
|
5
|
+
module Plurimath
|
6
|
+
module Math
|
7
|
+
module Function
|
8
|
+
class Table
|
9
|
+
class Multline < Table
|
10
|
+
def initialize(parameter_one,
|
11
|
+
parameter_two = "[",
|
12
|
+
parameter_three = "]")
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_latex
|
17
|
+
first_value = parameter_one&.map(&:to_latex)&.join("\\\\")
|
18
|
+
"\\begin{multline}#{first_value}\\end{multline}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|