plurimath 0.6.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/lib/plurimath/asciimath/parse.rb +3 -2
  4. data/lib/plurimath/asciimath/transform.rb +32 -5
  5. data/lib/plurimath/latex/constants.rb +2 -1
  6. data/lib/plurimath/latex/transform.rb +9 -13
  7. data/lib/plurimath/math/core.rb +134 -20
  8. data/lib/plurimath/math/formula.rb +88 -18
  9. data/lib/plurimath/math/function/abs.rb +28 -15
  10. data/lib/plurimath/math/function/bar.rb +5 -0
  11. data/lib/plurimath/math/function/base.rb +14 -0
  12. data/lib/plurimath/math/function/binary_function.rb +2 -8
  13. data/lib/plurimath/math/function/ceil.rb +24 -9
  14. data/lib/plurimath/math/function/ddot.rb +6 -1
  15. data/lib/plurimath/math/function/deg.rb +4 -1
  16. data/lib/plurimath/math/function/det.rb +4 -1
  17. data/lib/plurimath/math/function/dim.rb +4 -1
  18. data/lib/plurimath/math/function/dot.rb +5 -0
  19. data/lib/plurimath/math/function/exp.rb +4 -1
  20. data/lib/plurimath/math/function/fenced.rb +25 -16
  21. data/lib/plurimath/math/function/floor.rb +23 -13
  22. data/lib/plurimath/math/function/font_style.rb +18 -8
  23. data/lib/plurimath/math/function/frac.rb +32 -18
  24. data/lib/plurimath/math/function/gcd.rb +4 -1
  25. data/lib/plurimath/math/function/glb.rb +8 -1
  26. data/lib/plurimath/math/function/hat.rb +16 -5
  27. data/lib/plurimath/math/function/hom.rb +4 -1
  28. data/lib/plurimath/math/function/inf.rb +16 -0
  29. data/lib/plurimath/math/function/int.rb +28 -9
  30. data/lib/plurimath/math/function/ker.rb +4 -1
  31. data/lib/plurimath/math/function/lcm.rb +17 -1
  32. data/lib/plurimath/math/function/left.rb +1 -1
  33. data/lib/plurimath/math/function/lg.rb +4 -1
  34. data/lib/plurimath/math/function/lim.rb +10 -0
  35. data/lib/plurimath/math/function/liminf.rb +4 -1
  36. data/lib/plurimath/math/function/limits.rb +22 -9
  37. data/lib/plurimath/math/function/limsup.rb +4 -1
  38. data/lib/plurimath/math/function/linebreak.rb +95 -0
  39. data/lib/plurimath/math/function/ln.rb +4 -1
  40. data/lib/plurimath/math/function/log.rb +21 -12
  41. data/lib/plurimath/math/function/longdiv.rb +19 -0
  42. data/lib/plurimath/math/function/lub.rb +4 -1
  43. data/lib/plurimath/math/function/max.rb +4 -1
  44. data/lib/plurimath/math/function/mbox.rb +8 -7
  45. data/lib/plurimath/math/function/merror.rb +12 -3
  46. data/lib/plurimath/math/function/min.rb +4 -1
  47. data/lib/plurimath/math/function/mod.rb +42 -15
  48. data/lib/plurimath/math/function/msgroup.rb +4 -0
  49. data/lib/plurimath/math/function/msline.rb +10 -0
  50. data/lib/plurimath/math/function/multiscript.rb +20 -0
  51. data/lib/plurimath/math/function/nary.rb +39 -5
  52. data/lib/plurimath/math/function/norm.rb +24 -15
  53. data/lib/plurimath/math/function/obrace.rb +5 -0
  54. data/lib/plurimath/math/function/oint.rb +42 -20
  55. data/lib/plurimath/math/function/over.rb +23 -10
  56. data/lib/plurimath/math/function/overset.rb +13 -10
  57. data/lib/plurimath/math/function/phantom.rb +24 -6
  58. data/lib/plurimath/math/function/power.rb +13 -4
  59. data/lib/plurimath/math/function/power_base.rb +28 -6
  60. data/lib/plurimath/math/function/prod.rb +33 -14
  61. data/lib/plurimath/math/function/right.rb +1 -1
  62. data/lib/plurimath/math/function/rule.rb +1 -1
  63. data/lib/plurimath/math/function/scarries.rb +14 -0
  64. data/lib/plurimath/math/function/semantics.rb +9 -0
  65. data/lib/plurimath/math/function/sqrt.rb +5 -0
  66. data/lib/plurimath/math/function/stackrel.rb +8 -0
  67. data/lib/plurimath/math/function/substack.rb +12 -51
  68. data/lib/plurimath/math/function/sum.rb +43 -20
  69. data/lib/plurimath/math/function/sup.rb +11 -2
  70. data/lib/plurimath/math/function/table/array.rb +1 -1
  71. data/lib/plurimath/math/function/table/matrix.rb +4 -0
  72. data/lib/plurimath/math/function/table.rb +11 -3
  73. data/lib/plurimath/math/function/td.rb +14 -4
  74. data/lib/plurimath/math/function/ternary_function.rb +8 -10
  75. data/lib/plurimath/math/function/text.rb +1 -1
  76. data/lib/plurimath/math/function/tilde.rb +5 -0
  77. data/lib/plurimath/math/function/tr.rb +1 -1
  78. data/lib/plurimath/math/function/ubrace.rb +5 -0
  79. data/lib/plurimath/math/function/unary_function.rb +72 -26
  80. data/lib/plurimath/math/function/underover.rb +25 -8
  81. data/lib/plurimath/math/function/underset.rb +19 -9
  82. data/lib/plurimath/math/function/vec.rb +5 -0
  83. data/lib/plurimath/math/number.rb +3 -3
  84. data/lib/plurimath/math/symbol.rb +13 -5
  85. data/lib/plurimath/mathml/parser.rb +2 -0
  86. data/lib/plurimath/mathml/transform.rb +23 -15
  87. data/lib/plurimath/omml/transform.rb +22 -10
  88. data/lib/plurimath/unitsml.rb +2 -1
  89. data/lib/plurimath/utility.rb +29 -28
  90. data/lib/plurimath/version.rb +1 -1
  91. metadata +3 -3
  92. data/lib/plurimath/math/function/scarry.rb +0 -12
