asciimath 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: dbf88b3aa9fe930bab8c1cd59e2aefadf777c681
4
- data.tar.gz: 6f1c3017ab2e6253f839436db7125c13af78fd84
2
+ SHA256:
3
+ metadata.gz: d2a221676ad606382d11b321c85c1ab20181b811889ecbde2fffe9001ba49a2e
4
+ data.tar.gz: 632181cf62e5be454815f56892d39686dbc423b9e93c06e78efe9099a5bae47e
5
5
  SHA512:
6
- metadata.gz: 3c89e3a22d9c066f45ffda344dd6af9605ae10c1b0a09bfe984e4127625ed5eff6689de097a35df9157440632a16464e4b1a29fed31347198cd88d80ea53949e
7
- data.tar.gz: 6b46bc52dbe38edfad06d087343e7bc9bcb904aaa1f9723a567e3c5312be9d734df5b579a0118991d967ef57a8d0584f25f7dc008cfe776d4dea28243f9d9d32
6
+ metadata.gz: 55682f13d5f1803dcf677a9cd71753397c736087ce7e91ca27023e93185b643c1c4a040cfe490b01f2500e13b1ac453e5de4224f0bdcd703487eec61485fb36a
7
+ data.tar.gz: b944a87b4b2fea973d832248c0dd5e6344b3e26a5623067a9ecc40bbf562a4efa4c3c6ba9740cd305c776625961d256195c707cf633bdf599e067e440a5fbfd0
@@ -1,5 +1,12 @@
1
1
  = Asciimath Changelog
2
2
 
3
+ == 1.0.7.next
4
+
5
+ Bug fixes::
6
+
7
+ * Issue #6: Mark standard functions as identifiers instead of operators
8
+ * Issue #7: Correct parsing of TeX altenative style (`text()`) text strings
9
+
3
10
  == 1.0.6
4
11
 
5
12
  Bug fixes::
@@ -23,6 +23,8 @@ module AsciiMath
23
23
 
24
24
  private
25
25
 
26
+ ZWJ = "\u8205"
27
+
26
28
  def append(expression, opts = {})
27
29
  case expression
28
30
  when Array
@@ -98,7 +100,7 @@ module AsciiMath
98
100
  if expression[:lparen]
99
101
  brace(expression[:lparen], {:style => brace_height})
100
102
  else
101
- blank("‍")
103
+ blank(ZWJ)
102
104
  end
103
105
  matrix_width = "grid-template-columns:repeat(" + expression[:rows][0].length.to_s + ",1fr);"
104
106
  matrix_height = "grid-template-rows:repeat(" + expression[:rows].length.to_s + ",1fr);"
@@ -115,7 +117,7 @@ module AsciiMath
115
117
  if expression[:rparen]
116
118
  brace(expression[:rparen], {:style => brace_height})
117
119
  else
118
- blank("‍")
120
+ blank(ZWJ)
119
121
  end
120
122
  end
121
123
  end
@@ -130,26 +132,26 @@ module AsciiMath
130
132
  append(sup, :strip_paren => true)
131
133
  end
132
134
  else
133
- smaller("‍")
135
+ smaller(ZWJ)
134
136
  end
135
137
  if sub
136
138
  smaller do
137
139
  append(sub, :strip_paren => true)
138
140
  end
139
141
  else
140
- smaller("‍")
142
+ smaller(ZWJ)
141
143
  end
142
144
  end
143
145
  end
144
146
 
145
147
  def append_underover(base, under, over)
146
- blank("‍")
148
+ blank(ZWJ)
147
149
  underover do
148
150
  smaller do
149
151
  if over
150
152
  append(over, :strip_paren => true)
151
153
  else
152
- blank("‍")
154
+ blank(ZWJ)
153
155
  end
154
156
  end
155
157
  append(base)
@@ -157,14 +159,14 @@ module AsciiMath
157
159
  if under
158
160
  append(under, :strip_paren => true)
159
161
  else
160
- blank("‍")
162
+ blank(ZWJ)
161
163
  end
162
164
  end
163
165
  end
164
166
  end
165
167
 
166
168
  def append_fraction(numerator, denominator)
167
- blank("‍")
169
+ blank(ZWJ)
168
170
  fraction do
169
171
  fraction_row do
170
172
  fraction_cell do
@@ -203,7 +205,7 @@ module AsciiMath
203
205
 
204
206
  if block_given? || text
205
207
  @html << '>'
206
- @html << text
208
+ @html << text.encode(Encoding::US_ASCII, :xml => :text) if text
207
209
  yield if block_given?
208
210
  @html << '</span>'
209
211
  else
@@ -114,7 +114,7 @@ module AsciiMath
114
114
 
115
115
  if block_given? || text
116
116
  @mathml << '>'
117
- @mathml << text
117
+ @mathml << text.encode(Encoding::US_ASCII, :xml => :text) if text
118
118
  yield self if block_given?
119
119
  @mathml << '</' << @prefix << tag.to_s << '>'
120
120
  else
@@ -55,7 +55,8 @@ module AsciiMath
55
55
  class Tokenizer
56
56
  WHITESPACE = /^\s+/
57
57
  NUMBER = /-?[0-9]+(?:\.[0-9]+)?/
58
- TEXT = /"[^"]+"/
58
+ QUOTED_TEXT = /"[^"]*"/
59
+ TEX_TEXT = /text\([^)]*\)/
59
60
 
60
61
  # Public: Initializes an ASCIIMath tokenizer.
61
62
  #
@@ -85,12 +86,19 @@ module AsciiMath
85
86
  return {:value => nil, :type => :eof} if @string.eos?
86
87
 
87
88
  case @string.peek(1)
88
- when '"'
89
- read_text
90
- when '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
91
- read_number() || read_symbol
89
+ when '"'
90
+ read_quoted_text
91
+ when 't'
92
+ case @string.peek(5)
93
+ when 'text('
94
+ read_tex_text
92
95
  else
93
- read_symbol()
96
+ read_symbol
97
+ end
98
+ when '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
99
+ read_number || read_symbol
100
+ else
101
+ read_symbol
94
102
  end
95
103
  end
96
104
 
@@ -109,12 +117,22 @@ module AsciiMath
109
117
  #
110
118
  # Returns the text token or nil if a text token could not be matched at
111
119
  # the current position
112
- def read_text
113
- read_value(TEXT) do |text|
120
+ def read_quoted_text
121
+ read_value(QUOTED_TEXT) do |text|
114
122
  {:value => text[1..-2], :type => :text}
115
123
  end
116
124
  end
117
125
 
126
+ # Private: Reads a text token from the input string
127
+ #
128
+ # Returns the text token or nil if a text token could not be matched at
129
+ # the current position
130
+ def read_tex_text
131
+ read_value(TEX_TEXT) do |text|
132
+ {:value => text[5..-2], :type => :text}
133
+ end
134
+ end
135
+
118
136
  # Private: Reads a number token from the input string
119
137
  #
120
138
  # Returns the number token or nil if a number token could not be matched at
