mathml2asciimath 0.0.6 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,3 @@
1
1
  module MathML2AsciiMath
2
- VERSION = "0.0.6".freeze
2
+ VERSION = "0.0.11".freeze
3
3
  end
4
-
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require "mathml2asciimath/version"
6
6
 
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  This gem is in active development.
18
18
  DESCRIPTION
19
19
 
20
- spec.homepage = "https://github.com/metanorma/mathml2asciimath"
20
+ spec.homepage = "https://github.com/plurimath/mathml2asciimath"
21
21
  spec.license = "BSD-2-Clause"
22
22
 
23
23
  spec.bindir = "bin"
@@ -27,16 +27,16 @@ Gem::Specification.new do |spec|
27
27
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
28
28
 
29
29
  spec.add_dependency "htmlentities", "~> 4.3.4"
30
- spec.add_dependency "nokogiri", ">= 1.10.4"
30
+ spec.add_dependency "nokogiri", "~> 1.11"
31
31
 
32
- spec.add_development_dependency "bundler", "~> 2.0.1"
32
+ spec.add_development_dependency "bundler"
33
33
  spec.add_development_dependency "byebug", "~> 9.1"
34
- spec.add_development_dependency "rspec-match_fuzzy", "~> 0.1.3"
35
34
  spec.add_development_dependency "guard", "~> 2.14"
36
35
  spec.add_development_dependency "guard-rspec", "~> 4.7"
37
36
  spec.add_development_dependency "rake", "~> 12.0"
38
37
  spec.add_development_dependency "rspec", "~> 3.6"
39
- spec.add_development_dependency "rubocop", "= 0.54.0"
38
+ spec.add_development_dependency "rspec-match_fuzzy", "~> 0.1.3"
39
+ spec.add_development_dependency "rubocop", "~> 1.5.2"
40
40
  spec.add_development_dependency "simplecov", "~> 0.15"
41
41
  spec.add_development_dependency "timecop", "~> 0.9"
42
42
  end
data/spec/mathml_spec.rb CHANGED
@@ -1,332 +1,424 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe MathML2AsciiMath do
4
- it "processes some MathML" do
5
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
6
- <math xmlns="http://www.w3.org/1998/Math/MathML">
7
- <mrow>
8
- <mi>a</mi> <mo>⋄</mo> <msup><mi>x</mi><mn>2</mn></msup>
9
- <mo>+</mo><mi>b</mi><mo>×</mo><mi>x</mi>
10
- <mo>+</mo><msub><mi>c</mi><mn>3</mn></msub>
11
- </mrow>
12
- </math>
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>
13
15
  INPUT
14
- a diamond x^2\n + b xx x\n + c_3
16
+ a diamond x^2 + b xx x + c_3
15
17
  OUTPUT
16
18
  end
17
19
 
18
- it "processes some MathML" do
19
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
20
- <math xmlns="http://www.w3.org/1998/Math/MathML">
21
- <mrow>
22
- <mi>a</mi> <mo>⋄</mo> <msup><mi>x</mi><mn>2d</mn></msup>
23
- <mo>+</mo><mi>b</mi><mo>×</mo><mi>x</mi>
24
- <mo>+</mo><msub><mi>c</mi><mn>ab</mn></msub>
25
- </mrow>
26
- </math>
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>
27
29
  INPUT
28
- a diamond x^(2d)\n+ b xx x\n+ c_(ab)
30
+ a diamond x^(2d) + b xx x + c_(ab)
29
31
  OUTPUT
30
32
  end
31
33
 
32
- it "processes some MathML" do
33
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
34
- <math xmlns="http://www.w3.org/1998/Math/MathML">
35
- <mfrac>
36
- <mrow> <mn> 1 </mn> <mo> + </mo> <msqrt> <mn> 5 </mn> </msqrt> </mrow>
37
- <mn> 2 </mn>
38
- </mfrac>
39
- </math>
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>
40
42
  INPUT
41
- (( 1 + sqrt( 5 ) ))/( 2 )
43
+ ((1 + sqrt(5)))/(2)
42
44
  OUTPUT
43
45
  end
44
46
 
45
- it "processes some MathML" do
46
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
47
- <math xmlns="http://www.w3.org/1998/Math/MathML">
48
- <mfenced><mrow><mi> a </mi> <mo> + </mo> <mi> b </mi></mrow></mfenced>
49
- </math>
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>
50
52
  INPUT
51
- ( a + b )
53
+ (a + b)
52
54
  OUTPUT
53
55
  end
54
56
 
55
- it "processes some MathML" do
56
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
57
- <math xmlns="http://www.w3.org/1998/Math/MathML">
58
- <mfenced open="["> <mn> 0 </mn> <mn> 1 </mn> </mfenced>
59
- </math>
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>
60
62
  INPUT
61
- [ 0 , 1 )
63
+ [0,1)
62
64
  OUTPUT
63
65
  end
64
66
 