@@ -25,28 +25,33 @@ module Plurimath
25
25
  end
26
26
 
27
27
  def to_mathml_without_math_tag
28
- mo_tag = Utility.ox_element("mo") << invert_unicode_symbols.to_s
28
+ mo_tag = ox_element("mo")
29
+ mo_tag << invert_unicode_symbols.to_s unless hide_function_name
29
30
  return mo_tag unless all_values_exist?
30
31
 
31
- value_array = [mo_tag]
32
- value_array << parameter_one&.to_mathml_without_math_tag
33
- value_array << parameter_two&.to_mathml_without_math_tag
34
- tag_name = if parameter_one && parameter_two
35
- "subsup"
36
- else
37
- parameter_one ? "sub" : "sup"
38
- end
39
- msubsup_tag = Utility.ox_element("m#{tag_name}")
40
- Utility.update_nodes(msubsup_tag, value_array)
41
- return msubsup_tag if parameter_three.nil?
32
+ if parameter_one || parameter_two
33
+ value_array = [
34
+ mo_tag,
35
+ parameter_one&.to_mathml_without_math_tag,
36
+ parameter_two&.to_mathml_without_math_tag,
37
+ ]
38
+ tag_name = if parameter_one && parameter_two
39
+ "subsup"
40
+ else
41
+ parameter_one ? "sub" : "sup"
42
+ end
43
+ msubsup_tag = ox_element("m#{tag_name}")
44
+ Utility.update_nodes(msubsup_tag, value_array)
45
+ return msubsup_tag unless parameter_three
42
46
 
