plurimath 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/Latex-Supported-Data.adoc +1 -0
  4. data/lib/plurimath/asciimath/parse.rb +1 -1
  5. data/lib/plurimath/asciimath/transform.rb +2 -6
  6. data/lib/plurimath/latex/constants.rb +2 -0
  7. data/lib/plurimath/math/core.rb +38 -6
  8. data/lib/plurimath/math/formula.rb +60 -6
  9. data/lib/plurimath/math/function/abs.rb +4 -0
  10. data/lib/plurimath/math/function/arg.rb +22 -0
  11. data/lib/plurimath/math/function/bar.rb +4 -0
  12. data/lib/plurimath/math/function/base.rb +49 -0
  13. data/lib/plurimath/math/function/binary_function.rb +6 -0
  14. data/lib/plurimath/math/function/cancel.rb +5 -0
  15. data/lib/plurimath/math/function/ceil.rb +6 -0
  16. data/lib/plurimath/math/function/color.rb +20 -1
  17. data/lib/plurimath/math/function/ddot.rb +4 -0
  18. data/lib/plurimath/math/function/dot.rb +5 -0
  19. data/lib/plurimath/math/function/fenced.rb +98 -7
  20. data/lib/plurimath/math/function/floor.rb +6 -0
  21. data/lib/plurimath/math/function/font_style/monospace.rb +4 -0
  22. data/lib/plurimath/math/function/font_style.rb +31 -6
  23. data/lib/plurimath/math/function/frac.rb +69 -15
  24. data/lib/plurimath/math/function/hat.rb +4 -0
  25. data/lib/plurimath/math/function/inf.rb +30 -0
  26. data/lib/plurimath/math/function/int.rb +47 -1
  27. data/lib/plurimath/math/function/intent.rb +22 -0
  28. data/lib/plurimath/math/function/left.rb +4 -0
  29. data/lib/plurimath/math/function/lim.rb +6 -0
  30. data/lib/plurimath/math/function/limits.rb +28 -0
  31. data/lib/plurimath/math/function/linebreak.rb +5 -0
  32. data/lib/plurimath/math/function/log.rb +27 -20
  33. data/lib/plurimath/math/function/longdiv.rb +4 -0
  34. data/lib/plurimath/math/function/mbox.rb +4 -0
  35. data/lib/plurimath/math/function/menclose.rb +74 -5
  36. data/lib/plurimath/math/function/merror.rb +2 -0
  37. data/lib/plurimath/math/function/mglyph.rb +64 -0
  38. data/lib/plurimath/math/function/mlabeledtr.rb +29 -0
  39. data/lib/plurimath/math/function/mod.rb +4 -0
  40. data/lib/plurimath/math/function/mpadded.rb +84 -0
  41. data/lib/plurimath/math/function/ms.rb +33 -0
  42. data/lib/plurimath/math/function/msgroup.rb +4 -0
  43. data/lib/plurimath/math/function/msline.rb +2 -4
  44. data/lib/plurimath/math/function/multiscript.rb +70 -6
  45. data/lib/plurimath/math/function/nary.rb +69 -10
  46. data/lib/plurimath/math/function/none.rb +25 -0
  47. data/lib/plurimath/math/function/norm.rb +6 -0
  48. data/lib/plurimath/math/function/obrace.rb +4 -0
  49. data/lib/plurimath/math/function/oint.rb +25 -1
  50. data/lib/plurimath/math/function/over.rb +6 -0
  51. data/lib/plurimath/math/function/overset.rb +46 -1
  52. data/lib/plurimath/math/function/phantom.rb +18 -2
  53. data/lib/plurimath/math/function/power.rb +37 -0
  54. data/lib/plurimath/math/function/power_base.rb +45 -18
  55. data/lib/plurimath/math/function/prod.rb +46 -0
  56. data/lib/plurimath/math/function/right.rb +4 -0
  57. data/lib/plurimath/math/function/root.rb +9 -1
  58. data/lib/plurimath/math/function/rule.rb +4 -0
  59. data/lib/plurimath/math/function/sqrt.rb +7 -1
  60. data/lib/plurimath/math/function/stackrel.rb +6 -0
  61. data/lib/plurimath/math/function/substack.rb +4 -0
  62. data/lib/plurimath/math/function/sum.rb +45 -24
  63. data/lib/plurimath/math/function/table/bmatrix.rb +18 -5
  64. data/lib/plurimath/math/function/table/cases.rb +24 -0
  65. data/lib/plurimath/math/function/table/eqarray.rb +24 -0
  66. data/lib/plurimath/math/function/table/matrix.rb +23 -3
  67. data/lib/plurimath/math/function/table/pmatrix.rb +4 -0
  68. data/lib/plurimath/math/function/table/vmatrix.rb +10 -0
  69. data/lib/plurimath/math/function/table.rb +58 -7
  70. data/lib/plurimath/math/function/td.rb +9 -0
  71. data/lib/plurimath/math/function/ternary_function.rb +14 -1
  72. data/lib/plurimath/math/function/text.rb +6 -0
  73. data/lib/plurimath/math/function/tilde.rb +4 -0
  74. data/lib/plurimath/math/function/tr.rb +9 -0
  75. data/lib/plurimath/math/function/ubrace.rb +5 -0
  76. data/lib/plurimath/math/function/ul.rb +4 -0
  77. data/lib/plurimath/math/function/unary_function.rb +4 -0
  78. data/lib/plurimath/math/function/underover.rb +14 -0
  79. data/lib/plurimath/math/function/underset.rb +49 -1
  80. data/lib/plurimath/math/function/vec.rb +4 -0
  81. data/lib/plurimath/math/number.rb +33 -3
  82. data/lib/plurimath/math/symbol.rb +68 -3
  83. data/lib/plurimath/math.rb +3 -2
  84. data/lib/plurimath/mathml/constants.rb +16 -0
  85. data/lib/plurimath/mathml/parser.rb +42 -2
  86. data/lib/plurimath/mathml/transform.rb +80 -29
  87. data/lib/plurimath/omml/parser.rb +8 -0
  88. data/lib/plurimath/omml/transform.rb +29 -26
  89. data/lib/plurimath/unicode_math/constants.rb +1015 -0
  90. data/lib/plurimath/unicode_math/parse.rb +233 -0
  91. data/lib/plurimath/unicode_math/parser.rb +58 -0
  92. data/lib/plurimath/unicode_math/parsing_rules/absence_rules.rb +138 -0
  93. data/lib/plurimath/unicode_math/parsing_rules/common_rules.rb +114 -0
  94. data/lib/plurimath/unicode_math/parsing_rules/constants_rules.rb +102 -0
  95. data/lib/plurimath/unicode_math/parsing_rules/helper.rb +19 -0
  96. data/lib/plurimath/unicode_math/parsing_rules/masked.rb +62 -0
  97. data/lib/plurimath/unicode_math/parsing_rules/sub_sup.rb +254 -0
  98. data/lib/plurimath/unicode_math/transform.rb +3831 -0
  99. data/lib/plurimath/{unicode.rb → unicode_math.rb} +2 -2
  100. data/lib/plurimath/unitsml.rb +14 -1
  101. data/lib/plurimath/utility.rb +346 -11
  102. data/lib/plurimath/version.rb +1 -1
  103. data/lib/plurimath/xml_engine/oga.rb +5 -0
  104. data/lib/plurimath/xml_engine/ox.rb +5 -0
  105. metadata +23 -3
