plurimath 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec-opal +1 -1
  3. data/.rubocop.yml +9 -5
  4. data/.rubocop_todo.yml +0 -0
  5. data/Gemfile +7 -5
  6. data/README.adoc +57 -1
  7. data/Rakefile +11 -0
  8. data/lib/plurimath/asciimath/parse.rb +0 -1
  9. data/lib/plurimath/asciimath/parser.rb +0 -3
  10. data/lib/plurimath/asciimath.rb +5 -0
  11. data/lib/plurimath/cli.rb +28 -1
  12. data/lib/plurimath/errors.rb +0 -4
  13. data/lib/plurimath/formatter/numbers.rb +12 -0
  14. data/lib/plurimath/formatter/numeric_formatter.rb +4 -1
  15. data/lib/plurimath/formatter/standard.rb +0 -1
  16. data/lib/plurimath/formatter.rb +6 -9
  17. data/lib/plurimath/html/parse.rb +0 -1
  18. data/lib/plurimath/html/parser.rb +0 -3
  19. data/lib/plurimath/html.rb +5 -0
  20. data/lib/plurimath/latex/parse.rb +0 -1
  21. data/lib/plurimath/latex/parser.rb +2 -5
  22. data/lib/plurimath/latex.rb +5 -0
  23. data/lib/plurimath/math/core.rb +6 -2
  24. data/lib/plurimath/math/formula/mrow.rb +2 -41
  25. data/lib/plurimath/math/formula/mstyle.rb +6 -0
  26. data/lib/plurimath/math/formula.rb +59 -301
  27. data/lib/plurimath/math/function/abs.rb +0 -1
  28. data/lib/plurimath/math/function/arccos.rb +0 -1
  29. data/lib/plurimath/math/function/arcsin.rb +0 -1
  30. data/lib/plurimath/math/function/arctan.rb +0 -1
  31. data/lib/plurimath/math/function/arg.rb +0 -1
  32. data/lib/plurimath/math/function/bar.rb +0 -1
  33. data/lib/plurimath/math/function/base.rb +0 -3
  34. data/lib/plurimath/math/function/binary_function.rb +5 -3
  35. data/lib/plurimath/math/function/cancel.rb +0 -1
  36. data/lib/plurimath/math/function/ceil.rb +0 -1
  37. data/lib/plurimath/math/function/color.rb +0 -1
  38. data/lib/plurimath/math/function/cos.rb +0 -1
  39. data/lib/plurimath/math/function/cosh.rb +0 -1
  40. data/lib/plurimath/math/function/cot.rb +0 -1
  41. data/lib/plurimath/math/function/coth.rb +0 -1
  42. data/lib/plurimath/math/function/csc.rb +0 -1
  43. data/lib/plurimath/math/function/csch.rb +0 -1
  44. data/lib/plurimath/math/function/ddot.rb +0 -1
  45. data/lib/plurimath/math/function/deg.rb +0 -1
  46. data/lib/plurimath/math/function/det.rb +0 -1
  47. data/lib/plurimath/math/function/dim.rb +0 -1
  48. data/lib/plurimath/math/function/dot.rb +0 -1
  49. data/lib/plurimath/math/function/exp.rb +0 -1
  50. data/lib/plurimath/math/function/fenced.rb +1 -197
  51. data/lib/plurimath/math/function/floor.rb +0 -1
  52. data/lib/plurimath/math/function/font_style/bold-fraktur.rb +0 -1
  53. data/lib/plurimath/math/function/font_style/bold-italic.rb +0 -1
  54. data/lib/plurimath/math/function/font_style/bold-sans-serif.rb +0 -1
  55. data/lib/plurimath/math/function/font_style/bold-script.rb +0 -1
  56. data/lib/plurimath/math/function/font_style/bold.rb +0 -1
  57. data/lib/plurimath/math/function/font_style/double_struck.rb +0 -1
  58. data/lib/plurimath/math/function/font_style/fraktur.rb +0 -1
  59. data/lib/plurimath/math/function/font_style/italic.rb +0 -1
  60. data/lib/plurimath/math/function/font_style/monospace.rb +0 -1
  61. data/lib/plurimath/math/function/font_style/normal.rb +0 -1
  62. data/lib/plurimath/math/function/font_style/sans-serif-bold-italic.rb +0 -1
  63. data/lib/plurimath/math/function/font_style/sans-serif-italic.rb +0 -1
  64. data/lib/plurimath/math/function/font_style/sans-serif.rb +0 -1
  65. data/lib/plurimath/math/function/font_style/script.rb +0 -1
  66. data/lib/plurimath/math/function/font_style.rb +29 -2
  67. data/lib/plurimath/math/function/frac.rb +0 -3
  68. data/lib/plurimath/math/function/gcd.rb +0 -1
  69. data/lib/plurimath/math/function/glb.rb +0 -1
  70. data/lib/plurimath/math/function/hat.rb +0 -1
  71. data/lib/plurimath/math/function/hom.rb +0 -1
  72. data/lib/plurimath/math/function/inf.rb +1 -2
  73. data/lib/plurimath/math/function/int.rb +2 -3
  74. data/lib/plurimath/math/function/intent.rb +0 -1
  75. data/lib/plurimath/math/function/ker.rb +0 -1
  76. data/lib/plurimath/math/function/lcm.rb +0 -1
  77. data/lib/plurimath/math/function/left.rb +0 -1
  78. data/lib/plurimath/math/function/lg.rb +0 -1
  79. data/lib/plurimath/math/function/lim.rb +1 -2
  80. data/lib/plurimath/math/function/liminf.rb +0 -1
  81. data/lib/plurimath/math/function/limits.rb +0 -1
  82. data/lib/plurimath/math/function/limsup.rb +0 -1
  83. data/lib/plurimath/math/function/linebreak.rb +0 -1
  84. data/lib/plurimath/math/function/ln.rb +0 -1
  85. data/lib/plurimath/math/function/log.rb +1 -2
  86. data/lib/plurimath/math/function/longdiv.rb +0 -3
  87. data/lib/plurimath/math/function/lub.rb +0 -1
  88. data/lib/plurimath/math/function/max.rb +0 -1
  89. data/lib/plurimath/math/function/mbox.rb +0 -1
  90. data/lib/plurimath/math/function/menclose.rb +0 -3
  91. data/lib/plurimath/math/function/merror.rb +0 -3
  92. data/lib/plurimath/math/function/mglyph.rb +0 -3
  93. data/lib/plurimath/math/function/min.rb +0 -1
  94. data/lib/plurimath/math/function/mlabeledtr.rb +0 -20
  95. data/lib/plurimath/math/function/mod.rb +0 -1
  96. data/lib/plurimath/math/function/mpadded.rb +0 -3
  97. data/lib/plurimath/math/function/ms.rb +1 -77
  98. data/lib/plurimath/math/function/msgroup.rb +0 -27
  99. data/lib/plurimath/math/function/msline.rb +0 -3
  100. data/lib/plurimath/math/function/multiscript.rb +0 -14
  101. data/lib/plurimath/math/function/nary.rb +4 -0
  102. data/lib/plurimath/math/function/none.rb +1 -4
  103. data/lib/plurimath/math/function/norm.rb +0 -1
  104. data/lib/plurimath/math/function/obrace.rb +0 -1
  105. data/lib/plurimath/math/function/oint.rb +2 -3
  106. data/lib/plurimath/math/function/over.rb +0 -3
  107. data/lib/plurimath/math/function/overset.rb +3 -3
  108. data/lib/plurimath/math/function/phantom.rb +0 -3
  109. data/lib/plurimath/math/function/power.rb +0 -3
  110. data/lib/plurimath/math/function/power_base.rb +0 -3
  111. data/lib/plurimath/math/function/prod.rb +2 -3
  112. data/lib/plurimath/math/function/right.rb +0 -1
  113. data/lib/plurimath/math/function/root.rb +0 -3
  114. data/lib/plurimath/math/function/rule.rb +0 -1
  115. data/lib/plurimath/math/function/scarries.rb +0 -3
  116. data/lib/plurimath/math/function/scarry.rb +22 -0
  117. data/lib/plurimath/math/function/sec.rb +0 -1
  118. data/lib/plurimath/math/function/sech.rb +0 -1
  119. data/lib/plurimath/math/function/semantics.rb +0 -15
  120. data/lib/plurimath/math/function/sin.rb +0 -1
  121. data/lib/plurimath/math/function/sinh.rb +0 -1
  122. data/lib/plurimath/math/function/sqrt.rb +0 -3
  123. data/lib/plurimath/math/function/stackrel.rb +0 -3
  124. data/lib/plurimath/math/function/substack.rb +0 -1
  125. data/lib/plurimath/math/function/sum.rb +2 -3
  126. data/lib/plurimath/math/function/sup.rb +0 -1
  127. data/lib/plurimath/math/function/table/align.rb +0 -1
  128. data/lib/plurimath/math/function/table/array.rb +0 -1
  129. data/lib/plurimath/math/function/table/bmatrix.rb +0 -1
  130. data/lib/plurimath/math/function/table/cases.rb +0 -1
  131. data/lib/plurimath/math/function/table/eqarray.rb +0 -1
  132. data/lib/plurimath/math/function/table/matrix.rb +0 -1
  133. data/lib/plurimath/math/function/table/multline.rb +0 -1
  134. data/lib/plurimath/math/function/table/pmatrix.rb +0 -1
  135. data/lib/plurimath/math/function/table/split.rb +0 -1
  136. data/lib/plurimath/math/function/table/vmatrix.rb +0 -1
  137. data/lib/plurimath/math/function/table.rb +10 -23
  138. data/lib/plurimath/math/function/tan.rb +0 -1
  139. data/lib/plurimath/math/function/tanh.rb +0 -1
  140. data/lib/plurimath/math/function/td.rb +0 -4
  141. data/lib/plurimath/math/function/ternary_function.rb +6 -2
  142. data/lib/plurimath/math/function/text.rb +1 -6
  143. data/lib/plurimath/math/function/tilde.rb +4 -1
  144. data/lib/plurimath/math/function/tr.rb +0 -13
  145. data/lib/plurimath/math/function/ubrace.rb +0 -1
  146. data/lib/plurimath/math/function/ul.rb +4 -1
  147. data/lib/plurimath/math/function/underover.rb +0 -3
  148. data/lib/plurimath/math/function/underset.rb +22 -45
  149. data/lib/plurimath/math/function/unitsml.rb +2 -1
  150. data/lib/plurimath/math/function/vec.rb +4 -1
  151. data/lib/plurimath/math/function.rb +107 -10
  152. data/lib/plurimath/math/number.rb +9 -7
  153. data/lib/plurimath/math/symbols/comma.rb +1 -1
  154. data/lib/plurimath/math/symbols/plus.rb +1 -1
  155. data/lib/plurimath/math/symbols/symbol.rb +17 -4
  156. data/lib/plurimath/math.rb +8 -26
  157. data/lib/plurimath/mathml/constants.rb +1 -0
  158. data/lib/plurimath/mathml/formula_transformation.rb +442 -0
  159. data/lib/plurimath/mathml/parser.rb +11 -50
  160. data/lib/plurimath/mathml/translator.rb +584 -0
  161. data/lib/plurimath/mathml/utility/formula_transformation.rb +2 -341
  162. data/lib/plurimath/mathml.rb +5 -0
  163. data/lib/plurimath/number_formatter.rb +2 -1
  164. data/lib/plurimath/omml/parser.rb +10 -7
  165. data/lib/plurimath/omml/transform.rb +17 -5
  166. data/lib/plurimath/omml.rb +3 -0
  167. data/lib/plurimath/setup/opal.rb.erb +3 -4
  168. data/lib/plurimath/unicode_math/parse.rb +0 -5
  169. data/lib/plurimath/unicode_math/parser.rb +1 -6
  170. data/lib/plurimath/unicode_math/parsing_rules/absence_rules.rb +0 -1
  171. data/lib/plurimath/unicode_math/parsing_rules/common_rules.rb +0 -1
  172. data/lib/plurimath/unicode_math/parsing_rules/constants_rules.rb +0 -1
  173. data/lib/plurimath/unicode_math/parsing_rules/masked.rb +0 -1
  174. data/lib/plurimath/unicode_math/parsing_rules/sub_sup.rb +0 -1
  175. data/lib/plurimath/unicode_math/parsing_rules.rb +14 -0
  176. data/lib/plurimath/unicode_math.rb +6 -0
  177. data/lib/plurimath/utility.rb +1 -1
  178. data/lib/plurimath/version.rb +1 -1
  179. data/lib/plurimath/xml_engine/oga.rb +6 -6
  180. data/lib/plurimath/xml_engine/ox_engine.rb +2 -2
  181. data/lib/plurimath/xml_engine.rb +2 -0
  182. data/lib/plurimath.rb +43 -18
  183. data/plurimath.gemspec +5 -4
  184. metadata +33 -15
  185. data/lib/plurimath/mathml/utility/empty_defined_methods.rb +0 -483
  186. data/lib/plurimath/mathml/utility.rb +0 -369