43
- Utility.update_nodes(
44
- Utility.ox_element("mrow"),
45
- [
46
- msubsup_tag,
47
- parameter_three&.to_mathml_without_math_tag,
48
- ].compact,
49
- )
47
+ Utility.update_nodes(
48
+ ox_element("mrow"),
49
+ [
50
+ msubsup_tag,
51
+ parameter_three&.to_mathml_without_math_tag,
52
+ ],
53
+ )
54
+ end
50
55
  end
51
56
 
52
57
  def to_omml_without_math_tag(display_style)
@@ -55,7 +60,7 @@ module Plurimath
55
60
  Utility.update_nodes(
56
61
  nary,
57
62
  [
58
- narypr("∮", function_type: "subSup"),
63
+ narypr((hide_function_name ? "" : "∮"), function_type: "subSup"),
59
64
  omml_parameter(parameter_one, display_style, tag_name: "sub"),
60
65
  omml_parameter(parameter_two, display_style, tag_name: "sup"),
61
66
  omml_parameter(parameter_three, display_style, tag_name: "e"),
@@ -69,6 +74,23 @@ module Plurimath
69
74
  [r_tag]
70
75
  end
71
76
  end
77
+
78
+ def line_breaking(obj)
79
+ parameter_one&.line_breaking(obj)
80
+ if obj.value_exist?
81
+ oint = self.class.new(Utility.filter_values(obj.value), parameter_two, parameter_three)
82
+ oint.hide_function_name = true
83
+ obj.update(oint)
84
+ self.parameter_two = nil
85
+ self.parameter_three = nil
86
+ return
87
+ end
88
+
89
+ parameter_three&.line_breaking(obj)
90
+ if obj.value_exist?
91
+ obj.update(Utility.filter_values(obj.value))
92
+ end
93
+ end
72
94
  end
73
95
  end
74
96
  end
@@ -19,16 +19,12 @@ module Plurimath
19
19
  end
20
20
 
21
21
  def to_mathml_without_math_tag
22
- mover_tag = Utility.ox_element("mfrac")
23
- first_value = parameter_one&.to_mathml_without_math_tag
24
- second_value = parameter_two&.to_mathml_without_math_tag
25
- Utility.update_nodes(
26
- mover_tag,
27
- [
28
- first_value,
29
- second_value,
30
- ],
31
- )
22
+ tag_name = hide_function_name ? "mrow" : "mfrac"
23
+ mathml_value = [
24
+ parameter_one&.to_mathml_without_math_tag,
25
+ parameter_two&.to_mathml_without_math_tag,
26
+ ]
27
+ Utility.update_nodes(ox_element(tag_name), mathml_value)
32
28
  end
33
29
 
34
30
  def to_latex
@@ -50,6 +46,23 @@ module Plurimath
50
46
  )
51
47
  [f_element]
52
48
  end
49
+
50
+ def line_breaking(obj)
51
+ parameter_one&.line_breaking(obj)
52
+ if obj.value_exist?
53
+ obj.update(self.class.new(Utility.filter_values(obj.value), parameter_two))
54
+ self.parameter_two = nil
55
+ self.hide_function_name = true
56
+ return
57
+ end
58
+
59
+ parameter_two&.line_breaking(obj)
60
+ if obj.value_exist?
61
+ over = self.class.new(nil, Utility.filter_values(obj.value))
62
+ over.hide_function_name = true
63
+ obj.update(over)
64
+ end
65
+ end
53
66
  end
54
67
  end
55
68
  end
@@ -13,16 +13,11 @@ module Plurimath
13
13
  }.freeze
14
14
 
15
15
  def to_mathml_without_math_tag