@@ -32,6 +32,14 @@ module Plurimath
32
32
  Utility.update_nodes(phant, [phant_pr, e_tag])
33
33
  end
34
34
 
35
+ def to_unicodemath
36
+ if parameter_one.is_a?(Math::Function::Mpadded) && parameter_one&.options&.dig(:phantom)
37
+ "#{phantom_unicode}#{unicodemath_parens(parameter_one.parameter_one)}"
38
+ else
39
+ "⟡#{unicodemath_parens(parameter_one)}"
40
+ end
41
+ end
42
+
35
43
  def line_breaking(obj)
36
44
  custom_array_line_breaking(obj)
37
45
  end
@@ -39,10 +47,18 @@ module Plurimath
39
47
  protected
40
48
 
41
49
  def phant_pr
42
- attributes = { val: "m:off" }
43
- phant = Utility.ox_element("phant", namespace: "m")
50
+ attributes = { "m:val": "off" }
51
+ phant = Utility.ox_element("phantPr", namespace: "m")
44
52
  phant << Utility.ox_element("show", namespace: "m", attributes: attributes)
45
53
  end
54
+
55
+ def phantom_symbol
56
+ UnicodeMath::Constants::PHANTOM_SYMBOLS.key(parameter_one.options)
57
+ end
58
+
59
+ def phantom_unicode
60
+ UnicodeMath::Constants::UNARY_SYMBOLS[phantom_symbol]
61
+ end
46
62
  end
