plurimath 0.3.5 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/lib/plurimath/asciimath/constants.rb +5 -3
  3. data/lib/plurimath/asciimath/parse.rb +41 -28
  4. data/lib/plurimath/asciimath/transform.rb +111 -0
  5. data/lib/plurimath/latex/constants.rb +2 -2
  6. data/lib/plurimath/latex/parse.rb +3 -0
  7. data/lib/plurimath/latex/transform.rb +37 -0
  8. data/lib/plurimath/math/core.rb +43 -0
  9. data/lib/plurimath/math/formula.rb +43 -30
  10. data/lib/plurimath/math/function/abs.rb +19 -0
  11. data/lib/plurimath/math/function/arccos.rb +3 -0
  12. data/lib/plurimath/math/function/arcsin.rb +3 -0
  13. data/lib/plurimath/math/function/arctan.rb +3 -0
  14. data/lib/plurimath/math/function/bar.rb +2 -1
  15. data/lib/plurimath/math/function/base.rb +5 -7
  16. data/lib/plurimath/math/function/binary_function.rb +11 -61
  17. data/lib/plurimath/math/function/cos.rb +3 -0
  18. data/lib/plurimath/math/function/cosh.rb +3 -0
  19. data/lib/plurimath/math/function/cot.rb +3 -0
  20. data/lib/plurimath/math/function/coth.rb +3 -0
  21. data/lib/plurimath/math/function/csc.rb +3 -0
  22. data/lib/plurimath/math/function/csch.rb +3 -0
  23. data/lib/plurimath/math/function/ddot.rb +13 -0
  24. data/lib/plurimath/math/function/deg.rb +3 -0
  25. data/lib/plurimath/math/function/det.rb +3 -0
  26. data/lib/plurimath/math/function/dim.rb +3 -0
  27. data/lib/plurimath/math/function/exp.rb +3 -0
  28. data/lib/plurimath/math/function/fenced.rb +9 -21
  29. data/lib/plurimath/math/function/font_style.rb +7 -1
  30. data/lib/plurimath/math/function/frac.rb +5 -7
  31. data/lib/plurimath/math/function/gcd.rb +3 -0
  32. data/lib/plurimath/math/function/glb.rb +3 -0
  33. data/lib/plurimath/math/function/hat.rb +4 -0
  34. data/lib/plurimath/math/function/int.rb +36 -6
  35. data/lib/plurimath/math/function/left.rb +10 -3
  36. data/lib/plurimath/math/function/lg.rb +3 -0
  37. data/lib/plurimath/math/function/lim.rb +5 -14
  38. data/lib/plurimath/math/function/limits.rb +8 -0
  39. data/lib/plurimath/math/function/ln.rb +3 -0
  40. data/lib/plurimath/math/function/log.rb +40 -22
  41. data/lib/plurimath/math/function/lub.rb +3 -0
  42. data/lib/plurimath/math/function/max.rb +3 -0
  43. data/lib/plurimath/math/function/mbox.rb +1 -3
  44. data/lib/plurimath/math/function/menclose.rb +2 -1
  45. data/lib/plurimath/math/function/min.rb +3 -0
  46. data/lib/plurimath/math/function/msgroup.rb +1 -4
  47. data/lib/plurimath/math/function/multiscript.rb +4 -9
  48. data/lib/plurimath/math/function/obrace.rb +8 -0
  49. data/lib/plurimath/math/function/overset.rb +3 -16
  50. data/lib/plurimath/math/function/power.rb +5 -8
  51. data/lib/plurimath/math/function/power_base.rb +9 -39
  52. data/lib/plurimath/math/function/prod.rb +34 -4
  53. data/lib/plurimath/math/function/right.rb +10 -3
  54. data/lib/plurimath/math/function/root.rb +6 -4
  55. data/lib/plurimath/math/function/rule.rb +1 -1
  56. data/lib/plurimath/math/function/sec.rb +3 -0
  57. data/lib/plurimath/math/function/sech.rb +3 -0
  58. data/lib/plurimath/math/function/sin.rb +3 -0
  59. data/lib/plurimath/math/function/sinh.rb +3 -0
  60. data/lib/plurimath/math/function/sqrt.rb +4 -3
  61. data/lib/plurimath/math/function/sum.rb +31 -27
  62. data/lib/plurimath/math/function/table.rb +48 -6
  63. data/lib/plurimath/math/function/tan.rb +3 -0
  64. data/lib/plurimath/math/function/tanh.rb +3 -0
  65. data/lib/plurimath/math/function/td.rb +4 -1
  66. data/lib/plurimath/math/function/ternary_function.rb +34 -17
  67. data/lib/plurimath/math/function/text.rb +11 -0
  68. data/lib/plurimath/math/function/tr.rb +1 -0
  69. data/lib/plurimath/math/function/ubrace.rb +8 -0
  70. data/lib/plurimath/math/function/ul.rb +2 -1
  71. data/lib/plurimath/math/function/unary_function.rb +10 -9
  72. data/lib/plurimath/math/function/underover.rb +10 -27
  73. data/lib/plurimath/math/function/underset.rb +3 -16
  74. data/lib/plurimath/math/number.rb +17 -3
  75. data/lib/plurimath/math/symbol.rb +20 -2
  76. data/lib/plurimath/math.rb +1 -1
  77. data/lib/plurimath/mathml/parser.rb +13 -3
  78. data/lib/plurimath/mathml/transform.rb +21 -1
  79. data/lib/plurimath/omml/parser.rb +8 -1
  80. data/lib/plurimath/omml/transform.rb +27 -13
  81. data/lib/plurimath/utility.rb +18 -8
  82. data/lib/plurimath/version.rb +1 -1
  83. metadata +3 -3
  84. data/lib/plurimath/math/base.rb +0 -15
