plurimath 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +8 -11
  3. data/.gitignore +1 -0
  4. data/AsciiMath-Supported-Data.adoc +280 -0
  5. data/Gemfile +1 -0
  6. data/Latex-Supported-Data.adoc +1872 -0
  7. data/MathML-Supported-Data.adoc +270 -0
  8. data/README.adoc +94 -0
  9. data/lib/plurimath/asciimath/constants.rb +215 -222
  10. data/lib/plurimath/asciimath/parse.rb +45 -11
  11. data/lib/plurimath/asciimath/parser.rb +4 -3
  12. data/lib/plurimath/asciimath/transform.rb +222 -131
  13. data/lib/plurimath/asciimath.rb +1 -1
  14. data/lib/plurimath/html/constants.rb +50 -0
  15. data/lib/plurimath/html/parse.rb +149 -0
  16. data/lib/plurimath/html/parser.rb +26 -0
  17. data/lib/plurimath/html/transform.rb +363 -0
  18. data/lib/plurimath/html.rb +1 -1
  19. data/lib/plurimath/latex/constants.rb +1885 -1858
  20. data/lib/plurimath/latex/parse.rb +127 -34
  21. data/lib/plurimath/latex/parser.rb +5 -4
  22. data/lib/plurimath/latex/transform.rb +324 -164
  23. data/lib/plurimath/math/formula.rb +9 -1
  24. data/lib/plurimath/math/function/bar.rb +1 -1
  25. data/lib/plurimath/math/function/base.rb +7 -1
  26. data/lib/plurimath/math/function/binary_function.rb +10 -5
  27. data/lib/plurimath/math/function/color.rb +4 -4
  28. data/lib/plurimath/math/function/fenced.rb +7 -2
  29. data/lib/plurimath/math/function/font_style/bold.rb +18 -0
  30. data/lib/plurimath/math/function/font_style/double_struck.rb +18 -0
  31. data/lib/plurimath/math/function/font_style/fraktur.rb +18 -0
  32. data/lib/plurimath/math/function/font_style/monospace.rb +18 -0
  33. data/lib/plurimath/math/function/font_style/sans-serif.rb +18 -0
  34. data/lib/plurimath/math/function/font_style/script.rb +18 -0
  35. data/lib/plurimath/math/function/font_style.rb +2 -22
  36. data/lib/plurimath/math/function/frac.rb +4 -4
  37. data/lib/plurimath/math/function/inf.rb +0 -1
  38. data/lib/plurimath/math/function/left.rb +3 -6
  39. data/lib/plurimath/math/function/limits.rb +0 -1
  40. data/lib/plurimath/math/function/log.rb +6 -0
  41. data/lib/plurimath/math/function/mod.rb +6 -0
  42. data/lib/plurimath/math/function/multiscript.rb +11 -0
  43. data/lib/plurimath/math/function/norm.rb +2 -1
  44. data/lib/plurimath/math/function/over.rb +29 -0
  45. data/lib/plurimath/math/function/overset.rb +2 -2
  46. data/lib/plurimath/math/function/power.rb +7 -1
  47. data/lib/plurimath/math/function/power_base.rb +14 -7
  48. data/lib/plurimath/math/function/prod.rb +6 -0
  49. data/lib/plurimath/math/function/right.rb +24 -0
  50. data/lib/plurimath/math/function/root.rb +5 -4
  51. data/lib/plurimath/math/function/sqrt.rb +1 -1
  52. data/lib/plurimath/math/function/substack.rb +0 -1
  53. data/lib/plurimath/math/function/sum.rb +6 -0
  54. data/lib/plurimath/math/function/table/align.rb +24 -0
  55. data/lib/plurimath/math/function/table/array.rb +25 -0
  56. data/lib/plurimath/math/function/table/bmatrix.rb +26 -0
  57. data/lib/plurimath/math/function/table/matrix.rb +24 -0
  58. data/lib/plurimath/math/function/table/multline.rb +24 -0
  59. data/lib/plurimath/math/function/table/pmatrix.rb +24 -0
  60. data/lib/plurimath/math/function/table/split.rb +24 -0
  61. data/lib/plurimath/math/function/table/vmatrix.rb +25 -0
  62. data/lib/plurimath/math/function/table.rb +17 -5
  63. data/lib/plurimath/math/function/td.rb +6 -1
  64. data/lib/plurimath/math/function/ternary_function.rb +16 -6
  65. data/lib/plurimath/math/function/text.rb +19 -7
  66. data/lib/plurimath/math/function/tr.rb +6 -1
  67. data/lib/plurimath/math/function/unary_function.rb +5 -0
  68. data/lib/plurimath/math/function/vec.rb +4 -0
  69. data/lib/plurimath/math/function.rb +13 -2
  70. data/lib/plurimath/math/number.rb +8 -0
  71. data/lib/plurimath/math/symbol.rb +12 -3
  72. data/lib/plurimath/math.rb +9 -4
  73. data/lib/plurimath/mathml/constants.rb +2 -34
  74. data/lib/plurimath/mathml/parse.rb +7 -2
  75. data/lib/plurimath/mathml/parser.rb +2 -1
  76. data/lib/plurimath/mathml/transform.rb +73 -68
  77. data/lib/plurimath/mathml.rb +1 -1
  78. data/lib/plurimath/omml/constants.rb +154 -0
  79. data/lib/plurimath/omml/parser.rb +22 -0
  80. data/lib/plurimath/omml/transform.rb +216 -0
  81. data/lib/plurimath/omml.rb +1 -1
  82. data/lib/plurimath/unitsml.rb +4 -0
  83. data/lib/plurimath/utility.rb +73 -0
  84. data/lib/plurimath/version.rb +1 -1
  85. data/plurimath.gemspec +1 -0
  86. metadata +49 -7
  87. data/README.md +0 -40
