mathml2asciimath 0.0.8 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +32 -0
- data/.gitignore +1 -0
- data/.hound.yml +3 -1
- data/.rubocop.yml +7 -7
- data/Gemfile +1 -2
- data/README.adoc +6 -5
- data/Rakefile +1 -1
- data/bin/m2a.rb +5 -7
- data/bin/rspec +1 -1
- data/lib/mathml2asciimath/m2a.rb +284 -252
- data/lib/mathml2asciimath/version.rb +1 -2
- data/mathml2asciimath.gemspec +7 -7
- data/spec/mathml_spec.rb +341 -251
- data/spec/spec_helper.rb +6 -7
- metadata +36 -41
- data/.github/workflows/macos.yml +0 -27
- data/.github/workflows/ubuntu.yml +0 -27
- data/.github/workflows/windows.yml +0 -30
- data/.rubocop.ribose.yml +0 -65
- data/.rubocop.tb.yml +0 -650
- data/Gemfile.lock +0 -108
data/spec/mathml_spec.rb
CHANGED
@@ -1,334 +1,424 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe MathML2AsciiMath do
|
4
|
-
it "processes
|
5
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
it "processes mstyle and mrow" do
|
5
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip.strip
|
6
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
7
|
+
<mstyle>
|
8
|
+
<mrow>
|
9
|
+
<mi>a</mi> <mo>⋄</mo> <msup><mi>x</mi><mn>2</mn></msup>
|
10
|
+
<mo>+</mo><mi>b</mi><mo>×</mo><mi>x</mi>
|
11
|
+
<mo>+</mo><msub><mi>c</mi><mn>3</mn></msub>
|
12
|
+
</mrow>
|
13
|
+
</mstyle>
|
14
|
+
</math>
|
15
15
|
INPUT
|
16
|
-
|
16
|
+
a diamond x^2 + b xx x + c_3
|
17
17
|
OUTPUT
|
18
18
|
end
|
19
19
|
|
20
|
-
it "processes
|
21
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
20
|
+
it "processes mrow" do
|
21
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
22
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
23
|
+
<mrow>
|
24
|
+
<mi>a</mi> <mo>⋄</mo> <msup><mi>x</mi><mn>2d</mn></msup>
|
25
|
+
<mo>+</mo><mi>b</mi><mo>×</mo><mi>x</mi>
|
26
|
+
<mo>+</mo><msub><mi>c</mi><mn>ab</mn></msub>
|
27
|
+
</mrow>
|
28
|
+
</math>
|
29
29
|
INPUT
|
30
|
-
|
30
|
+
a diamond x^(2d) + b xx x + c_(ab)
|
31
31
|
OUTPUT
|
32
32
|
end
|
33
33
|
|
34
|
-
it "processes
|
35
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
</mfrac>
|
41
|
-
|
34
|
+
it "processes mfrac" do
|
35
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
36
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
37
|
+
<mfrac>
|
38
|
+
<mrow> <mn> 1 </mn> <mo> + </mo> <msqrt> <mn> 5 </mn> </msqrt> </mrow>
|
39
|
+
<mn> 2 </mn>
|
40
|
+
</mfrac>
|
41
|
+
</math>
|
42
42
|
INPUT
|
43
|
-
|
43
|
+
((1 + sqrt(5)))/(2)
|
44
44
|
OUTPUT
|
45
45
|
end
|
46
46
|
|
47
|
-
it "processes
|
48
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
it "processes mfenced default" do
|
48
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
49
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
50
|
+
<mfenced><mrow><mi> a </mi> <mo> + </mo> <mi> b </mi></mrow></mfenced>
|
51
|
+
</math>
|
52
52
|
INPUT
|
53
|
-
|
53
|
+
(a + b)
|
54
54
|
OUTPUT
|
55
55
|
end
|
56
56
|
|
57
|
-
it "processes
|
58
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
59
|
-
|
60
|
-
<mfenced open="["> <mn> 0 </mn> <mn> 1 </mn> </mfenced>
|
61
|
-
|
57
|
+
it "processes mfenced with unmatching braces" do
|
58
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.to_s.strip
|
59
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
60
|
+
<mfenced open="["> <mn> 0 </mn> <mn> 1 </mn> </mfenced>
|
61
|
+
</math>
|
62
62
|
INPUT
|
63
|
-
|
63
|
+
[0,1)
|
64
64
|
OUTPUT
|
65
65
|
end
|
66
66
|
|
67
|
-
it "processes
|
68
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
it "processes munderover" do
|
68
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
69
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
70
|
+
<munderover>
|
71
|
+
<mo>∫</mo> <mn>0</mn> <mi>∞</mi>
|
72
|
+
</munderover>
|
73
|
+
</math>
|
74
74
|
INPUT
|
75
|
-
|
75
|
+
int_0^(oo)
|
76
76
|
OUTPUT
|
77
77
|
end
|
78
78
|
|
79
|
-
it "processes
|
80
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
79
|
+
it "processes msubsup" do
|
80
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
81
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
82
|
+
<msubsup>
|
83
|
+
<mo>∫</mo>
|
84
|
+
<mn>ab</mn>
|
85
|
+
<mn>ds</mn>
|
86
|
+
</msubsup>
|
87
|
+
</math>
|
88
88
|
INPUT
|
89
|
-
|
89
|
+
int_(ab)^(ds)
|
90
90
|
OUTPUT
|
91
91
|
end
|
92
92
|
|
93
|
-
it "processes
|
94
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
</munder>
|
106
|
-
|
93
|
+
it "processes ubrace" do
|
94
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
95
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
96
|
+
<munder>
|
97
|
+
<mrow>
|
98
|
+
<mi> x </mi>
|
99
|
+
<mo> + </mo>
|
100
|
+
<mi> y </mi>
|
101
|
+
<mo> + </mo>
|
102
|
+
<mi> z </mi>
|
103
|
+
</mrow>
|
104
|
+
<mo> ⏟</mo>
|
105
|
+
</munder>
|
106
|
+
</math>
|
107
107
|
INPUT
|
108
|
-
|
108
|
+
ubrace (x + y + z)
|
109
109
|
OUTPUT
|
110
110
|
end
|
111
111
|
|
112
|
-
it "processes
|
113
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
</munder>
|
125
|
-
|
112
|
+
it "processes ul" do
|
113
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
114
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
115
|
+
<munder>
|
116
|
+
<mrow>
|
117
|
+
<mi> x </mi>
|
118
|
+
<mo> + </mo>
|
119
|
+
<mi> y </mi>
|
120
|
+
<mo> + </mo>
|
121
|
+
<mi> z </mi>
|
122
|
+
</mrow>
|
123
|
+
<mo> ̲</mo>
|
124
|
+
</munder>
|
125
|
+
</math>
|
126
126
|
INPUT
|
127
|
-
|
127
|
+
ul (x + y + z)
|
128
128
|
OUTPUT
|
129
129
|
end
|
130
130
|
|
131
|
-
it "processes
|
132
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
</munder>
|
144
|
-
|
131
|
+
it "processes underset" do
|
132
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
133
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
134
|
+
<munder>
|
135
|
+
<mrow>
|
136
|
+
<mi> x </mi>
|
137
|
+
<mo> + </mo>
|
138
|
+
<mi> y </mi>
|
139
|
+
<mo> + </mo>
|
140
|
+
<mi> z </mi>
|
141
|
+
</mrow>
|
142
|
+
<mo>fred </mo>
|
143
|
+
</munder>
|
144
|
+
</math>
|
145
145
|
INPUT
|
146
|
-
|
146
|
+
underset(fred)((x + y + z))
|
147
147
|
OUTPUT
|
148
148
|
end
|
149
149
|
|
150
|
-
it "processes
|
151
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
152
|
-
|
153
|
-
<mover accent="true">
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
</mover>
|
163
|
-
|
164
|
-
</math>
|
150
|
+
it "processes obrace" do
|
151
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
152
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
153
|
+
<mover accent="true">
|
154
|
+
<mrow>
|
155
|
+
<mi> x </mi>
|
156
|
+
<mo> + </mo>
|
157
|
+
<mi> y </mi>
|
158
|
+
<mo> + </mo>
|
159
|
+
<mi> z </mi>
|
160
|
+
</mrow>
|
161
|
+
<mo> ⏞</mo>
|
162
|
+
</mover>
|
163
|
+
</math>
|
165
164
|
INPUT
|
166
|
-
|
165
|
+
obrace x + y + z
|
167
166
|
OUTPUT
|
168
167
|
end
|
169
168
|
|
170
|
-
it "processes
|
171
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
172
|
-
|
173
|
-
<mover accent="true">
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
</mover>
|
183
|
-
|
184
|
-
</math>
|
169
|
+
it "processes hat" do
|
170
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
171
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
172
|
+
<mover accent="true">
|
173
|
+
<mrow>
|
174
|
+
<mi> x </mi>
|
175
|
+
<mo> + </mo>
|
176
|
+
<mi> y </mi>
|
177
|
+
<mo> + </mo>
|
178
|
+
<mi> z </mi>
|
179
|
+
</mrow>
|
180
|
+
<mo> ^</mo>
|
181
|
+
</mover>
|
182
|
+
</math>
|
185
183
|
INPUT
|
186
|
-
|
184
|
+
hat x + y + z
|
187
185
|
OUTPUT
|
188
186
|
end
|
189
187
|
|
190
|
-
it "processes
|
191
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
192
|
-
|
193
|
-
<mover accent="true">
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
</mover>
|
203
|
-
|
204
|
-
</math>
|
188
|
+
it "processes bar" do
|
189
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
190
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
191
|
+
<mover accent="true">
|
192
|
+
<mrow>
|
193
|
+
<mi> x </mi>
|
194
|
+
<mo> + </mo>
|
195
|
+
<mi> y </mi>
|
196
|
+
<mo> + </mo>
|
197
|
+
<mi> z </mi>
|
198
|
+
</mrow>
|
199
|
+
<mo> ¯</mo>
|
200
|
+
</mover>
|
201
|
+
</math>
|
205
202
|
INPUT
|
206
|
-
|
203
|
+
bar x + y + z
|
207
204
|
OUTPUT
|
208
205
|
end
|
209
206
|
|
210
|
-
it "processes
|
211
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
212
|
-
|
213
|
-
<mover accent="true">
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
</mover>
|
223
|
-
|
224
|
-
</math>
|
207
|
+
it "processes vec" do
|
208
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
209
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
210
|
+
<mover accent="true">
|
211
|
+
<mrow>
|
212
|
+
<mi> x </mi>
|
213
|
+
<mo> + </mo>
|
214
|
+
<mi> y </mi>
|
215
|
+
<mo> + </mo>
|
216
|
+
<mi> z </mi>
|
217
|
+
</mrow>
|
218
|
+
<mo>→</mo>
|
219
|
+
</mover>
|
220
|
+
</math>
|
225
221
|
INPUT
|
226
|
-
|
222
|
+
vec x + y + z
|
227
223
|
OUTPUT
|
228
224
|
end
|
229
225
|
|
230
|
-
it "processes
|
231
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
232
|
-
|
233
|
-
<mover accent="true">
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
</mover>
|
243
|
-
|
244
|
-
</math>
|
226
|
+
it "processes dot" do
|
227
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
228
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
229
|
+
<mover accent="true">
|
230
|
+
<mrow>
|
231
|
+
<mi> x </mi>
|
232
|
+
<mo> + </mo>
|
233
|
+
<mi> y </mi>
|
234
|
+
<mo> + </mo>
|
235
|
+
<mi> z </mi>
|
236
|
+
</mrow>
|
237
|
+
<mo> .</mo>
|
238
|
+
</mover>
|
239
|
+
</math>
|
245
240
|
INPUT
|
246
|
-
|
241
|
+
dot x + y + z
|
247
242
|
OUTPUT
|
248
243
|
end
|
249
244
|
|
250
|
-
it "processes
|
251
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
252
|
-
|
253
|
-
<mover accent="true">
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
</mover>
|
245
|
+
it "processes ddot" do
|
246
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
247
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
248
|
+
<mover accent="true">
|
249
|
+
<mrow>
|
250
|
+
<mi> x </mi>
|
251
|
+
<mo> + </mo>
|
252
|
+
<mi> y </mi>
|
253
|
+
<mo> + </mo>
|
254
|
+
<mi> z </mi>
|
255
|
+
</mrow>
|
256
|
+
<mo>..</mo>
|
257
|
+
</mover>
|
258
|
+
</math>
|
259
|
+
INPUT
|
260
|
+
ddot x + y + z
|
261
|
+
OUTPUT
|
262
|
+
end
|
263
263
|
|
264
|
-
|
264
|
+
it "processes overset" do
|
265
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
266
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
267
|
+
<mover accent="true">
|
268
|
+
<mrow>
|
269
|
+
<mi> x </mi>
|
270
|
+
<mo> + </mo>
|
271
|
+
<mi> y </mi>
|
272
|
+
<mo> + </mo>
|
273
|
+
<mi> z </mi>
|
274
|
+
</mrow>
|
275
|
+
<mo>fred</mo>
|
276
|
+
</mover>
|
277
|
+
</math>
|
265
278
|
INPUT
|
266
|
-
|
279
|
+
overset(fred)(x + y + z)
|
267
280
|
OUTPUT
|
268
281
|
end
|
269
282
|
|
270
|
-
it "processes
|
271
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
272
|
-
|
273
|
-
<
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
</
|
283
|
+
it "processes mtable" do
|
284
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
285
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
286
|
+
<mi>X</mi>
|
287
|
+
<mo>=</mo>
|
288
|
+
<mtable frame="solid" rowlines="solid" align="axis 3">
|
289
|
+
<mtr>
|
290
|
+
<mtd><mi>A</mi></mtd>
|
291
|
+
<mtd><mi>B</mi></mtd>
|
292
|
+
</mtr>
|
293
|
+
<mtr>
|
294
|
+
<mtd><mi>C</mi></mtd>
|
295
|
+
<mtd><mi>D</mi></mtd>
|
296
|
+
</mtr>
|
297
|
+
<mtr>
|
298
|
+
<mtd><mi>E</mi></mtd>
|
299
|
+
<mtd><mi>F</mi></mtd>
|
300
|
+
</mtr>
|
301
|
+
</mtable>
|
302
|
+
</math>
|
303
|
+
INPUT
|
304
|
+
X = [[A,B],[C,D],[E,F]]
|
305
|
+
OUTPUT
|
306
|
+
end
|
283
307
|
|
284
|
-
|
308
|
+
it "processes <semantics> wrapping element" do
|
309
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
310
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
311
|
+
<semantics>
|
312
|
+
<mrow>
|
313
|
+
<mover accent="true">
|
314
|
+
<mi>λ</mi>
|
315
|
+
<mo>¯</mo>
|
316
|
+
</mover>
|
317
|
+
<mo stretchy="false">(</mo>
|
318
|
+
<msub>
|
319
|
+
<mi>t</mi>
|
320
|
+
<mn>1</mn>
|
321
|
+
</msub>
|
322
|
+
<mo>,</mo>
|
323
|
+
<mtext> </mtext>
|
324
|
+
<msub>
|
325
|
+
<mi>t</mi>
|
326
|
+
<mn>2</mn>
|
327
|
+
</msub>
|
328
|
+
<mo stretchy="false">)</mo>
|
329
|
+
</mrow>
|
330
|
+
</semantics>
|
331
|
+
</math>
|
285
332
|
INPUT
|
286
|
-
|
333
|
+
bar lambda ( t_1 , t_2 )
|
287
334
|
OUTPUT
|
288
335
|
end
|
289
336
|
|
290
|
-
it "processes
|
291
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
337
|
+
it "processes <math> without xmlns" do
|
338
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
339
|
+
<math>
|
340
|
+
<semantics>
|
341
|
+
<mrow>
|
342
|
+
<mover accent="true">
|
343
|
+
<mi>z</mi>
|
344
|
+
<mo>¯</mo>
|
345
|
+
</mover>
|
346
|
+
<mo stretchy="false">(</mo>
|
347
|
+
<msub>
|
348
|
+
<mi>t</mi>
|
349
|
+
<mn>1</mn>
|
350
|
+
</msub>
|
351
|
+
<mo>,</mo>
|
352
|
+
<mtext> </mtext>
|
353
|
+
<msub>
|
354
|
+
<mi>t</mi>
|
355
|
+
<mn>2</mn>
|
356
|
+
</msub>
|
357
|
+
<mo stretchy="false">)</mo>
|
358
|
+
</mrow>
|
359
|
+
</semantics>
|
360
|
+
</math>
|
310
361
|
INPUT
|
311
|
-
|
362
|
+
bar z ( t_1 , t_2 )
|
312
363
|
OUTPUT
|
313
364
|
end
|
314
365
|
|
315
|
-
|
316
|
-
expect(MathML2AsciiMath.m2a(<<~INPUT)).to
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
</
|
327
|
-
|
366
|
+
it "processes and skips <annotation> element" do
|
367
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
368
|
+
<math>
|
369
|
+
<semantics>
|
370
|
+
<mrow>
|
371
|
+
<mover accent="true">
|
372
|
+
<mi>z</mi>
|
373
|
+
<mo>¯</mo>
|
374
|
+
</mover>
|
375
|
+
<mo stretchy="false">(</mo>
|
376
|
+
<msub>
|
377
|
+
<mi>t</mi>
|
378
|
+
<mn>1</mn>
|
379
|
+
</msub>
|
380
|
+
<mo>,</mo>
|
381
|
+
<mtext> </mtext>
|
382
|
+
<msub>
|
383
|
+
<mi>t</mi>
|
384
|
+
<mn>2</mn>
|
385
|
+
</msub>
|
386
|
+
<mo stretchy="false">)</mo>
|
387
|
+
</mrow>
|
388
|
+
<annotation encoding="MathType-MTEF">MathType@MTEF@5@5@+=feaagCart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLnhiov2DGi1BTfMBaeXatLxBI9gBaerbbjxAHXgarqqtubsr4rNCHbGeaGqipG0dh9qqWrVepG0dbbL8F4rqqrVepeea0xe9LqFf0xc9q8qqaqFn0lXdHiVcFbIOFHK8Feea0dXdar=Jb9hs0dXdHuk9fr=xfr=xfrpeWZqaaeqabiGaciGacaqadmaadaqaaqaaaOqaaiqadQhagaqeaiaacIcacaWG0bWaaSbaaSqaaiaaigdaaeqaaOGaaiilaiaaysW7caWG0bWaaSbaaSqaaiaaikdaaeqaaOGaaiykaaaa@3DCE@</annotation>
|
389
|
+
</semantics>
|
390
|
+
</math>
|
328
391
|
INPUT
|
329
|
-
|
392
|
+
bar z ( t_1 , t_2 )
|
330
393
|
OUTPUT
|
331
394
|
end
|
332
395
|
|
396
|
+
it "does not include non-significant whitespaces (spaces between nodes)" do
|
397
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
398
|
+
<math> <semantics> <mrow> <msub> <mi>x</mi> <mn>1</mn> </msub> <mo>,</mo><mtext> </mtext><msub> <mi>x</mi> <mn>2</mn> </msub> <mo>,</mo><mtext> </mtext><mtext> </mtext><mo>…</mo><mtext> </mtext><mtext> </mtext><mtext> </mtext><msub> <mi>x</mi> <mi>n</mi> </msub> </mrow> <annotation encoding='MathType-MTEF'>MathType@MTEF@5@5@+= feaagKart1ev2aqatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbbjxAHX garuavP1wzZbItLDhis9wBH5garmWu51MyVXgarqqtubsr4rNCHbGe aGqipG0dh9qqWrVepG0dbbL8F4rqqrVepeea0xe9LqFf0xc9q8qqaq Fn0lXdHiVcFbIOFHK8Feea0dXdar=Jb9hs0dXdHuk9fr=xfr=xfrpe WZqaaeGaciWaamGadaGadeaabaGaaqaaaOqaaiaadIhadaWgaaWcba GaaGymaaqabaGccaGGSaGaaGjbVlaadIhadaWgaaWcbaGaaGOmaaqa baGccaGGSaGaaGjbVlaaykW7cqWIMaYscaaMc8UaaGPaVlaaysW7ca WG4bWaaSbaaSqaaiaad6gaaeqaaaaa@4713@ </annotation> </semantics> </math>
|
399
|
+
INPUT
|
400
|
+
x_1 , x_2 , ... x_n
|
401
|
+
OUTPUT
|
402
|
+
end
|
333
403
|
|
404
|
+
it "processes unknown MathML" do
|
405
|
+
expect(MathML2AsciiMath.m2a(<<~INPUT)).to eq <<~OUTPUT.strip
|
406
|
+
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
407
|
+
<mrow>
|
408
|
+
<mi> x </mi>
|
409
|
+
<mo> + </mo>
|
410
|
+
<mphantom>
|
411
|
+
<mi> y </mi>
|
412
|
+
<mo> + </mo>
|
413
|
+
</mphantom>
|
414
|
+
<mi> z </mi>
|
415
|
+
</mrow>
|
416
|
+
</math>
|
417
|
+
INPUT
|
418
|
+
x + <math xmlns="http://www.w3.org/1998/Math/MathML"><mphantom>
|
419
|
+
<mi> y </mi>
|
420
|
+
<mo> + </mo>
|
421
|
+
</mphantom></math> z
|
422
|
+
OUTPUT
|
423
|
+
end
|
334
424
|
end
|