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,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../mathml/utility"
4
-
5
3
  module Plurimath
6
4
  module Math
7
5
  class Formula < Core
8
- include Mathml::Utility
6
+ autoload :Mrow, "#{__dir__}/formula/mrow"
7
+ autoload :Mstyle, "#{__dir__}/formula/mstyle"
8
+
9
+ include Mathml::FormulaTransformation
9
10
 
10
11
  attr_accessor :value, :left_right_wrapper, :displaystyle, :input_string, :display
11
12
 
@@ -54,11 +55,12 @@ module Plurimath
54
55
 
55
56
  def to_asciimath(formatter: nil, unitsml: {}, options: nil)
56
57
  options ||= { formatter: formatter, unitsml: unitsml }.compact
57
- output = value.map do |val|
58
- val.to_asciimath(options: asciimath_table_options(options, val))
59
- end.join(" ")
60
- rescue
61
- parse_error!(:asciimath)
58
+ options[:formula] ||= self
59
+ wrap_render_error(:asciimath) do
60
+ value.map do |val|
61
+ val.to_asciimath(options: asciimath_table_options(options, val))
62
+ end.join(" ")
63
+ end
62
64
  end
63
65
 
64
66
  def to_mathml(
@@ -74,21 +76,22 @@ module Plurimath
74
76
  unitsml: unitsml,
75
77
  unary_function_spacing: unary_function_spacing
76
78
  }.compact
79
+ options[:formula] ||= self
77
80
  return line_breaked_mathml(display_style, intent, options: options) if split_on_linebreak
78
81
 
79
- math_attrs = {
80
- xmlns: "http://www.w3.org/1998/Math/MathML",
81
- display: "block",
82
- }
83
- style_attrs = { displaystyle: boolean_display_style(display_style) }
84
- math = ox_element("math", attributes: math_attrs)
85
- style = ox_element("mstyle", attributes: style_attrs)
86
- Utility.update_nodes(style, mathml_content(intent, options: options))
87
- Utility.update_nodes(math, [style])
88
- unitsml_post_processing(math, style)
89
- dump_nodes(math, indent: 2)
90
- rescue
91
- parse_error!(:mathml)
82
+ wrap_render_error(:mathml) do
83
+ math_attrs = {
84
+ xmlns: "http://www.w3.org/1998/Math/MathML",
85
+ display: "block",
86
+ }
87
+ style_attrs = { displaystyle: boolean_display_style(display_style) }
88
+ math = ox_element("math", attributes: math_attrs)
89
+ style = ox_element("mstyle", attributes: style_attrs)
90
+ Utility.update_nodes(style, mathml_content(intent, options: options))
91
+ Utility.update_nodes(math, [style])
92
+ unitsml_post_processing(math, style)
93
+ dump_nodes(math, indent: 2)
94
+ end
92
95
  end
93
96
 
94
97
  def line_breaked_mathml(display_style, intent, options:)
@@ -119,34 +122,37 @@ module Plurimath
119
122
 
120
123
  def to_latex(formatter: nil, unitsml: {}, options: nil)
121
124
  options ||= { formatter: formatter, unitsml: unitsml }.compact
122
- value.map { |val| val.to_latex(options: options) }.join(" ")
123
- rescue
124
- parse_error!(:latex)
125
+ options[:formula] ||= self
126
+ wrap_render_error(:latex) do
127
+ value.map { |val| val.to_latex(options: options) }.join(" ")
128
+ end
125
129
  end
126
130
 
127
131
  def to_html(formatter: nil, unitsml: {}, options: nil)
128
132
  options ||= { formatter: formatter, unitsml: unitsml }.compact
129
- value&.map { |val| val.to_html(options: options) }&.join(" ")
130
- rescue
131
- parse_error!(:html)
133
+ options[:formula] ||= self
134
+ wrap_render_error(:html) do
135
+ value&.map { |val| val.to_html(options: options) }&.join(" ")
136
+ end
132
137
  end
133
138
 
134
139
  def to_omml(display_style: displaystyle, split_on_linebreak: false, formatter: nil, unitsml: {})