16
- first_value = parameter_one&.to_mathml_without_math_tag
17
- second_value = parameter_two&.to_mathml_without_math_tag
18
- over_tag = Utility.ox_element("mover")
19
- Utility.update_nodes(
20
- over_tag,
21
- [
22
- second_value,
23
- first_value,
24
- ],
25
- )
16
+ value_array = [
17
+ validate_mathml_fields(parameter_two),
18
+ validate_mathml_fields(parameter_one),
19
+ ]
20
+ Utility.update_nodes(ox_element("mover"), value_array)
26
21
  end
27
22
 
28
23
  def to_omml_without_math_tag(display_style)
@@ -44,6 +39,14 @@ module Plurimath
44
39
  )
45
40
  [limupp]
46
41
  end
42
+
43
+ def line_breaking(obj)
44
+ parameter_two&.line_breaking(obj)
45
+ if obj.value_exist?
46
+ obj.update(self.class.new(parameter_one, Utility.filter_values(obj.value)))
47
+ self.parameter_one = nil
48
+ end
49
+ end
47
50
  end
48
51
  end
49
52
  end
@@ -7,24 +7,42 @@ module Plurimath
7
7
  module Function
8
8
  class Phantom < UnaryFunction
9
9
  def to_asciimath
10
- "#{Array.new(parameter_one&.length, '\ ').join}"
10
+ "#{Array.new(asciimath_value&.length, '\ ').join}"
11
11
  end
12
12
 
13
13
  def to_html
14
- "<i>#{Array.new(parameter_one&.length, '&nbsp;').join}</i>"
14
+ "<i style='visibility: hidden;'>#{parameter_one&.to_html}</i>"
15
15
  end
16
16
 
17
17
  def to_latex
18
- Array.new(parameter_one&.length, '\\ ').join
18
+ "\\#{class_name}{#{latex_value}}"
19
19
  end
20
20
 
21
21
  def to_mathml_without_math_tag
22
- phantom = Utility.ox_element("mphantom")
23
22
  Utility.update_nodes(
24
- phantom,
25
- parameter_one&.map(&:to_mathml_without_math_tag),
23
+ Utility.ox_element("mphantom"),
24
+ Array(mathml_value),
26
25
  )
27
26
  end
27
+
28
+ def to_omml_without_math_tag(display_style)
29
+ phant = Utility.ox_element("phant", namespace: "m")
30
+ e_tag = Utility.ox_element("e", namespace: "m")
31
+ Utility.update_nodes(e_tag, Array(omml_value(display_style)))
32
+ Utility.update_nodes(phant, [phant_pr, e_tag])
33
+ end
34
+
35
+ def line_breaking(obj)
36
+ custom_array_line_breaking(obj)
37
+ end
38
+
39
+ protected
40
+
41
+ def phant_pr
42
+ attributes = { val: "m:off" }
43
+ phant = Utility.ox_element("phant", namespace: "m")
44
+ phant << Utility.ox_element("show", namespace: "m", attributes: attributes)
45
+ end
28
46
  end
29
47
  end
30
48
  end
@@ -19,10 +19,11 @@ module Plurimath
19
19
 
20
20
  def to_mathml_without_math_tag
21
21
  tag_name = (["ubrace", "obrace"].include?(parameter_one&.class_name) ? "over" : "sup")
22
- sup_tag = Utility.ox_element("m#{tag_name}")
23
- mathml_value = [validate_mathml_fields(parameter_one)]
24
- mathml_value << validate_mathml_fields(parameter_two)
25
- Utility.update_nodes(sup_tag, mathml_value)
22
+ value_array = [
23
+ validate_mathml_fields(parameter_one),
24
+ validate_mathml_fields(parameter_two),
25
+ ]
26
+ Utility.update_nodes(ox_element("m#{tag_name}"), value_array)
26
27
  end
27
28
 
28
29
  def to_latex
@@ -51,6 +52,14 @@ module Plurimath
51
52
  )
52
53
  [ssup_element]
53
54
  end
55
+
56
+ def line_breaking(obj)
57
+ parameter_one&.line_breaking(obj)
58
+ if obj.value_exist?
59
+ obj.update(self.class.new(Utility.filter_values(obj.value), parameter_two))
60
+ self.parameter_two = nil
61
+ end
62
+ end
54
63
  end