@@ -3,42 +3,76 @@
3
3
  module Plurimath
4
4
  class Asciimath
5
5
  class Transform < Parslet::Transform
6
- rule(expr: simple(:expr)) { expr }
7
- rule(base: simple(:base)) { base }
8
- rule(base: sequence(:base)) { base }
9
- rule(fonts: simple(:fonts)) { fonts }
10
- rule(power: simple(:power)) { power }
11
- rule(unary: simple(:unary)) { unary }
12
- rule(power: sequence(:power)) { power }
13
- rule(binary: simple(:binary)) { binary }
14
- rule(sequence: simple(:sequence)) { sequence }
15
- rule(power_base: simple(:power_base)) { power_base }
16
- rule(intermediate_exp: simple(:int_exp)) { int_exp }
6
+ rule(expr: simple(:expr)) { expr }
7
+ rule(base: simple(:base)) { base }
8
+ rule(base: sequence(:base)) { base }
9
+ rule(fonts: simple(:fonts)) { fonts }
10
+ rule(power: simple(:power)) { power }
11
+ rule(unary: simple(:unary)) { unary }
12
+ rule(table: simple(:table)) { table }
13
+ rule(power: sequence(:power)) { power }
14
+ rule(binary: simple(:binary)) { binary }
15
+
16
+ rule(sequence: simple(:sequence)) { sequence }
17
+ rule(table_row: simple(:table_row)) { table_row }
18
+
19
+ rule(power_base: simple(:power_base)) { power_base }
20
+ rule(left_right: simple(:left_right)) { left_right }
21
+ rule(table_left: simple(:table_left)) { table_left }
22
+
23
+ rule(table_right: simple(:table_right)) { table_right }
24
+ rule(intermediate_exp: simple(:int_exp)) { int_exp }
25
+
17
26
  rule(mod: simple(:mod), expr: simple(:expr)) { [mod, expr] }
18
27
  rule(base: sequence(:base), expr: simple(:exp)) { base + [exp] }
19
28
 
