plurimath 0.7.2 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/Latex-Supported-Data.adoc +1 -0
  4. data/UnicodeMath-Supported-Data.adoc +1342 -0
  5. data/UnitsML-Supported-Data.adoc +444 -0
  6. data/lib/plurimath/asciimath/parse.rb +1 -1
  7. data/lib/plurimath/asciimath/transform.rb +2 -6
  8. data/lib/plurimath/latex/constants.rb +2 -0
  9. data/lib/plurimath/math/core.rb +38 -6
  10. data/lib/plurimath/math/formula.rb +60 -6
  11. data/lib/plurimath/math/function/abs.rb +4 -0
  12. data/lib/plurimath/math/function/arg.rb +22 -0
  13. data/lib/plurimath/math/function/bar.rb +4 -0
  14. data/lib/plurimath/math/function/base.rb +49 -0
  15. data/lib/plurimath/math/function/binary_function.rb +6 -0
  16. data/lib/plurimath/math/function/cancel.rb +5 -0
  17. data/lib/plurimath/math/function/ceil.rb +6 -0
  18. data/lib/plurimath/math/function/color.rb +20 -1
  19. data/lib/plurimath/math/function/ddot.rb +4 -0
  20. data/lib/plurimath/math/function/dot.rb +5 -0
  21. data/lib/plurimath/math/function/fenced.rb +98 -7
  22. data/lib/plurimath/math/function/floor.rb +6 -0
  23. data/lib/plurimath/math/function/font_style/monospace.rb +4 -0
  24. data/lib/plurimath/math/function/font_style.rb +31 -6
  25. data/lib/plurimath/math/function/frac.rb +69 -15
  26. data/lib/plurimath/math/function/hat.rb +4 -0
  27. data/lib/plurimath/math/function/inf.rb +30 -0
  28. data/lib/plurimath/math/function/int.rb +47 -1
  29. data/lib/plurimath/math/function/intent.rb +22 -0
  30. data/lib/plurimath/math/function/left.rb +4 -0
  31. data/lib/plurimath/math/function/lim.rb +6 -0
  32. data/lib/plurimath/math/function/limits.rb +28 -0
  33. data/lib/plurimath/math/function/linebreak.rb +5 -0
  34. data/lib/plurimath/math/function/log.rb +27 -20
  35. data/lib/plurimath/math/function/longdiv.rb +4 -0
  36. data/lib/plurimath/math/function/mbox.rb +4 -0
  37. data/lib/plurimath/math/function/menclose.rb +74 -5
  38. data/lib/plurimath/math/function/merror.rb +2 -0
  39. data/lib/plurimath/math/function/mglyph.rb +64 -0
  40. data/lib/plurimath/math/function/mlabeledtr.rb +29 -0
  41. data/lib/plurimath/math/function/mod.rb +4 -0
  42. data/lib/plurimath/math/function/mpadded.rb +84 -0
  43. data/lib/plurimath/math/function/ms.rb +33 -0
  44. data/lib/plurimath/math/function/msgroup.rb +4 -0
  45. data/lib/plurimath/math/function/msline.rb +2 -4
  46. data/lib/plurimath/math/function/multiscript.rb +70 -6
  47. data/lib/plurimath/math/function/nary.rb +69 -10
  48. data/lib/plurimath/math/function/none.rb +25 -0
  49. data/lib/plurimath/math/function/norm.rb +6 -0
  50. data/lib/plurimath/math/function/obrace.rb +4 -0
  51. data/lib/plurimath/math/function/oint.rb +25 -1
  52. data/lib/plurimath/math/function/over.rb +6 -0
  53. data/lib/plurimath/math/function/overset.rb +46 -1
  54. data/lib/plurimath/math/function/phantom.rb +18 -2
  55. data/lib/plurimath/math/function/power.rb +37 -0
  56. data/lib/plurimath/math/function/power_base.rb +45 -18
  57. data/lib/plurimath/math/function/prod.rb +46 -0
  58. data/lib/plurimath/math/function/right.rb +4 -0
  59. data/lib/plurimath/math/function/root.rb +9 -1
  60. data/lib/plurimath/math/function/rule.rb +4 -0
  61. data/lib/plurimath/math/function/sqrt.rb +7 -1
  62. data/lib/plurimath/math/function/stackrel.rb +6 -0
  63. data/lib/plurimath/math/function/substack.rb +4 -0
  64. data/lib/plurimath/math/function/sum.rb +45 -24
  65. data/lib/plurimath/math/function/table/bmatrix.rb +18 -5
  66. data/lib/plurimath/math/function/table/cases.rb +24 -0
  67. data/lib/plurimath/math/function/table/eqarray.rb +24 -0
  68. data/lib/plurimath/math/function/table/matrix.rb +23 -3
  69. data/lib/plurimath/math/function/table/pmatrix.rb +4 -0
  70. data/lib/plurimath/math/function/table/vmatrix.rb +10 -0
  71. data/lib/plurimath/math/function/table.rb +58 -7
  72. data/lib/plurimath/math/function/td.rb +9 -0
  73. data/lib/plurimath/math/function/ternary_function.rb +14 -1
  74. data/lib/plurimath/math/function/text.rb +6 -0
  75. data/lib/plurimath/math/function/tilde.rb +4 -0
  76. data/lib/plurimath/math/function/tr.rb +9 -0
  77. data/lib/plurimath/math/function/ubrace.rb +5 -0
  78. data/lib/plurimath/math/function/ul.rb +4 -0
  79. data/lib/plurimath/math/function/unary_function.rb +4 -0
  80. data/lib/plurimath/math/function/underover.rb +14 -0
  81. data/lib/plurimath/math/function/underset.rb +49 -1
  82. data/lib/plurimath/math/function/vec.rb +4 -0
  83. data/lib/plurimath/math/number.rb +33 -3
  84. data/lib/plurimath/math/symbol.rb +68 -3
  85. data/lib/plurimath/math.rb +3 -2
  86. data/lib/plurimath/mathml/constants.rb +16 -0
  87. data/lib/plurimath/mathml/parser.rb +42 -2
  88. data/lib/plurimath/mathml/transform.rb +80 -29
  89. data/lib/plurimath/omml/parser.rb +8 -0
  90. data/lib/plurimath/omml/transform.rb +29 -26
  91. data/lib/plurimath/unicode_math/constants.rb +1014 -0
  92. data/lib/plurimath/unicode_math/parse.rb +233 -0
  93. data/lib/plurimath/unicode_math/parser.rb +58 -0
  94. data/lib/plurimath/unicode_math/parsing_rules/absence_rules.rb +138 -0
  95. data/lib/plurimath/unicode_math/parsing_rules/common_rules.rb +114 -0
  96. data/lib/plurimath/unicode_math/parsing_rules/constants_rules.rb +102 -0
  97. data/lib/plurimath/unicode_math/parsing_rules/helper.rb +19 -0
  98. data/lib/plurimath/unicode_math/parsing_rules/masked.rb +62 -0
  99. data/lib/plurimath/unicode_math/parsing_rules/sub_sup.rb +254 -0
  100. data/lib/plurimath/unicode_math/transform.rb +3831 -0
  101. data/lib/plurimath/{unicode.rb → unicode_math.rb} +2 -2
  102. data/lib/plurimath/unitsml.rb +14 -1
  103. data/lib/plurimath/utility.rb +346 -11
  104. data/lib/plurimath/version.rb +1 -1
  105. data/lib/plurimath/xml_engine/oga.rb +5 -0
  106. data/lib/plurimath/xml_engine/ox.rb +5 -0
  107. metadata +25 -3