@@ -21,9 +21,7 @@ module Plurimath
21
21
  end
22
22
 
23
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
24
+ omml_value
27
25
  end
28
26
  end
29
27
  end
@@ -31,7 +31,7 @@ module Plurimath
31
31
  borderpr = Utility.ox_element("borderBoxPr", namespace: "m")
32
32
  borderpr << Utility.pr_element("ctrl", true, namespace: "m")
33
33
  me = Utility.ox_element("e", namespace: "m")
34
- me << parameter_two.to_omml_without_math_tag if parameter_two
34
+ Utility.update_nodes(me, Array(parameter_two.to_omml_without_math_tag)) if parameter_two
35
35
  Utility.update_nodes(
36
36
  borderbox,
37
37
  [
@@ -39,6 +39,7 @@ module Plurimath
39
39
  me,
40
40
  ],
41
41
  )
42
+ [borderbox]
42
43
  end
43
44
  end
44
45
  end
@@ -6,6 +6,9 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Min < UnaryFunction
9
+ def validate_function_formula
10
+ false
11
+ end
9
12
  end
10
13
  end
11
14
  end
@@ -22,10 +22,7 @@ module Plurimath
22
22
  end
23
23
 
24
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
- )
25
+ omml_value
29
26
  end
30
27
 
31
28
  def to_html
@@ -8,21 +8,16 @@ module Plurimath
8
8
  def to_omml_without_math_tag
9
9
  pre_element = Utility.ox_element("sPre", namespace: "m")
10
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
11
  Utility.update_nodes(
18
12
  pre_element,
19
13
  [
20
14
  pr_element << Utility.pr_element("ctrl", true, namespace: "m"),
21
- sub_element,
22
- sup_element,
23
- e_element,
15
+ omml_parameter(parameter_two, tag_name: "sub"),
16
+ omml_parameter(parameter_three, tag_name: "sup"),
17
+ omml_parameter(parameter_one, tag_name: "e"),
24
18
  ],
25
19
  )
20
+ [pre_element]
26
21
  end
27
22
  end
28
23
  end
@@ -21,6 +21,14 @@ module Plurimath
21
21
  mo_tag
22
22
  end
23
23
  end
24
+
25
+ def tag_name
26
+ "underover"
27
+ end
28
+
29
+ def validate_function_formula
30
+ false
31
+ end
24
32
  end
25
33
 
26
34
  Overbrace = Obrace
@@ -20,31 +20,18 @@ module Plurimath
20
20
  end
21
21
 
22
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
23
  limupp = Utility.ox_element("limUpp", namespace: "m")
36
24
  limupppr = Utility.ox_element("limUppPr", namespace: "m")
37
25
  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
26
  Utility.update_nodes(
41
27
  limupp,
42
28
  [
43
29
  limupppr,
44
- me,
45
- lim,
30
+ omml_parameter(parameter_one, tag_name: "e"),
31
+ omml_parameter(parameter_two, tag_name: "lim"),
46
32
  ],
47
33
  )
