plurimath 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +8 -11
- data/.gitignore +1 -0
- data/AsciiMath-Supported-Data.adoc +280 -0
- data/Gemfile +1 -0
- data/Latex-Supported-Data.adoc +1872 -0
- data/MathML-Supported-Data.adoc +270 -0
- data/README.adoc +94 -0
- data/lib/plurimath/asciimath/constants.rb +215 -222
- data/lib/plurimath/asciimath/parse.rb +45 -11
- data/lib/plurimath/asciimath/parser.rb +4 -3
- data/lib/plurimath/asciimath/transform.rb +222 -131
- data/lib/plurimath/asciimath.rb +1 -1
- data/lib/plurimath/html/constants.rb +50 -0
- data/lib/plurimath/html/parse.rb +149 -0
- data/lib/plurimath/html/parser.rb +26 -0
- data/lib/plurimath/html/transform.rb +363 -0
- data/lib/plurimath/html.rb +1 -1
- data/lib/plurimath/latex/constants.rb +1885 -1858
- data/lib/plurimath/latex/parse.rb +127 -34
- data/lib/plurimath/latex/parser.rb +5 -4
- data/lib/plurimath/latex/transform.rb +324 -164
- data/lib/plurimath/math/formula.rb +9 -1
- data/lib/plurimath/math/function/bar.rb +1 -1
- data/lib/plurimath/math/function/base.rb +7 -1
- data/lib/plurimath/math/function/binary_function.rb +10 -5
- data/lib/plurimath/math/function/color.rb +4 -4
- data/lib/plurimath/math/function/fenced.rb +7 -2
- data/lib/plurimath/math/function/font_style/bold.rb +18 -0
- data/lib/plurimath/math/function/font_style/double_struck.rb +18 -0
- data/lib/plurimath/math/function/font_style/fraktur.rb +18 -0
- data/lib/plurimath/math/function/font_style/monospace.rb +18 -0
- data/lib/plurimath/math/function/font_style/sans-serif.rb +18 -0
- data/lib/plurimath/math/function/font_style/script.rb +18 -0
- data/lib/plurimath/math/function/font_style.rb +2 -22
- data/lib/plurimath/math/function/frac.rb +4 -4
- data/lib/plurimath/math/function/inf.rb +0 -1
- data/lib/plurimath/math/function/left.rb +3 -6
- data/lib/plurimath/math/function/limits.rb +0 -1
- data/lib/plurimath/math/function/log.rb +6 -0
- data/lib/plurimath/math/function/mod.rb +6 -0
- data/lib/plurimath/math/function/multiscript.rb +11 -0
- data/lib/plurimath/math/function/norm.rb +2 -1
- data/lib/plurimath/math/function/over.rb +29 -0
- data/lib/plurimath/math/function/overset.rb +2 -2
- data/lib/plurimath/math/function/power.rb +7 -1
- data/lib/plurimath/math/function/power_base.rb +14 -7
- data/lib/plurimath/math/function/prod.rb +6 -0
- data/lib/plurimath/math/function/right.rb +24 -0
- data/lib/plurimath/math/function/root.rb +5 -4
- data/lib/plurimath/math/function/sqrt.rb +1 -1
- data/lib/plurimath/math/function/substack.rb +0 -1
- data/lib/plurimath/math/function/sum.rb +6 -0
- data/lib/plurimath/math/function/table/align.rb +24 -0
- data/lib/plurimath/math/function/table/array.rb +25 -0
- data/lib/plurimath/math/function/table/bmatrix.rb +26 -0
- data/lib/plurimath/math/function/table/matrix.rb +24 -0
- data/lib/plurimath/math/function/table/multline.rb +24 -0
- data/lib/plurimath/math/function/table/pmatrix.rb +24 -0
- data/lib/plurimath/math/function/table/split.rb +24 -0
- data/lib/plurimath/math/function/table/vmatrix.rb +25 -0
- data/lib/plurimath/math/function/table.rb +17 -5
- data/lib/plurimath/math/function/td.rb +6 -1
- data/lib/plurimath/math/function/ternary_function.rb +16 -6
- data/lib/plurimath/math/function/text.rb +19 -7
- data/lib/plurimath/math/function/tr.rb +6 -1
- data/lib/plurimath/math/function/unary_function.rb +5 -0
- data/lib/plurimath/math/function/vec.rb +4 -0
- data/lib/plurimath/math/function.rb +13 -2
- data/lib/plurimath/math/number.rb +8 -0
- data/lib/plurimath/math/symbol.rb +12 -3
- data/lib/plurimath/math.rb +9 -4
- data/lib/plurimath/mathml/constants.rb +2 -34
- data/lib/plurimath/mathml/parse.rb +7 -2
- data/lib/plurimath/mathml/parser.rb +2 -1
- data/lib/plurimath/mathml/transform.rb +73 -68
- data/lib/plurimath/mathml.rb +1 -1
- data/lib/plurimath/omml/constants.rb +154 -0
- data/lib/plurimath/omml/parser.rb +22 -0
- data/lib/plurimath/omml/transform.rb +216 -0
- data/lib/plurimath/omml.rb +1 -1
- data/lib/plurimath/unitsml.rb +4 -0
- data/lib/plurimath/utility.rb +73 -0
- data/lib/plurimath/version.rb +1 -1
- data/plurimath.gemspec +1 -0
- metadata +49 -7
- 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))
|
7
|
-
rule(base: simple(:base))
|
8
|
-
rule(base: sequence(:base))
|
9
|
-
rule(fonts: simple(:fonts))
|
10
|
-
rule(power: simple(:power))
|
11
|
-
rule(unary: simple(:unary))
|
12
|
-
rule(
|
13
|
-
rule(
|
14
|
-
rule(
|
15
|
-
|
16
|
-
rule(
|
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
|
-
|
42
|
+
Math::Formula.new(expr)
|
22
43
|
end
|
23
44
|
|
24
|
-
rule(
|
25
|
-
|
45
|
+
rule(sequence: simple(:sequence),
|
46
|
+
expr: simple(:exp)) do
|
47
|
+
[sequence, exp]
|
26
48
|
end
|
27
49
|
|
28
|
-
rule(power:
|
29
|
-
|
50
|
+
rule(power: simple(:power),
|
51
|
+
expr: simple(:expr)) do
|
52
|
+
[power, expr]
|
30
53
|
end
|
31
54
|
|
32
|
-
rule(
|
33
|
-
|
55
|
+
rule(power: simple(:power),
|
56
|
+
expr: sequence(:expr)) do
|
57
|
+
expr.insert(0, power)
|
34
58
|
end
|
35
59
|
|
36
|
-
rule(
|
37
|
-
|
60
|
+
rule(table_row: simple(:table_row),
|
61
|
+
expr: simple(:expr)) do
|
62
|
+
[table_row, expr]
|
38
63
|
end
|
39
64
|
|
40
|
-
rule(
|
41
|
-
|
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),
|
50
|
-
|
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),
|
54
|
-
|
55
|
-
|
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),
|
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),
|
104
|
+
rule(power_base: simple(:power_base),
|
105
|
+
expr: simple(:expr)) do
|
63
106
|
[power_base, expr]
|
64
107
|
end
|
65
108
|
|
66
|
-
rule(
|
67
|
-
|
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),
|
114
|
+
rule(dividend: simple(:dividend),
|
115
|
+
mod: simple(:mod),
|
79
116
|
divisor: simple(:divisor)) do
|
80
|
-
|
117
|
+
Math::Function::Mod.new(
|
118
|
+
dividend,
|
119
|
+
divisor,
|
120
|
+
)
|
81
121
|
end
|
82
122
|
|
83
|
-
rule(unary: simple(:unary),
|
123
|
+
rule(unary: simple(:unary),
|
124
|
+
"^": simple(:exponent),
|
84
125
|
number: simple(:number)) do
|
85
|
-
|
126
|
+
Math::Function::Power.new(
|
86
127
|
unary,
|
87
|
-
|
88
|
-
|
89
|
-
]
|
128
|
+
Math::Number.new(number),
|
129
|
+
)
|
90
130
|
end
|
91
131
|
|
92
|
-
rule(unary: simple(:unary),
|
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),
|
141
|
+
rule(unary: simple(:unary),
|
142
|
+
"^": simple(:exponent),
|
102
143
|
text: simple(:text)) do
|
103
|
-
|
144
|
+
Math::Function::Power.new(
|
104
145
|
unary,
|
105
|
-
|
106
|
-
|
107
|
-
]
|
146
|
+
text.is_a?(String) ? Utility.get_class("text").new(text) : text,
|
147
|
+
)
|
108
148
|
end
|
109
149
|
|
110
|
-
rule(symbol: simple(:symbol),
|
150
|
+
rule(symbol: simple(:symbol),
|
151
|
+
"^": simple(:exponent),
|
111
152
|
number: simple(:number)) do
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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),
|
168
|
+
rule(binary: simple(:function),
|
169
|
+
"^": simple(:exponent),
|
130
170
|
number: simple(:number)) do
|
131
|
-
|
171
|
+
Math::Function::Power.new(
|
132
172
|
function,
|
133
|
-
|
134
|
-
|
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
|
-
|
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
|
-
|
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 =
|
157
|
-
|
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 =
|
163
|
-
|
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
|
-
|
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
|
-
|
181
|
-
|
182
|
-
|
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
|
-
|
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
|
-
|
249
|
+
Utility.get_class(function).new
|
204
250
|
end
|
205
251
|
|
206
|
-
rule(binary_class => simple(:function),
|
207
|
-
|
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
|
-
|
257
|
+
Utility.get_class(function).new(
|
258
|
+
int_exp,
|
259
|
+
exponent,
|
260
|
+
)
|
210
261
|
end
|
211
262
|
|
212
|
-
rule(binary_class => simple(:function),
|
263
|
+
rule(binary_class => simple(:function),
|
264
|
+
_: simple(:under_score),
|
213
265
|
intermediate_exp: simple(:int_exp)) do
|
214
|
-
|
266
|
+
Utility.get_class(function).new(int_exp, nil)
|
215
267
|
end
|
216
268
|
|
217
|
-
rule(binary_class => simple(:function),
|
269
|
+
rule(binary_class => simple(:function),
|
270
|
+
"^": simple(:exponent),
|
218
271
|
intermediate_exp: simple(:int_exp)) do
|
219
|
-
|
272
|
+
Utility.get_class(function).new(nil, int_exp)
|
220
273
|
end
|
221
274
|
|
222
|
-
rule(binary_class => simple(:function),
|
275
|
+
rule(binary_class => simple(:function),
|
276
|
+
_: simple(:under_score),
|
223
277
|
number: simple(:number)) do
|
224
|
-
|
225
|
-
|
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),
|
283
|
+
rule(binary_class => simple(:function),
|
284
|
+
_: simple(:under_score),
|
230
285
|
symbol: simple(:symbol)) do
|
231
|
-
|
232
|
-
|
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),
|
291
|
+
rule(binary_class => simple(:function),
|
292
|
+
_: simple(:under_score),
|
237
293
|
unary: simple(:unary)) do
|
238
|
-
|
294
|
+
Utility.get_class(function).new(unary, nil)
|
239
295
|
end
|
240
296
|
|
241
|
-
rule(binary_class => simple(:function),
|
297
|
+
rule(binary_class => simple(:function),
|
298
|
+
"^": simple(:power),
|
242
299
|
number: simple(:number)) do
|
243
|
-
|
300
|
+
Utility.get_class(function).new(
|
244
301
|
nil,
|
245
|
-
|
302
|
+
Math::Number.new(number),
|
246
303
|
)
|
247
304
|
end
|
248
305
|
|
249
|
-
rule(binary_class => simple(:function),
|
306
|
+
rule(binary_class => simple(:function),
|
307
|
+
"^": simple(:power),
|
250
308
|
symbol: simple(:symbol)) do
|
251
|
-
|
309
|
+
Utility.get_class(function).new(
|
252
310
|
nil,
|
253
|
-
|
311
|
+
Math::Symbol.new(symbol),
|
254
312
|
)
|
255
313
|
end
|
256
314
|
|
257
|
-
rule(binary_class => simple(:function),
|
315
|
+
rule(binary_class => simple(:function),
|
316
|
+
base: simple(:base),
|
258
317
|
exponent: simple(:exponent)) do
|
259
|
-
|
318
|
+
Utility.get_class(function).new(
|
319
|
+
base,
|
320
|
+
exponent,
|
321
|
+
)
|
260
322
|
end
|
261
323
|
|
262
|
-
rule(binary: simple(:function),
|
324
|
+
rule(binary: simple(:function),
|
325
|
+
"^": simple(:exponent),
|
263
326
|
text: simple(:text)) do
|
264
|
-
|
327
|
+
Math::Function::Power.new(
|
265
328
|
function,
|
266
|
-
|
267
|
-
|
268
|
-
]
|
329
|
+
text.is_a?(String) ? Utility.get_class("text").new(text) : text,
|
330
|
+
)
|
269
331
|
end
|
270
332
|
|
271
|
-
rule(binary: simple(:function),
|
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 =
|
285
|
-
|
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 =
|
292
|
-
|
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(
|
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
|
-
|
300
|
-
|
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
|
data/lib/plurimath/asciimath.rb
CHANGED
@@ -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,
|
42
|
+
"∑": :sum,
|
43
|
+
log: :log,
|
44
|
+
lim: :lim,
|
45
|
+
"∏": :prod,
|
46
|
+
"∑": :sum,
|
47
|
+
}.freeze
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|