plurimath 0.11.12 → 0.11.13

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 (170) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dependent-tests.yml +7 -0
  3. data/.github/workflows/shared-testsuite.yml +24 -0
  4. data/.gitmodules +3 -0
  5. data/.rspec-opal +3 -0
  6. data/Gemfile +18 -0
  7. data/README.adoc +297 -3
  8. data/docs/catalog.adoc +73 -0
  9. data/docs/uncertainty-asciimath-tree.md +92 -0
  10. data/docs/uncertainty.adoc +522 -0
  11. data/lib/plurimath/asciimath/parse.rb +43 -226
  12. data/lib/plurimath/asciimath/parser.rb +58 -1
  13. data/lib/plurimath/asciimath/slice_adapter.rb +138 -0
  14. data/lib/plurimath/asciimath/transform.rb +218 -0
  15. data/lib/plurimath/asciimath.rb +1 -0
  16. data/lib/plurimath/catalog/entry.rb +109 -0
  17. data/lib/plurimath/catalog/validation.rb +109 -0
  18. data/lib/plurimath/catalog.rb +96 -0
  19. data/lib/plurimath/cli/convert.rb +40 -0
  20. data/lib/plurimath/cli/helpers.rb +49 -0
  21. data/lib/plurimath/cli/render.rb +64 -0
  22. data/lib/plurimath/cli.rb +55 -57
  23. data/lib/plurimath/documentation.rb +99 -0
  24. data/lib/plurimath/errors/ambiguous_decimal_error.rb +19 -0
  25. data/lib/plurimath/errors/invalid_uncertainty.rb +18 -0
  26. data/lib/plurimath/errors/missing_dependency_error.rb +23 -0
  27. data/lib/plurimath/errors/rendering_failed.rb +17 -0
  28. data/lib/plurimath/errors/rendering_unavailable.rb +25 -0
  29. data/lib/plurimath/errors/unsupported_render_format.rb +18 -0
  30. data/lib/plurimath/errors/unsupported_semantic_tree_error.rb +12 -0
  31. data/lib/plurimath/errors.rb +5 -0
  32. data/lib/plurimath/math/evaluation/evaluator.rb +48 -0
  33. data/lib/plurimath/math/evaluation/expression_parser.rb +29 -20
  34. data/lib/plurimath/math/formula/class_tree.rb +92 -0
  35. data/lib/plurimath/math/formula.rb +43 -2
  36. data/lib/plurimath/math/function/abs.rb +6 -0
  37. data/lib/plurimath/math/function/arccos.rb +6 -0
  38. data/lib/plurimath/math/function/arcsin.rb +6 -0
  39. data/lib/plurimath/math/function/arctan.rb +6 -0
  40. data/lib/plurimath/math/function/arg.rb +20 -0
  41. data/lib/plurimath/math/function/bar.rb +6 -0
  42. data/lib/plurimath/math/function/base.rb +6 -0
  43. data/lib/plurimath/math/function/binary_function.rb +4 -0
  44. data/lib/plurimath/math/function/cancel.rb +6 -0
  45. data/lib/plurimath/math/function/ceil.rb +6 -0
  46. data/lib/plurimath/math/function/color.rb +12 -0
  47. data/lib/plurimath/math/function/cos.rb +6 -0
  48. data/lib/plurimath/math/function/cosh.rb +6 -0
  49. data/lib/plurimath/math/function/cot.rb +6 -0
  50. data/lib/plurimath/math/function/coth.rb +6 -0
  51. data/lib/plurimath/math/function/csc.rb +6 -0
  52. data/lib/plurimath/math/function/csch.rb +6 -0
  53. data/lib/plurimath/math/function/ddot.rb +6 -0
  54. data/lib/plurimath/math/function/deg.rb +6 -0
  55. data/lib/plurimath/math/function/det.rb +6 -0
  56. data/lib/plurimath/math/function/dim.rb +6 -0
  57. data/lib/plurimath/math/function/dot.rb +6 -0
  58. data/lib/plurimath/math/function/exp.rb +6 -0
  59. data/lib/plurimath/math/function/fenced.rb +6 -0
  60. data/lib/plurimath/math/function/floor.rb +6 -0
  61. data/lib/plurimath/math/function/font_style/bold-fraktur.rb +6 -0
  62. data/lib/plurimath/math/function/font_style/bold-italic.rb +6 -0
  63. data/lib/plurimath/math/function/font_style/bold-sans-serif.rb +6 -0
  64. data/lib/plurimath/math/function/font_style/bold-script.rb +6 -0
  65. data/lib/plurimath/math/function/font_style/bold.rb +6 -0
  66. data/lib/plurimath/math/function/font_style/double_struck.rb +6 -0
  67. data/lib/plurimath/math/function/font_style/fraktur.rb +6 -0
  68. data/lib/plurimath/math/function/font_style/italic.rb +6 -0
  69. data/lib/plurimath/math/function/font_style/monospace.rb +6 -0
  70. data/lib/plurimath/math/function/font_style/normal.rb +6 -0
  71. data/lib/plurimath/math/function/font_style/sans-serif-bold-italic.rb +6 -0
  72. data/lib/plurimath/math/function/font_style/sans-serif-italic.rb +6 -0
  73. data/lib/plurimath/math/function/font_style/sans-serif.rb +6 -0
  74. data/lib/plurimath/math/function/font_style/script.rb +6 -0
  75. data/lib/plurimath/math/function/font_style.rb +4 -0
  76. data/lib/plurimath/math/function/frac.rb +6 -0
  77. data/lib/plurimath/math/function/gcd.rb +6 -0
  78. data/lib/plurimath/math/function/glb.rb +12 -0
  79. data/lib/plurimath/math/function/hat.rb +6 -0
  80. data/lib/plurimath/math/function/hom.rb +6 -0
  81. data/lib/plurimath/math/function/inf.rb +6 -0
  82. data/lib/plurimath/math/function/int.rb +7 -1
  83. data/lib/plurimath/math/function/intent.rb +35 -0
  84. data/lib/plurimath/math/function/ker.rb +6 -0
  85. data/lib/plurimath/math/function/lcm.rb +12 -0
  86. data/lib/plurimath/math/function/lg.rb +6 -0
  87. data/lib/plurimath/math/function/lim.rb +6 -0
  88. data/lib/plurimath/math/function/liminf.rb +6 -0
  89. data/lib/plurimath/math/function/limits.rb +6 -0
  90. data/lib/plurimath/math/function/limsup.rb +6 -0
  91. data/lib/plurimath/math/function/ln.rb +6 -0
  92. data/lib/plurimath/math/function/log.rb +6 -0
  93. data/lib/plurimath/math/function/longdiv.rb +6 -0
  94. data/lib/plurimath/math/function/lub.rb +6 -0
  95. data/lib/plurimath/math/function/max.rb +6 -0
  96. data/lib/plurimath/math/function/mbox.rb +6 -0
  97. data/lib/plurimath/math/function/menclose.rb +19 -0
  98. data/lib/plurimath/math/function/merror.rb +22 -0
  99. data/lib/plurimath/math/function/min.rb +6 -0
  100. data/lib/plurimath/math/function/mlabeledtr.rb +23 -0
  101. data/lib/plurimath/math/function/mod.rb +6 -0
  102. data/lib/plurimath/math/function/msgroup.rb +20 -0
  103. data/lib/plurimath/math/function/multiscript.rb +6 -0
  104. data/lib/plurimath/math/function/nary.rb +11 -0
  105. data/lib/plurimath/math/function/norm.rb +6 -0
  106. data/lib/plurimath/math/function/obrace.rb +6 -0
  107. data/lib/plurimath/math/function/oint.rb +7 -1
  108. data/lib/plurimath/math/function/over.rb +6 -0
  109. data/lib/plurimath/math/function/overleftrightarrow.rb +6 -0
  110. data/lib/plurimath/math/function/overset.rb +6 -0
  111. data/lib/plurimath/math/function/phantom.rb +6 -0
  112. data/lib/plurimath/math/function/power.rb +6 -0
  113. data/lib/plurimath/math/function/power_base.rb +6 -0
  114. data/lib/plurimath/math/function/prod.rb +7 -1
  115. data/lib/plurimath/math/function/right.rb +1 -1
  116. data/lib/plurimath/math/function/root.rb +6 -0
  117. data/lib/plurimath/math/function/rule.rb +20 -0
  118. data/lib/plurimath/math/function/scarries.rb +20 -0
  119. data/lib/plurimath/math/function/sec.rb +6 -0
  120. data/lib/plurimath/math/function/sech.rb +6 -0
  121. data/lib/plurimath/math/function/semantics.rb +20 -0
  122. data/lib/plurimath/math/function/sin.rb +6 -0
  123. data/lib/plurimath/math/function/sinh.rb +6 -0
  124. data/lib/plurimath/math/function/sqrt.rb +6 -0
  125. data/lib/plurimath/math/function/stackrel.rb +6 -0
  126. data/lib/plurimath/math/function/substack.rb +6 -0
  127. data/lib/plurimath/math/function/sum.rb +7 -1
  128. data/lib/plurimath/math/function/sup.rb +6 -0
  129. data/lib/plurimath/math/function/table/align.rb +6 -0
  130. data/lib/plurimath/math/function/table/array.rb +6 -0
  131. data/lib/plurimath/math/function/table/bmatrix.rb +6 -0
  132. data/lib/plurimath/math/function/table/cases.rb +6 -0
  133. data/lib/plurimath/math/function/table/eqarray.rb +6 -0
  134. data/lib/plurimath/math/function/table/matrix.rb +6 -0
  135. data/lib/plurimath/math/function/table/multline.rb +6 -0
  136. data/lib/plurimath/math/function/table/pmatrix.rb +6 -0
  137. data/lib/plurimath/math/function/table/split.rb +6 -0
  138. data/lib/plurimath/math/function/table/vmatrix.rb +6 -0
  139. data/lib/plurimath/math/function/table.rb +10 -0
  140. data/lib/plurimath/math/function/tan.rb +6 -0
  141. data/lib/plurimath/math/function/tanh.rb +6 -0
  142. data/lib/plurimath/math/function/ternary_function.rb +4 -0
  143. data/lib/plurimath/math/function/text.rb +6 -0
  144. data/lib/plurimath/math/function/tilde.rb +6 -0
  145. data/lib/plurimath/math/function/ubrace.rb +6 -0
  146. data/lib/plurimath/math/function/ul.rb +6 -0
  147. data/lib/plurimath/math/function/unary_function.rb +4 -0
  148. data/lib/plurimath/math/function/uncertainty.rb +655 -0
  149. data/lib/plurimath/math/function/underover.rb +6 -0
  150. data/lib/plurimath/math/function/underset.rb +6 -0
  151. data/lib/plurimath/math/function/vec.rb +6 -0
  152. data/lib/plurimath/math/function.rb +1 -0
  153. data/lib/plurimath/math/renderer.rb +95 -0
  154. data/lib/plurimath/math/semantic_tree.rb +331 -0
  155. data/lib/plurimath/math/symbols/symbol.rb +2 -0
  156. data/lib/plurimath/math.rb +26 -0
  157. data/lib/plurimath/mathml/translator.rb +32 -0
  158. data/lib/plurimath/mathml/uncertainty_marker.rb +118 -0
  159. data/lib/plurimath/omml/translator.rb +68 -0
  160. data/lib/plurimath/omml/utility.rb +9 -1
  161. data/lib/plurimath/symbol_documentation.rb +57 -0
  162. data/lib/plurimath/unicode_math/parsing_rules/common_rules.rb +2 -1
  163. data/lib/plurimath/unicode_math/parsing_rules/masked.rb +3 -0
  164. data/lib/plurimath/unicode_math/transform.rb +64 -3
  165. data/lib/plurimath/unicode_math/utility.rb +38 -0
  166. data/lib/plurimath/version.rb +1 -1
  167. data/lib/plurimath.rb +3 -0
  168. data/plurimath.gemspec +3 -1
  169. data/scripts/replay_asciimath_corpus.rb +611 -0
  170. metadata +30 -4
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Plurimath
4
+ module Math
5
+ class Formula
6
+ # The stored model composition, independent of language rendering and its
7
+ # filtering. Only model content fields are visited; formatting options,
8
+ # source text, XML objects and rendering caches are deliberately omitted.
9
+ class ClassTree
10
+ UNCERTAINTY_FIELDS = %i[
11
+ value category magnitude coverage_factor coverage_probability lower
12
+ upper interval_kind notation unit
13
+ ].freeze
14
+
15
+ def render(formula)
16
+ lines = []
17
+ append(formula, nil, 0, lines, {})
18
+ lines.join("\n")
19
+ end
20
+
21
+ private
22
+
23
+ def append(object, label, depth, lines, ancestors)
24
+ prefix = "#{' ' * depth}#{"#{label}: " if label}"
25
+ unless object.is_a?(Core) || object.is_a?(::Array)
26
+ lines << "#{prefix}#{literal(object)}"
27
+ return
28
+ end
29
+
30
+ if ancestors.key?(object.object_id)
31
+ lines << "#{prefix}<cycle: #{object.class.name}>"
32
+ return
33
+ end
34
+
35
+ ancestors[object.object_id] = true
36
+ begin
37
+ if object.is_a?(::Array)
38
+ append_array(object, label, depth, lines, ancestors)
39
+ else
40
+ lines << "#{prefix}#{object.class.name}"
41
+ fields(object).each do |field|
42
+ append(object.public_send(field), field, depth + 1,
43
+ lines, ancestors)
44
+ end
45
+ end
46
+ ensure
47
+ ancestors.delete(object.object_id)
48
+ end
49
+ end
50
+
51
+ def append_array(array, label, depth, lines, ancestors)
52
+ if array.empty?
53
+ lines << "#{' ' * depth}#{label}: []"
54
+ else
55
+ array.each_with_index do |child, index|
56
+ append(child, "#{label}[#{index}]", depth, lines, ancestors)
57
+ end
58
+ end
59
+ end
60
+
61
+ def fields(object)
62
+ case object
63
+ when Function::Table
64
+ %i[value open_paren close_paren]
65
+ when Function::Uncertainty
66
+ UNCERTAINTY_FIELDS
67
+ else
68
+ parameters = Core::ALL_PARAMETERS.select do |field|
69
+ object.respond_to?(field)
70
+ end
71
+ return parameters unless parameters.empty?
72
+ return [:value] if object.respond_to?(:value)
73
+ return [:text] if object.respond_to?(:text)
74
+
75
+ []
76
+ end
77
+ end
78
+
79
+ def literal(object)
80
+ case object
81
+ when String, ::Symbol, Numeric, true, false, nil
82
+ object.inspect
83
+ else
84
+ # Never delegate to arbitrary #inspect: that can expose internal
85
+ # state or memory addresses in otherwise deterministic output.
86
+ "<#{object.class.name}>"
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -5,6 +5,7 @@ module Plurimath
5
5
  class Formula < Core