34
+ [limupp]
48
35
  end
49
36
  end
50
37
  end
@@ -34,19 +34,16 @@ module Plurimath
34
34
  def to_omml_without_math_tag
35
35
  ssup_element = Utility.ox_element("sSup", namespace: "m")
36
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
37
+ suppr_element << Utility.pr_element("ctrl", true, namespace: "m")
41
38
  Utility.update_nodes(
42
39
  ssup_element,
43
40
  [
44
- suppr_element << Utility.pr_element("ctrl", true, namespace: "m"),
45
- e_element,
46
- sup_element,
41
+ suppr_element,
42
+ omml_parameter(parameter_one, tag_name: "e"),
43
+ omml_parameter(parameter_two, tag_name: "sup"),
47
44
  ],
48
45
  )
49
- ssup_element
46
+ [ssup_element]
50
47
  end
51
48
  end
52
49
  end
@@ -7,16 +7,12 @@ module Plurimath
7
7
  module Function
8
8
  class PowerBase < TernaryFunction
9
9
  def to_mathml_without_math_tag
10
- tag_name = (["ubrace", "obrace"].include?(parameter_one&.class_name) ? "underover" : "subsup")
11
- subsup_tag = Utility.ox_element("m#{tag_name}")
10
+ subsup_tag = Utility.ox_element("m#{parameter_one.tag_name}")
12
11
  new_arr = []
13
12
  new_arr << parameter_one.to_mathml_without_math_tag
14
13
  new_arr << parameter_two&.to_mathml_without_math_tag
15
14
  new_arr << parameter_three&.to_mathml_without_math_tag
16
- Utility.update_nodes(
17
- subsup_tag,
18
- new_arr,
19
- )
15
+ Utility.update_nodes(subsup_tag, new_arr)
20
16
  end
21
17
 
22
18
  def to_latex
@@ -45,8 +41,8 @@ module Plurimath
45
41
  narypr << Utility.pr_element("ctrl", true, namespace: "m")
46
42
  [
47
43
  narypr,
48
- sub_element,
49
- sup_element,
44
+ omml_parameter(parameter_two, tag_name: "sub"),
45
+ omml_parameter(parameter_three, tag_name: "sup"),
50
46
  ]
51
47
  end
52
48
 
@@ -60,17 +56,18 @@ module Plurimath
60
56
  ssubsup,
61
57
  [
62
58
  ssubsuppr,
63
- e_element,
64
- sub_element,
65
- sup_element,
59
+ omml_parameter(parameter_one, tag_name: "e"),
60
+ omml_parameter(parameter_two, tag_name: "sub"),
61
+ omml_parameter(parameter_three, tag_name: "sup"),
66
62
  ],
67
63
  )
64
+ [ssubsup]
68
65
  end
69
66
 
70
67
  protected
71
68
 
72
69
  def chr_value(narypr)
73
- first_value = parameter_one.to_omml_without_math_tag
70
+ first_value = Utility.html_entity_to_unicode(parameter_one&.nary_attr_value)
74
71
  return narypr if first_value == "∫"
75
72
 
76
73
  narypr << Utility.ox_element(
@@ -80,33 +77,6 @@ module Plurimath
80
77
  )
81
78
  end
82
79
 
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
80
  def hide_tags(nar)
111
81
  attr = { "m:val": "1" }
112
82
  if parameter_two.nil?
@@ -1,21 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "binary_function"
3
+ require_relative "ternary_function"
4
4
 
5
5
  module Plurimath
6
6
  module Math
7
7
  module Function
8
- class Prod < BinaryFunction
8
+ class Prod < TernaryFunction
9
9
  def to_asciimath
10
10
  first_value = "_#{wrapped(parameter_one)}" if parameter_one
11
11
  second_value = "^#{wrapped(parameter_two)}" if parameter_two
12
- "prod#{first_value}#{second_value}"
12
+ "prod#{first_value}#{second_value} #{parameter_three&.to_asciimath}".strip
13
13
  end
14
14
 
15
15
  def to_latex
16
16
  first_value = "_{#{parameter_one.to_latex}}" if parameter_one
17
17
  second_value = "^{#{parameter_two.to_latex}}" if parameter_two
18
- "\\prod#{first_value}#{second_value}"
18
+ "\\prod#{first_value}#{second_value} #{parameter_three&.to_latex}".strip
19
19
  end
20
20
 
21
21
  def to_mathml_without_math_tag