47
63
  end
48
64
  end
@@ -53,6 +53,22 @@ module Plurimath
53
53
  [ssup_element]
54
54
  end
55
55
 
56
+ def to_unicodemath
57
+ if accented?(parameter_two)
58
+ "#{parameter_one.to_unicodemath}#{parameter_two.to_unicodemath}"
59
+ elsif parameter_two.mini_sized?
60
+ "#{parameter_one.to_unicodemath}#{parameter_two.to_unicodemath}"
61
+ else
62
+ first_value = parameter_one.to_unicodemath if parameter_one
63
+ second_value = if parameter_two.is_a?(self.class)
64
+ "^#{parameter_two.to_unicodemath}"
65
+ else
66
+ "^#{unicodemath_parens(parameter_two)}"
67
+ end
68
+ "#{first_value}#{second_value}"
69
+ end
70
+ end
71
+
56
72
  def line_breaking(obj)
57
73
  parameter_one&.line_breaking(obj)
58
74
  if obj.value_exist?
@@ -60,6 +76,27 @@ module Plurimath
60
76
  self.parameter_two = nil
61
77
  end
62
78
  end
79
+
80
+ def new_nary_function(fourth_value)
81
+ Nary.new(parameter_one, nil, parameter_two, fourth_value)
82
+ end
83
+
84
+ def is_nary_function?
85
+ parameter_one.is_nary_function? || parameter_one.is_nary_symbol?
86
+ end
87
+
88
+ def prime_unicode?(field)
89
+ return unless field.is_a?(Math::Symbol)
90
+
91
+ UnicodeMath::Constants::PREFIXED_PRIMES.any? { |prefix, prime| field.value.include?(prime) || field.value.include?("&#x27;") }
92
+ end
93
+
94
+ protected
95
+
96
+ def accented?(field)
97
+ (field.is_a?(Math::Symbol) && prime_unicode?(field)) ||
98
+ (field.is_a?(Math::Function::Power) && prime_unicode?(field.parameter_one))
99
+ end
63
100
  end
64
101
  end
65
102
  end
@@ -43,9 +43,7 @@ module Plurimath
43
43
 
44
44
  ssubsup = Utility.ox_element("sSubSup", namespace: "m")
45
45
  ssubsuppr = Utility.ox_element("sSubSupPr", namespace: "m")
