plurimath 0.11.11 → 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 +12 -5
  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
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class Monospace < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in a monospace 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 = "monospace")
10
16
  super
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class Normal < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in an upright (roman, non-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 = "rm")
10
16
  super
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class SansSerifBoldItalic < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in a bold italic 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: "bi", scr: "sans-serif",
10
16
  options: options)
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class SansSerifItalic < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in an italic 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: "i", scr: "sans-serif",
10
16
  options: options)
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class SansSerif < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in a 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 initialize(parameter_one,
9
15
  parameter_two = "sans-serif")
10
16
  super
@@ -5,6 +5,12 @@ module Plurimath
5
5
  module Function
6
6
  class FontStyle
7
7
  class Script < FontStyle
8
+ # --- Catalog documentation (see Plurimath::Documentation) ---
9
+ DESCRIPTION = "Renders its argument in a 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 initialize(parameter_one,
9
15
  parameter_two = "script")
10
16
  super
@@ -20,6 +20,10 @@ module Plurimath
20
20
  autoload :SansSerifItalic, "#{__dir__}/font_style/sans-serif-italic"
21
21
  autoload :Script, "#{__dir__}/font_style/script"
22
22
 
23
+ # Font styles wrap a single visible argument, so the catalog lists them
24
+ # as unary (overriding BinaryFunction's :binary) to match the site.
25
+ CATALOG_TYPE = :unary
26
+
23
27
  def to_asciimath(options:)
24
28
  parameter_one&.to_asciimath(options: options)
25
29
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Frac < BinaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "A fraction with a numerator over a denominator."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Fraction"
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,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Gcd < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The greatest common divisor."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Greatest_common_divisor"
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,18 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Glb < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The greatest lower bound (infimum) operator."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Infimum_and_supremum"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ CATALOG_FORMAT_LIMITATIONS = {
12
+ latexmath: {
13
+ status: :limited,
14
+ notes: ["The operator name is emitted as plain math letters, not an operator command."],
15
+ },
16
+ }.freeze
17
+ # --- end catalog documentation ---
18
+
7
19
  def validate_function_formula
8
20
  false
9
21
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Hat < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "A hat (circumflex) 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 Hom < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The collection of morphisms from one object to another."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Morphism"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def to_omml_without_math_tag(display_style, options:)
8
14
  array = []