65
- it "processes some MathML" do
66
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
67
- <math xmlns="http://www.w3.org/1998/Math/MathML">
68
- <munderover>
69
- <mo>&#x222B;</mo> <mn>0</mn> <mi>&#x221E;</mi>
70
- </munderover>
71
- </math>
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>&#x222B;</mo> <mn>0</mn> <mi>&#x221E;</mi>
72
+ </munderover>
73
+ </math>
72
74
  INPUT
73
- \u222B_0^( oo )
75
+ int_0^(oo)
74
76
  OUTPUT
75
77
  end
76
78
 
77
- it "processes some MathML" do
78
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
79
- <math xmlns="http://www.w3.org/1998/Math/MathML">
80
- <msubsup>
81
- <mo>&#x222B;</mo>
82
- <mn>ab</mn>
83
- <mn>ds</mn>
84
- </msubsup>
85
- </math>
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>&#x222B;</mo>
84
+ <mn>ab</mn>
85
+ <mn>ds</mn>
86
+ </msubsup>
87
+ </math>
86
88
  INPUT
87
- \u222B_(ab)^(ds)
89
+ int_(ab)^(ds)
88
90
  OUTPUT
89
91
  end
90
92
 
91
- it "processes some MathML" do
92
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
93
- <math xmlns="http://www.w3.org/1998/Math/MathML">
94
- <munder>
95
- <mrow>
96
- <mi> x </mi>
97
- <mo> + </mo>
98
- <mi> y </mi>
99
- <mo> + </mo>
100
- <mi> z </mi>
101
- </mrow>
102
- <mo> &#x23DF;</mo>
103
- </munder>
104
- </math>
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> &#x23DF;</mo>
105
+ </munder>
106
+ </math>
105
107
  INPUT
106
- ubrace (\nx\n+\ny\n+\nz\n)
108
+ ubrace (x + y + z)
107
109
  OUTPUT
108
110
  end
109
111
 
110
- it "processes some MathML" do
111
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
112
- <math xmlns="http://www.w3.org/1998/Math/MathML">
113
- <munder>
114
- <mrow>
115
- <mi> x </mi>
116
- <mo> + </mo>
117
- <mi> y </mi>
118
- <mo> + </mo>
119
- <mi> z </mi>
120
- </mrow>
121
- <mo> &#x0332;</mo>
122
- </munder>
123
- </math>
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> &#x0332;</mo>
124
+ </munder>
125
+ </math>
124
126
  INPUT
125
- ul (\nx\n+\ny\n+\nz\n)
127
+ ul (x + y + z)
126
128
  OUTPUT
127
129
  end
128
130
 
129
- it "processes some MathML" do
130
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
131
- <math xmlns="http://www.w3.org/1998/Math/MathML">
132
- <munder>
133
- <mrow>
134
- <mi> x </mi>
135
- <mo> + </mo>
136
- <mi> y </mi>
137
- <mo> + </mo>
138
- <mi> z </mi>
139
- </mrow>
140
- <mo>fred </mo>
141
- </munder>
142
- </math>
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>
143
145
  INPUT
144
- underset(fred)((\nx\n+\ny\n+\nz\n))
146
+ underset(fred)((x + y + z))
145
147
  OUTPUT
146
148
  end
147
149
 
148
- it "processes some MathML" do
149
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
150
- <math xmlns="http://www.w3.org/1998/Math/MathML">
151
- <mover accent="true">
152
- <mrow>
153
- <mi> x </mi>
154
- <mo> + </mo>
155
- <mi> y </mi>
156
- <mo> + </mo>
157
- <mi> z </mi>
158
- </mrow>
159
- <mo> &#x23DE;</mo>
160
- </mover>
161
-
162
- </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> &#x23DE;</mo>
162
+ </mover>
163
+ </math>
163
164
  INPUT
164
- obrace\nx\n+\ny\n+\nz
165
+ obrace x + y + z
165
166
  OUTPUT
166
167
  end
167
168
 
168
- it "processes some MathML" do
169
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
170
- <math xmlns="http://www.w3.org/1998/Math/MathML">
171
- <mover accent="true">
172
- <mrow>
173
- <mi> x </mi>
174
- <mo> + </mo>
175
- <mi> y </mi>
176
- <mo> + </mo>
177
- <mi> z </mi>
178
- </mrow>
179
- <mo> &#x5e;</mo>
180
- </mover>
181
-
182
- </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> &#x5e;</mo>
181
+ </mover>
182
+ </math>
183
183
  INPUT
184
- hat\nx\n+\ny\n+\nz
184
+ hat x + y + z
185
185
  OUTPUT
186
186
  end
187
187
 
188
- it "processes some MathML" do
189
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
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> &#xaf;</mo>
200
- </mover>
201
-
202
- </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> &#xaf;</mo>
200
+ </mover>
201
+ </math>
203
202
  INPUT
204
- bar\nx\n+\ny\n+\nz
203
+ bar x + y + z
205
204
  OUTPUT
206
205
  end
207
206
 