46
- ssubsuppr << hide_tags(
47
- Utility.pr_element("ctrl", true, namespace: "m"),
48
- )
46
+ ssubsuppr << Utility.pr_element("ctrl", true, namespace: "m")
49
47
  Utility.update_nodes(
50
48
  ssubsup,
51
49
  [
@@ -58,6 +56,16 @@ module Plurimath
58
56
  [ssubsup]
59
57
  end
60
58
 
59
+ def to_unicodemath
60
+ first_value = sub_value if parameter_two
61
+ second_value = sup_value if parameter_three
62
+ if prime_unicode?(parameter_three)
63
+ "#{parameter_one&.to_unicodemath}#{second_value}#{first_value}"
64
+ else
65
+ "#{parameter_one&.to_unicodemath}#{first_value}#{second_value}"
66
+ end
67
+ end
68
+
61
69
  def line_breaking(obj)
62
70
  parameter_one&.line_breaking(obj)
63
71
  if obj.value_exist?
@@ -78,25 +86,44 @@ module Plurimath
78
86
  end
79
87
  end
80
88
 
89
+ def new_nary_function(fourth_value)
90
+ Nary.new(parameter_one, parameter_two, parameter_three, fourth_value)
91
+ end
92
+
93
+ def is_nary_function?
94
+ parameter_one.is_nary_function? || parameter_one.is_nary_symbol?
95
+ end
96
+
97
+ def mmultiscript
98
+ [
99
+ validate_mathml_fields(parameter_one),
100
+ validate_mathml_fields(parameter_two),
101
+ validate_mathml_fields(parameter_three),
102
+ ]
103
+ end
104
+
81
105
  protected
82
106
 
83
- def hide_tags(nar)
84
- attr = { "m:val": "1" }
85
- if parameter_two.nil?
86
- nar << Utility.ox_element(
87
- "subHide",
88
- namespace: "m",
89
- attributes: attr,
90
- )
107
+ def sup_value
108
+ if parameter_three.mini_sized? || prime_unicode?(parameter_three)
109
+ parameter_three.to_unicodemath
110
+ elsif parameter_three.is_a?(Math::Function::Power)
111
+ "^#{parameter_three.to_unicodemath}"
112
+ elsif parameter_one.is_a?(Math::Function::Power) && parameter_one&.prime_unicode?(parameter_one&.parameter_two)
113
+ "^#{parameter_three.to_unicodemath}"
114
+ else
115
+ "^#{unicodemath_parens(parameter_three)}"
91
116
  end
92
- if parameter_three.nil?
93
- nar << Utility.ox_element(
94
- "supHide",
95
- namespace: "m",
96
- attributes: attr,
97
- )
117
+ end
118
+
119
+ def sub_value
120
+ if parameter_two.mini_sized?
121
+ parameter_two.to_unicodemath
122
+ elsif parameter_two.is_a?(Math::Function::Base)
123
+ "_#{parameter_two.to_unicodemath}"
124
+ else
125
+ "_#{unicodemath_parens(parameter_two)}"
98
126
  end
99
- nar
100
127
  end
101
128
  end
102
129
  end
@@ -6,12 +6,25 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Prod < TernaryFunction
9
+ attr_accessor :options
9
10
  FUNCTION = {
10
11
  name: "prod",
11
12
  first_value: "subscript",
12
13
  second_value: "supscript",
13
14
  }.freeze
14
15
 
16
+ def initialize(parameter_one = nil,
17
+ parameter_two = nil,
18
+ parameter_three = nil,
19
+ options = {})
20
+ super(parameter_one, parameter_two, parameter_three)
21
+ @options = options unless options&.empty?
22
+ end
23
+
24
+ def ==(object)
25
+ super(object) && object.options == options
26
+ end
27
+
15
28
  def to_asciimath
16
29
  first_value = "_#{wrapped(parameter_one)}" if parameter_one
17
30
  second_value = "^#{wrapped(parameter_two)}" if parameter_two
@@ -71,6 +84,13 @@ module Plurimath
71
84
  [nary]
72
85
  end
73
86
 
87
+ def to_unicodemath
88
+ first_value = sub_value if parameter_one
89
+ second_value = sup_value if parameter_two
90
+ mask = options&.dig(:mask) if options&.key?(:mask)
91
+ "#{nary_attr_value}#{mask}#{first_value}#{second_value}#{naryand_value(parameter_three)}"
92
+ end
93
+
74
94
  def nary_values(display_style)
75
95
  [
76
96
  narypr(hide_function_name ? "" : nary_attr_value),
@@ -98,6 +118,32 @@ module Plurimath
98
118
  obj.update(Utility.filter_values(obj.value))
99
119
  end
100
120
  end
121
+
122
+ def is_nary_function?
123
+ true
124
+ end
125
+
126
+ protected
127
+
128
+ def sup_value
129
+ if parameter_two&.mini_sized? || prime_unicode?(parameter_two)
130
+ parameter_two.to_unicodemath
131
+ elsif parameter_two.is_a?(Math::Function::Power)
132
+ "^#{parameter_two.to_unicodemath}"
133
+ else
134
+ "^#{unicodemath_parens(parameter_two)}"
135
+ end
136
+ end
137
+
138
+ def sub_value
139
+ if parameter_one&.mini_sized?
140
+ parameter_one.to_unicodemath
141
+ elsif parameter_one.is_a?(Math::Function::Base)
142
+ "_#{parameter_one.to_unicodemath}"
143
+ else
144
+ "_#{unicodemath_parens(parameter_one)}"
145
+ end
146
+ end
101
147
  end
102
148
  end
103
149
  end
@@ -33,6 +33,10 @@ module Plurimath
33
33
  "\\right #{latex_paren}"
34
34
  end
35
35
 
36
+ def to_unicodemath
37
+ parameter_one
38
+ end
39
+
36
40
  def validate_function_formula
37
41
  false
38
42
  end
@@ -31,18 +31,26 @@ module Plurimath
31
31
  end
32
32
 
33
33
  def to_omml_without_math_tag(display_style)
34
+ attribute = { "m:val": "off" }
34
35
  rad_element = Utility.ox_element("rad", namespace: "m")
35
36
  pr_element = Utility.ox_element("radPr", namespace: "m")
37
+ pr_element << Utility.ox_element("degHide", namespace: "m", attributes: attribute)
36
38
  Utility.update_nodes(
37
39
  rad_element,
38
40
  [
39
- (pr_element << Utility.pr_element("ctrl", true, namespace: "m")),
41
+ pr_element,
40
42
  omml_parameter(parameter_two, display_style, tag_name: "deg"),
41
43
  omml_parameter(parameter_one, display_style, tag_name: "e"),
42
44
  ],
43
45
  )
44
46
  [rad_element]
45
47
  end
48
+
49
+ def to_unicodemath
50
+ first_value = parameter_one.to_unicodemath if parameter_one
51
+ second_value = parameter_two.to_unicodemath if parameter_two
52
+ "√(#{first_value}&#{second_value})"
53
+ end
46
54
  end
47
55
  end
48
56
  end
@@ -34,6 +34,10 @@ module Plurimath
34
34
  def to_html
35
35
  ""
36
36
  end
37
+
38
+ def to_unicodemath
39
+ ""
40
+ end
37
41
  end
38
42
  end
39
43
  end
@@ -6,6 +6,8 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Sqrt < UnaryFunction
9
+ attr_accessor :options
10
+
9
11
  def to_mathml_without_math_tag
10
12
  sqrt_tag = Utility.ox_element("msqrt")
11
13
  Utility.update_nodes(
@@ -21,7 +23,7 @@ module Plurimath
21
23
  pr_element << Utility.ox_element(
22
24
  "degHide",
23
25
  namespace: "m",
24
- attributes: { "m:val": "1" },
26
+ attributes: { "m:val": "on" },
25
27
  )
26
28
  Utility.update_nodes(
27
29
  rad_element,
@@ -38,6 +40,10 @@ module Plurimath
38
40
  parameter_one&.line_breaking(obj)
39
41
  obj.update(Utility.filter_values(obj.value)) if obj.value_exist?
40
42
  end
43
+
44
+ def to_unicodemath
45
+ "√#{unicodemath_parens(parameter_one)}"
46
+ end
41
47
  end
42
48
  end
43
49
  end
@@ -48,6 +48,12 @@ module Plurimath
48
48
  [limupp]
49
49
  end
50
50
 
51
+ def to_unicodemath
52
+ first_value = "(#{parameter_one&.to_unicodemath})"
53
+ second_value = "(#{parameter_two&.to_unicodemath})"
54
+ "#{second_value}┴#{first_value}"
55
+ end
56
+
51
57
  def line_breaking(obj)
52
58
  parameter_one.line_breaking(obj)
53
59
  if obj.value_exist?
@@ -30,6 +30,10 @@ module Plurimath
30
30
  def to_omml_without_math_tag(display_style)
31
31
  Table.new(parameter_one).to_omml_without_math_tag(display_style)
32
32
  end
33
+
34
+ def to_unicodemath
35
+ "■(#{parameter_one.compact.map(&:to_unicodemath).join("@")})"
36
+ end
33
37
  end
34
38
  end
35
39
  end
@@ -6,6 +6,7 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Sum < TernaryFunction
9
+ attr_accessor :options
9
10
  FUNCTION = {
10
11
  name: "summation",
11
12
  first_value: "subscript",
@@ -13,6 +14,18 @@ module Plurimath
13
14
  third_value: "term",
14
15
  }.freeze
15
16
 
17
+ def initialize(parameter_one = nil,
18
+ parameter_two = nil,
19
+ parameter_three = nil,
20
+ options = {})
21
+ super(parameter_one, parameter_two, parameter_three)
22
+ @options = options unless options&.empty?
23
+ end
24
+
25
+ def ==(object)
26
+ super(object) && object.options == options
27
+ end
28
+
16
29
  def to_asciimath
17
30
  first_value = "_#{wrapped(parameter_one)}" if parameter_one
18
31
  second_value = "^#{wrapped(parameter_two)}" if parameter_two
@@ -28,31 +41,28 @@ module Plurimath
28
41
  def to_mathml_without_math_tag
29
42
  first_value = ox_element("mo")
30
43
  first_value << invert_unicode_symbols.to_s unless hide_function_name
44
+ return first_value unless all_values_exist?
31
45
 
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?
45
-
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
46
+ value_array = [
47
+ parameter_one&.to_mathml_without_math_tag,
48
+ parameter_two&.to_mathml_without_math_tag,
49
+ ]
50
+ tag_name = if parameter_two && parameter_one
51
+ "underover"
52
+ else
53
+ parameter_one ? "under" : "over"
54
+ end
55
+ munderover_tag = Utility.ox_element("m#{tag_name}")
56
+ Utility.update_nodes(munderover_tag, value_array.insert(0, first_value))
57
+ return munderover_tag if parameter_three.nil?
58
+
59
+ Utility.update_nodes(
60
+ ox_element("mrow"),
61
+ [
62
+ munderover_tag,
63
+ parameter_three&.to_mathml_without_math_tag,
64
+ ],
65
+ )
56
66
  end
57
67
 
58
68
  def to_html
@@ -61,6 +71,13 @@ module Plurimath
61
71
  "<i>&sum;</i>#{first_value}#{second_value}"
62
72
  end
63
73
 
74
+ def to_unicodemath
75
+ first_value = "_#{unicodemath_parens(parameter_one)}" if parameter_one
76
+ second_value = "^#{unicodemath_parens(parameter_two)}" if parameter_two
77
+ mask = options&.dig(:mask) if options&.key?(:mask)
78
+ "∑#{mask}#{first_value}#{second_value}#{naryand_value(parameter_three)}"
79
+ end
80
+
64
81
  def to_omml_without_math_tag(display_style)
65
82
  return r_element("&#x2211;", rpr_tag: false) unless all_values_exist?
66
83
 
@@ -101,6 +118,10 @@ module Plurimath
101
118
  obj.update(Utility.filter_values(obj.value))
102
119
  end
103
120
  end
121
+
122
+ def is_nary_function?
123
+ true
124
+ end
104
125
  end
105
126
  end
106
127
  end
@@ -24,11 +24,24 @@ module Plurimath
24
24
  table_tag,
25
25
  value&.map(&:to_mathml_without_math_tag),
26
26
  )
27
- attributes = {
28
- open: mathml_parenthesis(open_paren),
29
- close: mathml_parenthesis(close_paren),
30
- }
31
- Utility.ox_element("mfenced", attributes: attributes) << table_tag
27
+ Utility.update_nodes(
28
+ Utility.ox_element("mrow"),
29
+ [
30
+ mo_element(mathml_parenthesis(open_paren)),
31
+ table_tag,
32
+ mo_element(mathml_parenthesis(close_paren)),
33
+ ],
34
+ )
35
+ end
36
+
37
+ def to_unicodemath
38
+ "#{matrix_symbol}(#{value.map(&:to_unicodemath).join("@")})"
39
+ end
40
+
41
+ private
42
+
43
+ def matrix_symbol
44
+ open_paren == "{" ? "Ⓢ" : "ⓢ"
32
45
  end
33
46
  end
34
47
  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 Cases < Table
10
+ def initialize(value = [],
11
+ open_paren = "{",
12
+ close_paren = ":}",
13
+ options = {})
14
+ super
15
+ end
16
+
17
+ def to_unicodemath
18
+ "Ⓒ(#{value.map(&:to_unicodemath).join("@")})"
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 Eqarray < Table
10
+ def initialize(value = [],
11
+ open_paren = "",
12
+ close_paren = "",
13
+ options = {})
14
+ super
15
+ end
16
+
17
+ def to_unicodemath
18
+ "#{open_paren}█(#{value&.map(&:to_unicodemath).join("@")})#{close_paren}"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -23,12 +23,32 @@ module Plurimath
23
23
  end
24
24
 
25
25
  def to_mathml_without_math_tag
26
- table_tag = Utility.ox_element("mtable", attributes: table_attribute)
26
+ table_tag = Utility.update_nodes(
27
+ ox_element("mtable", attributes: table_attribute),
28
+ value&.map(&:to_mathml_without_math_tag)
29
+ )
30
+ return table_tag if table_tag_only?
31
+
27
32
  Utility.update_nodes(
28
- table_tag,
29
- value&.map(&:to_mathml_without_math_tag),
33
+ ox_element("mrow"),
34
+ [mo_tag(open_paren), table_tag, mo_tag(close_paren)]
30
35
  )
31
36
  end
37
+
38
+ def to_unicodemath
39
+ first_value = value.map(&:to_unicodemath).join("@")
40
+ "#{open_paren}■(#{first_value})#{close_paren}"
41
+ end
42
+
43
+ protected
44
+
45
+ def mo_tag(paren)
46
+ (ox_element("mo") << paren) unless validate_paren(paren)
47
+ end
48
+
49
+ def table_tag_only?
50
+ (open_paren&.include?("(") && close_paren&.include?(")")) || !(open_paren && close_paren)
51
+ end
32
52
  end
33
53
  end
34
54
  end
@@ -17,6 +17,10 @@ module Plurimath
17
17
  def to_latex
18
18
  "\\begin#{opening}#{latex_content}\\end#{matrix_class}"
19
19
  end
20
+
21
+ def to_unicodemath
22
+ "⒨(#{value.map(&:to_unicodemath).join("@")})"
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -17,6 +17,16 @@ module Plurimath
17
17
  def to_latex
18
18
  "\\begin#{opening}#{latex_content}\\end#{matrix_class}"
19
19
  end
20
+
21
+ def to_unicodemath
22
+ "#{matrix_symbol}(#{value.map(&:to_unicodemath).join("@")})"
23
+ end
24
+
25
+ private
26
+
27
+ def matrix_symbol
28
+ open_paren == "norm[" ? "⒩" : "⒱"
29
+ end
20
30
  end
21
31
  end
22
32
  end