@@ -1,369 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "utility/empty_defined_methods"
4
- require_relative "utility/formula_transformation"
5
-
6
- module Plurimath
7
- class Mathml
8
- module Utility
9
- include EmptyDefinedMethods
10
- include FormulaTransformation
11
-
12
- attr_accessor :temp_mathml_order
13
-
14
- def element_order=(value)
15
- @temp_mathml_order = Array(validated_order(value&.map(&:name)))
16
- end
17
-
18
- def clear_temp_order
19
- @temp_mathml_order.shift(@temp_mathml_order.count)
20
- end
21
-
22
- def mathvariant=(value)
23
- return if value.nil? || value.empty?
24
- return unless Plurimath::Utility::FONT_STYLES.key?(value.to_sym)
25
-
26
- @temp_mathml_order = [
27
- Plurimath::Utility::FONT_STYLES[value.to_sym].new(
28
- nil,
29
- value,
30
- ),
31
- ]
32
- end
33
-
34
- def accent=(value)
35
- return if value.nil? || value.empty?
36
-
37
- @options = Hash(@options).merge(accent: true)
38
- end
39
-
40
- def accentunder=(value)
41
- return if value.nil? || value.empty?
42
-
43
- @options = Hash(@options).merge(accentunder: true)
44
- end
45
-
46
- def bevelled=(value)
47
- return if value.nil? || value.empty?
48
-
49
- @options = (@options || {}).merge(bevelled: value)
50
- end
51
-
52
- def linebreak=(value)
53
- return if value.nil? || value.empty?
54
-
55
- @temp_mathml_order << Plurimath::Math::Function::Linebreak.new(
56
- nil,
57
- { linebreak: value },
58
- )
59
- end
60
-
61
- def linebreakstyle=(value)
62
- return if value.nil? || value.empty?
63
-
64
- linebreak_object = @temp_mathml_order.find do |object|
65
- object.is_a?(Math::Function::Linebreak)
66
- end
67
- linebreak_object.attributes[:linebreakstyle] = value if linebreak_object
68
- end
69
-
70
- def linethickness=(value)
71
- return if value.nil? || value.empty?
72
-
73
- @options = (@options || {}).merge(linethickness: value)
74
- end
75
-
76
- def notation=(value)
77
- return if value.nil? || value.empty?
78
-
79
- @parameter_one = value
80
- end
81
-
82
- def mi_value=(value)
83
- return if value.nil? || value.empty?
84
-
85
- update_temp(
86
- replace_order_with_value(
87
- @temp_mathml_order,
88
- validate_symbols(value),
89
- "mi",
90
- ),
91
- )
92
- end
93
-
94
- def mo_value=(value)
95
- return if value.nil? || value.empty?
96
-
97
- update_temp(
98
- replace_order_with_value(
99
- @temp_mathml_order,
100
- validate_symbols(value),
101
- "mo",
102
- ),
103
- )
104
- end
105
-
106
- def mn_value=(value)
107
- return if value.nil? || value.empty?
108
-
109
- update_temp(
110
- replace_order_with_value(
111
- @temp_mathml_order,
112
- value,
113
- "mn",
114
- ),
115
- )
116
- end
117
-
118
- def ms_value=(value)
119
- return if value.nil? || value.empty?
120
-
121
- update_temp(
122
- replace_order_with_value(
123
- @temp_mathml_order,
124
- Array(value),
125
- "ms",
126
- ),
127
- )
128
- end
129
-
130
- def mtext_value=(value)
131
- return if value.nil? || value.empty?
132
-
133
- update_temp(
134
- replace_order_with_value(
135
- @temp_mathml_order,
136
- Array(value),
137
- "mtext",
138
- ),
139
- )
140
- end
141
-
142
- def mrow_value=(value)
143
- return if value.nil? || value.empty?
144
-
145
- update_temp(
146
- replace_order_with_value(
147
- @temp_mathml_order,
148
- filter_values(value, array_to_instance: true),
149
- "mrow",
150
- ),
151
- )
152
- end
153
-
154
- def mstyle_value=(value)
155
- return if value.nil? || value.empty?
156
-
157
- update_temp(
158
- replace_order_with_value(
159
- @temp_mathml_order,
160
- Array(value),
161
- "mstyle",
162
- ),
163
- )
164
- end
165
-
166
- def mfrac_value=(value)
167
- return if value.nil? || value.empty?
168
-
169
- update_temp_order(value, "mfrac")
170
- end
171
-
172
- def munderover_value=(value)
173
- return if value.nil? || value.empty?
174
-
175
- update_temp_order(value, "munderover")
176
- end
177
-
178
- def msubsup_value=(value)
179
- return if value.nil? || value.empty?
180
-
181
- update_temp_order(value, "msubsup")
182
- end
183
-
184
- def munder_value=(value)
185
- return if value.nil? || value.empty?
186
-
187
- update_temp_order(value, "munder")
188
- end
189
-
190
- def mover_value=(value)
191
- return if value.nil? || value.empty?
192
-
193
- update_temp_order(value, "mover")
194
- end
195
-
196
- def msup_value=(value)
197
- return if value.nil? || value.empty?
198
-
199
- update_temp_order(value, "msup")
200
- end
201
-
202
- def msub_value=(value)
203
- return if value.nil? || value.empty?
204
-
205
- update_temp_order(value, "msub")
206
- end
207
-
208
- def mtable_value=(value)
209
- return if value.nil? || value.empty?
210
-
211
- if respond_to?(:value)
212
- self.value = replace_order_with_value(
213
- self.value,
214
- update_temp_mathml_values(value),
215
- "mtable",
216
- )
217
- else
218
- update_temp_order(value, "mtable")
219
- end
220
- end
221
-
222
- def msqrt_value=(value)
223
- return if value.nil? || value.empty?
224
-
225
- update_temp_order(value, "msqrt")
226
- end
227
-
228
- def mfenced_value=(value)
229
- return if value.nil? || value.empty?
230
-
231
- update_temp_order(value, "mfenced")
232
- end
233
-
234
- def mroot_value=(value)
235
- return if value.nil? || value.empty?
236
-
237
- update_temp_order(value, "mroot")
238
- end
239
-
240
- def msgroup_value=(value)
241
- return if value.nil? || value.empty?
242
-
243
- update_temp_order(value, "msgroup")
244
- end
245
-
246
- def mscarries_value=(value)
247
- return if value.nil? || value.empty?
248
-
249
- update_temp_order(value, "mscarries")
250
- end
251
-
252
- def msline_value=(value)
253
- return if value.nil? || value.empty?
254
-
255
- update_temp_order(value, "msline")
256
- end
257
-
258
- def msrow_value=(value)
259
- return if value.nil? || value.empty?
260
-
261
- update_temp_order(value, "msrow")
262
- end
263
-
264
- def mspace_value=(value)
265
- return if value.nil? || value.empty?
266
-
267
- if value.first.linebreak
268
- linebreak = Math::Function::Linebreak.new(
269
- nil,
270
- { linebreak: value.first.linebreak },
271
- )
272
- update_temp_order([linebreak], "mspace")
273
- else
274
- @temp_mathml_order&.delete("mspace")
275
- end
276
- end
277
-
278
- def semantics_value=(value)
279
- return if value.nil? || value.empty?
280
-
281
- update_temp_order(value, "semantics")
282
- end
283
-
284
- def mstack_value=(value)
285
- return if value.nil? || value.empty?
286
-
287
- update_temp_order(value, "mstack")
288
- end
289
-
290
- def merror_value=(value)
291
- return if value.nil? || value.empty?
292
-
293
- update_temp_order(value, "merror")
294
- end
295
-
296
- def mlongdiv_value=(value)
297
- return if value.nil? || value.empty?
298
-
299
- update_temp_order(value, "mlongdiv")
300
- end
301
-
302
- def none_value=(_)
303
- @temp_mathml_order&.delete("none")
304
- end
305
-
306
- def mscarry_value=(value)
307
- return if value.nil? || value.empty?
308
-
309
- @temp_mathml_order&.delete("mscarry")
310
- end
311
-
312
- def menclose_value=(value)
313
- return if value.nil? || value.empty?
314
-
315
- update_temp_order(value, "menclose")
316
- end
317
-
318
- def maligngroup_value=(_)
319
- @temp_mathml_order&.delete("maligngroup")
320
- end
321
-
322
- def malignmark_value=(_)
323
- @temp_mathml_order&.delete("malignmark")
324
- end
325
-
326
- def mpadded_value=(value)
327
- return if value.nil? || value.empty?
328
-
329
- update_temp_order(value, "mpadded")
330
- end
331
-
332
- def mfraction_value=(value)
333
- return if value.nil? || value.empty?
334
-
335
- update_temp_order(value, "mfraction")
336
- end
337
-
338
- def mlabeledtr_value=(value)
339
- return if value.nil? || value.empty?
340
-
341
- update_temp_order(value, "mlabeledtr")
342
- end
343
-
344
- def mmultiscripts_value=(value)
345
- return if value.nil? || value.empty?
346
-
347
- update_temp_order(value, "mmultiscripts")
348
- end
349
-
350
- def mphantom_value=(value)
351
- return if value.nil? || value.empty?
352
-
353
- update_temp_order(value, "mphantom")
354
- end
355
-
356
- def mglyph_value=(value)
357
- return if value.nil? || value.empty?
358
-
359
- update_temp_order(value, "mglyph")
360
- end
361
-
362
- def rspace=(value)
363
- return if value.nil? || value.empty?
364
-
365
- @options = Hash(@options).merge(rspace: value)
366
- end
367
- end
368
- end
369
- end