@@ -185,69 +203,72 @@ module AsciiMath
185
203
  SYMBOLS = {
186
204
  # Operation symbols
187
205
  '+' => {:value => '+', :type => :operator},
188
- '-' => {:value => '&#x2212;', :type => :operator},
189
- '*' => {:value => '&#x22C5;', :type => :operator},
190
- '**' => {:value => '&#x22C6;', :type => :operator},
206
+ '-' => {:value => "\u2212", :type => :operator},
207
+ '*' => {:value => "\u22C5", :type => :operator},
208
+ '**' => {:value => "\u002A", :type => :operator},
209
+ '***' => {:value => "\u22C6", :type => :operator},
191
210
  '//' => {:value => '/', :type => :operator},
192
211
  '\\\\' => {:value => '\\', :type => :operator},
193
- 'xx' => {:value => '&#x00D7;', :type => :operator},
194
- '-:' => {:value => '&#x00F7;', :type => :operator},
195
- '@' => {:value => '&#x26AC;', :type => :operator},
196
- 'o+' => {:value => '&#x2295;', :type => :operator},
197
- 'ox' => {:value => '&#x2297;', :type => :operator},
198
- 'o.' => {:value => '&#x2299;', :type => :operator},
199
- 'sum' => {:value => '&#x2211;', :type => :operator, :underover => true},
200
- 'prod' => {:value => '&#x220F;', :type => :operator, :underover => true},
201
- '^^' => {:value => '&#x2227;', :type => :operator},
202
- '^^^' => {:value => '&#x22C0;', :type => :operator, :underover => true},
203
- 'vv' => {:value => '&#x2228;', :type => :operator},
204
- 'vvv' => {:value => '&#x22C1;', :type => :operator, :underover => true},
205
- 'nn' => {:value => '&#x2229;', :type => :operator},
206
- 'nnn' => {:value => '&#x22C2;', :type => :operator, :underover => true},
207
- 'uu' => {:value => '&#x222A;', :type => :operator},
208
- 'uuu' => {:value => '&#x22C3;', :type => :operator, :underover => true},
212
+ 'xx' => {:value => "\u00D7", :type => :operator},
213
+ '-:' => {:value => "\u00F7", :type => :operator},
214
+ '|><' => {:value => "\u22C9", :type => :operator},
215
+ '><|' => {:value => "\u22CA", :type => :operator},
216
+ '|><|' => {:value => "\u22C8", :type => :operator},
217
+ '@' => {:value => "\u26AC", :type => :operator},
218
+ 'o+' => {:value => "\u2295", :type => :operator},
219
+ 'ox' => {:value => "\u2297", :type => :operator},
220
+ 'o.' => {:value => "\u2299", :type => :operator},
221
+ 'sum' => {:value => "\u2211", :type => :operator, :underover => true},
222
+ 'prod' => {:value => "\u220F", :type => :operator, :underover => true},
223
+ '^^' => {:value => "\u2227", :type => :operator},
224
+ '^^^' => {:value => "\u22C0", :type => :operator, :underover => true},
225
+ 'vv' => {:value => "\u2228", :type => :operator},
226
+ 'vvv' => {:value => "\u22C1", :type => :operator, :underover => true},
227
+ 'nn' => {:value => "\u2229", :type => :operator},
228
+ 'nnn' => {:value => "\u22C2", :type => :operator, :underover => true},
229
+ 'uu' => {:value => "\u222A", :type => :operator},
230
+ 'uuu' => {:value => "\u22C3", :type => :operator, :underover => true},
209
231
 
210
232
  # Relation symbols
211
233
  '=' => {:value => '=', :type => :operator},
212
- '!=' => {:value => '&#x2260;', :type => :operator},
234
+ '!=' => {:value => "\u2260", :type => :operator},
213
235
  ':=' => {:value => ':=', :type => :operator},
214
- '<' => {:value => '&#x003C;', :type => :operator},
215
- 'lt' => {:value => '&#x003C;', :type => :operator},
216
- '>' => {:value => '&#x003E;', :type => :operator},
217
- 'gt' => {:value => '&#x003E;', :type => :operator},
218
- '<=' => {:value => '&#x2264;', :type => :operator},
219
- 'lt=' => {:value => '&#x2264;', :type => :operator},
220
- '>=' => {:value => '&#x2265;', :type => :operator},
221
- 'geq' => {:value => '&#x2265;', :type => :operator},
222
- '-<' => {:value => '&#x227A;', :type => :operator},
223
- '-lt' => {:value => '&#x227A;', :type => :operator},
224
- '>-' => {:value => '&#x227B;', :type => :operator},
225
- '-<=' => {:value => '&#x2AAF;', :type => :operator},
226
- '>-=' => {:value => '&#x2AB0;', :type => :operator},
227
- 'in' => {:value => '&#x2208;', :type => :operator},
228
- '!in' => {:value => '&#x2209;', :type => :operator},
229
- 'sub' => {:value => '&#x2282;', :type => :operator},
230
- 'sup' => {:value => '&#x2283;', :type => :operator},
231
- 'sube' => {:value => '&#x2286;', :type => :operator},
232
- 'supe' => {:value => '&#x2287;', :type => :operator},
233
- '-=' => {:value => '&#x2261;', :type => :operator},
234
- '~=' => {:value => '&#x2245;', :type => :operator},
235
- '~~' => {:value => '&#x2248;', :type => :operator},
236
- 'prop' => {:value => '&#x221D;', :type => :operator},
236
+ '<' => {:value => "\u003C", :type => :operator},
237
+ 'lt' => {:value => "\u003C", :type => :operator},
238
+ '>' => {:value => "\u003E", :type => :operator},
239
+ 'gt' => {:value => "\u003E", :type => :operator},
240
+ '<=' => {:value => "\u2264", :type => :operator},
241
+ 'le' => {:value => "\u2264", :type => :operator},
242
+ '>=' => {:value => "\u2265", :type => :operator},
243
+ 'ge' => {:value => "\u2265", :type => :operator},
244
+ '-<' => {:value => "\u227A", :type => :operator},
245
+ '>-' => {:value => "\u227B", :type => :operator},
246
+ '-<=' => {:value => "\u2AAF", :type => :operator},
247
+ '>-=' => {:value => "\u2AB0", :type => :operator},
248
+ 'in' => {:value => "\u2208", :type => :operator},
249
+ '!in' => {:value => "\u2209", :type => :operator},
250
+ 'sub' => {:value => "\u2282", :type => :operator},
251
+ 'sup' => {:value => "\u2283", :type => :operator},
252
+ 'sube' => {:value => "\u2286", :type => :operator},
253
+ 'supe' => {:value => "\u2287", :type => :operator},
254
+ '-=' => {:value => "\u2261", :type => :operator},
255
+ '~=' => {:value => "\u2245", :type => :operator},
256
+ '~~' => {:value => "\u2248", :type => :operator},
257
+ 'prop' => {:value => "\u221D", :type => :operator},
237
258
 
238
259
  # Logical symbols
239
260
  'and' => {:value => 'and', :type => :text},
240
261
  'or' => {:value => 'or', :type => :text},
241
- 'not' => {:value => '&#x00AC;', :type => :operator},
242
- '=>' => {:value => '&#x21D2;', :type => :operator},
262
+ 'not' => {:value => "\u00AC", :type => :operator},
263
+ '=>' => {:value => "\u21D2", :type => :operator},
243
264
  'if' => {:value => 'if', :type => :operator},
244
- '<=>' => {:value => '&#x21D4;', :type => :operator},
245
- 'AA' => {:value => '&#x2200;', :type => :operator},
246
- 'EE' => {:value => '&#x2203;', :type => :operator},
247
- '_|_' => {:value => '&#x22A5;', :type => :operator},
248
- 'TT' => {:value => '&#x22A4;', :type => :operator},
249
- '|--' => {:value => '&#x22A2;', :type => :operator},
250
- '|==' => {:value => '&#x22A8;', :type => :operator},
265
+ '<=>' => {:value => "\u21D4", :type => :operator},
266
+ 'AA' => {:value => "\u2200", :type => :operator},
267
+ 'EE' => {:value => "\u2203", :type => :operator},
268
+ '_|_' => {:value => "\u22A5", :type => :operator},
269
+ 'TT' => {:value => "\u22A4", :type => :operator},
270
+ '|--' => {:value => "\u22A2", :type => :operator},
271
+ '|==' => {:value => "\u22A8", :type => :operator},
251
272
 
252
273
  # Grouping brackets
253
274
  '(' => {:value => '(', :type => :lparen},
@@ -256,97 +277,107 @@ module AsciiMath
256
277
  ']' => {:value => ']', :type => :rparen},
257
278
  '{' => {:value => '{', :type => :lparen},
258
279
  '}' => {:value => '}', :type => :rparen},
280
+ '(:' => {:value => "\u2329", :type => :lparen},
281
+ ':)' => {:value => "\u232A", :type => :rparen},
282
+ '<<' => {:value => "\u2329", :type => :lparen},
283
+ '>>' => {:value => "\u232A", :type => :rparen},
259
284
  '|' => {:value => '|', :type => :lrparen},
260
285
  '||' => {:value => '||', :type => :lrparen},
261
- '(:' => {:value => '&#x2329;', :type => :lparen},
262
- ':)' => {:value => '&#x232A;', :type => :rparen},
263
- '<<' => {:value => '&#x2329;', :type => :lparen},
264
- '>>' => {:value => '&#x232A;', :type => :rparen},
265
286
  '{:' => {:value => nil, :type => :lparen},
266
287
  ':}' => {:value => nil, :type => :rparen},
267
288
 
268
289
  # Miscellaneous symbols
269
- 'int' => {:value => '&#x222B;', :type => :operator},
290
+ 'int' => {:value => "\u222B", :type => :operator},
270
291
  'dx' => {:value => 'dx', :type => :identifier},
271
292
  'dy' => {:value => 'dy', :type => :identifier},
272
293
  'dz' => {:value => 'dz', :type => :identifier},
273
294
  'dt' => {:value => 'dt', :type => :identifier},
274
- 'oint' => {:value => '&#x222E;', :type => :operator},
275
- 'del' => {:value => '&#x2202;', :type => :operator},
276
- 'grad' => {:value => '&#x2207;', :type => :operator},
277
- '+-' => {:value => '&#x00B1;', :type => :operator},
278
- 'O/' => {:value => '&#x2205;', :type => :operator},
279
- 'oo' => {:value => '&#x221E;', :type => :operator},
280
- 'aleph' => {:value => '&#x2135;', :type => :operator},
295
+ 'oint' => {:value => "\u222E", :type => :operator},
296
+ 'del' => {:value => "\u2202", :type => :operator},
297
+ 'grad' => {:value => "\u2207", :type => :operator},
298
+ '+-' => {:value => "\u00B1", :type => :operator},
299
+ 'O/' => {:value => "\u2205", :type => :operator},
300
+ 'oo' => {:value => "\u221E", :type => :operator},
301
+ 'aleph' => {:value => "\u2135", :type => :operator},
281
302
  '...' => {:value => '...', :type => :operator},
282
- ':.' => {:value => '&#x2234;', :type => :operator},
283
- '/_' => {:value => '&#x2220;', :type => :operator},
284
- '\\ ' => {:value => '&#x00A0;', :type => :operator},
303
+ ':.' => {:value => "\u2234", :type => :operator},
304
+ '/_' => {:value => "\u2220", :type => :operator},
305
+ '\\ ' => {:value => "\u00A0", :type => :operator},
285
306
  'quad' => {:value => '\u00A0\u00A0', :type => :operator},
286
307
  'qquad' => {:value => '\u00A0\u00A0\u00A0\u00A0', :type => :operator},
287
- 'cdots' => {:value => '&#x22EF;', :type => :operator},
288
- 'vdots' => {:value => '&#x22EE;', :type => :operator},
289
- 'ddots' => {:value => '&#x22F1;', :type => :operator},
290
- 'diamond' => {:value => '&#x22C4;', :type => :operator},
291
- 'square' => {:value => '&#x25A1;', :type => :operator},
292
- '|__' => {:value => '&#x230A;', :type => :operator},
293
- '__|' => {:value => '&#x230B;', :type => :operator},
294
- '|~' => {:value => '&#x2308;', :type => :operator},
295
- '~|' => {:value => '&#x2309;', :type => :operator},
296
- 'CC' => {:value => '&#x2102;', :type => :operator},
297
- 'NN' => {:value => '&#x2115;', :type => :operator},
298
- 'QQ' => {:value => '&#x211A;', :type => :operator},
299
- 'RR' => {:value => '&#x211D;', :type => :operator},
300
- 'ZZ' => {:value => '&#x2124;', :type => :operator},
301
- 'f' => {:value => 'f', :type => :identifier},
302
- 'g' => {:value => 'g', :type => :identifier},
308
+ 'cdots' => {:value => "\u22EF", :type => :operator},
309
+ 'vdots' => {:value => "\u22EE", :type => :operator},
310
+ 'ddots' => {:value => "\u22F1", :type => :operator},
311
+ 'diamond' => {:value => "\u22C4", :type => :operator},
312
+ 'square' => {:value => "\u25A1", :type => :operator},
313
+ '|__' => {:value => "\u230A", :type => :operator},
314
+ '__|' => {:value => "\u230B", :type => :operator},
315
+ '|~' => {:value => "\u2308", :type => :operator},
316
+ '~|' => {:value => "\u2309", :type => :operator},
317
+ 'CC' => {:value => "\u2102", :type => :operator},
318
+ 'NN' => {:value => "\u2115", :type => :operator},
319
+ 'QQ' => {:value => "\u211A", :type => :operator},
320
+ 'RR' => {:value => "\u211D", :type => :operator},
321
+ 'ZZ' => {:value => "\u2124", :type => :operator},
303
322
 
304
- # Standard functions
305
323
  'lim' => {:value => 'lim', :type => :operator, :underover => true},
306
324
  'Lim' => {:value => 'Lim', :type => :operator, :underover => true},
307
- 'sin' => {:value => 'sin', :type => :operator},
308
- 'cos' => {:value => 'cos', :type => :operator},
309
- 'tan' => {:value => 'tan', :type => :operator},
310
- 'sinh' => {:value => 'sinh', :type => :operator},
311
- 'cosh' => {:value => 'cosh', :type => :operator},
312
- 'tanh' => {:value => 'tanh', :type => :operator},
313
- 'cot' => {:value => 'cot', :type => :operator},
314
- 'sec' => {:value => 'sec', :type => :operator},
315
- 'csc' => {:value => 'csc', :type => :operator},
316
- 'log' => {:value => 'log', :type => :operator},
317
- 'ln' => {:value => 'ln', :type => :operator},
318
- 'det' => {:value => 'det', :type => :operator},
319
- 'dim' => {:value => 'dim', :type => :operator},
320
- 'mod' => {:value => 'mod', :type => :operator},
321
- 'gcd' => {:value => 'gcd', :type => :operator},
322
- 'lcm' => {:value => 'lcm', :type => :operator},
323
- 'lub' => {:value => 'lub', :type => :operator},
324
- 'glb' => {:value => 'glb', :type => :operator},
325
- 'min' => {:value => 'min', :type => :operator, :underover => true},
326
- 'max' => {:value => 'max', :type => :operator, :underover => true},
325
+
326
+ # Standard functions
327
+ 'sin' => {:value => 'sin', :type => :identifier},
328
+ 'cos' => {:value => 'cos', :type => :identifier},
329
+ 'tan' => {:value => 'tan', :type => :identifier},
330
+ 'sec' => {:value => 'sec', :type => :identifier},
331
+ 'csc' => {:value => 'csc', :type => :identifier},
332
+ 'cot' => {:value => 'cot', :type => :identifier},
333
+ 'arcsin' => {:value => 'arcsin', :type => :identifier},
334
+ 'arccos' => {:value => 'arccos', :type => :identifier},
335
+ 'arctan' => {:value => 'arctan', :type => :identifier},
336
+ 'sinh' => {:value => 'sinh', :type => :identifier},
337
+ 'cosh' => {:value => 'cosh', :type => :identifier},
338
+ 'tanh' => {:value => 'tanh', :type => :identifier},
339
+ 'sech' => {:value => 'sech', :type => :identifier},
340
+ 'csch' => {:value => 'csch', :type => :identifier},
341
+ 'coth' => {:value => 'coth', :type => :identifier},
342
+ 'exp' => {:value => 'exp', :type => :identifier},
343
+ 'log' => {:value => 'log', :type => :identifier},
344
+ 'ln' => {:value => 'ln', :type => :identifier},
345
+ 'det' => {:value => 'det', :type => :identifier},
346
+ 'dim' => {:value => 'dim', :type => :identifier},
347
+ 'mod' => {:value => 'mod', :type => :identifier},
348
+ 'gcd' => {:value => 'gcd', :type => :identifier},
349
+ 'lcm' => {:value => 'lcm', :type => :identifier},
350
+ 'lub' => {:value => 'lub', :type => :identifier},
351
+ 'glb' => {:value => 'glb', :type => :identifier},
352
+ 'min' => {:value => 'min', :type => :identifier, :underover => true},
353
+ 'max' => {:value => 'max', :type => :identifier, :underover => true},
354
+ 'f' => {:value => 'f', :type => :identifier},
355
+ 'g' => {:value => 'g', :type => :identifier},
327
356
 
328
357
  # Accents
329
- 'hat' => {:value => '&#x005E;', :type => :accent, :position => :over},
330
- 'bar' => {:value => '&#x00AF;', :type => :accent, :position => :over},
358
+ 'hat' => {:value => "\u005E", :type => :accent, :position => :over},
359
+ 'bar' => {:value => "\u00AF", :type => :accent, :position => :over},
331
360
  'ul' => {:value => '_', :type => :accent, :position => :under},
332
- 'vec' => {:value => '&#x2192;', :type => :accent, :position => :over},
361
+ 'vec' => {:value => "\u2192", :type => :accent, :position => :over},
333
362
  'dot' => {:value => '.', :type => :accent, :position => :over},
334
363
  'ddot' => {:value => '..', :type => :accent, :position => :over},
364
+ 'obrace' => {:value => "\u23DE", :type => :accent, :position => :over},
365
+ 'ubrace' => {:value => "\u23DF", :type => :accent, :position => :under},
335
366
 
336
367
  # Arrows
337
- 'uarr' => {:value => '&#x2191;', :type => :operator},
338
- 'darr' => {:value => '&#x2193;', :type => :operator},
339
- 'rarr' => {:value => '&#x2192;', :type => :operator},
340
- '->' => {:value => '&#x2192;', :type => :operator},
341
- '>->' => {:value => '&#x21A3;', :type => :operator},
342
- '->>' => {:value => '&#x21A0;', :type => :operator},
343
- '>->>' => {:value => '&#x2916;', :type => :operator},
344
- '|->' => {:value => '&#x21A6;', :type => :operator},
345
- 'larr' => {:value => '&#x2190;', :type => :operator},
346
- 'harr' => {:value => '&#x2194;', :type => :operator},
347
- 'rArr' => {:value => '&#x21D2;', :type => :operator},
348
- 'lArr' => {:value => '&#x21D0;', :type => :operator},
349
- 'hArr' => {:value => '&#x21D4;', :type => :operator},
368
+ 'uarr' => {:value => "\u2191", :type => :operator},
369
+ 'darr' => {:value => "\u2193", :type => :operator},
370
+ 'rarr' => {:value => "\u2192", :type => :operator},
371
+ '->' => {:value => "\u2192", :type => :operator},
372
+ '>->' => {:value => "\u21A3", :type => :operator},
373
+ '->>' => {:value => "\u21A0", :type => :operator},
374
+ '>->>' => {:value => "\u2916", :type => :operator},
375
+ '|->' => {:value => "\u21A6", :type => :operator},
376
+ 'larr' => {:value => "\u2190", :type => :operator},
377
+ 'harr' => {:value => "\u2194", :type => :operator},
378
+ 'rArr' => {:value => "\u21D2", :type => :operator},
379
+ 'lArr' => {:value => "\u21D0", :type => :operator},
380
+ 'hArr' => {:value => "\u21D4", :type => :operator},
350
381
 
351
382
  # Other
352
383
  'sqrt' => {:value => :sqrt, :type => :unary},
@@ -372,57 +403,57 @@ module AsciiMath
372
403
  '^' => {:value => :sup, :type => :infix},
373
404
 
374
405
  # Greek letters
375
- 'alpha' => {:value => '&#x03b1;', :type => :identifier},
376
- 'Alpha' => {:value => '&#x0391;', :type => :identifier},
377
- 'beta' => {:value => '&#x03b2;', :type => :identifier},
378
- 'Beta' => {:value => '&#x0392;', :type => :identifier},
379
- 'gamma' => {:value => '&#x03b3;', :type => :identifier},
380
- 'Gamma' => {:value => '&#x0393;', :type => :operator},
381
- 'delta' => {:value => '&#x03b4;', :type => :identifier},
382
- 'Delta' => {:value => '&#x0394;', :type => :operator},
383
- 'epsilon' => {:value => '&#x03b5;', :type => :identifier},
384
- 'Epsilon' => {:value => '&#x0395;', :type => :identifier},
385
- 'varepsilon' => {:value => '&#x025b;', :type => :identifier},
386
- 'zeta' => {:value => '&#x03b6;', :type => :identifier},
387
- 'Zeta' => {:value => '&#x0396;', :type => :identifier},
388
- 'eta' => {:value => '&#x03b7;', :type => :identifier},
389
- 'Eta' => {:value => '&#x0397;', :type => :identifier},
390
- 'theta' => {:value => '&#x03b8;', :type => :identifier},
391
- 'Theta' => {:value => '&#x0398;', :type => :operator},
392
- 'vartheta' => {:value => '&#x03d1;', :type => :identifier},
393
- 'iota' => {:value => '&#x03b9;', :type => :identifier},
394
- 'Iota' => {:value => '&#x0399;', :type => :identifier},
395
- 'kappa' => {:value => '&#x03ba;', :type => :identifier},
396
- 'Kappa' => {:value => '&#x039a;', :type => :identifier},
397
- 'lambda' => {:value => '&#x03bb;', :type => :identifier},
398
- 'Lambda' => {:value => '&#x039b;', :type => :operator},
399
- 'mu' => {:value => '&#x03bc;', :type => :identifier},
400
- 'Mu' => {:value => '&#x039c;', :type => :identifier},
401
- 'nu' => {:value => '&#x03bd;', :type => :identifier},
402
- 'Nu' => {:value => '&#x039d;', :type => :identifier},
403
- 'xi' => {:value => '&#x03be;', :type => :identifier},
404
- 'Xi' => {:value => '&#x039e;', :type => :operator},
405
- 'omicron' => {:value => '&#x03bf;', :type => :identifier},
406
- 'Omicron' => {:value => '&#x039f;', :type => :identifier},
407
- 'pi' => {:value => '&#x03c0;', :type => :identifier},
408
- 'Pi' => {:value => '&#x03a0;', :type => :operator},
409
- 'rho' => {:value => '&#x03c1;', :type => :identifier},
410
- 'Rho' => {:value => '&#x03a1;', :type => :identifier},
411
- 'sigma' => {:value => '&#x03c3;', :type => :identifier},
412
- 'Sigma' => {:value => '&#x03a3;', :type => :operator},
413
- 'tau' => {:value => '&#x03c4;', :type => :identifier},
414
- 'Tau' => {:value => '&#x03a4;', :type => :identifier},
415
- 'upsilon' => {:value => '&#x03c5;', :type => :identifier},
416
- 'Upsilon' => {:value => '&#x03a5;', :type => :identifier},
417
- 'phi' => {:value => '&#x03c6;', :type => :identifier},
418
- 'Phi' => {:value => '&#x03a6;', :type => :identifier},
419
- 'varphi' => {:value => '&#x03d5;', :type => :identifier},
406
+ 'alpha' => {:value => "\u03b1", :type => :identifier},
407
+ 'Alpha' => {:value => "\u0391", :type => :identifier},
408
+ 'beta' => {:value => "\u03b2", :type => :identifier},
409
+ 'Beta' => {:value => "\u0392", :type => :identifier},
410
+ 'gamma' => {:value => "\u03b3", :type => :identifier},
411
+ 'Gamma' => {:value => "\u0393", :type => :operator},
412
+ 'delta' => {:value => "\u03b4", :type => :identifier},
413
+ 'Delta' => {:value => "\u0394", :type => :operator},
414
+ 'epsilon' => {:value => "\u03b5", :type => :identifier},
415
+ 'Epsilon' => {:value => "\u0395", :type => :identifier},
416
+ 'varepsilon' => {:value => "\u025b", :type => :identifier},
417
+ 'zeta' => {:value => "\u03b6", :type => :identifier},
418
+ 'Zeta' => {:value => "\u0396", :type => :identifier},
419
+ 'eta' => {:value => "\u03b7", :type => :identifier},
420
+ 'Eta' => {:value => "\u0397", :type => :identifier},
421
+ 'theta' => {:value => "\u03b8", :type => :identifier},
422
+ 'Theta' => {:value => "\u0398", :type => :operator},
423
+ 'vartheta' => {:value => "\u03d1", :type => :identifier},
424
+ 'iota' => {:value => "\u03b9", :type => :identifier},
425
+ 'Iota' => {:value => "\u0399", :type => :identifier},
426
+ 'kappa' => {:value => "\u03ba", :type => :identifier},
427
+ 'Kappa' => {:value => "\u039a", :type => :identifier},
428
+ 'lambda' => {:value => "\u03bb", :type => :identifier},
429
+ 'Lambda' => {:value => "\u039b", :type => :operator},
430
+ 'mu' => {:value => "\u03bc", :type => :identifier},
431
+ 'Mu' => {:value => "\u039c", :type => :identifier},
432
+ 'nu' => {:value => "\u03bd", :type => :identifier},
433
+ 'Nu' => {:value => "\u039d", :type => :identifier},
434
+ 'xi' => {:value => "\u03be", :type => :identifier},
435
+ 'Xi' => {:value => "\u039e", :type => :operator},
436
+ 'omicron' => {:value => "\u03bf", :type => :identifier},
437
+ 'Omicron' => {:value => "\u039f", :type => :identifier},
438
+ 'pi' => {:value => "\u03c0", :type => :identifier},
439
+ 'Pi' => {:value => "\u03a0", :type => :operator},
440
+ 'rho' => {:value => "\u03c1", :type => :identifier},
441
+ 'Rho' => {:value => "\u03a1", :type => :identifier},
442
+ 'sigma' => {:value => "\u03c3", :type => :identifier},
443
+ 'Sigma' => {:value => "\u03a3", :type => :operator},
444
+ 'tau' => {:value => "\u03c4", :type => :identifier},
445
+ 'Tau' => {:value => "\u03a4", :type => :identifier},
446
+ 'upsilon' => {:value => "\u03c5", :type => :identifier},
447
+ 'Upsilon' => {:value => "\u03a5", :type => :identifier},
448
+ 'phi' => {:value => "\u03c6", :type => :identifier},
449
+ 'Phi' => {:value => "\u03a6", :type => :identifier},
450
+ 'varphi' => {:value => "\u03d5", :type => :identifier},
420
451
  'chi' => {:value => '\u03b3c7', :type => :identifier},
421
452
  'Chi' => {:value => '\u0393a7', :type => :identifier},
422
- 'psi' => {:value => '&#x03c8;', :type => :identifier},
423
- 'Psi' => {:value => '&#x03a8;', :type => :identifier},
424
- 'omega' => {:value => '&#x03c9;', :type => :identifier},
425
- 'Omega' => {:value => '&#x03a9;', :type => :operator},
453
+ 'psi' => {:value => "\u03c8", :type => :identifier},
454
+ 'Psi' => {:value => "\u03a8", :type => :identifier},
455
+ 'omega' => {:value => "\u03c9", :type => :identifier},
456
+ 'Omega' => {:value => "\u03a9", :type => :operator},
426
457
  }