@@ -34,6 +34,15 @@ module Plurimath
34
34
  munderover_tag,
35
35
  value_array,
36
36
  )
37
+ return munderover_tag if parameter_three.nil?
38
+
39
+ Utility.update_nodes(
40
+ Utility.ox_element("mrow"),
41
+ [
42
+ munderover_tag,
43
+ parameter_three&.to_mathml_without_math_tag,
44
+ ].flatten.compact,
45
+ )
37
46
  else
38
47
  first_value
39
48
  end
@@ -44,6 +53,27 @@ module Plurimath
44
53
  second_value = "<sup>#{parameter_two.to_html}</sup>" if parameter_two
45
54
  "<i>&prod;</i>#{first_value}#{second_value}"
46
55
  end
56
+
57
+ def to_omml_without_math_tag
58
+ if all_values_exist?
59
+ nary = Utility.ox_element("nary", namespace: "m")
60
+ Utility.update_nodes(
61
+ nary,
62
+ [
63
+ narypr("∏"),
64
+ omml_parameter(parameter_one, tag_name: "sub"),
65
+ omml_parameter(parameter_two, tag_name: "sup"),
66
+ omml_parameter(parameter_three, tag_name: "e"),
67
+ ],
68
+ )
69
+ [nary]
70
+ else
71
+ r_tag = Utility.ox_element("r", namespace: "m")
72
+ t_tag = Utility.ox_element("t", namespace: "m")
73
+ r_tag << (t_tag << "&#x220f;")
74
+ [r_tag]
75
+ end
76
+ end
47
77
  end
48
78
  end
49
79
  end
@@ -17,9 +17,12 @@ module Plurimath
17
17
  end
18
18
 
19
19
  def to_omml_without_math_tag
20
- mt = Utility.ox_element("m:t")
21
- mt << parameter_one if parameter_one
22
- mt
20
+ mr = Utility.ox_element("m:r")
21
+ if parameter_one
22
+ mt = Utility.ox_element("m:t")
23
+ mr << (mt << parameter_one)
24
+ end
25
+ [mr]
23
26
  end
24
27
 
25
28
  def to_html
@@ -30,6 +33,10 @@ module Plurimath
30
33
  "\\right #{Latex::Constants::LEFT_RIGHT_PARENTHESIS.invert[parameter_one] || '.'}"
31
34
  end
32
35
 
36
+ def validate_function_formula
37
+ false
38
+ end
39
+
33
40
  protected
34
41
 
35
42
  def right_paren
@@ -29,15 +29,17 @@ module Plurimath
29
29
  pr_element = Utility.ox_element("radPr", namespace: "m")
30
30
  deg_element = Utility.ox_element("deg", namespace: "m")
31
31
  e_element = Utility.ox_element("e", namespace: "m")
32
+ Utility.update_nodes(e_element, parameter_one.to_omml_without_math_tag)
33
+ Utility.update_nodes(deg_element, parameter_two.to_omml_without_math_tag)
32
34
  Utility.update_nodes(
33
35
  rad_element,
34
36
  [
35
- pr_element << Utility.pr_element("ctrl", true, namespace: "m"),
36
- deg_element << parameter_two.to_omml_without_math_tag,
37
- e_element << parameter_one.to_omml_without_math_tag,
37
+ (pr_element << Utility.pr_element("ctrl", true, namespace: "m")),
38
+ deg_element,
39
+ e_element,
38
40
  ],
39
41
  )
40
- rad_element
42
+ [rad_element]
41
43
  end
42
44
  end
43
45
  end
@@ -21,7 +21,7 @@ module Plurimath
21
21
  end
22
22
 
23
23
  def to_omml_without_math_tag
24
- Utility.ox_element("m:e")
24
+ [Utility.ox_element("m:r") << Utility.ox_element("m:t")]
25
25
  end
26
26
 
27
27
  def to_html
@@ -6,6 +6,9 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Sec < UnaryFunction
9
+ def validate_function_formula
10
+ false
11
+ end
9
12
  end
10
13
  end
11
14
  end
@@ -6,6 +6,9 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Sech < UnaryFunction
9
+ def validate_function_formula
10
+ false
11
+ end
9
12
  end
10
13
  end
11
14
  end
@@ -6,6 +6,9 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Sin < UnaryFunction
9
+ def validate_function_formula
10
+ false
11
+ end
9
12
  end
10
13
  end
11
14
  end