@@ -6,12 +6,25 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Int < TernaryFunction
9
+ attr_accessor :options
9
10
  FUNCTION = {
10
11
  name: "integral",
11
12
  first_value: "lower limit",
12
13
  second_value: "upper limit",
13
14
  third_value: "integrand"
14
- }
15
+ }.freeze
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
15
28
 
16
29
  def to_asciimath
17
30
  first_value = "_#{wrapped(parameter_one)}" if parameter_one
@@ -62,6 +75,13 @@ module Plurimath
62
75
  end
63
76
  end
64
77
 
78
+ def to_unicodemath
79
+ first_value = sub_value if parameter_one
80
+ second_value = sup_value if parameter_two
81
+ mask = options&.dig(:mask) if options&.key?(:mask)
82
+ "∫#{mask}#{first_value}#{second_value}#{naryand_value(parameter_three)}"
83
+ end
84
+
65
85
  def line_breaking(obj)
66
86
  parameter_one&.line_breaking(obj)
67
87
  if obj.value_exist?
@@ -88,6 +108,32 @@ module Plurimath
88
108
  omml_parameter(parameter_three, display_style, tag_name: "e"),
89
109
  ]
90
110
  end
111
+
112
+ def is_nary_function?
113
+ true
114
+ end
115
+
116
+ protected
117
+
118
+ def sup_value
119
+ if parameter_two&.mini_sized? || prime_unicode?(parameter_two)
120
+ parameter_two.to_unicodemath
121
+ elsif parameter_two.is_a?(Math::Function::Power)
122
+ "^#{parameter_two.to_unicodemath}"
123
+ else
124
+ "^#{unicodemath_parens(parameter_two)}"
125
+ end
126
+ end
127
+
128
+ def sub_value
129
+ if parameter_one&.mini_sized?
130
+ parameter_one.to_unicodemath
131
+ elsif parameter_one.is_a?(Math::Function::Base)
132
+ "_#{parameter_one.to_unicodemath}"
133
+ else
134
+ "_#{unicodemath_parens(parameter_one)}"
135
+ end
136
+ end
91
137
  end