427
458
 
428
459
  def parse(input)
@@ -1,3 +1,3 @@
1
1
  module AsciiMath
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
@@ -5,33 +5,33 @@ require 'asciimath'
5
5
  TEST_CASES = {
6
6
  'x+b/(2a)<+-sqrt((b^2)/(4a^2)-c/a)' =>
7
7
  {
8
- :mathml => '<math><mi>x</mi><mo>+</mo><mfrac><mi>b</mi><mrow><mn>2</mn><mi>a</mi></mrow></mfrac><mo>&#x003C;</mo><mo>&#x00B1;</mo><msqrt><mrow><mfrac><msup><mi>b</mi><mn>2</mn></msup><mrow><mn>4</mn><msup><mi>a</mi><mn>2</mn></msup></mrow></mfrac><mo>&#x2212;</mo><mfrac><mi>c</mi><mi>a</mi></mfrac></mrow></msqrt></math>',
9
- :html => 'Unsupported',
8
+ :mathml => '<math><mi>x</mi><mo>+</mo><mfrac><mi>b</mi><mrow><mn>2</mn><mi>a</mi></mrow></mfrac><mo>&lt;</mo><mo>&#xB1;</mo><msqrt><mrow><mfrac><msup><mi>b</mi><mn>2</mn></msup><mrow><mn>4</mn><msup><mi>a</mi><mn>2</mn></msup></mrow></mfrac><mo>&#x2212;</mo><mfrac><mi>c</mi><mi>a</mi></mfrac></mrow></msqrt></math>',
9
+ :html => nil,
10
10
  },
11
11
  'a^2 + b^2 = c^2' =>
12
12
  {
13
13
  :mathml => '<math><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>=</mo><msup><mi>c</mi><mn>2</mn></msup></math>',
14
- :html => '<span class="math-inline"><span class="math-row"><span class="math-identifier">a</span><span class="math-subsup"><span class="math-smaller"><span class="math-number">2</span></span><span class="math-smaller">&zwj;</span></span><span class="math-operator">+</span><span class="math-identifier">b</span><span class="math-subsup"><span class="math-smaller"><span class="math-number">2</span></span><span class="math-smaller">&zwj;</span></span><span class="math-operator">=</span><span class="math-identifier">c</span><span class="math-subsup"><span class="math-smaller"><span class="math-number">2</span></span><span class="math-smaller">&zwj;</span></span></span></span>',
14
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-identifier">a</span><span class="math-subsup"><span class="math-smaller"><span class="math-number">2</span></span><span class="math-smaller">&#x8205;</span></span><span class="math-operator">+</span><span class="math-identifier">b</span><span class="math-subsup"><span class="math-smaller"><span class="math-number">2</span></span><span class="math-smaller">&#x8205;</span></span><span class="math-operator">=</span><span class="math-identifier">c</span><span class="math-subsup"><span class="math-smaller"><span class="math-number">2</span></span><span class="math-smaller">&#x8205;</span></span></span></span>',
15
15
  },
16
16
  'x = (-b+-sqrt(b^2-4ac))/(2a)' =>
17
17
  {
18
- :mathml => '<math><mi>x</mi><mo>=</mo><mfrac><mrow><mo>&#x2212;</mo><mi>b</mi><mo>&#x00B1;</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mn>-4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></math>',
19
- :html => 'Unsupported'
18
+ :mathml => '<math><mi>x</mi><mo>=</mo><mfrac><mrow><mo>&#x2212;</mo><mi>b</mi><mo>&#xB1;</mo><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mn>-4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></math>',
19
+ :html => nil
20
20
  },
21
21
  'm = (y_2 - y_1)/(x_2 - x_1) = (Deltay)/(Deltax)' =>
22
22
  {
23
- :mathml => '<math><mi>m</mi><mo>=</mo><mfrac><mrow><msub><mi>y</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>y</mi><mn>1</mn></msub></mrow><mrow><msub><mi>x</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>x</mi><mn>1</mn></msub></mrow></mfrac><mo>=</mo><mfrac><mrow><mo>&#x0394;</mo><mi>y</mi></mrow><mrow><mo>&#x0394;</mo><mi>x</mi></mrow></mfrac></math>',
24
- :html => '<span class="math-inline"><span class="math-row"><span class="math-identifier">m</span><span class="math-operator">=</span><span class="math-blank">&zwj;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">y</span><span class="math-subsup"><span class="math-smaller">&zwj;</span><span class="math-smaller"><span class="math-number">2</span></span></span><span class="math-operator">&#x2212;</span><span class="math-identifier">y</span><span class="math-subsup"><span class="math-smaller">&zwj;</span><span class="math-smaller"><span class="math-number">1</span></span></span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">x</span><span class="math-subsup"><span class="math-smaller">&zwj;</span><span class="math-smaller"><span class="math-number">2</span></span></span><span class="math-operator">&#x2212;</span><span class="math-identifier">x</span><span class="math-subsup"><span class="math-smaller">&zwj;</span><span class="math-smaller"><span class="math-number">1</span></span></span></span></span></span></span></span></span><span class="math-operator">=</span><span class="math-blank">&zwj;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-operator">&#x0394;</span><span class="math-identifier">y</span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-operator">&#x0394;</span><span class="math-identifier">x</span></span></span></span></span></span></span></span></span>'
23
+ :mathml => '<math><mi>m</mi><mo>=</mo><mfrac><mrow><msub><mi>y</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>y</mi><mn>1</mn></msub></mrow><mrow><msub><mi>x</mi><mn>2</mn></msub><mo>&#x2212;</mo><msub><mi>x</mi><mn>1</mn></msub></mrow></mfrac><mo>=</mo><mfrac><mrow><mo>&#x394;</mo><mi>y</mi></mrow><mrow><mo>&#x394;</mo><mi>x</mi></mrow></mfrac></math>',
24
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-identifier">m</span><span class="math-operator">=</span><span class="math-blank">&#x8205;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">y</span><span class="math-subsup"><span class="math-smaller">&#x8205;</span><span class="math-smaller"><span class="math-number">2</span></span></span><span class="math-operator">&#x2212;</span><span class="math-identifier">y</span><span class="math-subsup"><span class="math-smaller">&#x8205;</span><span class="math-smaller"><span class="math-number">1</span></span></span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">x</span><span class="math-subsup"><span class="math-smaller">&#x8205;</span><span class="math-smaller"><span class="math-number">2</span></span></span><span class="math-operator">&#x2212;</span><span class="math-identifier">x</span><span class="math-subsup"><span class="math-smaller">&#x8205;</span><span class="math-smaller"><span class="math-number">1</span></span></span></span></span></span></span></span></span><span class="math-operator">=</span><span class="math-blank">&#x8205;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-operator">&#x394;</span><span class="math-identifier">y</span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-operator">&#x394;</span><span class="math-identifier">x</span></span></span></span></span></span></span></span></span>'
25
25
  },
26
26
  'f\'(x) = lim_(Deltax->0)(f(x+Deltax)-f(x))/(Deltax)' =>
27
27
  {
28
- :mathml => '<math><mi>f</mi><mi>\'</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mo>=</mo><munder><mo>lim</mo><mrow><mo>&#x0394;</mo><mi>x</mi><mo>&#x2192;</mo><mn>0</mn></mrow></munder><mfrac><mrow><mi>f</mi><mrow><mo>(</mo><mi>x</mi><mo>+</mo><mo>&#x0394;</mo><mi>x</mi><mo>)</mo></mrow><mo>&#x2212;</mo><mi>f</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow><mrow><mo>&#x0394;</mo><mi>x</mi></mrow></mfrac></math>',
29
- :html => '<span class="math-inline"><span class="math-row"><span class="math-identifier">f</span><span class="math-identifier">\'</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span></span><span class="math-brace">)</span></span><span class="math-operator">=</span><span class="math-blank">&zwj;</span><span class="math-underover"><span class="math-smaller"><span class="math-blank">&zwj;</span></span><span class="math-operator">lim</span><span class="math-smaller"><span class="math-row"><span class="math-operator">&#x0394;</span><span class="math-identifier">x</span><span class="math-operator">&#x2192;</span><span class="math-number">0</span></span></span></span><span class="math-blank">&zwj;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span><span class="math-operator">+</span><span class="math-operator">&#x0394;</span><span class="math-identifier">x</span></span><span class="math-brace">)</span></span><span class="math-operator">&#x2212;</span><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span></span><span class="math-brace">)</span></span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-operator">&#x0394;</span><span class="math-identifier">x</span></span></span></span></span></span></span></span></span>'
28
+ :mathml => '<math><mi>f</mi><mi>\'</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mo>=</mo><munder><mo>lim</mo><mrow><mo>&#x394;</mo><mi>x</mi><mo>&#x2192;</mo><mn>0</mn></mrow></munder><mfrac><mrow><mi>f</mi><mrow><mo>(</mo><mi>x</mi><mo>+</mo><mo>&#x394;</mo><mi>x</mi><mo>)</mo></mrow><mo>&#x2212;</mo><mi>f</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mrow><mrow><mo>&#x394;</mo><mi>x</mi></mrow></mfrac></math>',
29
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-identifier">f</span><span class="math-identifier">\'</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span></span><span class="math-brace">)</span></span><span class="math-operator">=</span><span class="math-blank">&#x8205;</span><span class="math-underover"><span class="math-smaller"><span class="math-blank">&#x8205;</span></span><span class="math-operator">lim</span><span class="math-smaller"><span class="math-row"><span class="math-operator">&#x394;</span><span class="math-identifier">x</span><span class="math-operator">&#x2192;</span><span class="math-number">0</span></span></span></span><span class="math-blank">&#x8205;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span><span class="math-operator">+</span><span class="math-operator">&#x394;</span><span class="math-identifier">x</span></span><span class="math-brace">)</span></span><span class="math-operator">&#x2212;</span><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span></span><span class="math-brace">)</span></span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-operator">&#x394;</span><span class="math-identifier">x</span></span></span></span></span></span></span></span></span>'
30
30
  },
31
31
  'd/dx [x^n] = nx^(n - 1)' =>
32
32
  {
33
33
  :mathml => '<math><mfrac><mi>d</mi><mi>dx</mi></mfrac><mrow><mo>[</mo><msup><mi>x</mi><mi>n</mi></msup><mo>]</mo></mrow><mo>=</mo><mi>n</mi><msup><mi>x</mi><mrow><mi>n</mi><mo>&#x2212;</mo><mn>1</mn></mrow></msup></math>',
34
- :html => '<span class="math-inline"><span class="math-row"><span class="math-blank">&zwj;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-identifier">d</span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-identifier">dx</span></span></span></span></span></span><span class="math-row"><span class="math-brace">[</span><span class="math-row"><span class="math-identifier">x</span><span class="math-subsup"><span class="math-smaller"><span class="math-identifier">n</span></span><span class="math-smaller">&zwj;</span></span></span><span class="math-brace">]</span></span><span class="math-operator">=</span><span class="math-identifier">n</span><span class="math-identifier">x</span><span class="math-subsup"><span class="math-smaller"><span class="math-row"><span class="math-identifier">n</span><span class="math-operator">&#x2212;</span><span class="math-number">1</span></span></span><span class="math-smaller">&zwj;</span></span></span></span>'
34
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-blank">&#x8205;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-identifier">d</span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-identifier">dx</span></span></span></span></span></span><span class="math-row"><span class="math-brace">[</span><span class="math-row"><span class="math-identifier">x</span><span class="math-subsup"><span class="math-smaller"><span class="math-identifier">n</span></span><span class="math-smaller">&#x8205;</span></span></span><span class="math-brace">]</span></span><span class="math-operator">=</span><span class="math-identifier">n</span><span class="math-identifier">x</span><span class="math-subsup"><span class="math-smaller"><span class="math-row"><span class="math-identifier">n</span><span class="math-operator">&#x2212;</span><span class="math-number">1</span></span></span><span class="math-smaller">&#x8205;</span></span></span></span>'
35
35
  },
36
36
  'int_a^b f(x) dx = [F(x)]_a^b = F(b) - F(a)' =>
37
37
  {
@@ -46,22 +46,22 @@ TEST_CASES = {
46
46
  'ax^2 + bx + c = 0' =>
47
47
  {
48
48
  :mathml => '<math><mi>a</mi><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mi>b</mi><mi>x</mi><mo>+</mo><mi>c</mi><mo>=</mo><mn>0</mn></math>',
49
- :html => '<span class="math-inline"><span class="math-row"><span class="math-identifier">a</span><span class="math-identifier">x</span><span class="math-subsup"><span class="math-smaller"><span class="math-number">2</span></span><span class="math-smaller">&zwj;</span></span><span class="math-operator">+</span><span class="math-identifier">b</span><span class="math-identifier">x</span><span class="math-operator">+</span><span class="math-identifier">c</span><span class="math-operator">=</span><span class="math-number">0</span></span></span>'
49
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-identifier">a</span><span class="math-identifier">x</span><span class="math-subsup"><span class="math-smaller"><span class="math-number">2</span></span><span class="math-smaller">&#x8205;</span></span><span class="math-operator">+</span><span class="math-identifier">b</span><span class="math-identifier">x</span><span class="math-operator">+</span><span class="math-identifier">c</span><span class="math-operator">=</span><span class="math-number">0</span></span></span>'
50
50
  },
51
51
  '"average value"=1/(b-a) int_a^b f(x) dx' =>
52
52
  {
53
53
  :mathml => '<math><mtext>average value</mtext><mo>=</mo><mfrac><mn>1</mn><mrow><mi>b</mi><mo>&#x2212;</mo><mi>a</mi></mrow></mfrac><msubsup><mo>&#x222B;</mo><mi>a</mi><mi>b</mi></msubsup><mi>f</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mi>dx</mi></math>',
54
- :html => '<span class="math-inline"><span class="math-row"><span class="math-text">average value</span><span class="math-operator">=</span><span class="math-blank">&zwj;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-number">1</span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">b</span><span class="math-operator">&#x2212;</span><span class="math-identifier">a</span></span></span></span></span></span></span><span class="math-operator">&#x222B;</span><span class="math-subsup"><span class="math-smaller"><span class="math-identifier">b</span></span><span class="math-smaller"><span class="math-identifier">a</span></span></span><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span></span><span class="math-brace">)</span></span><span class="math-identifier">dx</span></span></span>'
54
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-text">average value</span><span class="math-operator">=</span><span class="math-blank">&#x8205;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-number">1</span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">b</span><span class="math-operator">&#x2212;</span><span class="math-identifier">a</span></span></span></span></span></span></span><span class="math-operator">&#x222B;</span><span class="math-subsup"><span class="math-smaller"><span class="math-identifier">b</span></span><span class="math-smaller"><span class="math-identifier">a</span></span></span><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span></span><span class="math-brace">)</span></span><span class="math-identifier">dx</span></span></span>'
55
55
  },
56
56
  'd/dx[int_a^x f(t) dt] = f(x)' =>
57
57
  {
58
58
  :mathml => '<math><mfrac><mi>d</mi><mi>dx</mi></mfrac><mrow><mo>[</mo><msubsup><mo>&#x222B;</mo><mi>a</mi><mi>x</mi></msubsup><mi>f</mi><mrow><mo>(</mo><mi>t</mi><mo>)</mo></mrow><mi>dt</mi><mo>]</mo></mrow><mo>=</mo><mi>f</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow></math>',
59
- :html => '<span class="math-inline"><span class="math-row"><span class="math-blank">&zwj;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-identifier">d</span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-identifier">dx</span></span></span></span></span></span><span class="math-row"><span class="math-brace">[</span><span class="math-row"><span class="math-operator">&#x222B;</span><span class="math-subsup"><span class="math-smaller"><span class="math-identifier">x</span></span><span class="math-smaller"><span class="math-identifier">a</span></span></span><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">t</span></span><span class="math-brace">)</span></span><span class="math-identifier">dt</span></span><span class="math-brace">]</span></span><span class="math-operator">=</span><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span></span><span class="math-brace">)</span></span></span></span>'
59
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-blank">&#x8205;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-identifier">d</span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-identifier">dx</span></span></span></span></span></span><span class="math-row"><span class="math-brace">[</span><span class="math-row"><span class="math-operator">&#x222B;</span><span class="math-subsup"><span class="math-smaller"><span class="math-identifier">x</span></span><span class="math-smaller"><span class="math-identifier">a</span></span></span><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">t</span></span><span class="math-brace">)</span></span><span class="math-identifier">dt</span></span><span class="math-brace">]</span></span><span class="math-operator">=</span><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span></span><span class="math-brace">)</span></span></span></span>'
60
60
  },