@@ -6,6 +6,9 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Sinh < UnaryFunction
9
+ def validate_function_formula
10
+ false
11
+ end
9
12
  end
10
13
  end
11
14
  end
@@ -22,15 +22,16 @@ module Plurimath
22
22
  attributes: { "m:val": "1" },
23
23
  )
24
24
  e_element = Utility.ox_element("e", namespace: "m")
25
+ Utility.update_nodes(e_element, omml_value)
25
26
  Utility.update_nodes(
26
27
  rad_element,
27
28
  [
28
- pr_element << Utility.pr_element("ctrl", true, namespace: "m"),
29
+ (pr_element << Utility.pr_element("ctrl", true, namespace: "m")),
29
30
  Utility.ox_element("deg", namespace: "m"),
30
- e_element << parameter_one.to_omml_without_math_tag,
31
+ e_element,
31
32
  ],
32
33
  )
33
- rad_element
34
+ [rad_element]
34
35
  end
35
36
  end
36
37
  end
@@ -1,21 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "binary_function"
3
+ require_relative "ternary_function"
4
4
 
5
5
  module Plurimath
6
6
  module Math
7
7
  module Function
8
- class Sum < BinaryFunction
8
+ class Sum < TernaryFunction
9
9
  def to_asciimath
10
10
  first_value = "_#{wrapped(parameter_one)}" if parameter_one
11
11
  second_value = "^#{wrapped(parameter_two)}" if parameter_two
12
- "sum#{first_value}#{second_value}"
12
+ "sum#{first_value}#{second_value} #{parameter_three&.to_asciimath}".strip
13
13
  end
14
14
 
15
15
  def to_latex
16
16
  first_value = "_{#{parameter_one.to_latex}}" if parameter_one
17
17
  second_value = "^{#{parameter_two.to_latex}}" if parameter_two
18
- "\\sum#{first_value}#{second_value}"
18
+ "\\sum#{first_value}#{second_value} #{parameter_three&.to_latex}".strip
19
19
  end
20
20
 
21
21
  def to_mathml_without_math_tag
@@ -34,6 +34,15 @@ module Plurimath
34
34
  munderover_tag,
35
35
  value_array.insert(0, first_value),
36
36
  )
37
+ return munderover_tag if parameter_three.nil?
38
+
39
+ Utility.update_nodes(
40
+ Utility.ox_element("mrow"),
41
+ [
42
+ munderover_tag,
43
+ parameter_three&.to_mathml_without_math_tag,
44
+ ].flatten.compact,
45
+ )
37
46
  else
38
47
  first_value
39
48
  end
@@ -46,29 +55,24 @@ module Plurimath
46
55
  end
47
56
 
48
57
  def to_omml_without_math_tag
49
- limupp = Utility.ox_element("limLow", namespace: "m")
50
- limupppr = Utility.ox_element("limUppPr", namespace: "m")
51
- me = (Utility.ox_element("e", namespace: "m") << omml_first_value) if parameter_one
52
- lim = (Utility.ox_element("lim", namespace: "m") << omml_second_value) if parameter_two
53
- Utility.update_nodes(limupp, [limupppr, me, lim])
54
- end
55
-
56
- protected
57
-
58
- def omml_first_value
59
- return parameter_one&.to_omml_without_math_tag unless parameter_one.is_a?(Math::Symbol)
60
-
61
- mt = Utility.ox_element("t", namespace: "m")
62
- mt << parameter_one.to_omml_without_math_tag if parameter_one
63
- mt
64
- end
65
-
66
- def omml_second_value
67
- return parameter_two&.to_omml_without_math_tag unless parameter_two.is_a?(Math::Symbol)
68
-
69
- mt = Utility.ox_element("t", namespace: "m")
70
- mt << parameter_two.to_omml_without_math_tag if parameter_two
71
- mt
58
+ if all_values_exist?
59
+ nary = Utility.ox_element("nary", namespace: "m")
60
+ Utility.update_nodes(
61
+ nary,
62
+ [
63
+ narypr("∑"),
64
+ omml_parameter(parameter_one, tag_name: "sub"),
65
+ omml_parameter(parameter_two, tag_name: "sup"),
66
+ omml_parameter(parameter_three, tag_name: "e"),
67
+ ],
68
+ )
69
+ [nary]
70
+ else
71
+ r_tag = Utility.ox_element("r", namespace: "m")
72
+ t_tag = Utility.ox_element("t", namespace: "m")
73
+ r_tag << (t_tag << "&#x2211;")
74
+ [r_tag]
75
+ end
72
76
  end