6
6
  autoload :Mrow, "#{__dir__}/formula/mrow"
7
7
  autoload :Mstyle, "#{__dir__}/formula/mstyle"
8
+ autoload :ClassTree, "#{__dir__}/formula/class_tree"
8
9
 
9
10
  include Mathml::FormulaTransformation
10
11
 
@@ -13,7 +14,7 @@ module Plurimath
13
14
 
14
15
  POWER_BASE_CLASSES = %w[powerbase power base].freeze
15
16
  DERIVATIVE_CONSTS = ["&#x1d451;", "&#x2145;", "&#x2146;", "d"].freeze
16
- MATH_ZONE_TYPES = %i[omml latex mathml asciimath unicodemath].freeze
17
+ MATH_ZONE_TYPES = %i[omml latex mathml asciimath unicodemath formula].freeze
17
18
  OMML_NAMESPACES = {
18
19
  "xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math",
19
20
  "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
@@ -195,13 +196,23 @@ formatter: nil, unitsml: {})
195
196
  end
196
197
 
197
198
  def to_display(type = nil, formatter: nil, unitsml: {},
198
- unary_function_spacing: true)
199
+ unary_function_spacing: true, tree: :display)
200
+ unless %i[display semantic].include?(tree)
201
+ raise ArgumentError, "Unknown display tree: #{tree.inspect}"
202
+ end
203
+ if tree == :display && type.downcase.to_sym == :formula
204
+ return ClassTree.new.render(self)
205
+ end
206
+
199
207
  options = {
200
208
  formatter: formatter,
201
209
  unitsml: unitsml,
202
210
  unary_function_spacing: unary_function_spacing,
203
211
  }