61
61
  'hat(ab) bar(xy) ul(A) vec(v)' =>
62
62
  {
63
- :mathml => '<math><mover><mrow><mi>a</mi><mi>b</mi></mrow><mo>&#x005E;</mo></mover><mover><mrow><mi>x</mi><mi>y</mi></mrow><mo>&#x00AF;</mo></mover><munder><mi>A</mi><mo>_</mo></munder><mover><mi>v</mi><mo>&#x2192;</mo></mover></math>',
64
- :html => '<span class="math-inline"><span class="math-row"><span class="math-blank">&zwj;</span><span class="math-underover"><span class="math-smaller"><span class="math-operator">&#x005E;</span></span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">a</span><span class="math-identifier">b</span></span><span class="math-brace">)</span></span><span class="math-smaller"><span class="math-blank">&zwj;</span></span></span><span class="math-blank">&zwj;</span><span class="math-underover"><span class="math-smaller"><span class="math-operator">&#x00AF;</span></span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span><span class="math-identifier">y</span></span><span class="math-brace">)</span></span><span class="math-smaller"><span class="math-blank">&zwj;</span></span></span><span class="math-blank">&zwj;</span><span class="math-underover"><span class="math-smaller"><span class="math-blank">&zwj;</span></span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">A</span></span><span class="math-brace">)</span></span><span class="math-smaller"><span class="math-operator">_</span></span></span><span class="math-blank">&zwj;</span><span class="math-underover"><span class="math-smaller"><span class="math-operator">&#x2192;</span></span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">v</span></span><span class="math-brace">)</span></span><span class="math-smaller"><span class="math-blank">&zwj;</span></span></span></span></span>'
63
+ :mathml => '<math><mover><mrow><mi>a</mi><mi>b</mi></mrow><mo>^</mo></mover><mover><mrow><mi>x</mi><mi>y</mi></mrow><mo>&#xAF;</mo></mover><munder><mi>A</mi><mo>_</mo></munder><mover><mi>v</mi><mo>&#x2192;</mo></mover></math>',
64
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-blank">&#x8205;</span><span class="math-underover"><span class="math-smaller"><span class="math-operator">^</span></span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">a</span><span class="math-identifier">b</span></span><span class="math-brace">)</span></span><span class="math-smaller"><span class="math-blank">&#x8205;</span></span></span><span class="math-blank">&#x8205;</span><span class="math-underover"><span class="math-smaller"><span class="math-operator">&#xAF;</span></span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span><span class="math-identifier">y</span></span><span class="math-brace">)</span></span><span class="math-smaller"><span class="math-blank">&#x8205;</span></span></span><span class="math-blank">&#x8205;</span><span class="math-underover"><span class="math-smaller"><span class="math-blank">&#x8205;</span></span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">A</span></span><span class="math-brace">)</span></span><span class="math-smaller"><span class="math-operator">_</span></span></span><span class="math-blank">&#x8205;</span><span class="math-underover"><span class="math-smaller"><span class="math-operator">&#x2192;</span></span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">v</span></span><span class="math-brace">)</span></span><span class="math-smaller"><span class="math-blank">&#x8205;</span></span></span></span></span>'
65
65
  },