55
64
  end
56
65
  end
@@ -14,11 +14,13 @@ module Plurimath
14
14
  }.freeze
15
15
 
16
16
  def to_mathml_without_math_tag
17
- subsup_tag = Utility.ox_element("m#{parameter_one.tag_name}")
18
- new_arr = []
19
- new_arr << validate_mathml_fields(parameter_one)
20
- new_arr << validate_mathml_fields(parameter_two)
21
- new_arr << validate_mathml_fields(parameter_three)
17
+ tag_name = parameter_one&.tag_name || "subsup"
18
+ subsup_tag = ox_element("m#{tag_name}")
19
+ new_arr = [
20
+ validate_mathml_fields(parameter_one),
21
+ validate_mathml_fields(parameter_two),
22
+ validate_mathml_fields(parameter_three),
23
+ ]
22
24
  Utility.update_nodes(subsup_tag, new_arr)
23
25
  end
24
26
 
@@ -37,7 +39,7 @@ module Plurimath
37
39
  end
38
40
 
39
41
  def to_omml_without_math_tag(display_style)
40
- return underover(display_style) if parameter_one.omml_tag_name == "undOvr"
42
+ return underover(display_style) if parameter_one&.omml_tag_name == "undOvr"
41
43
 
42
44
  ssubsup = Utility.ox_element("sSubSup", namespace: "m")
43
45
  ssubsuppr = Utility.ox_element("sSubSupPr", namespace: "m")
@@ -56,6 +58,26 @@ module Plurimath
56
58
  [ssubsup]
57
59
  end
58
60
 
61
+ def line_breaking(obj)
62
+ parameter_one&.line_breaking(obj)
63
+ if obj.value_exist?
64
+ obj.update(
65
+ self.class.new(Utility.filter_values(obj.value), parameter_two, parameter_three)
66
+ )
67
+ self.parameter_two = nil
68
+ self.parameter_three = nil
69
+ return
70
+ end
71
+
72
+ parameter_two.line_breaking(obj)
73
+ if obj.value_exist?
74
+ obj.update(
75
+ self.class.new(nil, Utility.filter_values(obj.value), parameter_three)
76
+ )
77
+ self.parameter_three = nil
78
+ end
79
+ end
80
+
59
81
  protected
60
82
 
61
83
  def hide_tags(nar)
@@ -25,17 +25,20 @@ module Plurimath
25
25
  end
26
26
 
27
27
  def to_mathml_without_math_tag
28
- first_value = Utility.ox_element("mo") << invert_unicode_symbols.to_s
28
+ first_value = ox_element("mo")
29
+ first_value << invert_unicode_symbols.to_s unless hide_function_name
29
30
  if parameter_one || parameter_two
30
- value_array = [first_value]
31
- value_array << parameter_one&.to_mathml_without_math_tag
32
- value_array << parameter_two&.to_mathml_without_math_tag
33
31
  tag_name = if parameter_two && parameter_one
34
32
  "underover"
35
33
  else
36
34
  parameter_one ? "under" : "over"
37
35
  end