92
138
  end
93
139
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "binary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Intent < BinaryFunction
9
+ def to_mathml_without_math_tag
10
+ first_value = parameter_one.to_mathml_without_math_tag
11
+ first_value.attributes[:intent] = Utility.html_entity_to_unicode(parameter_two.value)
12
+ first_value
13
+ end
14
+
15
+ def to_unicodemath
16
+ first_value = "(#{parameter_two.to_unicodemath}#{parameter_one.to_unicodemath})" if parameter_one || parameter_two
17
+ "ⓘ#{first_value}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -33,6 +33,10 @@ module Plurimath
33
33
  "\\left #{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
@@ -49,6 +49,12 @@ module Plurimath
49
49
  underover(display_style)
50
50
  end
51
51
 
52
+ def to_unicodemath
53
+ first_value = "_#{unicodemath_parens(parameter_one)}" if parameter_one
54
+ second_value = "^#{unicodemath_parens(parameter_two)}" if parameter_two
55
+ "lim#{first_value}#{second_value}"
56
+ end
57
+
52
58
  def line_breaking(obj)
53
59
  parameter_one.line_breaking(obj)
54
60
  if obj.value_exist?
@@ -34,6 +34,10 @@ module Plurimath
34
34
  underover(display_style)
35
35
  end
36
36
 
37
+ def to_unicodemath
38
+ "#{parameter_one&.to_unicodemath}#{sup_value}#{sub_value}"
39
+ end
40
+
37
41
  def line_breaking(obj)
38
42
  parameter_one&.line_breaking(obj)
39
43
  if obj.value_exist?
@@ -49,6 +53,30 @@ module Plurimath
49
53
  self.parameter_three = nil
50
54
  end
51
55
  end