135
- objects = split_on_linebreak ? new_line_support : [self]
136
- options = { formatter: formatter, unitsml: unitsml }.compact
137
- para_element = Utility.ox_element("oMathPara", attributes: OMML_NAMESPACES, namespace: "m")
138
- objects.each.with_index(1) do |object, index|
139
- para_element << Utility.update_nodes(
140
- Utility.ox_element("oMath", namespace: "m"),
141
- object.omml_content(boolean_display_style(display_style), options: options),
142
- )
143
- next if objects.length == index
140
+ wrap_render_error(:omml) do
141
+ objects = split_on_linebreak ? new_line_support : [self]
142
+ options = { formatter: formatter, unitsml: unitsml }.compact
143
+ options[:formula] ||= self
144
+ para_element = Utility.ox_element("oMathPara", attributes: OMML_NAMESPACES, namespace: "m")
145
+ objects.each.with_index(1) do |object, index|
146
+ para_element << Utility.update_nodes(
147
+ Utility.ox_element("oMath", namespace: "m"),
148
+ object.omml_content(boolean_display_style(display_style), options: options),
149
+ )
150
+ next if objects.length == index
144
151
 
145
- para_element << omml_br_tag
152
+ para_element << omml_br_tag
153
+ end
154
+ dump_nodes(para_element, indent: 2)
146
155
  end
147
- dump_nodes(para_element, indent: 2)
148
- rescue
149
- parse_error!(:omml)
150
156
  end
151
157
 
152
158
  def omml_content(display_style, options:)
@@ -159,9 +165,10 @@ module Plurimath
159
165
 
160
166
  def to_unicodemath(formatter: nil, unitsml: {}, options: nil)
161
167
  options ||= { formatter: formatter, unitsml: unitsml }.compact
162
- Utility.html_entity_to_unicode(unicodemath_value(options: options)).gsub(/\s\/\s/, "/")
163
- rescue
164
- parse_error!(:unicodemath)
168
+ options[:formula] ||= self
169
+ wrap_render_error(:unicodemath) do
170
+ Utility.html_entity_to_unicode(unicodemath_value(options: options)).gsub(/\s\/\s/, "/")
171
+ end
165
172
  end
166
173
 
167
174
  def to_display(type = nil, formatter: nil, unitsml: {}, unary_function_spacing: true)
@@ -170,6 +177,7 @@ module Plurimath
170
177
  unitsml: unitsml,
171
178
  unary_function_spacing: unary_function_spacing
172
179
  }
180
+ options[:formula] ||= self
173
181
  return type_error!(type) unless MATH_ZONE_TYPES.include?(type.downcase.to_sym)
174
182
 
175
183
  math_zone = case type
@@ -305,10 +313,6 @@ module Plurimath
305
313
  }
306
314
  end
307
315
 
308
- def element_order=(value)
309
- @value = validated_order(value.map(&:name))
310
- end
311
-
312
316
  # Attributes start
313
317
  def mathcolor=(value)
314
318
  return if value.nil? || value.empty?
@@ -352,244 +356,6 @@ module Plurimath
352
356
  end
353
357
  # Attributes end
354
358
 