38
- munderover_tag = Utility.ox_element("m#{tag_name}")
36
+ value_array = [
37
+ first_value,
38
+ parameter_one&.to_mathml_without_math_tag,
39
+ parameter_two&.to_mathml_without_math_tag,
40
+ ]
41
+ munderover_tag = ox_element("m#{tag_name}")
39
42
  Utility.update_nodes(
40
43
  munderover_tag,
41
44
  value_array,
@@ -64,21 +67,37 @@ module Plurimath
64
67
  return r_element("&#x220f;", rpr_tag: false) unless all_values_exist?
65
68
 
66
69
  nary = Utility.ox_element("nary", namespace: "m")
67
- Utility.update_nodes(
68
- nary,
69
- [
70
- narypr("∏"),
71
- omml_parameter(parameter_one, display_style, tag_name: "sub"),
72
- omml_parameter(parameter_two, display_style, tag_name: "sup"),
73
- omml_parameter(parameter_three, display_style, tag_name: "e"),
74
- ],
75
- )
70
+ Utility.update_nodes(nary, nary_values(display_style))
76
71
  [nary]
77
72
  end
78
73
 
74
+ def nary_values(display_style)
75
+ [
76
+ narypr(hide_function_name ? "" : nary_attr_value),
77
+ omml_parameter(parameter_one, display_style, tag_name: "sub"),
78
+ omml_parameter(parameter_two, display_style, tag_name: "sup"),
79
+ omml_parameter(parameter_three, display_style, tag_name: "e"),
80
+ ]
81
+ end
82
+
79
83
  def nary_attr_value
80
84
  "∏"
81
85
  end
86
+
87
+ def line_breaking(obj)
88
+ parameter_one&.line_breaking(obj)
89
+ if obj.value_exist?
90
+ prod = self.class.new(Utility.filter_values(obj.value), parameter_two, parameter_three)
91
+ prod.hide_function_name = true
92
+ obj.update(prod)
93
+ return
94
+ end
95
+
96
+ parameter_three&.line_breaking(obj)
97
+ if obj.value_exist?
98
+ obj.update(Utility.filter_values(obj.value))
99
+ end
100
+ end
82
101
  end
83
102
  end
84
103
  end
@@ -16,7 +16,7 @@ module Plurimath
16
16
  mo
17
17
  end
18
18
 
19
- def to_omml_without_math_tag(display_style)
19
+ def to_omml_without_math_tag(_)
20
20
  mr = Utility.ox_element("m:r")
21
21
  if parameter_one
22
22
  mt = Utility.ox_element("m:t")
@@ -27,7 +27,7 @@ module Plurimath
27
27
  Utility.ox_element("mi")
28
28
  end
29
29
 
30
- def to_omml_without_math_tag(display_style)
30
+ def to_omml_without_math_tag(_)
31
31
  [Utility.ox_element("m:r") << Utility.ox_element("m:t")]
32
32
  end
33
33
 
@@ -6,6 +6,20 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Scarries < UnaryFunction
9
+ def to_asciimath
10
+ asciimath_value
11
+ end
12
+
13
+ def to_latex
14
+ latex_value
15
+ end
16
+
17
+ def to_mathml_without_math_tag
18
+ scarries_tag = Utility.ox_element("mscarries")
19
+ Utility.update_nodes(scarries_tag, mathml_value)
20
+ scarries_tag
21
+ end
22
+
9
23
  def to_omml_without_math_tag(display_style)
10
24
  omml_value(display_style)
11
25
  end
@@ -33,6 +33,15 @@ module Plurimath
33
33
  Array(parameter_one.insert_t_tag(display_style))
34
34
  end
35
35
 
36
+ def line_breaking(obj)
37
+ parameter_one&.line_breaking(obj)
38
+ if obj.value_exist?
39
+ semantics = self.class.new(Utility.filter_values(obj.value), self.parameter_two)
40
+ self.parameter_two = nil
41
+ obj.update(semantics)
42
+ end
43
+ end
44
+
36
45
  protected
37
46
 
38
47
  def other_tags(array)
@@ -33,6 +33,11 @@ module Plurimath
33
33
  )
34
34
  [rad_element]
35
35
  end
36
+
37
+ def line_breaking(obj)
38
+ parameter_one&.line_breaking(obj)
39
+ obj.update(Utility.filter_values(obj.value)) if obj.value_exist?
40
+ end
36
41
  end
37
42
  end
38
43
  end
@@ -48,6 +48,14 @@ module Plurimath
48
48
  [limupp]
49
49
  end
50
50
 