204
212
  options[:formula] ||= self
213
+ if tree == :semantic
214
+ return SemanticTree.new(type.downcase.to_sym, options).render(self)
215
+ end
205
216
  return type_error!(type) unless MATH_ZONE_TYPES.include?(type.downcase.to_sym)
206
217
 
207
218
  math_zone = case type
@@ -402,6 +413,36 @@ options:)
402
413
  ],
403
414
  )
404
415
  end
416
+
417
+ # Render this formula to a binary image string via the optional `lasem`
418
+ # gem (https://github.com/plurimath/lasem-ruby).
419
+ #
420
+ # +format+ is the output image format, one of :svg, :png, :pdf, :ps.
421
+ #
422
+ # Remaining keyword options are split between the two stages:
423
+ # * to_mathml options (forwarded to #to_mathml): :intent, :formatter,
424
+ # :unitsml, :split_on_linebreak, :display_style,
425
+ # :unary_function_spacing. When :display_style is omitted the
426
+ # formula's own displaystyle is used.
427
+ # * lasem geometry options (forwarded to the renderer): :ppi, :zoom,
428
+ # :width, :height, :offset_x, :offset_y. Omit them for lasem defaults.
429
+ # Unrecognized keyword options are ignored.
430
+ #
431
+ # Raises a Plurimath::Errors rendering error (RenderingUnavailable,
432
+ # UnsupportedRenderFormat, or RenderingFailed) when lasem / its native
433
+ # extension is unavailable, the format is unsupported, or rendering fails.
434
+ # A malformed formula surfaces as Plurimath::Math::ParseError from
435
+ # #to_mathml, not as a rendering error. Note: :split_on_linebreak emits
436
+ # multiple <math> roots,
437
+ # which lasem cannot render as a single document.
438
+ def render(format: :svg, **opts)
439
+ mathml = to_mathml(**opts.slice(*Renderer::MATHML_OPTIONS).compact)
440
+ Renderer.render(
441
+ mathml,
442
+ format: format,
443
+ **opts.slice(*Renderer::LASEM_OPTIONS),
444
+ )
445
+ end
405
446
  # Attributes end