208
- it "processes some MathML" do
209
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
210
- <math xmlns="http://www.w3.org/1998/Math/MathML">
211
- <mover accent="true">
212
- <mrow>
213
- <mi> x </mi>
214
- <mo> + </mo>
215
- <mi> y </mi>
216
- <mo> + </mo>
217
- <mi> z </mi>
218
- </mrow>
219
- <mo>&#x2192;</mo>
220
- </mover>
221
-
222
- </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>&#x2192;</mo>
219
+ </mover>
220
+ </math>
223
221
  INPUT
224
- vec\nx\n+\ny\n+\nz
222
+ vec x + y + z
225
223
  OUTPUT
226
224
  end
227
225
 
228
- it "processes some MathML" do
229
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
230
- <math xmlns="http://www.w3.org/1998/Math/MathML">
231
- <mover accent="true">
232
- <mrow>
233
- <mi> x </mi>
234
- <mo> + </mo>
235
- <mi> y </mi>
236
- <mo> + </mo>
237
- <mi> z </mi>
238
- </mrow>
239
- <mo> .</mo>
240
- </mover>
241
-
242
- </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>
243
240
  INPUT
244
- dot\nx\n+\ny\n+\nz
241
+ dot x + y + z
245
242
  OUTPUT
246
243
  end
247
244
 
248
- it "processes some MathML" do
249
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
250
- <math xmlns="http://www.w3.org/1998/Math/MathML">
251
- <mover accent="true">
252
- <mrow>
253
- <mi> x </mi>
254
- <mo> + </mo>
255
- <mi> y </mi>
256
- <mo> + </mo>
257
- <mi> z </mi>
258
- </mrow>
259
- <mo>..</mo>
260
- </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
261
263
 
262
- </math>
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>
263
278
  INPUT
264
- ddot\nx\n+\ny\n+\nz
279
+ overset(fred)(x + y + z)
265
280
  OUTPUT
266
281
  end
267
282
 
268
- it "processes some MathML" do
269
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
270
- <math xmlns="http://www.w3.org/1998/Math/MathML">
271
- <mover accent="true">
272
- <mrow>
273
- <mi> x </mi>
274
- <mo> + </mo>
275
- <mi> y </mi>
276
- <mo> + </mo>
277
- <mi> z </mi>
278
- </mrow>
279
- <mo>fred</mo>
280
- </mover>
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
281
307
 
282
- </math>
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>&#x3BB;</mi>
315
+ <mo>&#xAF;</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>&#x2009;</mtext>
324
+ <msub>
325
+ <mi>t</mi>
326
+ <mn>2</mn>
327
+ </msub>
328
+ <mo stretchy="false">)</mo>
329
+ </mrow>
330
+ </semantics>
331
+ </math>
283
332
  INPUT
284
- overset(fred)(\nx\n+\ny\n+\nz\n)
333
+ bar lambda ( t_1 , t_2 )
285
334
  OUTPUT
286
335
  end
287
336
 
288
- it "processes some MathML" do
289
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
290
- <math xmlns="http://www.w3.org/1998/Math/MathML">
291
- <mi>X</mi>
292
- <mo>=</mo>
293
- <mtable frame="solid" rowlines="solid" align="axis 3">
294
- <mtr>
295
- <mtd><mi>A</mi></mtd>
296
- <mtd><mi>B</mi></mtd>
297
- </mtr>
298
- <mtr>
299
- <mtd><mi>C</mi></mtd>
300
- <mtd><mi>D</mi></mtd>
301
- </mtr>
302
- <mtr>
303
- <mtd><mi>E</mi></mtd>
304
- <mtd><mi>F</mi></mtd>
305
- </mtr>
306
- </mtable>
307
- </math>
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>&#xAF;</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>&#x2009;</mtext>
353
+ <msub>
354
+ <mi>t</mi>
355
+ <mn>2</mn>
356
+ </msub>
357
+ <mo stretchy="false">)</mo>
358
+ </mrow>
359
+ </semantics>
360
+ </math>
308
361
  INPUT
309
- X = [[A,B],[C,D],[E,F]]
362
+ bar z ( t_1 , t_2 )
310
363
  OUTPUT
311
364
  end
312
365
 
313
- it "processes some unknown MathML" do
314
- expect(MathML2AsciiMath.m2a(<<~INPUT)).to match_fuzzy <<~OUTPUT
315
- <math xmlns="http://www.w3.org/1998/Math/MathML">
316
- <mrow>
317
- <mi> x </mi>
318
- <mo> + </mo>
319
- <mphantom>
320
- <mi> y </mi>
321
- <mo> + </mo>
322
- </mphantom>
323
- <mi> z </mi>
324
- </mrow>
325
- </math>
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>&#xAF;</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>&#x2009;</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>
326
391
  INPUT
327
- x\n+\n<mphantom>\n<mi> y </mi>\n<mo> + </mo>\n</mphantom>\nz
392
+ bar z ( t_1 , t_2 )
328
393
  OUTPUT
329
394
  end
330
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
331
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
332
424
  end