51
+ def line_breaking(obj)
52
+ parameter_one.line_breaking(obj)
53
+ if obj.value_exist?
54
+ obj.update(self.class.new(Utility.filter_values(obj.value), parameter_two))
55
+ self.parameter_two = nil
56
+ end
57
+ end
58
+
51
59
  protected
52
60
 
53
61
  def wrapped(field)
@@ -1,73 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "binary_function"
3
+ require_relative "unary_function"
4
4
 
5
5
  module Plurimath
6
6
  module Math
7
7
  module Function
8
- class Substack < BinaryFunction
8
+ class Substack < UnaryFunction
9
9
  FUNCTION = {
10
10
  name: "substack",
11
11
  first_value: "above",
12
12
  second_value: "below",
13
13
  }.freeze
14
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
- "\\#{class_name}{#{first_value}#{second_value}}"
15
+ def to_asciimath
16
+ "{:#{parameter_one.compact.map(&:to_asciimath).join(",")}:}"
19
17
  end
20
18
 
21
- def to_mathml_without_math_tag
22
- value_array = []
23
- value_array << parameter_one.to_mathml_without_math_tag if parameter_one
24
- value_array << parameter_two.to_mathml_without_math_tag if parameter_two
25
- Utility.update_nodes(Utility.ox_element("mtable"), value_array)
19
+ def to_latex
20
+ "\\#{class_name}{#{parameter_one&.compact&.map(&:to_latex)&.join(" \\\\ ")}}"
26
21
  end
27
22
 