406
447
 
407
448
  protected
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Abs < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The absolute value of an expression."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Absolute_value"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  attr_accessor :open_paren, :close_paren
8
14
 
9
15
  def to_mathml_without_math_tag(intent, options:)
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Arccos < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The inverse cosine (arccosine) function."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Inverse_trigonometric_functions"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Arcsin < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The inverse sine (arcsine) function."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Inverse_trigonometric_functions"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Arctan < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The inverse tangent (arctangent) function."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Inverse_trigonometric_functions"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,26 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Arg < BinaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "An expression given an `arg` name for reference from an ancestor MathML `intent` annotation."
9
+ REFERENCE = "https://www.w3.org/TR/mathml4/#mixing_intent"
10
+ EXAMPLE = -> { new(sym("x"), sym("x")) }
11
+ CATALOG_FORMAT_LIMITATIONS = {
12
+ asciimath: {
13
+ status: :limited,
14
+ notes: ["The argument name is emitted as visible content instead of an arg annotation."],
15
+ },
16
+ latexmath: {
17
+ status: :limited,
18
+ notes: ["The argument name is emitted as visible content instead of an arg annotation."],
19
+ },
20
+ omml: {
21
+ status: :limited,
22
+ notes: ["The argument name is emitted as visible content instead of an arg annotation."],
23
+ },
24
+ }.freeze
25
+ # --- end catalog documentation ---
26
+
7
27
  def to_mathml_without_math_tag(intent, options:)