73
77
  end
74
78
  end
@@ -1,11 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "ternary_function"
4
-
5
3
  module Plurimath
6
4
  module Math
7
5
  module Function
8
- class Table
6
+ class Table < Core
9
7
  attr_accessor :value, :open_paren, :close_paren, :options
10
8
 
11
9
  def initialize(value = nil,
@@ -75,7 +73,7 @@ module Plurimath
75
73
  if value.map { |d| d.parameter_one.length == 1 }.all?
76
74
  single_td_table
77
75
  else
78
- multiple_td_table
76
+ fenced_table(multiple_td_table)
79
77
  end
80
78
  end
81
79
 
@@ -173,6 +171,7 @@ module Plurimath
173
171
  eqarr << eqarrpr
174
172
  tr_value = value.map(&:to_omml_without_math_tag).flatten
175
173
  Utility.update_nodes(eqarr, tr_value.compact)
174
+ [eqarr]
176
175
  end
177
176
 
178
177
  def multiple_td_table
@@ -200,16 +199,59 @@ module Plurimath
200
199
  mpr << mcs
201
200
  mpr << ctrlpr
202
201
  mm_value = value&.map(&:to_omml_without_math_tag)
203
- Utility.update_nodes(mm, mm_value.insert(0, mpr).flatten)
202
+ Utility.update_nodes(
203
+ mm,
204
+ mm_value.insert(0, mpr).flatten,
205
+ )
206
+ [mm]
204
207
  end
205
208
 
206
209
  def norm_table(table_tag)
207
210
  mo_tag = Utility.ox_element("mo") << "&#x2225;"
208
211
  Utility.update_nodes(
209
212
  Utility.ox_element("mrow"),
210
- [mo_tag, table_tag, mo_tag],
213
+ [
214
+ mo_tag,
215
+ table_tag,
216
+ mo_tag,
217
+ ],
211
218
  )
212
219
  end
220
+
221
+ def fenced_table(ox_table)
222
+ return ox_table unless open_paren && close_paren
223
+
224
+ d_node = Utility.ox_element("d", namespace: "m")
225
+ e_node = Utility.ox_element("e", namespace: "m")
226
+ Utility.update_nodes(e_node, ox_table)
227
+ Utility.update_nodes(d_node, [mdpr_node, e_node])
228
+ [d_node]
229
+ end
230
+
231
+ def mdpr_node
232
+ begchr = Utility.ox_element("begChr", namespace: "m")
233
+ begchr.attributes["m:val"] = paren(open_paren)
234
+ endchr = Utility.ox_element("endChr", namespace: "m")
235
+ endchr.attributes["m:val"] = paren(close_paren)
236
+ sepchr = Utility.ox_element("sepChr", attributes: { "m:val": "" }, namespace: "m")
237
+ mgrow = Utility.ox_element("grow", namespace: "m")
238
+ mdpr = Utility.ox_element("dPr", namespace: "m")
239
+ Utility.update_nodes(
240
+ mdpr,
241
+ [
242
+ begchr,
243
+ endchr,
244
+ sepchr,
245
+ mgrow,
246
+ ],
247
+ )
248
+ end
249
+
250
+ def paren(parenthesis)
251
+ return "" if ["{:", ":}"].include?(parenthesis)
252
+
253
+ parenthesis
254
+ end
213
255
  end
214
256
  end
215
257
  end
@@ -6,6 +6,9 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Tan < UnaryFunction
9
+ def validate_function_formula
10
+ false
11
+ end
9
12
  end
10
13
  end
11
14
  end
@@ -6,6 +6,9 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Tanh < UnaryFunction
9
+ def validate_function_formula
10
+ false
11
+ end
9
12
  end
10
13
  end
11
14
  end
@@ -34,10 +34,13 @@ module Plurimath
34
34
 
35
35
  def to_omml_without_math_tag
36
36
  me = Utility.ox_element("e", namespace: "m")
37
+ return [me] if parameter_one&.empty?
38
+
37
39
  Utility.update_nodes(
38
40
  me,
39
- parameter_one&.map(&:to_omml_without_math_tag),
41
+ Formula.new(parameter_one).omml_content,
40
42
  )
43
+ [me]
41
44
  end
42
45
  end
43
46
  end