56
+
57
+ protected
58
+
59
+ def sup_value
60
+ return unless parameter_three
61
+
62
+ if parameter_three.is_a?(Math::Function::Power)
63
+ "┴#{parameter_three.to_unicodemath}"
64
+ elsif parameter_one.is_a?(Math::Function::Power) && parameter_one&.prime_unicode?(parameter_one&.parameter_two)
65
+ "┴#{parameter_three.to_unicodemath}"
66
+ else
67
+ "┴#{unicodemath_parens(parameter_three)}"
68
+ end
69
+ end
70
+
71
+ def sub_value
72
+ return unless parameter_two
73
+
74
+ if parameter_two.is_a?(Math::Function::Base)
75
+ "┬#{parameter_two.to_unicodemath}"
76
+ else
77
+ "┬#{unicodemath_parens(parameter_two)}"
78
+ end
79
+ end
52
80
  end
53
81
  end
54
82
  end
@@ -82,6 +82,11 @@ module Plurimath
82
82
  result
83
83
  end
84
84
 
85
+ def to_unicodemath
86
+ first_value = parameter_one.to_unicodemath if parameter_one
87
+ "&#xa;#{first_value}"
88
+ end
89
+
85
90
  def separate_table
86
91
  true
87
92
  end
@@ -35,7 +35,7 @@ module Plurimath
35
35
 
36
36
  ssubsup = Utility.ox_element("sSubSup", namespace: "m")
37
37
  ssubsuppr = Utility.ox_element("sSubSupPr", namespace: "m")