29
+ rule(number: simple(:number)) do
30
+ Math::Number.new(number)
31
+ end
32
+
33
+ rule(symbol: simple(:symbol)) do
34
+ Math::Symbol.new(symbol)
35
+ end
36
+
37
+ rule(text: simple(:text)) do
38
+ text.is_a?(String) ? Utility.get_class("text").new(text) : text
39
+ end
40
+
20
41
  rule(expr: sequence(:expr)) do
21
- Plurimath::Math::Formula.new(expr)
42
+ Math::Formula.new(expr)
22
43
  end
23
44
 
24
- rule(power: sequence(:power), expr: simple(:expr)) do
25
- power + [expr]
45
+ rule(sequence: simple(:sequence),
46
+ expr: simple(:exp)) do
47
+ [sequence, exp]
26
48
  end
27
49
 
28
- rule(power: sequence(:power), expr: sequence(:expr)) do
29
- power + expr
50
+ rule(power: simple(:power),
51
+ expr: simple(:expr)) do
52
+ [power, expr]
30
53
  end
31
54
 
32
- rule(number: simple(:number)) do
33
- Plurimath::Math::Number.new(number.to_s)
55
+ rule(power: simple(:power),
56
+ expr: sequence(:expr)) do
57
+ expr.insert(0, power)
34
58
  end
35
59
 
36
- rule(symbol: simple(:symbol)) do
37
- Plurimath::Math::Symbol.new(symbol.to_s)
60
+ rule(table_row: simple(:table_row),
61
+ expr: simple(:expr)) do
62
+ [table_row, expr]
38
63
  end
39
64
 
40
- rule(text: simple(:text)) do
41
- text.is_a?(Slice) ? Transform.get_class("text").new(text.to_s) : text
65
+ rule(td: simple(:td),
66
+ tds: simple(:tds)) do
67
+ [
68
+ Math::Function::Td.new([td]),
69
+ Math::Function::Td.new([tds]),
70
+ ]
71
+ end
72
+
73
+ rule(open_tr: simple(:tr),
74
+ tds_list: sequence(:tds_list)) do
75
+ Math::Function::Tr.new(tds_list)
42
76
  end
43
77
 
