plurimath 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +8 -11
  3. data/.gitignore +1 -0
  4. data/AsciiMath-Supported-Data.adoc +280 -0
  5. data/Gemfile +1 -0
  6. data/Latex-Supported-Data.adoc +1872 -0
  7. data/MathML-Supported-Data.adoc +270 -0
  8. data/README.adoc +94 -0
  9. data/lib/plurimath/asciimath/constants.rb +215 -222
  10. data/lib/plurimath/asciimath/parse.rb +45 -11
  11. data/lib/plurimath/asciimath/parser.rb +4 -3
  12. data/lib/plurimath/asciimath/transform.rb +222 -131
  13. data/lib/plurimath/asciimath.rb +1 -1
  14. data/lib/plurimath/html/constants.rb +50 -0
  15. data/lib/plurimath/html/parse.rb +149 -0
  16. data/lib/plurimath/html/parser.rb +26 -0
  17. data/lib/plurimath/html/transform.rb +363 -0
  18. data/lib/plurimath/html.rb +1 -1
  19. data/lib/plurimath/latex/constants.rb +1885 -1858
  20. data/lib/plurimath/latex/parse.rb +127 -34
  21. data/lib/plurimath/latex/parser.rb +5 -4
  22. data/lib/plurimath/latex/transform.rb +324 -164
  23. data/lib/plurimath/math/formula.rb +9 -1
  24. data/lib/plurimath/math/function/bar.rb +1 -1
  25. data/lib/plurimath/math/function/base.rb +7 -1
  26. data/lib/plurimath/math/function/binary_function.rb +10 -5
  27. data/lib/plurimath/math/function/color.rb +4 -4
  28. data/lib/plurimath/math/function/fenced.rb +7 -2
  29. data/lib/plurimath/math/function/font_style/bold.rb +18 -0
  30. data/lib/plurimath/math/function/font_style/double_struck.rb +18 -0
  31. data/lib/plurimath/math/function/font_style/fraktur.rb +18 -0
  32. data/lib/plurimath/math/function/font_style/monospace.rb +18 -0
  33. data/lib/plurimath/math/function/font_style/sans-serif.rb +18 -0
  34. data/lib/plurimath/math/function/font_style/script.rb +18 -0
  35. data/lib/plurimath/math/function/font_style.rb +2 -22
  36. data/lib/plurimath/math/function/frac.rb +4 -4
  37. data/lib/plurimath/math/function/inf.rb +0 -1
  38. data/lib/plurimath/math/function/left.rb +3 -6
  39. data/lib/plurimath/math/function/limits.rb +0 -1
  40. data/lib/plurimath/math/function/log.rb +6 -0
  41. data/lib/plurimath/math/function/mod.rb +6 -0
  42. data/lib/plurimath/math/function/multiscript.rb +11 -0
  43. data/lib/plurimath/math/function/norm.rb +2 -1
  44. data/lib/plurimath/math/function/over.rb +29 -0
  45. data/lib/plurimath/math/function/overset.rb +2 -2
  46. data/lib/plurimath/math/function/power.rb +7 -1
  47. data/lib/plurimath/math/function/power_base.rb +14 -7
  48. data/lib/plurimath/math/function/prod.rb +6 -0
  49. data/lib/plurimath/math/function/right.rb +24 -0
  50. data/lib/plurimath/math/function/root.rb +5 -4
  51. data/lib/plurimath/math/function/sqrt.rb +1 -1
  52. data/lib/plurimath/math/function/substack.rb +0 -1
  53. data/lib/plurimath/math/function/sum.rb +6 -0
  54. data/lib/plurimath/math/function/table/align.rb +24 -0
  55. data/lib/plurimath/math/function/table/array.rb +25 -0
  56. data/lib/plurimath/math/function/table/bmatrix.rb +26 -0
  57. data/lib/plurimath/math/function/table/matrix.rb +24 -0
  58. data/lib/plurimath/math/function/table/multline.rb +24 -0
  59. data/lib/plurimath/math/function/table/pmatrix.rb +24 -0
  60. data/lib/plurimath/math/function/table/split.rb +24 -0
  61. data/lib/plurimath/math/function/table/vmatrix.rb +25 -0
  62. data/lib/plurimath/math/function/table.rb +17 -5
  63. data/lib/plurimath/math/function/td.rb +6 -1
  64. data/lib/plurimath/math/function/ternary_function.rb +16 -6
  65. data/lib/plurimath/math/function/text.rb +19 -7
  66. data/lib/plurimath/math/function/tr.rb +6 -1
  67. data/lib/plurimath/math/function/unary_function.rb +5 -0
  68. data/lib/plurimath/math/function/vec.rb +4 -0
  69. data/lib/plurimath/math/function.rb +13 -2
  70. data/lib/plurimath/math/number.rb +8 -0
  71. data/lib/plurimath/math/symbol.rb +12 -3
  72. data/lib/plurimath/math.rb +9 -4
  73. data/lib/plurimath/mathml/constants.rb +2 -34
  74. data/lib/plurimath/mathml/parse.rb +7 -2
  75. data/lib/plurimath/mathml/parser.rb +2 -1
  76. data/lib/plurimath/mathml/transform.rb +73 -68
  77. data/lib/plurimath/mathml.rb +1 -1
  78. data/lib/plurimath/omml/constants.rb +154 -0
  79. data/lib/plurimath/omml/parser.rb +22 -0
  80. data/lib/plurimath/omml/transform.rb +216 -0
  81. data/lib/plurimath/omml.rb +1 -1
  82. data/lib/plurimath/unitsml.rb +4 -0
  83. data/lib/plurimath/utility.rb +73 -0
  84. data/lib/plurimath/version.rb +1 -1
  85. data/plurimath.gemspec +1 -0
  86. metadata +49 -7
  87. 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.to_mathml_without_math_tag if parameter_one