66
66
  'z_12^34' =>
67
67
  {
@@ -71,17 +71,17 @@ TEST_CASES = {
71
71
  'lim_(x->c)(f(x)-f(c))/(x-c)' =>
72
72
  {
73
73
  :mathml => '<math><munder><mo>lim</mo><mrow><mi>x</mi><mo>&#x2192;</mo><mi>c</mi></mrow></munder><mfrac><mrow><mi>f</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mo>&#x2212;</mo><mi>f</mi><mrow><mo>(</mo><mi>c</mi><mo>)</mo></mrow></mrow><mrow><mi>x</mi><mo>&#x2212;</mo><mi>c</mi></mrow></mfrac></math>',
74
- :html => '<span class="math-inline"><span class="math-row"><span class="math-blank">&zwj;</span><span class="math-underover"><span class="math-smaller"><span class="math-blank">&zwj;</span></span><span class="math-operator">lim</span><span class="math-smaller"><span class="math-row"><span class="math-identifier">x</span><span class="math-operator">&#x2192;</span><span class="math-identifier">c</span></span></span></span><span class="math-blank">&zwj;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span></span><span class="math-brace">)</span></span><span class="math-operator">&#x2212;</span><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">c</span></span><span class="math-brace">)</span></span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">x</span><span class="math-operator">&#x2212;</span><span class="math-identifier">c</span></span></span></span></span></span></span></span></span>'
74
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-blank">&#x8205;</span><span class="math-underover"><span class="math-smaller"><span class="math-blank">&#x8205;</span></span><span class="math-operator">lim</span><span class="math-smaller"><span class="math-row"><span class="math-identifier">x</span><span class="math-operator">&#x2192;</span><span class="math-identifier">c</span></span></span></span><span class="math-blank">&#x8205;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span></span><span class="math-brace">)</span></span><span class="math-operator">&#x2212;</span><span class="math-identifier">f</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">c</span></span><span class="math-brace">)</span></span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">x</span><span class="math-operator">&#x2212;</span><span class="math-identifier">c</span></span></span></span></span></span></span></span></span>'
75
75
  },
76
76
  'int_0^(pi/2) g(x) dx' =>
77
77
  {
78
- :mathml => '<math><msubsup><mo>&#x222B;</mo><mn>0</mn><mfrac><mi>&#x03c0;</mi><mn>2</mn></mfrac></msubsup><mi>g</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mi>dx</mi></math>',
79
- :html => '<span class="math-inline"><span class="math-row"><span class="math-operator">&#x222B;</span><span class="math-subsup"><span class="math-smaller"><span class="math-row"><span class="math-blank">&zwj;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-identifier">&#x03c0;</span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-number">2</span></span></span></span></span></span></span></span><span class="math-smaller"><span class="math-number">0</span></span></span><span class="math-identifier">g</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span></span><span class="math-brace">)</span></span><span class="math-identifier">dx</span></span></span>'
78
+ :mathml => '<math><msubsup><mo>&#x222B;</mo><mn>0</mn><mfrac><mi>&#x3C0;</mi><mn>2</mn></mfrac></msubsup><mi>g</mi><mrow><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mi>dx</mi></math>',
79
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-operator">&#x222B;</span><span class="math-subsup"><span class="math-smaller"><span class="math-row"><span class="math-blank">&#x8205;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-identifier">&#x3C0;</span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-number">2</span></span></span></span></span></span></span></span><span class="math-smaller"><span class="math-number">0</span></span></span><span class="math-identifier">g</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">x</span></span><span class="math-brace">)</span></span><span class="math-identifier">dx</span></span></span>'
80
80
  },
81
81
  'sum_(n=0)^oo a_n' =>
82
82
  {
83
83
  :mathml => '<math><munderover><mo>&#x2211;</mo><mrow><mi>n</mi><mo>=</mo><mn>0</mn></mrow><mo>&#x221E;</mo></munderover><msub><mi>a</mi><mi>n</mi></msub></math>',
84
- :html => '<span class="math-inline"><span class="math-row"><span class="math-blank">&zwj;</span><span class="math-underover"><span class="math-smaller"><span class="math-operator">&#x221E;</span></span><span class="math-operator">&#x2211;</span><span class="math-smaller"><span class="math-row"><span class="math-identifier">n</span><span class="math-operator">=</span><span class="math-number">0</span></span></span></span><span class="math-identifier">a</span><span class="math-subsup"><span class="math-smaller">&zwj;</span><span class="math-smaller"><span class="math-identifier">n</span></span></span></span></span>'
84
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-blank">&#x8205;</span><span class="math-underover"><span class="math-smaller"><span class="math-operator">&#x221E;</span></span><span class="math-operator">&#x2211;</span><span class="math-smaller"><span class="math-row"><span class="math-identifier">n</span><span class="math-operator">=</span><span class="math-number">0</span></span></span></span><span class="math-identifier">a</span><span class="math-subsup"><span class="math-smaller">&#x8205;</span><span class="math-smaller"><span class="math-identifier">n</span></span></span></span></span>'
85
85
  },
86
86
  '((1,2,3),(4,5,6),(7,8,9))' =>
87
87
  {
@@ -96,27 +96,34 @@ TEST_CASES = {
96
96
  '((a_(11), cdots , a_(1n)),(vdots, ddots, vdots),(a_(m1), cdots , a_(mn)))' =>
97
97
  {
98
98
  :mathml => '<math><mrow><mo>(</mo><mtable><mtr><mtd><msub><mi>a</mi><mn>11</mn></msub></mtd><mtd><mo>&#x22EF;</mo></mtd><mtd><msub><mi>a</mi><mrow><mn>1</mn><mi>n</mi></mrow></msub></mtd></mtr><mtr><mtd><mo>&#x22EE;</mo></mtd><mtd><mo>&#x22F1;</mo></mtd><mtd><mo>&#x22EE;</mo></mtd></mtr><mtr><mtd><msub><mi>a</mi><mrow><mi>m</mi><mn>1</mn></mrow></msub></mtd><mtd><mo>&#x22EF;</mo></mtd><mtd><msub><mi>a</mi><mrow><mi>m</mi><mi>n</mi></mrow></msub></mtd></mtr></mtable><mo>)</mo></mrow></math>',
99
- :html => '<span class="math-inline"><span class="math-row"><span class="math-row"><span class="math-brace" style="font-size: 300%;">(</span><span class="math-matrix" style="grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(3,1fr);"><span class="math-row"><span class="math-identifier">a</span><span class="math-subsup"><span class="math-smaller">&zwj;</span><span class="math-smaller"><span class="math-row"><span class="math-number">11</span></span></span></span></span><span class="math-row"><span class="math-operator">&#x22EF;</span></span><span class="math-row"><span class="math-identifier">a</span><span class="math-subsup"><span class="math-smaller">&zwj;</span><span class="math-smaller"><span class="math-row"><span class="math-number">1</span><span class="math-identifier">n</span></span></span></span></span><span class="math-row"><span class="math-operator">&#x22EE;</span></span><span class="math-row"><span class="math-operator">&#x22F1;</span></span><span class="math-row"><span class="math-operator">&#x22EE;</span></span><span class="math-row"><span class="math-identifier">a</span><span class="math-subsup"><span class="math-smaller">&zwj;</span><span class="math-smaller"><span class="math-row"><span class="math-identifier">m</span><span class="math-number">1</span></span></span></span></span><span class="math-row"><span class="math-operator">&#x22EF;</span></span><span class="math-row"><span class="math-identifier">a</span><span class="math-subsup"><span class="math-smaller">&zwj;</span><span class="math-smaller"><span class="math-row"><span class="math-identifier">m</span><span class="math-identifier">n</span></span></span></span></span></span><span class="math-brace" style="font-size: 300%;">)</span></span></span></span>'
99
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-row"><span class="math-brace" style="font-size: 300%;">(</span><span class="math-matrix" style="grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(3,1fr);"><span class="math-row"><span class="math-identifier">a</span><span class="math-subsup"><span class="math-smaller">&#x8205;</span><span class="math-smaller"><span class="math-row"><span class="math-number">11</span></span></span></span></span><span class="math-row"><span class="math-operator">&#x22EF;</span></span><span class="math-row"><span class="math-identifier">a</span><span class="math-subsup"><span class="math-smaller">&#x8205;</span><span class="math-smaller"><span class="math-row"><span class="math-number">1</span><span class="math-identifier">n</span></span></span></span></span><span class="math-row"><span class="math-operator">&#x22EE;</span></span><span class="math-row"><span class="math-operator">&#x22F1;</span></span><span class="math-row"><span class="math-operator">&#x22EE;</span></span><span class="math-row"><span class="math-identifier">a</span><span class="math-subsup"><span class="math-smaller">&#x8205;</span><span class="math-smaller"><span class="math-row"><span class="math-identifier">m</span><span class="math-number">1</span></span></span></span></span><span class="math-row"><span class="math-operator">&#x22EF;</span></span><span class="math-row"><span class="math-identifier">a</span><span class="math-subsup"><span class="math-smaller">&#x8205;</span><span class="math-smaller"><span class="math-row"><span class="math-identifier">m</span><span class="math-identifier">n</span></span></span></span></span></span><span class="math-brace" style="font-size: 300%;">)</span></span></span></span>'
100
100
  },
101
101
  'sum_(k=1)^n k = 1+2+ cdots +n=(n(n+1))/2' =>
102
102
  {
103
103
  :mathml => '<math><munderover><mo>&#x2211;</mo><mrow><mi>k</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></munderover><mi>k</mi><mo>=</mo><mn>1</mn><mo>+</mo><mn>2</mn><mo>+</mo><mo>&#x22EF;</mo><mo>+</mo><mi>n</mi><mo>=</mo><mfrac><mrow><mi>n</mi><mrow><mo>(</mo><mi>n</mi><mo>+</mo><mn>1</mn><mo>)</mo></mrow></mrow><mn>2</mn></mfrac></math>',
104
- :html => '<span class="math-inline"><span class="math-row"><span class="math-blank">&zwj;</span><span class="math-underover"><span class="math-smaller"><span class="math-identifier">n</span></span><span class="math-operator">&#x2211;</span><span class="math-smaller"><span class="math-row"><span class="math-identifier">k</span><span class="math-operator">=</span><span class="math-number">1</span></span></span></span><span class="math-identifier">k</span><span class="math-operator">=</span><span class="math-number">1</span><span class="math-operator">+</span><span class="math-number">2</span><span class="math-operator">+</span><span class="math-operator">&#x22EF;</span><span class="math-operator">+</span><span class="math-identifier">n</span><span class="math-operator">=</span><span class="math-blank">&zwj;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">n</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">n</span><span class="math-operator">+</span><span class="math-number">1</span></span><span class="math-brace">)</span></span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-number">2</span></span></span></span></span></span></span></span>'
104
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-blank">&#x8205;</span><span class="math-underover"><span class="math-smaller"><span class="math-identifier">n</span></span><span class="math-operator">&#x2211;</span><span class="math-smaller"><span class="math-row"><span class="math-identifier">k</span><span class="math-operator">=</span><span class="math-number">1</span></span></span></span><span class="math-identifier">k</span><span class="math-operator">=</span><span class="math-number">1</span><span class="math-operator">+</span><span class="math-number">2</span><span class="math-operator">+</span><span class="math-operator">&#x22EF;</span><span class="math-operator">+</span><span class="math-identifier">n</span><span class="math-operator">=</span><span class="math-blank">&#x8205;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">n</span><span class="math-row"><span class="math-brace">(</span><span class="math-row"><span class="math-identifier">n</span><span class="math-operator">+</span><span class="math-number">1</span></span><span class="math-brace">)</span></span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-number">2</span></span></span></span></span></span></span></span>'
105
105
  },
106
106
  '"Скорость"=("Расстояние")/("Время")' =>
107
107
  {
108
- :mathml => '<math><mtext>Скорость</mtext><mo>=</mo><mfrac><mtext>Расстояние</mtext><mtext>Время</mtext></mfrac></math>',
109
- :html => '<span class="math-inline"><span class="math-row"><span class="math-text">Скорость</span><span class="math-operator">=</span><span class="math-blank">&zwj;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-text">Расстояние</span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-text">Время</span></span></span></span></span></span></span></span></span>'
108
+ :mathml => '<math><mtext>&#x421;&#x43A;&#x43E;&#x440;&#x43E;&#x441;&#x442;&#x44C;</mtext><mo>=</mo><mfrac><mtext>&#x420;&#x430;&#x441;&#x441;&#x442;&#x43E;&#x44F;&#x43D;&#x438;&#x435;</mtext><mtext>&#x412;&#x440;&#x435;&#x43C;&#x44F;</mtext></mfrac></math>',
109
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-text">&#x421;&#x43A;&#x43E;&#x440;&#x43E;&#x441;&#x442;&#x44C;</span><span class="math-operator">=</span><span class="math-blank">&#x8205;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-text">&#x420;&#x430;&#x441;&#x441;&#x442;&#x43E;&#x44F;&#x43D;&#x438;&#x435;</span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-text">&#x412;&#x440;&#x435;&#x43C;&#x44F;</span></span></span></span></span></span></span></span></span>'
110
110
  },
111
111
  'bb (a + b) + cc c = fr (d^n)' =>
112
112
  {
113
113
  :mathml => '<math><mstyle mathvariant="bold"><mrow><mi>a</mi><mo>+</mo><mi>b</mi></mrow></mstyle><mo>+</mo><mstyle mathvariant="script"><mi>c</mi></mstyle><mo>=</mo><mstyle mathvariant="fraktur"><msup><mi>d</mi><mi>n</mi></msup></mstyle></math>',
114
- :html => 'Unsupported'
114
+ :html => nil
115
115
  },
116
116
  'max()' =>
117
117
  {
118
- :mathml => '<math><mo>max</mo><mrow><mo>(</mo><mo>)</mo></mrow></math>',
119
- :html => '<span class="math-inline"><span class="math-row"><span class="math-operator">max</span><span class="math-row"><span class="math-brace">(</span><span class="math-brace">)</span></span></span></span>'
118
+ :mathml => '<math><mi>max</mi><mrow><mo>(</mo><mo>)</mo></mrow></math>',
119
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-identifier">max</span><span class="math-row"><span class="math-brace">(</span><span class="math-brace">)</span></span></span></span>'
120
+ },
121
+ 'text("foo")' => {
122
+ :mathml => '<math><mtext>"foo"</mtext></math>',
123
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-text">"foo"</span></span></span>'
124
+ },
125
+ 'ubrace(1 + 2) obrace(3 + 4' => {
126
+ :mathml => '<math><munder><mrow><mn>1</mn><mo>+</mo><mn>2</mn></mrow><mo>&#x23DF;</mo></munder><mover><mrow><mn>3</mn><mo>+</mo><mn>4</mn></mrow><mo>&#x23DE;</mo></mover></math>'
120
127
  }
121
128
  }
122
129
 
@@ -125,9 +132,9 @@ version = RUBY_VERSION.split('.').map { |s| s.to_i }
125
132
  if version[0] > 1 || version[1] > 8
126
133
  TEST_CASES['Скорость=(Расстояние)/(Время)'] =
127
134
  {
128
- :mathml => '<math><mi>С</mi><mi>к</mi><mi>о</mi><mi>р</mi><mi>о</mi><mi>с</mi><mi>т</mi><mi>ь</mi><mo>=</mo><mfrac><mrow><mi>Р</mi><mi>а</mi><mi>с</mi><mi>с</mi><mi>т</mi><mi>о</mi><mi>я</mi><mi>н</mi><mi>и</mi><mi>е</mi></mrow><mrow><mi>В</mi><mi>р</mi><mi>е</mi><mi>м</mi><mi>я</mi></mrow></mfrac></math>',
129
- :html => '<span class="math-inline"><span class="math-row"><span class="math-identifier">С</span><span class="math-identifier">к</span><span class="math-identifier">о</span><span class="math-identifier">р</span><span class="math-identifier">о</span><span class="math-identifier">с</span><span class="math-identifier">т</span><span class="math-identifier">ь</span><span class="math-operator">=</span><span class="math-blank">&zwj;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">Р</span><span class="math-identifier">а</span><span class="math-identifier">с</span><span class="math-identifier">с</span><span class="math-identifier">т</span><span class="math-identifier">о</span><span class="math-identifier">я</span><span class="math-identifier">н</span><span class="math-identifier">и</span><span class="math-identifier">е</span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">В</span><span class="math-identifier">р</span><span class="math-identifier">е</span><span class="math-identifier">м</span><span class="math-identifier">я</span></span></span></span></span></span></span></span></span>'
130
- }
135
+ :mathml => '<math><mi>&#x421;</mi><mi>&#x43A;</mi><mi>&#x43E;</mi><mi>&#x440;</mi><mi>&#x43E;</mi><mi>&#x441;</mi><mi>&#x442;</mi><mi>&#x44C;</mi><mo>=</mo><mfrac><mrow><mi>&#x420;</mi><mi>&#x430;</mi><mi>&#x441;</mi><mi>&#x441;</mi><mi>&#x442;</mi><mi>&#x43E;</mi><mi>&#x44F;</mi><mi>&#x43D;</mi><mi>&#x438;</mi><mi>&#x435;</mi></mrow><mrow><mi>&#x412;</mi><mi>&#x440;</mi><mi>&#x435;</mi><mi>&#x43C;</mi><mi>&#x44F;</mi></mrow></mfrac></math>',
136
+ :html => '<span class="math-inline"><span class="math-row"><span class="math-identifier">&#x421;</span><span class="math-identifier">&#x43A;</span><span class="math-identifier">&#x43E;</span><span class="math-identifier">&#x440;</span><span class="math-identifier">&#x43E;</span><span class="math-identifier">&#x441;</span><span class="math-identifier">&#x442;</span><span class="math-identifier">&#x44C;</span><span class="math-operator">=</span><span class="math-blank">&#x8205;</span><span class="math-fraction"><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">&#x420;</span><span class="math-identifier">&#x430;</span><span class="math-identifier">&#x441;</span><span class="math-identifier">&#x441;</span><span class="math-identifier">&#x442;</span><span class="math-identifier">&#x43E;</span><span class="math-identifier">&#x44F;</span><span class="math-identifier">&#x43D;</span><span class="math-identifier">&#x438;</span><span class="math-identifier">&#x435;</span></span></span></span></span></span><span class="math-fraction_row"><span class="math-fraction_cell"><span class="math-smaller"><span class="math-row"><span class="math-row"><span class="math-identifier">&#x412;</span><span class="math-identifier">&#x440;</span><span class="math-identifier">&#x435;</span><span class="math-identifier">&#x43C;</span><span class="math-identifier">&#x44F;</span></span></span></span></span></span></span></span></span>'
137
+ }
131
138
  end
132
139
 
133
140
  module AsciiMathHelper
@@ -149,7 +156,7 @@ describe "AsciiMath::MathMLBuilder" do
149
156
  it "should produce identical output to asciimathml.js for '#{asciimath}'" do
150
157
  expect_mathml(asciimath, output[:mathml])
151
158
  end
152
- if output[:html] != "Unsupported"
159
+ if output[:html]
153
160
  it "should produce html that looks like the output from asciimathml.js for '#{asciimath}'" do
154
161
  expect_html(asciimath, output[:html])
155
162
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciimath
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pepijn Van Eeckhoudt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-23 00:00:00.000000000 Z
11
+ date: 2019-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  requirements: []
99
99
  rubyforge_project:
100
- rubygems_version: 2.5.1
100
+ rubygems_version: 2.7.6
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: AsciiMath parser and converter