44
78
  rule(base: simple(:base),
@@ -46,141 +80,155 @@ module Plurimath
46
80
  [base, expr]
47
81
  end
48
82
 
49
- rule(fonts: simple(:font_style), intermediate_exp: simple(:int_exp)) do
50
- Plurimath::Math::Function::FontStyle.new(int_exp, font_style.to_s)
83
+ rule(fonts: simple(:font_style),
84
+ intermediate_exp: simple(:int_exp)) do
85
+ Utility::FONT_STYLES[font_style.to_sym].new(
86
+ int_exp,
87
+ font_style,
88
+ )
51
89
  end
52
90
 
53
- rule(fonts: simple(:font_style), text: simple(:text)) do
54
- parameter_one = Plurimath::Math::Function::Text.new(text.to_s)
55
- Plurimath::Math::Function::FontStyle.new(parameter_one, font_style.to_s)
91
+ rule(fonts: simple(:font_style),
92
+ text: simple(:text)) do
93
+ Utility::FONT_STYLES[font_style.to_sym].new(
94
+ Math::Function::Text.new(text),
95
+ font_style,
96
+ )
56
97
  end
57
98
 
58
- rule(power_base: simple(:power_base), expr: sequence(:expr)) do
99
+ rule(power_base: simple(:power_base),
100
+ expr: sequence(:expr)) do
59
101
  expr.insert(0, power_base)
60
102
  end
61
103
 
62
- rule(power_base: simple(:power_base), expr: simple(:expr)) do
104
+ rule(power_base: simple(:power_base),
105
+ expr: simple(:expr)) do
63
106
  [power_base, expr]
64
107
  end
65
108
 
66
- rule(power_base: sequence(:power_base), expr: simple(:expr)) do
67
- power_base + [expr]
68
- end
69
-
70
- rule(power_base: sequence(:power_base), expr: sequence(:expr)) do
71
- power_base + expr
72
- end
73
-
74
- rule(sequence: simple(:sequence), expr: sequence(:expr)) do
109
+ rule(sequence: simple(:sequence),
110
+ expr: sequence(:expr)) do
75
111
  expr.insert(0, sequence)
76
112
  end
77
113
 
78
- rule(dividend: simple(:dividend), mod: simple(:mod),
114
+ rule(dividend: simple(:dividend),
115
+ mod: simple(:mod),
79
116
  divisor: simple(:divisor)) do
80
- Plurimath::Math::Function::Mod.new(dividend, divisor)
117
+ Math::Function::Mod.new(
118
+ dividend,
119
+ divisor,
120
+ )
81
121
  end
82
122
 
83
- rule(unary: simple(:unary), "^": simple(:exponent),
123
+ rule(unary: simple(:unary),
124
+ "^": simple(:exponent),
84
125
  number: simple(:number)) do
85
- [
126
+ Math::Function::Power.new(
86
127
  unary,
87
- Plurimath::Math::Symbol.new(exponent.to_s),
88
- Plurimath::Math::Number.new(number.to_s),
89
- ]
128
+ Math::Number.new(number),
129
+ )
90
130
  end
91
131
 
92
- rule(unary: simple(:unary), "^": simple(:exponent),
132
+ rule(unary: simple(:unary),
133
+ "^": simple(:exponent),
93
134
  intermediate_exp: simple(:intermediate_exp)) do
94
- [
135
+ Math::Function::Power.new(
95
136
  unary,
96
- Plurimath::Math::Symbol.new(exponent.to_s),
97
137
  intermediate_exp,
98
- ]
138
+ )
99
139
  end
100
140
 
101
- rule(unary: simple(:unary), "^": simple(:exponent),
141
+ rule(unary: simple(:unary),
142
+ "^": simple(:exponent),
102
143
  text: simple(:text)) do
103
- [
144
+ Math::Function::Power.new(
104
145
  unary,
105
- Plurimath::Math::Symbol.new(exponent.to_s),
106
- text.is_a?(Slice) ? Transform.get_class("text").new(text.to_s) : text,
107
- ]
146
+ text.is_a?(String) ? Utility.get_class("text").new(text) : text,
147
+ )
108
148
  end
109
149
 
110
- rule(symbol: simple(:symbol), "^": simple(:exponent),
150
+ rule(symbol: simple(:symbol),
151
+ "^": simple(:exponent),
111
152
  number: simple(:number)) do
112
- [
113
- Plurimath::Math::Symbol.new(symbol.to_s),
114
- Plurimath::Math::Symbol.new(exponent.to_s),
115
- Plurimath::Math::Number.new(number.to_s),
116
- ]
153
+ Math::Function::Power.new(
154
+ Math::Symbol.new(symbol),
155
+ Math::Number.new(number),
156
+ )
117
157
  end
118
158
 
119
159
  rule(binary: simple(:binary),
120
160
  "^": simple(:under_score),
121
161
  intermediate_exp: simple(:int_exp)) do
122
- [
162
+ Math::Function::Power.new(
123
163
  binary,
124
- Plurimath::Math::Symbol.new("^"),
125
164
  int_exp,
126
- ]
165
+ )
127
166
  end
128
167
 
129
- rule(binary: simple(:function), "^": simple(:exponent),
168
+ rule(binary: simple(:function),
169
+ "^": simple(:exponent),
130
170
  number: simple(:number)) do
131
- [
171
+ Math::Function::Power.new(
132
172
  function,
133
- Plurimath::Math::Symbol.new("^"),
134
- Plurimath::Math::Number.new(number.to_s),
135
- ]
173
+ Math::Number.new(number),
174
+ )
175
+ end
176
+
177
+ rule(left: simple(:left),
178
+ left_right_value: simple(:left_right),
179
+ right: simple(:right)) do
180
+ Math::Formula.new(
181
+ [
182
+ Math::Function::Left.new(left),
183
+ left_right,
184
+ Math::Function::Right.new(right),
185
+ ],
186
+ )
136
187
  end
137
188
 
138
189
  Constants::UNARY_CLASSES.each do |unary_class|
139
190
  rule(unary_class => simple(:function),
140
191
  intermediate_exp: simple(:int_exp)) do
141
- Transform.get_class(function).new(int_exp)
192
+ Utility.get_class(function).new(int_exp)
142
193
  end
143
194
 
144
195
  rule(unary_class => simple(:function),
145
196
  _: simple(:under_score),
146
197
  intermediate_exp: simple(:int_exp)) do
147
- [
148
- Transform.get_class(function).new,
149
- Plurimath::Math::Symbol.new("_"),
198
+ Math::Function::Base.new(
199
+ Utility.get_class(function).new,
150
200
  int_exp,
151
- ]
201
+ )
152
202
  end
153
203
 
154
204
  rule(unary_class => simple(:function),
155
205
  symbol: simple(:new_symbol)) do
156
- symbol = Plurimath::Math::Symbol.new(new_symbol.to_s)
157
- Transform.get_class(function).new(symbol)
206
+ symbol = Math::Symbol.new(new_symbol)
207
+ Utility.get_class(function).new(symbol)
158
208
  end
159
209
 
160
210
  rule(unary_class => simple(:function),
161
211
  number: simple(:new_number)) do
162
- number = Plurimath::Math::Number.new(new_number.to_s)
163
- Transform.get_class(function).new(number)
212
+ number = Math::Number.new(new_number)
213
+ Utility.get_class(function).new(number)
164
214
  end
165
215
 
166
216
  rule(unary_class => simple(:function),
167
217
  "^": simple(:base),
168
218
  intermediate_exp: simple(:unary)) do
169
- [
170
- Transform.get_class(unary_class).new,
171
- Plurimath::Math::Symbol.new("^"),
219
+ Math::Function::Power.new(
220
+ Utility.get_class(unary_class).new,
172
221
  unary,
173
- ]
222
+ )
174
223
  end
175
224
 
176
225
  rule(unary_class => simple(:function),
177
226
  _: simple(:base),
178
227
  symbol: simple(:symbol)) do
179
- [
180
- Transform.get_class(unary_class).new,
181
- Plurimath::Math::Symbol.new("_"),
182
- Plurimath::Math::Symbol.new(symbol.to_s),
183
- ]
228
+ Math::Function::Base.new(
229
+ Utility.get_class(unary_class).new,
230
+ Math::Symbol.new(symbol),
231
+ )
184
232
  end
185
233
 
186
234
  rule(unary_class => simple(:function),
@@ -188,116 +236,159 @@ module Plurimath
188
236
  base: simple(:base),
189
237
  "^": simple(:power),
190
238
  exponent: simple(:exponent)) do
191
- [
192
- Transform.get_class(function).new,
193
- Plurimath::Math::Symbol.new("_"),
239
+ Math::Function::PowerBase.new(
240
+ Utility.get_class(function).new,
194
241
  base,
195
- Plurimath::Math::Symbol.new("^"),
196
242
  exponent,
197
- ]
243
+ )
198
244
  end
199
245
  end
200
246
 
201
247
  Constants::BINARY_CLASSES.each do |binary_class|
202
248
  rule(binary_class => simple(:function)) do
203
- Transform.get_class(function).new
249
+ Utility.get_class(function).new
204
250
  end
205
251
 
206
- rule(binary_class => simple(:function), _: simple(:under_score),
207
- base: simple(:int_exp), "^": simple(:power),
252
+ rule(binary_class => simple(:function),
253
+ _: simple(:under_score),
254
+ base: simple(:int_exp),
255
+ "^": simple(:power),
208
256
  exponent: simple(:exponent)) do
209
- Transform.get_class(function).new(int_exp, exponent)
257
+ Utility.get_class(function).new(
258
+ int_exp,
259
+ exponent,
260
+ )
210
261
  end
211
262
 
212
- rule(binary_class => simple(:function), _: simple(:under_score),
263
+ rule(binary_class => simple(:function),
264
+ _: simple(:under_score),
213
265
  intermediate_exp: simple(:int_exp)) do
214
- Transform.get_class(function).new(int_exp, nil)
266
+ Utility.get_class(function).new(int_exp, nil)
215
267
  end
216
268
 
217
- rule(binary_class => simple(:function), "^": simple(:exponent),
269
+ rule(binary_class => simple(:function),
270
+ "^": simple(:exponent),
218
271
  intermediate_exp: simple(:int_exp)) do
219
- Transform.get_class(function).new(nil, int_exp)
272
+ Utility.get_class(function).new(nil, int_exp)
220
273
  end
221
274
 
222
- rule(binary_class => simple(:function), _: simple(:under_score),
275
+ rule(binary_class => simple(:function),
276
+ _: simple(:under_score),
223
277
  number: simple(:number)) do
224
- Transform.get_class(function).new(
225
- Plurimath::Math::Number.new(number.to_s), nil
278
+ Utility.get_class(function).new(
279
+ Math::Number.new(number), nil
226
280
  )
227
281
  end
228
282
 
229
- rule(binary_class => simple(:function), _: simple(:under_score),
283
+ rule(binary_class => simple(:function),
284
+ _: simple(:under_score),
230
285
  symbol: simple(:symbol)) do
231
- Transform.get_class(function).new(
232
- Plurimath::Math::Symbol.new(symbol.to_s), nil
286
+ Utility.get_class(function).new(
287
+ Math::Symbol.new(symbol), nil
233
288
  )
234
289
  end
235
290
 
236
- rule(binary_class => simple(:function), _: simple(:under_score),
291
+ rule(binary_class => simple(:function),
292
+ _: simple(:under_score),
237
293
  unary: simple(:unary)) do
238
- Transform.get_class(function).new(unary, nil)
294
+ Utility.get_class(function).new(unary, nil)
239
295
  end
240
296
 
241
- rule(binary_class => simple(:function), "^": simple(:power),
297
+ rule(binary_class => simple(:function),
298
+ "^": simple(:power),
242
299
  number: simple(:number)) do
243
- Transform.get_class(function).new(
300
+ Utility.get_class(function).new(
244
301
  nil,
245
- Plurimath::Math::Number.new(number.to_s),
302
+ Math::Number.new(number),
246
303
  )
247
304
  end
248
305
 
249
- rule(binary_class => simple(:function), "^": simple(:power),
306
+ rule(binary_class => simple(:function),
307
+ "^": simple(:power),
250
308
  symbol: simple(:symbol)) do
251
- Transform.get_class(function).new(
309
+ Utility.get_class(function).new(
252
310
  nil,
253
- Plurimath::Math::Symbol.new(symbol.to_s),
311
+ Math::Symbol.new(symbol),
254
312
  )
255
313
  end
256
314
 
257
- rule(binary_class => simple(:function), base: simple(:base),
315
+ rule(binary_class => simple(:function),
316
+ base: simple(:base),
258
317
  exponent: simple(:exponent)) do
259
- Transform.get_class(function).new(base, exponent)
318
+ Utility.get_class(function).new(
319
+ base,
320
+ exponent,
321
+ )
260
322
  end
261
323
 
262
- rule(binary: simple(:function), "^": simple(:exponent),
324
+ rule(binary: simple(:function),
325
+ "^": simple(:exponent),
263
326
  text: simple(:text)) do
264
- [
327
+ Math::Function::Power.new(
265
328
  function,
266
- Plurimath::Math::Symbol.new("^"),
267
- text.is_a?(Slice) ? Transform.get_class("text").new(text.to_s) : text,
268
- ]
329
+ text.is_a?(String) ? Utility.get_class("text").new(text) : text,
330
+ )
269
331
  end
270
332
 
271
- rule(binary: simple(:function), "^": simple(:exponent),
333
+ rule(binary: simple(:function),
334
+ "^": simple(:exponent),
272
335
  unary: simple(:unary)) do
273
- [
336
+ Math::Function::Power.new(
274
337
  function,
275
- Plurimath::Math::Symbol.new("^"),
276
338
  unary,
277
- ]
339
+ )
278
340
  end
279
341
 
280
342
  Constants::UNARY_CLASSES.each do |unary_class|
281
343
  rule(binary_class => simple(:function),
282
344
  _: simple(:base),
283
345
  unary_class => simple(:unary)) do
284
- unary_class = Transform.get_class(unary).new
285
- Transform.get_class(binary_class).new(unary_class, nil)
346
+ unary_class = Utility.get_class(unary).new
347
+ Utility.get_class(binary_class).new(unary_class, nil)
286
348
  end
287
349
 
288
350
  rule(binary_class => simple(:function),
289
351
  "^": simple(:base),
290
352
  unary_class => simple(:unary)) do
291
- unary_class = Transform.get_class(unary).new
292
- Transform.get_class(binary_class).new(nil, unary_class)
353
+ unary_class = Utility.get_class(unary).new
354
+ Utility.get_class(binary_class).new(nil, unary_class)
293
355
  end
294
356
  end
295
357
  end
296
358
 
297
- rule(sequence: simple(:sequence), expr: simple(:exp)) { [sequence, exp] }
359
+ rule(table_left: simple(:table_left),
360
+ table_row: simple(:table_row),
361
+ expr: simple(:expr),
362
+ table_right: simple(:table_right)) do
363
+ Math::Function::Table.new(
364
+ [table_row, expr],
365
+ table_left,
366
+ table_right,
367
+ )
368
+ end
369
+
370
+ rule(table_left: simple(:table_left),
371
+ table_row: simple(:table_row),
372
+ expr: sequence(:expr),
373
+ table_right: simple(:table_right)) do
374
+ Math::Function::Table.new(
375
+ expr.insert(0, table_row),
376
+ table_left,
377
+ table_right,
378
+ )
379
+ end
298
380
 
299
- def self.get_class(text)
300
- Object.const_get("Plurimath::Math::Function::#{text.to_s.capitalize}")
381
+ rule(left: simple(:left),
382
+ table_row: simple(:table_row),
383
+ expr: sequence(:expr),
384
+ right: simple(:right)) do
385
+ Math::Formula.new(
386
+ [
387
+ Math::Function::Left.new(left),
388
+ Math::Function::Table.new(expr.insert(0, table_row), "", ""),
389
+ Math::Function::Right.new(right),
390
+ ],
391
+ )
301
392
  end
302
393
  end
303
394
  end
@@ -10,7 +10,7 @@ module Plurimath
10
10
  end
11
11
 
12
12
  def to_formula
13
- @text = Plurimath::Asciimath::Parser.new(text).parse
13
+ Parser.new(text).parse
14
14
  end
15
15
  end
16
16
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Plurimath
4
+ class Html
5
+ class Constants
6
+ PARENTHESIS = {
7
+ "(": :")",
8
+ "{": :"}",
9
+ "[": :"]",
10
+ }.freeze
11
+ UNARY_CLASSES = %w[
12
+ arcsin
13
+ arccos
14
+ arctan
15
+ coth
16
+ tanh
17
+ sech
18
+ csch
19
+ sqrt
20
+ ceil
21
+ sinh
22
+ cosh
23
+ sin
24
+ cos
25
+ gcd
26
+ csc
27
+ abs
28
+ vec
29
+ exp
30
+ sec
31
+ tan
32
+ cot
33
+ lcm
34
+ det
35
+ ln
36
+ lg
37
+ g
38
+ f
39
+ ].freeze
40
+ SUB_SUP_CLASSES = {
41
+ "&prod;": :prod,
42
+ "&sum;": :sum,
43
+ log: :log,
44
+ lim: :lim,
45
+ "∏": :prod,
46
+ "∑": :sum,
47
+ }.freeze
48
+ end
49
+ end
50
+ end