8
28
  first_value = parameter_one.to_mathml_without_math_tag(intent,
9
29
  options: options)
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Bar < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "An overbar (vinculum) over an expression."
9
+ REFERENCE = "https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/mover"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  attr_accessor :attributes
8
14
 
9
15
  def initialize(parameter_one = nil, attributes = {})
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Base < BinaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "A base carrying a subscript."
9
+ REFERENCE = "https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/msub"
10
+ EXAMPLE = -> { new(sym("x"), sym("y")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  attr_accessor :options
8
14
 
9
15
  FUNCTION = {
@@ -4,6 +4,10 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class BinaryFunction < Core
7
+ extend Documentation
8
+
9
+ CATALOG_TYPE = :binary
10
+
7
11
  attr_accessor :parameter_one, :parameter_two, :hide_function_name
8
12
 
9
13
  def initialize(parameter_one = nil, parameter_two = nil)
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Cancel < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "Strikes its argument through with a diagonal line."
9
+ REFERENCE = "https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/menclose"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def to_mathml_without_math_tag(intent, options:)
8
14
  cancel_tag = XmlHelper.ox_element(
9
15
  "menclose",
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Ceil < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The ceiling of a value, rounded up to an integer."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Floor_and_ceiling_functions"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  attr_accessor :open_paren, :close_paren
8
14
 
9
15
  def to_latex(options:)
@@ -4,6 +4,18 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Color < BinaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "An expression rendered in a specified color."
9
+ REFERENCE = "https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/mstyle"
10
+ EXAMPLE = -> { new(sym("red"), sym("x")) }
11
+ CATALOG_FORMAT_LIMITATIONS = {
12
+ omml: {
13
+ status: :limited,
14
+ notes: ["Color styling is omitted; only the expression is emitted."],
15
+ },
16
+ }.freeze
17
+ # --- end catalog documentation ---
18
+
7
19
  attr_accessor :options
8
20
 
9
21
  FUNCTION = {
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Cos < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The cosine function."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Sine_and_cosine"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Cosh < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The hyperbolic cosine function."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Hyperbolic_functions"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Cot < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The cotangent function."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Trigonometric_functions"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Coth < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The hyperbolic cotangent function."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Hyperbolic_functions"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Csc < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The cosecant function."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Trigonometric_functions"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Csch < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The hyperbolic cosecant function."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Hyperbolic_functions"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Ddot < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "A double-dot accent over an expression."
9
+ REFERENCE = "https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/mover"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  attr_accessor :attributes
8
14
 
9
15
  def initialize(parameter_one = nil, attributes = {})
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Deg < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The degree of a polynomial."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Degree_of_a_polynomial"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Det < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The determinant of a matrix."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Determinant"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Dim < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The dimension of a vector space."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Dimension_(vector_space)"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Dot < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "A single-dot accent over an expression."
9
+ REFERENCE = "https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/mover"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  attr_accessor :attributes
8
14
 
9
15
  def initialize(parameter_one = nil, attributes = {})
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Exp < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The exponential function."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Exponential_function"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def validate_function_formula
8
14
  false
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Fenced < TernaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "Content enclosed by a pair of delimiters (fences), such as parentheses or brackets."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Bracket_(mathematics)"
10
+ EXAMPLE = -> { new(Math::Symbols::Paren::Lround.new, [sym("x")], Math::Symbols::Paren::Rround.new) }
11
+ # --- end catalog documentation ---
12
+
7
13
  include Mathml::FormulaTransformation
8
14
 
9
15
  attr_accessor :options
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Floor < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The floor of a value, rounded down to an integer."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Floor_and_ceiling_functions"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  attr_accessor :open_paren, :close_paren
8
14
 
9
15
  def to_latex(options:)
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class BoldFraktur < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in a bold Fraktur (blackletter) font."
10
+ REFERENCE = "https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols"
11
+ EXAMPLE = -> { new(sym("x")) }
12
+ # --- end catalog documentation ---
13
+
8
14
  def to_omml_without_math_tag(display_style, options:)
9
15
  font_styles(display_style, sty: "b", scr: "fraktur",
10
16
  options: options)
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class BoldItalic < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in a bold italic font."
10
+ REFERENCE = "https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols"
11
+ EXAMPLE = -> { new(sym("x")) }
12
+ # --- end catalog documentation ---
13
+
8
14
  def to_omml_without_math_tag(display_style, options:)
9
15
  font_styles(display_style, sty: "bi", options: options)
10
16
  end
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class BoldSansSerif < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in a bold sans-serif font."
10
+ REFERENCE = "https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols"
11
+ EXAMPLE = -> { new(sym("x")) }
12
+ # --- end catalog documentation ---
13
+
8
14
  def to_omml_without_math_tag(display_style, options:)
9
15
  font_styles(display_style, sty: "b", scr: "sans-serif",
10
16
  options: options)
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class BoldScript < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in a bold script (calligraphic) font."
10
+ REFERENCE = "https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols"
11
+ EXAMPLE = -> { new(sym("x")) }
12
+ # --- end catalog documentation ---
13
+
8
14
  def to_omml_without_math_tag(display_style, options:)
9
15
  font_styles(display_style, sty: "b", scr: "script",
10
16
  options: options)
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class Bold < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in a bold font."
10
+ REFERENCE = "https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols"
11
+ EXAMPLE = -> { new(sym("x")) }
12
+ # --- end catalog documentation ---
13
+
8
14
  def initialize(parameter_one,
9
15
  parameter_two = "bold")
10
16
  super
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class DoubleStruck < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in a double-struck (blackboard bold) font."
10
+ REFERENCE = "https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols"
11
+ EXAMPLE = -> { new(sym("x")) }
12
+ # --- end catalog documentation ---
13
+
8
14
  def initialize(parameter_one,
9
15
  parameter_two = "double-struck")
10
16
  super
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class Fraktur < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in a Fraktur (blackletter) font."
10
+ REFERENCE = "https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols"
11
+ EXAMPLE = -> { new(sym("x")) }
12
+ # --- end catalog documentation ---
13
+
8
14
  def initialize(parameter_one,
9
15
  parameter_two = "fraktur")
10
16
  super
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class Italic < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in an italic font."
10
+ REFERENCE = "https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols"
11
+ EXAMPLE = -> { new(sym("x")) }
12
+ # --- end catalog documentation ---
13
+
8
14
  def initialize(parameter_one,
9
15
  parameter_two = "italic")
10
16
  super