355
- def ms_value=(value)
356
- return if value.nil? || value.empty?
357
-
358
- update(
359
- replace_order_with_value(
360
- @value,
361
- Array(validate_symbols(value)),
362
- "ms"
363
- )
364
- )
365
- end
366
-
367
- def mi_value=(value)
368
- return if value.nil? || value.empty?
369
-
370
- value = update_temp_mathml_values(value) if value.any? do |val|
371
- val.is_a?(Math::Core) && val.temp_mathml_order.any?
372
- end
373
- update(
374
- replace_order_with_value(
375
- @value,
376
- Array(validate_symbols(value)).flatten,
377
- "mi"
378
- )
379
- )
380
- end
381
-
382
- def mn_value=(value)
383
- return if value.nil? || value.empty?
384
-
385
- update(
386
- replace_order_with_value(
387
- @value,
388
- Array(validate_symbols(value)),
389
- "mn"
390
- )
391
- )
392
- end
393
-
394
- def mtext_value=(value)
395
- return if value.nil? || value.empty?
396
-
397
- update(
398
- replace_order_with_value(
399
- @value,
400
- Array(validate_symbols(value)),
401
- "mtext"
402
- )
403
- )
404
- end
405
-
406
- def mo_value=(value)
407
- return if value.nil? || value.empty?
408
-
409
- value = update_temp_mathml_values(value)
410
- update(
411
- replace_order_with_value(
412
- @value,
413
- Array(value),
414
- "mo"
415
- )
416
- )
417
- end
418
-
419
- def mstyle_value=(value)
420
- return if value.nil? || value.empty?
421
-
422
- replacing_order = value.length > 1 && value.any?(String)
423
- update(
424
- filter_values(
425
- replace_order_with_value(
426
- @value,
427
- Array(
428
- filter_values(
429
- value,
430
- array_to_instance: true,
431
- replacing_order: replacing_order,
432
- ),
433
- ),
434
- "mstyle"
435
- )
436
- )
437
- )
438
- end
439
-
440
- def mrow_value=(value)
441
- return if value.nil? || value.empty?
442
-
443
- replacing_order = value.length > 1 && value.any?(String)
444
- update(
445
- replace_order_with_value(
446
- @value,
447
- filter_values(
448
- value,
449
- array_to_instance: true,
450
- replacing_order: replacing_order
451
- ),
452
- "mrow"
453
- )
454
- )
455
- end
456
-
457
- def munderover_value=(value)
458
- update_temp_order(value, "munderover")
459
- end
460
-
461
- def msub_value=(value)
462
- update_temp_order(value, "msub")
463
- end
464
-
465
- def msup_value=(value)
466
- update_temp_order(value, "msup")
467
- end
468
-
469
- def mover_value=(value)
470
- update_temp_order(value, "mover")
471
- end
472
-
473
- def munder_value=(value)
474
- update_temp_order(value, "munder")
475
- end
476
-
477
- def msubsup_value=(value)
478
- update_temp_order(value, "msubsup")
479
- end
480
-
481
- def mfrac_value=(value)
482
- update_temp_order(value, "mfrac")
483
- end
484
-
485
- def msqrt_value=(value)
486
- update_temp_order(value, "msqrt")
487
- end
488
-
489
- def mfenced_value=(value)
490
- update_temp_order(value, "mfenced")
491
- end
492
-
493
- def mroot_value=(value)
494
- update_temp_order(value, "mroot")
495
- end
496
-
497
- def msgroup_value=(value)
498
- update_temp_order(value, "msgroup")
499
- end
500
-
501
- def mscarries_value=(value)
502
- update_temp_order(value, "mscarries")
503
- end
504
-
505
- def msline_value=(value)
506
- update_temp_order(value, "msline")
507
- end
508
-
509
- def msrow_value=(value)
510
- update_temp_order(value, "msrow")
511
- end
512
-
513
- def semantics_value=(value)
514
- update_temp_order(value, "semantics")
515
- end
516
-
517
- def mstack_value=(value)
518
- update_temp_order(value, "mstack")
519
- end
520
-
521
- def merror_value=(value)
522
- return if value.nil? || value.empty?
523
-
524
- update(
525
- replace_order_with_value(
526
- @value,
527
- filter_values(update_temp_mathml_values(value)),
528
- "merror"
529
- )
530
- )
531
- end
532
-
533
- def mlongdiv_value=(value)
534
- update_temp_order(value, "mlongdiv")
535
- end
536
-
537
- def none_value=(_)
538
- @value&.delete("none")
539
- end
540
-
541
- def maligngroup_value=(value)
542
- @value&.delete("maligngroup")
543
- end
544
-
545
- def menclose_value=(value)
546
- update_temp_order(value, "menclose")
547
- end
548
-
549
- def mspace_value=(value)
550
- return if value.nil? || value.empty?
551
-
552
- if value.first.linebreak
553
- linebreak = Math::Function::Linebreak.new(
554
- nil,
555
- { linebreak: value.first.linebreak }
556
- )
557
- update(
558
- replace_order_with_value(
559
- @value,
560
- [linebreak],
561
- "mspace"
562
- )
563
- )
564
- else
565
- @value&.delete("mspace")
566
- end
567
- end
568
-
569
- def malignmark_value=(value)
570
- @value&.delete("malignmark")
571
- end
572
-
573
- def mpadded_value=(value)
574
- update_temp_order(value, "mpadded")
575
- end
576
-
577
- def mfraction_value=(value)
578
- update_temp_order(value, "mfraction")
579
- end
580
-
581
- def mmultiscripts_value=(value)
582
- update_temp_order(value, "mmultiscripts")
583
- end
584
-
585
- def mphantom_value=(value)
586
- update_temp_order(value, "mphantom")
587
- end
588
-
589
- def mglyph_value=(value)
590
- update_temp_order(value, "mglyph")
591
- end
592
-
593
359
  protected