9
15
  array << r_element("hom", rpr_tag: false) unless hide_function_name
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Inf < BinaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The infimum operator, carrying a subscript and superscript."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Infimum_and_supremum"
10
+ EXAMPLE = -> { new(sym("x"), sym("y")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def to_asciimath(options:)
8
14
  first_value = "_(#{parameter_one.to_asciimath(options: options)})" if parameter_one
9
15
  second_value = "^(#{parameter_two.to_asciimath(options: options)})" if parameter_two
@@ -4,7 +4,11 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Int < TernaryFunction
7
- attr_accessor :options
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "An integral of an expression, with optional lower and upper limits."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Integral"
10
+ EXAMPLE = -> { new(sym("x"), sym("y"), sym("z")) }
11
+ # --- end catalog documentation ---
8
12
 
9
13
  FUNCTION = {
10
14
  name: "integral",
@@ -13,6 +17,8 @@ module Plurimath
13
17
  third_value: "integrand",
14
18
  }.freeze
15
19
 
20
+ attr_accessor :options
21
+
16
22
  def initialize(parameter_one = nil,
17
23
  parameter_two = nil,
18
24
  parameter_three = nil,
@@ -4,6 +4,26 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Intent < BinaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "An expression carrying an `intent` annotation for MathML accessibility semantics."
9
+ REFERENCE = "https://www.w3.org/TR/mathml4/#mixing_intent"
10
+ EXAMPLE = -> { new(expr(sym("x")), Text.new("variable")) }
11
+ CATALOG_FORMAT_LIMITATIONS = {
12
+ asciimath: {
13
+ status: :limited,
14
+ notes: ["The intent string is emitted as a visible function argument instead of metadata."],
15
+ },
16
+ latexmath: {
17
+ status: :limited,
18
+ notes: ["The intent string is emitted as a visible function argument instead of metadata."],
19
+ },
20
+ omml: {
21
+ status: :limited,
22
+ notes: ["The MathML intent annotation is omitted; only the expression is emitted."],
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)
@@ -11,6 +31,21 @@ module Plurimath
11
31
  first_value
12
32
  end
13
33
 
34
+ # The intent string is metadata, not content: OMML has no slot for it,
35
+ # so only the wrapped content is written. The inherited BinaryFunction
36
+ # rendering wrapped both parameters in an <m:r>, nesting runs (invalid
37
+ # OMML) and printing the intent text as a visible run.
38
+ def to_omml_without_math_tag(display_style, options:)
39
+ return [] unless parameter_one
40
+
41
+ parameter_one.insert_t_tag(display_style, options: options)
42
+ end
43
+
44
+ # Same leak as OMML: the inherited rendering printed the intent text.
45
+ def to_html(options:)
46
+ "<i>#{parameter_one.to_html(options: options)}</i>" if parameter_one
47
+ end
48
+
14
49
  def to_unicodemath(options:)
15
50
  first_value = "(#{parameter_two.to_unicodemath(options: options)}#{parameter_one.to_unicodemath(options: options)})" if parameter_one || parameter_two
16
51
  "ⓘ#{first_value}"
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Ker < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The kernel of a homomorphism or linear map."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Kernel_(algebra)"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def to_omml_without_math_tag(display_style, options:)
8
14
  array = []
9
15
  array << r_element("ker", rpr_tag: false) unless hide_function_name
@@ -4,6 +4,18 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Lcm < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The least common multiple operator."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Least_common_multiple"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ CATALOG_FORMAT_LIMITATIONS = {
12
+ latexmath: {
13
+ status: :limited,
14
+ notes: ["The operator name is emitted as plain math letters, not an operator command."],
15
+ },
16
+ }.freeze
17
+ # --- end catalog documentation ---
18
+
7
19
  def validate_function_formula
8
20
  false
9
21
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Lg < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The base-10 (common) logarithm."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Common_logarithm"
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 Lim < BinaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The limit operator, carrying a subscript and superscript."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Limit_(mathematics)"
10
+ EXAMPLE = -> { new(sym("x"), sym("y")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  FUNCTION = {
8
14
  name: "limit",
9
15
  first_value: "limit subscript",
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Liminf < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The limit inferior of a sequence."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Limit_inferior_and_limit_superior"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def to_omml_without_math_tag(display_style, options:)
8
14
  array = []
9
15
  array << r_element("liminf", rpr_tag: false) unless hide_function_name
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Limits < TernaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "Lower and upper bounds forced below and above an operator, as with LaTeX's \\limits."
9
+ REFERENCE = "https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/munderover"
10
+ EXAMPLE = -> { new(Int.new, sym("x"), sym("y")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  FUNCTION = {
8
14
  name: "function apply",
9
15
  first_value: "base",
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Limsup < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The limit superior of a sequence."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Limit_inferior_and_limit_superior"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def to_omml_without_math_tag(display_style, options:)
8
14
  array = []
9
15
  array << r_element("limsup", rpr_tag: false) unless hide_function_name
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Ln < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The natural logarithm."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Natural_logarithm"
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 Log < BinaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The logarithm operator, carrying a subscript and superscript."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Logarithm"
10
+ EXAMPLE = -> { new(sym("x"), sym("y")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  FUNCTION = {
8
14
  name: "function apply",
9
15
  first_value: "subscript",
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Longdiv < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "Sets its argument under a long-division bracket."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Long_division"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  def to_asciimath(options:)
8
14
  asciimath_value(options: options)
9
15
  end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Lub < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The least upper bound (supremum) of a set."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Infimum_and_supremum"
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 Max < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The maximum of a set."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Maximum_and_minimum"
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 Mbox < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "Typesets its argument in a single-line text box."
9
+ REFERENCE = "https://latexref.xyz/_005cmbox-_0026-_005cmakebox.html"
10
+ EXAMPLE = -> { new("x") }
11
+ # --- end catalog documentation ---
12
+
7
13
  def to_asciimath(options:)
8
14
  Text.new(parameter_one).to_asciimath(options: options)
9
15
  end
@@ -4,6 +4,25 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Menclose < BinaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ # Menclose wraps a single visible expression, so the catalog lists it as
9
+ # unary (overriding BinaryFunction's :binary) to match the site.
10
+ CATALOG_TYPE = :unary
11
+ DESCRIPTION = "An expression wrapped in an enclosing notation, such as a box, circle, or strike."
12
+ REFERENCE = "https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/menclose"
13
+ EXAMPLE = -> { new("box", sym("x")) }
14
+ CATALOG_FORMAT_LIMITATIONS = {
15
+ asciimath: {
16
+ status: :limited,
17
+ notes: ["The enclosure notation is omitted; only the enclosed expression is emitted."],
18
+ },
19
+ latexmath: {
20
+ status: :limited,
21
+ notes: ["The enclosure notation is omitted; only the enclosed expression is emitted."],
22
+ },
23
+ }.freeze
24
+ # --- end catalog documentation ---
25
+
7
26
  FUNCTION = {
8
27
  name: "enclosure",
9
28
  first_value: "enclosure type",
@@ -4,6 +4,28 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Merror < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ # MathML-only element: it has no AsciiMath/LaTeX form, so those render
9
+ # empty — accepted for the catalog (no page vanishes).
10
+ DESCRIPTION = "Displays its argument as a MathML error message."
11
+ REFERENCE = "https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/merror"
12
+ EXAMPLE = -> { new(sym("x")) }
13
+ CATALOG_FORMAT_LIMITATIONS = {
14
+ asciimath: {
15
+ status: :unavailable,
16
+ notes: ["No AsciiMath representation of the error expression is emitted."],
17
+ },
18
+ latexmath: {
19
+ status: :unavailable,
20
+ notes: ["No LaTeX representation of the error expression is emitted."],
21
+ },
22
+ omml: {
23
+ status: :unavailable,
24
+ notes: ["Only an empty OMML document is emitted; the error expression is omitted."],
25
+ },
26
+ }.freeze
27
+ # --- end catalog documentation ---
28
+
7
29
  def to_asciimath(**); end
8
30
 
9
31
  def to_latex(**); end
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Min < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The minimum of a set."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Maximum_and_minimum"
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,29 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Mlabeledtr < BinaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ # parameter_one is the row content, parameter_two the label (e.g. an
9
+ # equation number). Only MathML and UnicodeMath are overridden; the
10
+ # other formats fall back to the generic binary rendering.
11
+ DESCRIPTION = "A table row carrying a label, such as an equation number."
12
+ REFERENCE = "https://www.w3.org/TR/MathML3/chapter3.html#presm.mlabeledtr"
13
+ EXAMPLE = -> { new(sym("x"), Text.new("1")) }
14
+ CATALOG_FORMAT_LIMITATIONS = {
15
+ asciimath: {
16
+ status: :limited,
17
+ notes: ["A generic function expression is emitted instead of a labeled table row."],
18
+ },
19
+ latexmath: {
20
+ status: :limited,
21
+ notes: ["A generic mlabeledtr macro is emitted instead of equation-label notation."],
22
+ },
23
+ omml: {
24
+ status: :limited,
25
+ notes: ["The row content and label are flattened; labeled table-row structure is omitted."],
26
+ },
27
+ }.freeze
28
+ # --- end catalog documentation ---
29
+
7
30
  def to_mathml_without_math_tag(intent, options:)
8
31
  table = ox_element("mtable")
9
32
  mlabeledtr = ox_element(class_name)
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Mod < BinaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The modulo operation between two operands."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Modulo"
10
+ EXAMPLE = -> { new(sym("x"), sym("y")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  FUNCTION = {
8
14
  name: "mod",
9
15
  first_value: "base",
@@ -4,6 +4,26 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Msgroup < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "Groups elementary-math rows so their positions shift together."
9
+ REFERENCE = "https://www.w3.org/TR/mathml4/#presm_msgroup"
10
+ EXAMPLE = -> { new([sym("x")]) }
11
+ CATALOG_FORMAT_LIMITATIONS = {
12
+ asciimath: {
13
+ status: :limited,
14
+ notes: ["Elementary-math grouping is omitted; only the group contents are emitted."],
15
+ },
16
+ latexmath: {
17
+ status: :limited,
18
+ notes: ["Elementary-math grouping is omitted; only the group contents are emitted."],
19
+ },
20
+ omml: {
21
+ status: :limited,
22
+ notes: ["Elementary-math grouping is omitted; only the group contents are emitted."],
23
+ },
24
+ }.freeze
25
+ # --- end catalog documentation ---
26
+
7
27
  def to_asciimath(options:)
8
28
  parameter_one.map do |param|
9
29
  param.to_asciimath(options: options)
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Multiscript < TernaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "A base carrying prescripts set before it, optionally alongside postscripts after it."
9
+ REFERENCE = "https://developer.mozilla.org/en-US/docs/Web/MathML/Reference/Element/mmultiscripts"
10
+ EXAMPLE = -> { new(PowerBase.new(sym("x"), sym("y"), sym("z")), [sym("a")], [sym("b")]) }
11
+ # --- end catalog documentation ---
12
+
7
13
  FUNCTION = {
8
14
  name: "multiscript",
9
15
  first_value: "base",
@@ -4,6 +4,17 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Nary < Core
7
+ extend Documentation
8
+
9
+ # --- Catalog documentation (see Plurimath::Documentation) ---
10
+ # The page slug is "n-ary" rather than the derived "nary".
11
+ CATALOG_NAME = "n-ary"
12
+ CATALOG_TYPE = :binary
13
+ DESCRIPTION = "A large n-ary operator, such as an integral, sum, or product, carrying optional lower and upper limits and an operand."
14
+ REFERENCE = "https://www.unicode.org/notes/tn28/UTN28-PlainTextMath-v3.2.pdf"
15
+ EXAMPLE = -> { new(sym("v"), sym("x"), sym("y"), sym("z")) }
16
+ # --- end catalog documentation ---
17
+
7
18
  attr_accessor :parameter_one, :parameter_two, :parameter_three,
8
19
  :parameter_four, :options
9
20
 
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Norm < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "The norm of its argument, written between double bars."
9
+ REFERENCE = "https://en.wikipedia.org/wiki/Norm_(mathematics)"
10
+ EXAMPLE = -> { new(sym("x")) }
11
+ # --- end catalog documentation ---
12
+
7
13
  attr_accessor :open_paren, :close_paren
8
14
 
9
15
  def to_asciimath(options:)
@@ -4,6 +4,12 @@ module Plurimath
4
4
  module Math
5
5
  module Function
6
6
  class Obrace < UnaryFunction
7
+ # --- Catalog documentation (see Plurimath::Documentation) ---
8
+ DESCRIPTION = "An overbrace spanning 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 = {})