38
- ssubsuppr << hide_tags(Utility.pr_element("ctrl", true, namespace: "m"))
38
+ ssubsuppr << Utility.pr_element("ctrl", true, namespace: "m")
39
39
  Utility.update_nodes(
40
40
  ssubsup,
41
41
  [
@@ -63,6 +63,12 @@ module Plurimath
63
63
  end
64
64
  end
65
65
 
66
+ def to_unicodemath
67
+ first_value = sub_value if parameter_one
68
+ second_value = sup_value if parameter_two
69
+ "log#{first_value}#{second_value}"
70
+ end
71
+
66
72
  def line_breaking(obj)
67
73
  parameter_one&.line_breaking(obj)
68
74
  if obj.value_exist?
@@ -82,25 +88,6 @@ module Plurimath
82
88
  e_tag << rpr_tag
83
89
  end
84
90
 
85
- def hide_tags(nar)
86
- attr = { "m:val": "1" }
87
- if parameter_one.nil?
88
- nar << Utility.ox_element(
89
- "subHide",
90
- namespace: "m",
91
- attributes: attr,
92
- )
93
- end
94
- if parameter_two.nil?
95
- nar << Utility.ox_element(
96
- "supHide",
97
- namespace: "m",
98
- attributes: attr,
99
- )
100
- end
101
- nar
102
- end
103
-
104
91
  def rpr_tag
105
92
  sty_atrs = { "m:val": "p" }
106
93
  sty_tag = Utility.ox_element("sty", attributes: sty_atrs, namespace: "m")
@@ -109,6 +96,26 @@ module Plurimath
109
96
  t_tag = (Utility.ox_element("t", namespace: "m") << "log")
110
97
  Utility.update_nodes(r_tag, [rpr_tag, t_tag])
111
98
  end
99
+
100
+ def sup_value
101
+ if parameter_two&.mini_sized? || prime_unicode?(parameter_two)
102
+ parameter_two.to_unicodemath
103
+ elsif parameter_two.is_a?(Math::Function::Power)
104
+ "^#{parameter_two.to_unicodemath}"
105
+ else
106
+ "^#{unicodemath_parens(parameter_two)}"
107
+ end
108
+ end
109
+
110
+ def sub_value
111
+ if parameter_one&.mini_sized?
112
+ parameter_one.to_unicodemath
113
+ elsif parameter_one.is_a?(Math::Function::Base)
114
+ "_#{parameter_one.to_unicodemath}"
115
+ else
116
+ "_#{unicodemath_parens(parameter_one)}"
117
+ end
118
+ end
112
119
  end
113
120
  end
114
121
  end
@@ -25,6 +25,10 @@ module Plurimath
25
25
  omml_value(display_style)
26
26
  end
27
27
 
28
+ def to_unicodemath
29
+ parameter_one&.to_unicodemath
30
+ end
31
+
28
32
  def line_breaking(obj)
29
33
  custom_array_line_breaking(obj)
30
34
  end
@@ -24,6 +24,10 @@ module Plurimath
24
24
  def to_omml_without_math_tag(display_style)
25
25
  Text.new(parameter_one).to_omml_without_math_tag(display_style)
26
26
  end
27
+
28
+ def to_unicodemath
29
+ Text.new(parameter_one).to_unicodemath
30
+ end
27
31
  end
28
32
  end
29
33
  end
@@ -11,6 +11,18 @@ module Plurimath
11
11
  first_value: "enclosure type",
12
12
  second_value: "expression",
13
13
  }.freeze
14
+ FOUR_SIDED_NOTATIONS = {
15
+ top: "hideTop",
16
+ bottom: "hideBot",
17
+ left: "hideLeft",
18
+ right: "hideRight",
19
+ }
20
+ STRIKES_NOTATIONS = {
21
+ horizontalstrike: "strikeH",
22
+ verticalstrike: "strikeV",
23
+ updiagonalstrike: "strikeBLTR",
24
+ downdiagonalstrike: "strikeTLBR",
25
+ }
14
26
 
15
27
  def to_asciimath
16
28
  parameter_two&.to_asciimath
@@ -18,7 +30,7 @@ module Plurimath
18
30
 
19
31
  def to_mathml_without_math_tag
20
32
  attributes = { notation: parameter_one }
21
- menclose = Utility.ox_element("menclose", attributes: attributes)
33
+ menclose = ox_element("menclose", attributes: attributes)
22
34
  menclose << parameter_two.to_mathml_without_math_tag if parameter_two
23
35
  menclose
24
36
  end
@@ -33,18 +45,75 @@ module Plurimath
33
45
  end
34
46
 
35
47
  def to_omml_without_math_tag(display_style)
36
- borderbox = Utility.ox_element("borderBox", namespace: "m")
37
- borderpr = Utility.ox_element("borderBoxPr", namespace: "m")
38
- borderpr << Utility.pr_element("ctrl", true, namespace: "m")
48
+ borderbox = ox_element("borderBox", namespace: "m")
39
49
  Utility.update_nodes(
40
50
  borderbox,
41
51
  [
42
- borderpr,
52
+ borderboxpr,
43
53
  omml_parameter(parameter_two, display_style, tag_name: "e"),
44
54
  ],
45
55
  )
46
56
  [borderbox]
47
57
  end
58
+
59
+ def to_unicodemath
60
+ if unicode_symbol?
61
+ "#{unicode_symbol}#{unicodemath_parens(parameter_two)}"
62
+ elsif masked_class?
63
+ first_value = Utility.notations_to_mask(parameter_one) if parameter_one
64
+ second_value = parameter_two&.to_unicodemath if parameter_two
65
+ "▭(#{first_value}&#{second_value})"
66
+ end
67
+ end
68
+
69
+ protected
70
+
71
+ def borderboxpr
72
+ return if %w[box circle roundedbox].include?(parameter_one)
73
+
74
+ borderpr = ox_element("borderBoxPr", namespace: "m")
75
+ four_sided_notations(borderpr)
76
+ strikes_notations(borderpr)
77
+ borderpr
78
+ end
79
+
80
+ def four_sided_notations(borderpr)
81
+ return if %w[box circle roundedbox].any? { |value| parameter_one.include?(value) }
82
+
83
+ FOUR_SIDED_NOTATIONS.each do |side, rep|
84
+ border_ox_element(rep, !parameter_one.include?(side.to_s), borderpr)
85
+ end
86
+ end
87
+
88
+ def strikes_notations(borderpr)
89
+ STRIKES_NOTATIONS.each do |strike, rep|
90
+ border_ox_element(rep, parameter_one.include?(strike.to_s), borderpr)
91
+ end
92
+ end
93
+
94
+ def border_ox_element(tag_name, condition, borderpr)
95
+ return unless condition
96
+
97
+ borderpr << ox_element(
98
+ tag_name,
99
+ namespace: "m",
100
+ attributes: { "m:val": "on" },
101
+ )
102
+ end
103
+
104
+ def masked_class?
105
+ Utility::MASK_CLASSES.values.any? { |mask| parameter_one.include?(mask) }
106
+ end
107
+
108
+ def unicode_symbol
109
+ class_name = Utility::UNICODEMATH_MENCLOSE_FUNCTIONS.key(parameter_one)
110
+ UnicodeMath::Constants::UNARY_ARG_FUNCTIONS[class_name] ||
111
+ UnicodeMath::Constants::UNARY_SYMBOLS[class_name]
112
+ end
113
+
114
+ def unicode_symbol?
115
+ Utility::UNICODEMATH_MENCLOSE_FUNCTIONS.value?(parameter_one)
116
+ end
48
117
  end
49
118
  end
50
119
  end
@@ -16,6 +16,8 @@ module Plurimath
16
16
  end
17
17
 
18
18
  def to_omml_without_math_tag(_); end
19
+
20
+ def to_unicodemath; end
19
21
  end
20
22
  end
21
23
  end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Mglyph < UnaryFunction
9
+ def initialize(parameter_one = {})
10
+ super(parameter_one)
11
+ end
12
+
13
+ def to_asciimath
14
+ parameter_one[:alt]
15
+ end
16
+
17
+ def to_latex
18
+ parameter_one[:alt]
19
+ end
20
+
21
+ def to_mathml_without_math_tag
22
+ ox_element(class_name, attributes: parameter_one)
23
+ end
24
+
25
+ def to_omml_without_math_tag(_)
26
+ index = parameter_one[:index].to_i
27
+ r_element(
28
+ (ignoring_index(index) ? parameter_one[:alt].to_s : "&#x#{glyph_user_index(index)};"),
29
+ rpr_tag: false,
30
+ )
31
+ end
32
+
33
+ def to_unicodemath
34
+ parameter_one[:alt] if parameter_one
35
+ end
36
+
37
+ protected
38
+
39
+ def glyph_user_index(index)
40
+ return "" unless index > 0
41
+
42
+ remaining = index.modulo(16)
43
+ hex_bits = glyph_user_index(index / 16)
44
+ hex_digit = case remaining
45
+ when 0..9 then remaining.to_s
46
+ when 10 then "A"
47
+ when 11 then "B"
48
+ when 12 then "C"
49
+ when 13 then "D"
50
+ when 14 then "E"
51
+ when 15 then "F"
52
+ end
53
+ "#{hex_bits}#{hex_digit}"
54
+ end
55
+
56
+ def ignoring_index(index)
57
+ index.zero? ||
58
+ (index < 32 && !([9, 10, 13].include?(index))) ||
59
+ [65534, 65535].include?(index)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ 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 Mlabeledtr < BinaryFunction
9
+ def to_mathml_without_math_tag
10
+ table = ox_element("mtable")
11
+ mlabeledtr = ox_element(class_name)
12
+ labeledtr_td(mlabeledtr, parameter_two.to_mathml_without_math_tag)
13
+ labeledtr_td(mlabeledtr, parameter_one.to_mathml_without_math_tag)
14
+ table << mlabeledtr
15
+ end
16
+
17
+ def to_unicodemath
18
+ "#{parameter_one&.to_unicodemath}##{parameter_two&.value}"
19
+ end
20
+
21
+ protected
22
+
23
+ def labeledtr_td(tr, value)
24
+ tr << (ox_element("mtd") << value)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -47,6 +47,10 @@ module Plurimath
47
47
  values
48
48
  end
49
49
 
50
+ def to_unicodemath
51
+ "#{parameter_one&.to_unicodemath}mod#{parameter_two&.to_unicodemath}"
52
+ end
53
+
50
54
  def line_breaking(obj)
51
55
  parameter_one&.line_breaking(obj)
52
56
  if obj.value_exist?
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Mpadded < UnaryFunction
9
+ attr_accessor :options
10
+ ZERO_TAGS = {
11
+ height: "zeroAsc",
12
+ depth: "zeroDesc",
13
+ width: "zeroWid",
14
+ }
15
+
16
+ def initialize(parameter_one = nil, options = {})
17
+ super(parameter_one)
18
+ @options = options unless options.empty?
19
+ end
20
+
21
+ def ==(object)
22
+ super(object) &&
23
+ object&.options == options
24
+ end
25
+
26
+ def to_asciimath
27
+ asciimath_value
28
+ end
29
+
30
+ def to_latex
31
+ latex_value
32
+ end
33
+
34
+ def to_mathml_without_math_tag
35
+ Utility.update_nodes(
36
+ ox_element(class_name, attributes: options),
37
+ Array(mathml_value),
38
+ )
39
+ end
40
+
41
+ def to_omml_without_math_tag(display_style)
42
+ phant = ox_element("phant", namespace: "m")
43
+ phantpr = ox_element("phantPr", namespace: "m")
44
+ Utility.update_nodes(phantpr, phant_pr)
45
+ phant << phantpr unless phantpr.nodes.empty?
46
+
47
+ phant << omml_parameter(parameter_one, display_style, tag_name: "e")
48
+ end
49
+
50
+ def to_unicodemath
51
+ if options&.dig(:mpadded)
52
+ "#{mpadded_unicode}#{unicodemath_parens(parameter_one)}"
53
+ elsif options&.key?(:mask)
54
+ "⟡(#{options.dig(:mask)}&#{parameter_one&.to_unicodemath})"
55
+ else
56
+ first_value = "(#{parameter_one.to_unicodemath})" if parameter_one
57
+ "⟡#{first_value}"
58
+ end
59
+ end
60
+
61
+ protected
62
+
63
+ def phant_pr
64
+ attributes = { "m:val": "on" }
65
+ options.map do |atr, value|
66
+ ox_element(ZERO_TAGS[atr], attributes: attributes) if attr_value_zero?(value)
67
+ end
68
+ end
69
+
70
+ def attr_value_zero?(atr)
71
+ !atr.match?(/[1-9]/) && atr.match?(/\d/)
72
+ end
73
+
74
+ def mpadded_symbol
75
+ UnicodeMath::Constants::PHANTOM_SYMBOLS.key(options)
76
+ end
77
+
78
+ def mpadded_unicode
79
+ UnicodeMath::Constants::UNARY_SYMBOLS[mpadded_symbol]
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Ms < UnaryFunction
9
+ def to_mathml_without_math_tag
10
+ Utility.ox_element("ms") << parameter_one
11
+ end
12
+
13
+ def to_asciimath
14
+ "\"“#{parameter_one}”\""
15
+ end
16
+
17
+ def to_latex
18
+ "\\text{“#{parameter_one}”}"
19
+ end
20
+
21
+ def to_omml_without_math_tag(display_style)
22
+ [
23
+ (Utility.ox_element("t", namespace: "m") << "“#{parameter_one}”"),
24
+ ]
25
+ end
26
+
27
+ def to_unicodemath
28
+ Text.new(parameter_one).to_unicodemath
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -57,6 +57,10 @@ module Plurimath
57
57
  ]
58
58
  end
59
59
 
60
+ def to_unicodemath
61
+ parameter_one.map(&:to_unicodemath).join
62
+ end
63
+
60
64
  def line_breaking(obj)
61
65
  custom_array_line_breaking(obj)
62
66
  end
@@ -14,11 +14,9 @@ module Plurimath
14
14
  ox_element("msline")
15
15
  end
16
16
 
17
- def to_omml_without_math_tag(display_style)
18
- omml_value(display_style)
19
- end
20
-
21
17
  def to_omml_without_math_tag(display_style);end
18
+
19
+ def to_unicodemath; end
22
20
  end
23
21
  end
24
22
  end