594
360
 
595
361
  def asciimath_table_options(options, object)
@@ -598,22 +364,6 @@ module Plurimath
598
364
  options.merge(literal_comma: true)
599
365
  end
600
366
 
601
- def update_temp_order(value, order_name)
602
- return if value.nil? || value.empty?
603
-
604
- update(
605
- replace_order_with_value(
606
- Array(@value),
607
- Array(update_temp_mathml_values(value)),
608
- order_name
609
- )
610
- )
611
- end
612
-
613
- def remove_order(order)
614
- value.delete_if { |val| val.is_a?(String) && val == order }
615
- end
616
-
617
367
  def boolean_display_style(display_style = displaystyle)
618
368
  YAML.safe_load(display_style.to_s)
619
369
  end
@@ -634,6 +384,14 @@ module Plurimath
634
384
  raise ParseError.new(input_string, type)
635
385
  end
636
386
 
387
+ def wrap_render_error(type)
388
+ yield
389
+ rescue ParseError
390
+ raise
391
+ rescue StandardError
392
+ parse_error!(type)
393
+ end
394
+
637
395
  def omml_br_tag
638
396
  r_tag = ox_element("r", namespace: "m")
639
397
  r_tag << ox_element("br")
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "binary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,13 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "binary_function"
4
- require_relative "../../mathml/utility"
5
3
 
6
4
  module Plurimath
7
5
  module Math
8
6
  module Function
9
7
  class Base < BinaryFunction
10
- include Mathml::Utility
11
8
 
12
9
  attr_accessor :options
13
10
 
@@ -57,11 +57,11 @@ module Plurimath
57
57
  end
58
58
 
59
59
  def any_value_exist?
60
- !(parameter_one.nil? || parameter_two.nil?)
60
+ (parameter_one || parameter_two)
61
61
  end
62
62
 
63
63
  def all_values_exist?
64
- !(parameter_one.nil? && parameter_two.nil?)
64
+ (parameter_one && parameter_two)
65
65
  end
66
66
 
67
67
  def to_asciimath_math_zone(spacing, last = false, _, options:)
@@ -127,7 +127,7 @@ module Plurimath
127
127
  end
128
128
 
129
129
  def underover(display_style, options:)
130
- return r_element(class_name, rpr_tag: false) unless all_values_exist?
130
+ return r_element(class_name, rpr_tag: false) unless any_value_exist?
131
131
 
132
132
  first_value = Symbols::Symbol.new(class_name)
133
133
  if !display_style
@@ -135,6 +135,8 @@ module Plurimath
135
135
  return power_base.to_omml_without_math_tag(display_style, options: options)
136
136
  end
137
137
 
138
+ # Build Overset from source argument positions, not OMML child names,
139
+ # so shared under/over functions keep the same format-neutral model.
138
140
  overset = Overset.new(first_value, parameter_two)
139
141
  return Array(overset.to_omml_without_math_tag(display_style, options: options)) unless parameter_one
140
142
 
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "binary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
4
3
 
5
4
  module Plurimath
6
5
  module Math