plurimath 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +33 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +2 -0
  5. data/AsciiMath-Supported-Data.adoc +280 -0
  6. data/Gemfile +1 -0
  7. data/Latex-Supported-Data.adoc +1872 -0
  8. data/MathML-Supported-Data.adoc +270 -0
  9. data/README.adoc +94 -0
  10. data/lib/plurimath/asciimath/constants.rb +301 -0
  11. data/lib/plurimath/asciimath/parse.rb +121 -0
  12. data/lib/plurimath/asciimath/parser.rb +25 -0
  13. data/lib/plurimath/asciimath/transform.rb +395 -0
  14. data/lib/plurimath/asciimath.rb +16 -0
  15. data/lib/plurimath/html/constants.rb +50 -0
  16. data/lib/plurimath/html/parse.rb +149 -0
  17. data/lib/plurimath/html/parser.rb +26 -0
  18. data/lib/plurimath/html/transform.rb +363 -0
  19. data/lib/plurimath/html.rb +15 -0
  20. data/lib/plurimath/latex/constants.rb +1990 -0
  21. data/lib/plurimath/latex/parse.rb +198 -0
  22. data/lib/plurimath/latex/parser.rb +25 -0
  23. data/lib/plurimath/latex/transform.rb +458 -0
  24. data/lib/plurimath/latex.rb +15 -0
  25. data/lib/plurimath/math/formula.rb +51 -0
  26. data/lib/plurimath/math/function/abs.rb +12 -0
  27. data/lib/plurimath/math/function/arccos.rb +12 -0
  28. data/lib/plurimath/math/function/arcsin.rb +12 -0
  29. data/lib/plurimath/math/function/arctan.rb +12 -0
  30. data/lib/plurimath/math/function/bar.rb +16 -0
  31. data/lib/plurimath/math/function/base.rb +36 -0
  32. data/lib/plurimath/math/function/binary_function.rb +58 -0
  33. data/lib/plurimath/math/function/cancel.rb +12 -0
  34. data/lib/plurimath/math/function/ceil.rb +12 -0
  35. data/lib/plurimath/math/function/color.rb +23 -0
  36. data/lib/plurimath/math/function/cos.rb +12 -0
  37. data/lib/plurimath/math/function/cosh.rb +12 -0
  38. data/lib/plurimath/math/function/cot.rb +12 -0
  39. data/lib/plurimath/math/function/coth.rb +12 -0
  40. data/lib/plurimath/math/function/csc.rb +12 -0
  41. data/lib/plurimath/math/function/csch.rb +12 -0
  42. data/lib/plurimath/math/function/ddot.rb +12 -0
  43. data/lib/plurimath/math/function/deg.rb +12 -0
  44. data/lib/plurimath/math/function/det.rb +12 -0
  45. data/lib/plurimath/math/function/dim.rb +12 -0
  46. data/lib/plurimath/math/function/dot.rb +12 -0
  47. data/lib/plurimath/math/function/exp.rb +12 -0
  48. data/lib/plurimath/math/function/f.rb +12 -0
  49. data/lib/plurimath/math/function/fenced.rb +27 -0
  50. data/lib/plurimath/math/function/floor.rb +12 -0
  51. data/lib/plurimath/math/function/font_style/bold.rb +18 -0
  52. data/lib/plurimath/math/function/font_style/double_struck.rb +18 -0
  53. data/lib/plurimath/math/function/font_style/fraktur.rb +18 -0
  54. data/lib/plurimath/math/function/font_style/monospace.rb +18 -0
  55. data/lib/plurimath/math/function/font_style/sans-serif.rb +18 -0
  56. data/lib/plurimath/math/function/font_style/script.rb +18 -0
  57. data/lib/plurimath/math/function/font_style.rb +25 -0
  58. data/lib/plurimath/math/function/frac.rb +23 -0
  59. data/lib/plurimath/math/function/g.rb +12 -0
  60. data/lib/plurimath/math/function/gcd.rb +12 -0
  61. data/lib/plurimath/math/function/glb.rb +12 -0
  62. data/lib/plurimath/math/function/hat.rb +12 -0
  63. data/lib/plurimath/math/function/hom.rb +12 -0
  64. data/lib/plurimath/math/function/inf.rb +17 -0
  65. data/lib/plurimath/math/function/int.rb +17 -0
  66. data/lib/plurimath/math/function/ker.rb +12 -0
  67. data/lib/plurimath/math/function/lcm.rb +12 -0
  68. data/lib/plurimath/math/function/left.rb +20 -0
  69. data/lib/plurimath/math/function/lg.rb +12 -0
  70. data/lib/plurimath/math/function/lim.rb +23 -0
  71. data/lib/plurimath/math/function/liminf.rb +12 -0
  72. data/lib/plurimath/math/function/limits.rb +18 -0
  73. data/lib/plurimath/math/function/limsup.rb +12 -0
  74. data/lib/plurimath/math/function/ln.rb +12 -0
  75. data/lib/plurimath/math/function/log.rb +29 -0
  76. data/lib/plurimath/math/function/lub.rb +12 -0
  77. data/lib/plurimath/math/function/max.rb +12 -0
  78. data/lib/plurimath/math/function/min.rb +12 -0
  79. data/lib/plurimath/math/function/mod.rb +29 -0
  80. data/lib/plurimath/math/function/multiscript.rb +11 -0
  81. data/lib/plurimath/math/function/norm.rb +16 -0
  82. data/lib/plurimath/math/function/obrace.rb +12 -0
  83. data/lib/plurimath/math/function/oint.rb +17 -0
  84. data/lib/plurimath/math/function/over.rb +29 -0
  85. data/lib/plurimath/math/function/overset.rb +23 -0
  86. data/lib/plurimath/math/function/power.rb +36 -0
  87. data/lib/plurimath/math/function/power_base.rb +33 -0
  88. data/lib/plurimath/math/function/prod.rb +29 -0
  89. data/lib/plurimath/math/function/right.rb +24 -0
  90. data/lib/plurimath/math/function/root.rb +23 -0
  91. data/lib/plurimath/math/function/sec.rb +12 -0
  92. data/lib/plurimath/math/function/sech.rb +12 -0
  93. data/lib/plurimath/math/function/sin.rb +12 -0
  94. data/lib/plurimath/math/function/sinh.rb +12 -0
  95. data/lib/plurimath/math/function/sqrt.rb +16 -0
  96. data/lib/plurimath/math/function/stackrel.rb +12 -0
  97. data/lib/plurimath/math/function/substack.rb +17 -0
  98. data/lib/plurimath/math/function/sum.rb +29 -0
  99. data/lib/plurimath/math/function/sup.rb +12 -0
  100. data/lib/plurimath/math/function/table/align.rb +24 -0
  101. data/lib/plurimath/math/function/table/array.rb +25 -0
  102. data/lib/plurimath/math/function/table/bmatrix.rb +26 -0
  103. data/lib/plurimath/math/function/table/matrix.rb +24 -0
  104. data/lib/plurimath/math/function/table/multline.rb +24 -0
  105. data/lib/plurimath/math/function/table/pmatrix.rb +24 -0
  106. data/lib/plurimath/math/function/table/split.rb +24 -0
  107. data/lib/plurimath/math/function/table/vmatrix.rb +25 -0
  108. data/lib/plurimath/math/function/table.rb +54 -0
  109. data/lib/plurimath/math/function/tan.rb +12 -0
  110. data/lib/plurimath/math/function/tanh.rb +12 -0
  111. data/lib/plurimath/math/function/td.rb +32 -0
  112. data/lib/plurimath/math/function/ternary_function.rb +52 -0
  113. data/lib/plurimath/math/function/text.rb +44 -0
  114. data/lib/plurimath/math/function/tilde.rb +12 -0
  115. data/lib/plurimath/math/function/tr.rb +30 -0
  116. data/lib/plurimath/math/function/ubrace.rb +12 -0
  117. data/lib/plurimath/math/function/ul.rb +12 -0
  118. data/lib/plurimath/math/function/unary_function.rb +46 -0
  119. data/lib/plurimath/math/function/underover.rb +12 -0
  120. data/lib/plurimath/math/function/underset.rb +12 -0
  121. data/lib/plurimath/math/function/vec.rb +16 -0
  122. data/lib/plurimath/math/function.rb +14 -0
  123. data/lib/plurimath/math/number.rb +37 -0
  124. data/lib/plurimath/math/symbol.rb +43 -0
  125. data/lib/plurimath/math.rb +56 -0
  126. data/lib/plurimath/mathml/constants.rb +295 -0
  127. data/lib/plurimath/mathml/parse.rb +68 -0
  128. data/lib/plurimath/mathml/parser.rb +26 -0
  129. data/lib/plurimath/mathml/transform.rb +200 -0
  130. data/lib/plurimath/mathml.rb +16 -0
  131. data/lib/plurimath/omml/constants.rb +154 -0
  132. data/lib/plurimath/omml/parser.rb +22 -0
  133. data/lib/plurimath/omml/transform.rb +216 -0
  134. data/lib/plurimath/omml.rb +15 -0
  135. data/lib/plurimath/unicode.rb +15 -0
  136. data/lib/plurimath/unitsml.rb +15 -0
  137. data/lib/plurimath/utility.rb +73 -0
  138. data/lib/plurimath/version.rb +3 -1
  139. data/lib/plurimath.rb +3 -5
  140. data/plurimath.gemspec +4 -3
  141. metadata +169 -9
  142. data/README.md +0 -40
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "binary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Substack < BinaryFunction
9
+ def to_latex
10
+ first_value = parameter_one.to_latex if parameter_one
11
+ second_value = "\\\\#{parameter_two.to_latex}" if parameter_two
12
+ "\\#{class_name}{#{first_value}#{second_value}}"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ 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 Sum < 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
+ "sum#{first_value}#{second_value}"
13
+ end
14
+
15
+ def to_latex
16
+ first_value = "_{#{parameter_one.to_latex}}" if parameter_one
17
+ second_value = "^{#{parameter_two.to_latex}}" if parameter_two
18
+ "\\sum#{first_value}#{second_value}"
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
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Sup < UnaryFunction
9
+ end
10
+ end
11
+ end
12
+ 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
@@ -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 Pmatrix < 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{pmatrix}#{first_value}\\end{pmatrix}"
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 Split < 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{split}#{first_value}\\end{split}"
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 Vmatrix < Table
10
+ def initialize(parameter_one,
11
+ parameter_two = "|",
12
+ parameter_three = "|")
13
+ parameter_three = nil if parameter_two == "norm["
14
+ super
15
+ end
16
+
17
+ def to_latex
18
+ first_value = parameter_one&.map(&:to_latex)&.join("\\\\")
19
+ "\\begin{vmatrix}#{first_value}\\end{vmatrix}"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ternary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Table < TernaryFunction
9
+ def initialize(parameter_one = nil,
10
+ parameter_two = nil,
11
+ parameter_three = nil)
12
+ super
13
+ end
14
+
15
+ def to_asciimath
16
+ first_value = parameter_one.map(&:to_asciimath).join(",")
17
+ second_value = parameter_two.nil? ? "[" : parameter_two
18
+ third_value = parameter_three.nil? ? "]" : parameter_three
19
+ "#{second_value}#{first_value}#{third_value}"
20
+ end
21
+
22
+ def to_mathml_without_math_tag
23
+ table_value = parameter_one.map(&:to_mathml_without_math_tag).join
24
+ parenthesis = Latex::Constants::PARENTHESIS
25
+ if parenthesis.key?(parameter_two) || parameter_two == "|"
26
+ "<mfenced open='#{parameter_two}' close='#{parameter_three}'>"\
27
+ "<mtable>#{table_value}</mtable></mfenced>"
28
+ elsif parameter_two == "norm["
29
+ "<mo>&#x2225;</mo>#{table_value}<mo>&#x2225;</mo>"
30
+ else
31
+ "<mtable>#{table_value}</mtable>"
32
+ end
33
+ end
34
+
35
+ def to_latex
36
+ first_value = parameter_one&.map(&:to_latex)&.join("\\\\")
37
+ environment = latex_environment
38
+ "\\begin{#{environment}}#{first_value}\\end{#{environment}}"
39
+ end
40
+
41
+ def latex_environment
42
+ matrices_hash = Latex::Constants::MATRICES
43
+ matric_value = matrices_hash.value?(parameter_two)
44
+ matrices_hash.invert[parameter_two] if matric_value
45
+ end
46
+
47
+ def to_html
48
+ first_value = parameter_one.map(&:to_html).join
49
+ "<table>#{first_value}</table>"
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Tan < UnaryFunction
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Tanh < UnaryFunction
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Td < UnaryFunction
9
+ def to_asciimath
10
+ if parameter_one.length > 1
11
+ "[#{parameter_one.map(&:to_asciimath).join(',')}]"
12
+ else
13
+ parameter_one.map(&:to_asciimath).join(",")
14
+ end
15
+ end
16
+
17
+ def to_mathml_without_math_tag
18
+ "<mtd>#{parameter_one.map(&:to_mathml_without_math_tag).join}</mtd>"
19
+ end
20
+
21
+ def to_latex
22
+ parameter_one.map(&:to_latex).join
23
+ end
24
+
25
+ def to_html
26
+ first_value = parameter_one.map(&:to_html).join
27
+ "<td>#{first_value}</td>"
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Plurimath
4
+ module Math
5
+ module Function
6
+ class TernaryFunction
7
+ attr_accessor :parameter_one, :parameter_two, :parameter_three
8
+
9
+ def initialize(parameter_one = nil,
10
+ parameter_two = nil,
11
+ parameter_three = nil)
12
+ @parameter_one = parameter_one
13
+ @parameter_two = parameter_two
14
+ @parameter_three = parameter_three
15
+ end
16
+
17
+ def to_asciimath
18
+ first_value = parameter_one&.to_asciimath
19
+ second_value = "_(#{parameter_two.to_asciimath})" if parameter_two
20
+ third_value = "^(#{parameter_three.to_asciimath})" if parameter_three
21
+ "#{first_value}#{second_value}#{third_value}"
22
+ end
23
+
24
+ def ==(object)
25
+ self.class == object.class &&
26
+ object.parameter_one == parameter_one &&
27
+ object.parameter_two == parameter_two &&
28
+ object.parameter_three == parameter_three
29
+ end
30
+
31
+ def to_mathml_without_math_tag
32
+ first_value = parameter_one&.to_mathml_without_math_tag
33
+ second_value = parameter_two&.to_mathml_without_math_tag
34
+ third_value = parameter_three&.to_mathml_without_math_tag
35
+ body_value = "#{first_value}#{second_value}#{third_value}"
36
+ "<m#{class_name}>#{body_value}</m#{class_name}>"
37
+ end
38
+
39
+ def to_html
40
+ first_value = "<i>#{parameter_one.to_html}</i>" if parameter_one
41
+ second_value = "<i>#{parameter_two.to_html}</i>" if parameter_two
42
+ third_value = "<i>#{parameter_three.to_html}</i>" if parameter_three
43
+ first_value + second_value + third_value
44
+ end
45
+
46
+ def class_name
47
+ self.class.name.split("::").last.downcase
48
+ end
49
+ end
50
+ end
51
+ end
52
+ 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 Text < UnaryFunction
9
+ def to_asciimath
10
+ "\"#{parse_text('asciimath') || parameter_one}\""
11
+ end
12
+
13
+ def to_mathml_without_math_tag
14
+ "<mtext>#{parse_text('mathml') || parameter_one}</mtext>"
15
+ end
16
+
17
+ def symbol_value(unicode)
18
+ Mathml::Constants::UNICODE_SYMBOLS.invert[unicode] ||
19
+ Mathml::Constants::SYMBOLS.invert[unicode]
20
+ end
21
+
22
+ def to_latex
23
+ parse_text("latex") || parameter_one
24
+ end
25
+
26
+ def to_html
27
+ parse_text("html") || parameter_one
28
+ end
29
+
30
+ def parse_text(lang)
31
+ regex = %r{\\mbox\{(?<mbox>.{1,})\}|unicode\[:(?<unicode>\w{1,})\]}
32
+ parameter_one.gsub!(regex) do |_text|
33
+ last_match = Regexp.last_match
34
+ if ["mathml", "html"].include?(lang)
35
+ symbol_value(last_match[:unicode]) || last_match[:mbox]
36
+ else
37
+ last_match[:unicode] || last_match[:mbox]
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Tilde < UnaryFunction
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Tr < UnaryFunction
9
+ def to_asciimath
10
+ "[#{parameter_one.map(&:to_asciimath).join(',')}]"
11
+ end
12
+
13
+ def to_mathml_without_math_tag
14
+ "<mtr>#{parameter_one.map(&:to_mathml_without_math_tag).join}</mtr>"
15
+ end
16
+
17
+ def to_latex
18
+ parameter_one.reject do |td|
19
+ td if td.is_a?(Math::Symbol) && td.value == "|"
20
+ end.map(&:to_latex).join("&")
21
+ end
22
+
23
+ def to_html
24
+ first_value = parameter_one.map(&:to_html).join
25
+ "<tr>#{first_value}</tr>"
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Ubrace < UnaryFunction
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Ul < UnaryFunction
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Plurimath
4
+ module Math
5
+ module Function
6
+ class UnaryFunction
7
+ attr_accessor :parameter_one
8
+
9
+ def initialize(parameter_one = nil)
10
+ @parameter_one = parameter_one
11
+ end
12
+
13
+ def ==(object)
14
+ object.class == self.class &&
15
+ object.parameter_one == parameter_one
16
+ end
17
+
18
+ def to_asciimath
19
+ "#{class_name}#{value_to_asciimath}"
20
+ end
21
+
22
+ def value_to_asciimath
23
+ "(#{parameter_one.to_asciimath})" unless parameter_one.nil?
24
+ end
25
+
26
+ def to_mathml_without_math_tag
27
+ "<mi>#{class_name}</mi>"
28
+ end
29
+
30
+ def to_latex
31
+ first_value = "{#{parameter_one.to_latex}}" if parameter_one
32
+ "\\#{class_name}#{first_value}"
33
+ end
34
+
35
+ def to_html
36
+ first_value = "<i>#{parameter_one.to_html}</i>" if parameter_one
37
+ "<i>#{class_name}</i>#{first_value}"
38
+ end
39
+
40
+ def class_name
41
+ self.class.name.split("::").last.downcase
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ternary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Underover < TernaryFunction
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "binary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Underset < BinaryFunction
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Vec < UnaryFunction
9
+ def to_mathml_without_math_tag
10
+ first_value = parameter_one&.to_mathml_without_math_tag
11
+ "<mover>#{first_value}<mo>&#x20D1;</mo></mover>"
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module Plurimath
2
+ module Math
3
+ module Function
4
+ end
5
+ end
6
+ end
7
+
8
+ # Include the first level files before the next
9
+ (
10
+ Dir.glob(File.join(__dir__, "function", "*.rb")) +
11
+ Dir.glob(File.join(__dir__, "function", "*", "*.rb"))
12
+ ).each do |file|
13
+ require file
14
+ end