32
- second_value = parameter_two.to_mathml_without_math_tag if parameter_two
33
- third_value = invert_unicode_symbols.empty? ? class_name : invert_unicode_symbols
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].to_s
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.value if parameter_one
11
- second_value = parameter_two.to_mathml_without_math_tag if 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.to_latex if parameter_one
17
- second_value = parameter_two.to_latex if 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.map(&:to_asciimath).join(",") if 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
- "<mfenced open='#{parameter_one.value}' close='#{parameter_three.value}'>#{parameter_two.map(&:to_mathml_without_math_tag).join}</mfenced>"
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
- if Asciimath::Constants::FONT_STYLES.include?(parameter_two.to_sym)
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='#{type}'>#{first_value}</mstyle>"
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.to_mathml_without_math_tag if parameter_one
11
- two_value = parameter_two.to_mathml_without_math_tag if 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.to_latex if parameter_one
17
- two_value = parameter_two.to_latex if 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
@@ -6,7 +6,6 @@ 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
@@ -7,15 +7,12 @@ module Plurimath
7
7
  module Function
8
8
  class Left < UnaryFunction
9
9
  def to_asciimath
10
- "left#{value_to_asciimath}"
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
- "\\left(#{parameter_one&.to_latex}\\right)"
14
+ prefix = "\\" if parameter_one == "{"
15
+ "\\left#{prefix}#{parameter_one}"
19
16
  end
20
17
  end
21
18
  end
@@ -6,7 +6,6 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Limits < TernaryFunction
9
-
10
9
  def to_latex
11
10
  first_value = parameter_one&.to_latex
12
11
  second_value = "{#{parameter_two.to_latex}}" if parameter_two
@@ -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
@@ -0,0 +1,11 @@
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
+ end
9
+ end
10
+ end
11
+ 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
- "<mo>&#x2225;</mo>#{parameter_one.to_mathml_without_math_tag}<mo>&#x2225;</mo>"
10
+ first_value = parameter_one&.to_mathml_without_math_tag
11
+ "<mo>&#x2225;</mo>#{first_value}<mo>&#x2225;</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.to_mathml_without_math_tag if parameter_one
11
- second_value = parameter_two.to_mathml_without_math_tag if 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?(Math::Formula)
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.to_mathml_without_math_tag if parameter_one
11
- second_value = parameter_two.to_mathml_without_math_tag if parameter_two
12
- third_value = parameter_three.to_mathml_without_math_tag if 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.to_latex if parameter_one
18
- second_value = parameter_two.to_latex if parameter_two
19
- third_value = parameter_three.to_latex if parameter_three
20
- first_value = "{#{first_value}}" if parameter_one.is_a?(Math::Formula)
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>&prod;</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.to_mathml_without_math_tag if parameter_one
11
- "<root>#{first_value}</root>"
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.to_latex if parameter_one
16
- second_value = parameter_two.to_latex if 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.to_mathml_without_math_tag if parameter_one
10
+ first_value = parameter_one&.to_mathml_without_math_tag
11
11
  "<msqrt>#{first_value}</msqrt>"
12
12
  end
13
13
  end
@@ -6,7 +6,6 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Substack < 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
@@ -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>&sum;</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