28
- def to_omml_without_math_tag(display_style)
29
- Array(
30
- Utility.update_nodes(
31
- mm_element,
32
- [
33
- omml_parameter(parameter_one, display_style, tag_name: "mr"),
34
- omml_parameter(parameter_two, display_style, tag_name: "mr"),
35
- ],
36
- ),
23
+ def to_mathml_without_math_tag
24
+ Utility.update_nodes(
25
+ Utility.ox_element("mtable"),
26
+ mathml_value,
37
27
  )
38
28
  end
39
29
 
40
- protected
41
-
42
- def mm_element
43
- mcjc = Utility.ox_element(
44
- "mcJc",
45
- namespace: "m",
46
- attributes: { "m:val": "center" },
47
- )
48
- mcount = Utility.ox_element(
49
- "count",
50
- namespace: "m",
51
- attributes: { "m:val": "1" },
52
- )
53
- mbasejc = Utility.ox_element(
54
- "baseJc",
55
- namespace: "m",
56
- attributes: { "m:val": "center", },
57
- )
58
- mplchide = Utility.ox_element(
59
- "plcHide",
60
- namespace: "m",
61
- attributes: { "m:val": "1" },
62
- )
63
- mm = Utility.ox_element("m", namespace: "m")
64
- mc = Utility.ox_element("mc", namespace: "m")
65
- mpr = Utility.ox_element("mpr", namespace: "m")
66
- mcs = Utility.ox_element("mcs", namespace: "m")
67
- mcpr = Utility.ox_element("mcPr", namespace: "m")
68
- mc << Utility.update_nodes(mcpr, [mcjc, mcount])
69
- mcs << mc
70
- Utility.update_nodes(mm, [mpr])
30
+ def to_omml_without_math_tag(display_style)
31
+ Table.new(parameter_one).to_omml_without_math_tag(display_style)
71
32
  end
72
33
  end
73
34
  end
@@ -26,27 +26,33 @@ module Plurimath
26
26
  end
27
27
 
28
28
  def to_mathml_without_math_tag
29
- first_value = Utility.ox_element("mo") << invert_unicode_symbols.to_s
30
- return first_value unless parameter_one || parameter_two
29
+ first_value = ox_element("mo")
30
+ first_value << invert_unicode_symbols.to_s unless hide_function_name
31
31
 
32
- value_array = [parameter_one&.to_mathml_without_math_tag]
33
- value_array << parameter_two&.to_mathml_without_math_tag
34
- tag_name = if parameter_two && parameter_one
35
- "underover"
36
- else
37
- parameter_one ? "under" : "over"
38
- end
39
- munderover_tag = Utility.ox_element("m#{tag_name}")
40
- Utility.update_nodes(munderover_tag, value_array.insert(0, first_value))
41
- return munderover_tag if parameter_three.nil?
32
+ if parameter_one || parameter_two
33
+ value_array = [
34
+ parameter_one&.to_mathml_without_math_tag,
35
+ parameter_two&.to_mathml_without_math_tag,
36
+ ]
37
+ tag_name = if parameter_two && parameter_one
38
+ "underover"
39
+ else
40
+ parameter_one ? "under" : "over"
41
+ end
42
+ munderover_tag = ox_element("m#{tag_name}")
43
+ Utility.update_nodes(munderover_tag, value_array.insert(0, first_value))
44
+ return munderover_tag if parameter_three.nil?
42
45
 
43
- Utility.update_nodes(
44
- Utility.ox_element("mrow"),
45
- [
46
- munderover_tag,
47
- parameter_three&.to_mathml_without_math_tag,
48
- ].flatten.compact,
49
- )
46
+ Utility.update_nodes(
47
+ ox_element("mrow"),
48
+ [
49
+ munderover_tag,
50
+ parameter_three&.to_mathml_without_math_tag,
51
+ ],
52
+ )
53
+ else
54
+ first_value
55
+ end
50
56
  end
51
57
 
52
58
  def to_html
@@ -62,7 +68,7 @@ module Plurimath
62
68
  Utility.update_nodes(
63
69
  nary,
64
70
  [
65
- narypr("∑"),
71
+ narypr(hide_function_name ? "" : "∑"),
66
72
  omml_parameter(parameter_one, display_style, tag_name: "sub"),
67
73
  omml_parameter(parameter_two, display_style, tag_name: "sup"),
68
74
  omml_parameter(parameter_three, display_style, tag_name: "e"),
@@ -78,6 +84,23 @@ module Plurimath
78
84
  def nary_attr_value
79
85
  "∑"
80
86
  end
87
+
88
+ def line_breaking(obj)
89
+ parameter_one&.line_breaking(obj)
90
+ if obj.value_exist?
91
+ sum = self.class.new(Utility.filter_values(obj.value), parameter_two, parameter_three)
92
+ sum.hide_function_name = true
93
+ obj.update(sum)
94
+ self.parameter_two = nil
95
+ self.parameter_three = nil
96
+ return
97
+ end
98
+
99
+ parameter_three&.line_breaking(obj)
100
+ if obj.value_exist?
101
+ obj.update(Utility.filter_values(obj.value))
102
+ end
103
+ end
81
104
  end
82
105
  end
83
106
  end
@@ -7,11 +7,20 @@ module Plurimath
7
7
  module Function
8
8
  class Sup < UnaryFunction
9
9
  def to_mathml_without_math_tag
10
- Utility.ox_element("mo") << "sup"
10
+ mo_tag = Utility.ox_element("mo") << "sup"
11
+ first_value = mathml_value
12
+ first_value = mathml_value&.insert(0, mo_tag) unless hide_function_name
13
+ Utility.update_nodes(
14
+ ox_element("mrow"),
15
+ first_value,
16
+ )
11
17
  end
12
18
 
13
19
  def to_omml_without_math_tag(display_style)
14
- [r_element("sup", rpr_tag: false), omml_value(display_style)]
20
+ array = []
21
+ array << r_element("sup", rpr_tag: false) unless hide_function_name
22
+ array += Array(omml_value(display_style))
23
+ array
15
24
  end
16
25
  end
17
26
  end
@@ -15,7 +15,7 @@ module Plurimath
15
15
  end
16
16
 
17
17
  def to_latex
18
- "\\begin{array}#{array_args}#{latex_content}\\end{array}"
18
+ "\\begin{array}#{array_args || '.'}#{latex_content}\\end{array}"
19
19
  end
20
20
 
21
21
  def array_args