@umoteam/editor-external 9.0.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.js +3 -3
- package/edgeone.json +4 -0
- package/libs/katex/README.md +3 -3
- package/libs/katex/contrib/auto-render.js +29 -65
- package/libs/katex/contrib/auto-render.min.js +1 -1
- package/libs/katex/contrib/auto-render.mjs +34 -68
- package/libs/katex/contrib/copy-tex.js +23 -37
- package/libs/katex/contrib/copy-tex.min.js +1 -1
- package/libs/katex/contrib/copy-tex.mjs +20 -40
- package/libs/katex/contrib/mathtex-script-type.js +4 -10
- package/libs/katex/contrib/mathtex-script-type.min.js +1 -1
- package/libs/katex/contrib/mathtex-script-type.mjs +0 -3
- package/libs/katex/contrib/mhchem.js +59 -310
- package/libs/katex/contrib/mhchem.min.js +1 -1
- package/libs/katex/contrib/mhchem.mjs +62 -307
- package/libs/katex/contrib/render-a11y-string.js +17 -119
- package/libs/katex/contrib/render-a11y-string.min.js +1 -1
- package/libs/katex/contrib/render-a11y-string.mjs +55 -157
- package/libs/katex/katex-swap.css +1237 -0
- package/libs/katex/katex-swap.min.css +1 -0
- package/libs/katex/katex.css +32 -4
- package/libs/katex/katex.js +4987 -6215
- package/libs/katex/katex.min.css +1 -1
- package/libs/katex/katex.min.js +1 -1
- package/libs/katex/katex.mjs +4562 -6559
- package/libs/mermaid/mermaid.min.js +3022 -0
- package/libs/plyr/plyr.css +1 -0
- package/libs/plyr/plyr.js +8803 -0
- package/libs/plyr/plyr.min.js +2 -0
- package/libs/plyr/plyr.min.js.map +1 -0
- package/libs/plyr/plyr.min.mjs +1 -0
- package/libs/plyr/plyr.min.mjs.map +1 -0
- package/libs/plyr/plyr.mjs +8795 -0
- package/libs/plyr/plyr.polyfilled.js +9296 -0
- package/libs/plyr/plyr.polyfilled.min.js +2 -0
- package/libs/plyr/plyr.polyfilled.min.js.map +1 -0
- package/libs/plyr/plyr.polyfilled.min.mjs +1 -0
- package/libs/plyr/plyr.polyfilled.min.mjs.map +1 -0
- package/libs/plyr/plyr.polyfilled.mjs +9288 -0
- package/libs/plyr/plyr.svg +1 -0
- package/package.json +15 -16
- package/libs/imgly/background-removal-data/12086412521285f855c2921ae13d3370ab243c9a250ebe340430075780f4624b +0 -0
- package/libs/imgly/background-removal-data/26a663c5a768f39155009f52e0f66815f36983ae275eec676365f7d09ef97edd +0 -0
- package/libs/imgly/background-removal-data/378cd0ab154b324c0b1fe3136a605a8618865d4ce38824a30c938cc1e6312ce4 +0 -0
- package/libs/imgly/background-removal-data/391ce9664d3a506e4333adb82581fc2dc6fbef0354f497ab417c050cb6eba6c4 +0 -0
- package/libs/imgly/background-removal-data/417316220b16ddd1c2a4730a315206ec0405aac7b64a878bdbe514e687b07b6f +0 -0
- package/libs/imgly/background-removal-data/7b64520a3747dd5dcf6ac48f612504bb3b1e273a08b42b5a7efd614b9e4a397c +0 -0
- package/libs/imgly/background-removal-data/7b95dd2733643f999b985105afb755122ca36de12decadc7855ebfbdab6920e6 +0 -0
- package/libs/imgly/background-removal-data/8b993f75a6dc28aab79d1f216e62b59aaa6b3a15e62159bcad4a2ac197c4db0a +0 -0
- package/libs/imgly/background-removal-data/90741e8ae8b47de7666ae4163ba26087500d534973a853bbd02cea715f24b5ee +0 -0
- package/libs/imgly/background-removal-data/9f0512f9be98be0f44ad2f9ec9fe706ae626f2037aca910df6d1396a06a30d41 +0 -0
- package/libs/imgly/background-removal-data/a2a1f2d68cd58b5a6262755e434dee496fc0f27c0ba8fcbb5d57c56ffa1bb15f +0 -0
- package/libs/imgly/background-removal-data/a984abd436e7a8119dc170730260a37436ce0d0542984b71c5a1a386777ab7fd +0 -0
- package/libs/imgly/background-removal-data/af8fb2b72ffb03ed999778c4de73fd4ade196890be6e0253230b198dd11e9db0 +0 -0
- package/libs/imgly/background-removal-data/b53229786ebfbaabcfec4955c248135ba47a13972bf700116a2ff85b86507d2e +0 -0
- package/libs/imgly/background-removal-data/bbf8e366b8f11bb64e60c8532fc2ffed21535fa1cf981464ac45485972107855 +0 -0
- package/libs/imgly/background-removal-data/c1eba9d5d2ee58ba832bf98b50624ea8813f2279505643401c23674c6b326d0b +0 -0
- package/libs/imgly/background-removal-data/c9f954707cb992edf62319d9aed365b4fc9ec3f08693a020db30040c0f953198 +0 -0
- package/libs/imgly/background-removal-data/cad6b95099faeba3ea1299d717990453208cc075b53332db9123a4e2bdaf160c +0 -0
- package/libs/imgly/background-removal-data/dd4fad06953738263bc4d5f94974376467fc74081cba665cef18af8223894ed4 +0 -0
- package/libs/imgly/background-removal-data/e9445ca5ac21e04579658183cd886440f3524caafe6a8947dd20a73b34fba5b0 +0 -0
- package/libs/imgly/background-removal-data/ea46f83f60203065638f183fc8a5446dfc28a163d7ba1922fc3bc6cf40347fa2 +0 -0
- package/libs/imgly/background-removal-data/ef7fb517ae63534f48efa657702b3821fb5d59e4fd372016793edc0389341cc0 +0 -0
- package/libs/imgly/background-removal-data/f69890cf74d0a687904dd088c0aaadce598c8bc217366ebee6993eadd4d56208 +0 -0
- package/libs/imgly/background-removal-data/f6e7e01556358ed875f260bdfb22fb6f7213ac6fd4098ed72c0e7af081f0c23c +0 -0
- package/libs/imgly/background-removal-data/fa3e4102c796fb6d1dab5417c5c0b4b5d219e6b9624d045d7361a033e7db183f +0 -0
- package/libs/imgly/background-removal-data/resources.json +0 -462
- package/libs/mammoth/mammoth.browser.min.js +0 -21
|
@@ -139,14 +139,11 @@ var accentUnderMap = {
|
|
|
139
139
|
"\\underlinesegment": "line segment",
|
|
140
140
|
"\\utilde": "tilde"
|
|
141
141
|
};
|
|
142
|
-
|
|
143
142
|
var buildString = (str, type, a11yStrings) => {
|
|
144
143
|
if (!str) {
|
|
145
144
|
return;
|
|
146
145
|
}
|
|
147
|
-
|
|
148
146
|
var ret;
|
|
149
|
-
|
|
150
147
|
if (type === "open") {
|
|
151
148
|
ret = str in openMap ? openMap[str] : stringMap[str] || str;
|
|
152
149
|
} else if (type === "close") {
|
|
@@ -157,140 +154,118 @@ var buildString = (str, type, a11yStrings) => {
|
|
|
157
154
|
ret = relMap[str] || str;
|
|
158
155
|
} else {
|
|
159
156
|
ret = stringMap[str] || str;
|
|
160
|
-
}
|
|
157
|
+
}
|
|
158
|
+
// If the text to add is a number and there is already a string
|
|
161
159
|
// in the list and the last string is a number then we should
|
|
162
160
|
// combine them into a single number
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (/^\d+$/.test(ret) && a11yStrings.length > 0 && // TODO(kevinb): check that the last item in a11yStrings is a string
|
|
166
|
-
// I think we might be able to drop the nested arrays, which would make
|
|
167
|
-
// this easier to type
|
|
168
|
-
// $FlowFixMe
|
|
169
|
-
/^\d+$/.test(a11yStrings[a11yStrings.length - 1])) {
|
|
161
|
+
var last = a11yStrings[a11yStrings.length - 1];
|
|
162
|
+
if (/^\d+$/.test(ret) && a11yStrings.length > 0 && typeof last === "string" && /^\d+$/.test(last)) {
|
|
170
163
|
a11yStrings[a11yStrings.length - 1] += ret;
|
|
171
164
|
} else if (ret) {
|
|
172
165
|
a11yStrings.push(ret);
|
|
173
166
|
}
|
|
174
167
|
};
|
|
175
|
-
|
|
176
168
|
var buildRegion = (a11yStrings, callback) => {
|
|
177
169
|
var regionStrings = [];
|
|
178
170
|
a11yStrings.push(regionStrings);
|
|
179
171
|
callback(regionStrings);
|
|
180
172
|
};
|
|
181
|
-
|
|
182
173
|
var handleObject = (tree, a11yStrings, atomType) => {
|
|
183
174
|
// Everything else is assumed to be an object...
|
|
184
175
|
switch (tree.type) {
|
|
185
176
|
case "accent":
|
|
186
177
|
{
|
|
187
178
|
buildRegion(a11yStrings, a11yStrings => {
|
|
188
|
-
|
|
179
|
+
_buildA11yStrings(tree.base, a11yStrings, atomType);
|
|
189
180
|
a11yStrings.push("with");
|
|
190
181
|
buildString(tree.label, "normal", a11yStrings);
|
|
191
182
|
a11yStrings.push("on top");
|
|
192
183
|
});
|
|
193
184
|
break;
|
|
194
185
|
}
|
|
195
|
-
|
|
196
186
|
case "accentUnder":
|
|
197
187
|
{
|
|
198
188
|
buildRegion(a11yStrings, a11yStrings => {
|
|
199
|
-
|
|
189
|
+
_buildA11yStrings(tree.base, a11yStrings, atomType);
|
|
200
190
|
a11yStrings.push("with");
|
|
201
191
|
buildString(accentUnderMap[tree.label], "normal", a11yStrings);
|
|
202
192
|
a11yStrings.push("underneath");
|
|
203
193
|
});
|
|
204
194
|
break;
|
|
205
195
|
}
|
|
206
|
-
|
|
207
196
|
case "accent-token":
|
|
208
197
|
{
|
|
209
198
|
// Used internally by accent symbols.
|
|
210
199
|
break;
|
|
211
200
|
}
|
|
212
|
-
|
|
213
201
|
case "atom":
|
|
214
202
|
{
|
|
215
203
|
var {
|
|
216
204
|
text
|
|
217
205
|
} = tree;
|
|
218
|
-
|
|
219
206
|
switch (tree.family) {
|
|
220
207
|
case "bin":
|
|
221
208
|
{
|
|
222
209
|
buildString(text, "bin", a11yStrings);
|
|
223
210
|
break;
|
|
224
211
|
}
|
|
225
|
-
|
|
226
212
|
case "close":
|
|
227
213
|
{
|
|
228
214
|
buildString(text, "close", a11yStrings);
|
|
229
215
|
break;
|
|
230
216
|
}
|
|
231
217
|
// TODO(kevinb): figure out what should be done for inner
|
|
232
|
-
|
|
233
218
|
case "inner":
|
|
234
219
|
{
|
|
235
220
|
buildString(tree.text, "inner", a11yStrings);
|
|
236
221
|
break;
|
|
237
222
|
}
|
|
238
|
-
|
|
239
223
|
case "open":
|
|
240
224
|
{
|
|
241
225
|
buildString(text, "open", a11yStrings);
|
|
242
226
|
break;
|
|
243
227
|
}
|
|
244
|
-
|
|
245
228
|
case "punct":
|
|
246
229
|
{
|
|
247
230
|
buildString(text, "punct", a11yStrings);
|
|
248
231
|
break;
|
|
249
232
|
}
|
|
250
|
-
|
|
251
233
|
case "rel":
|
|
252
234
|
{
|
|
253
235
|
buildString(text, "rel", a11yStrings);
|
|
254
236
|
break;
|
|
255
237
|
}
|
|
256
|
-
|
|
257
238
|
default:
|
|
258
239
|
{
|
|
259
240
|
tree.family;
|
|
260
241
|
throw new Error("\"" + tree.family + "\" is not a valid atom type");
|
|
261
242
|
}
|
|
262
243
|
}
|
|
263
|
-
|
|
264
244
|
break;
|
|
265
245
|
}
|
|
266
|
-
|
|
267
246
|
case "color":
|
|
268
247
|
{
|
|
269
248
|
var color = tree.color.replace(/katex-/, "");
|
|
270
249
|
buildRegion(a11yStrings, regionStrings => {
|
|
271
250
|
regionStrings.push("start color " + color);
|
|
272
|
-
|
|
251
|
+
_buildA11yStrings(tree.body, regionStrings, atomType);
|
|
273
252
|
regionStrings.push("end color " + color);
|
|
274
253
|
});
|
|
275
254
|
break;
|
|
276
255
|
}
|
|
277
|
-
|
|
278
256
|
case "color-token":
|
|
279
257
|
{
|
|
280
258
|
// Used by \color, \colorbox, and \fcolorbox but not directly rendered.
|
|
281
259
|
// It's a leaf node and has no children so just break.
|
|
282
260
|
break;
|
|
283
261
|
}
|
|
284
|
-
|
|
285
262
|
case "delimsizing":
|
|
286
263
|
{
|
|
287
264
|
if (tree.delim && tree.delim !== ".") {
|
|
288
265
|
buildString(tree.delim, "normal", a11yStrings);
|
|
289
266
|
}
|
|
290
|
-
|
|
291
267
|
break;
|
|
292
268
|
}
|
|
293
|
-
|
|
294
269
|
case "genfrac":
|
|
295
270
|
{
|
|
296
271
|
buildRegion(a11yStrings, regionStrings => {
|
|
@@ -298,153 +273,133 @@ var handleObject = (tree, a11yStrings, atomType) => {
|
|
|
298
273
|
var {
|
|
299
274
|
leftDelim,
|
|
300
275
|
rightDelim
|
|
301
|
-
} = tree;
|
|
276
|
+
} = tree;
|
|
277
|
+
// NOTE: Not sure if this is a safe assumption
|
|
302
278
|
// hasBarLine true -> fraction, false -> binomial
|
|
303
|
-
|
|
304
279
|
if (tree.hasBarLine) {
|
|
305
280
|
regionStrings.push("start fraction");
|
|
306
281
|
leftDelim && buildString(leftDelim, "open", regionStrings);
|
|
307
|
-
|
|
282
|
+
_buildA11yStrings(tree.numer, regionStrings, atomType);
|
|
308
283
|
regionStrings.push("divided by");
|
|
309
|
-
|
|
284
|
+
_buildA11yStrings(tree.denom, regionStrings, atomType);
|
|
310
285
|
rightDelim && buildString(rightDelim, "close", regionStrings);
|
|
311
286
|
regionStrings.push("end fraction");
|
|
312
287
|
} else {
|
|
313
288
|
regionStrings.push("start binomial");
|
|
314
289
|
leftDelim && buildString(leftDelim, "open", regionStrings);
|
|
315
|
-
|
|
290
|
+
_buildA11yStrings(tree.numer, regionStrings, atomType);
|
|
316
291
|
regionStrings.push("over");
|
|
317
|
-
|
|
292
|
+
_buildA11yStrings(tree.denom, regionStrings, atomType);
|
|
318
293
|
rightDelim && buildString(rightDelim, "close", regionStrings);
|
|
319
294
|
regionStrings.push("end binomial");
|
|
320
295
|
}
|
|
321
296
|
});
|
|
322
297
|
break;
|
|
323
298
|
}
|
|
324
|
-
|
|
325
299
|
case "hbox":
|
|
326
300
|
{
|
|
327
|
-
|
|
301
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
328
302
|
break;
|
|
329
303
|
}
|
|
330
|
-
|
|
331
304
|
case "kern":
|
|
332
305
|
{
|
|
333
306
|
// No op: we don't attempt to present kerning information
|
|
334
307
|
// to the screen reader.
|
|
335
308
|
break;
|
|
336
309
|
}
|
|
337
|
-
|
|
338
310
|
case "leftright":
|
|
339
311
|
{
|
|
340
312
|
buildRegion(a11yStrings, regionStrings => {
|
|
341
313
|
buildString(tree.left, "open", regionStrings);
|
|
342
|
-
|
|
314
|
+
_buildA11yStrings(tree.body, regionStrings, atomType);
|
|
343
315
|
buildString(tree.right, "close", regionStrings);
|
|
344
316
|
});
|
|
345
317
|
break;
|
|
346
318
|
}
|
|
347
|
-
|
|
348
319
|
case "leftright-right":
|
|
349
320
|
{
|
|
350
321
|
// TODO: double check that this is a no-op
|
|
351
322
|
break;
|
|
352
323
|
}
|
|
353
|
-
|
|
354
324
|
case "lap":
|
|
355
325
|
{
|
|
356
|
-
|
|
326
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
357
327
|
break;
|
|
358
328
|
}
|
|
359
|
-
|
|
360
329
|
case "mathord":
|
|
361
330
|
{
|
|
362
331
|
buildString(tree.text, "normal", a11yStrings);
|
|
363
332
|
break;
|
|
364
333
|
}
|
|
365
|
-
|
|
366
334
|
case "op":
|
|
367
335
|
{
|
|
368
336
|
var {
|
|
369
337
|
body,
|
|
370
338
|
name
|
|
371
339
|
} = tree;
|
|
372
|
-
|
|
373
340
|
if (body) {
|
|
374
|
-
|
|
341
|
+
_buildA11yStrings(body, a11yStrings, atomType);
|
|
375
342
|
} else if (name) {
|
|
376
343
|
buildString(name, "normal", a11yStrings);
|
|
377
344
|
}
|
|
378
|
-
|
|
379
345
|
break;
|
|
380
346
|
}
|
|
381
|
-
|
|
382
347
|
case "op-token":
|
|
383
348
|
{
|
|
384
349
|
// Used internally by operator symbols.
|
|
385
350
|
buildString(tree.text, atomType, a11yStrings);
|
|
386
351
|
break;
|
|
387
352
|
}
|
|
388
|
-
|
|
389
353
|
case "ordgroup":
|
|
390
354
|
{
|
|
391
|
-
|
|
355
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
392
356
|
break;
|
|
393
357
|
}
|
|
394
|
-
|
|
395
358
|
case "overline":
|
|
396
359
|
{
|
|
397
360
|
buildRegion(a11yStrings, function (a11yStrings) {
|
|
398
361
|
a11yStrings.push("start overline");
|
|
399
|
-
|
|
362
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
400
363
|
a11yStrings.push("end overline");
|
|
401
364
|
});
|
|
402
365
|
break;
|
|
403
366
|
}
|
|
404
|
-
|
|
405
367
|
case "pmb":
|
|
406
368
|
{
|
|
407
369
|
a11yStrings.push("bold");
|
|
408
370
|
break;
|
|
409
371
|
}
|
|
410
|
-
|
|
411
372
|
case "phantom":
|
|
412
373
|
{
|
|
413
374
|
a11yStrings.push("empty space");
|
|
414
375
|
break;
|
|
415
376
|
}
|
|
416
|
-
|
|
417
377
|
case "raisebox":
|
|
418
378
|
{
|
|
419
|
-
|
|
379
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
420
380
|
break;
|
|
421
381
|
}
|
|
422
|
-
|
|
423
382
|
case "rule":
|
|
424
383
|
{
|
|
425
384
|
a11yStrings.push("rectangle");
|
|
426
385
|
break;
|
|
427
386
|
}
|
|
428
|
-
|
|
429
387
|
case "sizing":
|
|
430
388
|
{
|
|
431
|
-
|
|
389
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
432
390
|
break;
|
|
433
391
|
}
|
|
434
|
-
|
|
435
392
|
case "spacing":
|
|
436
393
|
{
|
|
437
394
|
a11yStrings.push("space");
|
|
438
395
|
break;
|
|
439
396
|
}
|
|
440
|
-
|
|
441
397
|
case "styling":
|
|
442
398
|
{
|
|
443
399
|
// We ignore the styling and just pass through the contents
|
|
444
|
-
|
|
400
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
445
401
|
break;
|
|
446
402
|
}
|
|
447
|
-
|
|
448
403
|
case "sqrt":
|
|
449
404
|
{
|
|
450
405
|
buildRegion(a11yStrings, regionStrings => {
|
|
@@ -452,31 +407,26 @@ var handleObject = (tree, a11yStrings, atomType) => {
|
|
|
452
407
|
body,
|
|
453
408
|
index
|
|
454
409
|
} = tree;
|
|
455
|
-
|
|
456
410
|
if (index) {
|
|
457
|
-
var indexString =
|
|
458
|
-
|
|
411
|
+
var indexString = _flatten(_buildA11yStrings(index, [], atomType)).join(",");
|
|
459
412
|
if (indexString === "3") {
|
|
460
413
|
regionStrings.push("cube root of");
|
|
461
|
-
|
|
414
|
+
_buildA11yStrings(body, regionStrings, atomType);
|
|
462
415
|
regionStrings.push("end cube root");
|
|
463
416
|
return;
|
|
464
417
|
}
|
|
465
|
-
|
|
466
418
|
regionStrings.push("root");
|
|
467
419
|
regionStrings.push("start index");
|
|
468
|
-
|
|
420
|
+
_buildA11yStrings(index, regionStrings, atomType);
|
|
469
421
|
regionStrings.push("end index");
|
|
470
422
|
return;
|
|
471
423
|
}
|
|
472
|
-
|
|
473
424
|
regionStrings.push("square root of");
|
|
474
|
-
|
|
425
|
+
_buildA11yStrings(body, regionStrings, atomType);
|
|
475
426
|
regionStrings.push("end square root");
|
|
476
427
|
});
|
|
477
428
|
break;
|
|
478
429
|
}
|
|
479
|
-
|
|
480
430
|
case "supsub":
|
|
481
431
|
{
|
|
482
432
|
var {
|
|
@@ -485,71 +435,60 @@ var handleObject = (tree, a11yStrings, atomType) => {
|
|
|
485
435
|
sup
|
|
486
436
|
} = tree;
|
|
487
437
|
var isLog = false;
|
|
488
|
-
|
|
489
438
|
if (base) {
|
|
490
|
-
|
|
439
|
+
_buildA11yStrings(base, a11yStrings, atomType);
|
|
491
440
|
isLog = base.type === "op" && base.name === "\\log";
|
|
492
441
|
}
|
|
493
|
-
|
|
494
442
|
if (sub) {
|
|
495
443
|
var regionName = isLog ? "base" : "subscript";
|
|
496
444
|
buildRegion(a11yStrings, function (regionStrings) {
|
|
497
445
|
regionStrings.push("start " + regionName);
|
|
498
|
-
|
|
446
|
+
_buildA11yStrings(sub, regionStrings, atomType);
|
|
499
447
|
regionStrings.push("end " + regionName);
|
|
500
448
|
});
|
|
501
449
|
}
|
|
502
|
-
|
|
503
450
|
if (sup) {
|
|
504
451
|
buildRegion(a11yStrings, function (regionStrings) {
|
|
505
|
-
var supString =
|
|
506
|
-
|
|
452
|
+
var supString = _flatten(_buildA11yStrings(sup, [], atomType)).join(",");
|
|
507
453
|
if (supString in powerMap) {
|
|
508
454
|
regionStrings.push(powerMap[supString]);
|
|
509
455
|
return;
|
|
510
456
|
}
|
|
511
|
-
|
|
512
457
|
regionStrings.push("start superscript");
|
|
513
|
-
|
|
458
|
+
_buildA11yStrings(sup, regionStrings, atomType);
|
|
514
459
|
regionStrings.push("end superscript");
|
|
515
460
|
});
|
|
516
461
|
}
|
|
517
|
-
|
|
518
462
|
break;
|
|
519
463
|
}
|
|
520
|
-
|
|
521
464
|
case "text":
|
|
522
465
|
{
|
|
523
466
|
// TODO: handle other fonts
|
|
524
467
|
if (tree.font === "\\textbf") {
|
|
525
468
|
buildRegion(a11yStrings, function (regionStrings) {
|
|
526
469
|
regionStrings.push("start bold text");
|
|
527
|
-
|
|
470
|
+
_buildA11yStrings(tree.body, regionStrings, atomType);
|
|
528
471
|
regionStrings.push("end bold text");
|
|
529
472
|
});
|
|
530
473
|
break;
|
|
531
474
|
}
|
|
532
|
-
|
|
533
475
|
buildRegion(a11yStrings, function (regionStrings) {
|
|
534
476
|
regionStrings.push("start text");
|
|
535
|
-
|
|
477
|
+
_buildA11yStrings(tree.body, regionStrings, atomType);
|
|
536
478
|
regionStrings.push("end text");
|
|
537
479
|
});
|
|
538
480
|
break;
|
|
539
481
|
}
|
|
540
|
-
|
|
541
482
|
case "textord":
|
|
542
483
|
{
|
|
543
484
|
buildString(tree.text, atomType, a11yStrings);
|
|
544
485
|
break;
|
|
545
486
|
}
|
|
546
|
-
|
|
547
487
|
case "smash":
|
|
548
488
|
{
|
|
549
|
-
|
|
489
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
550
490
|
break;
|
|
551
491
|
}
|
|
552
|
-
|
|
553
492
|
case "enclose":
|
|
554
493
|
{
|
|
555
494
|
// TODO: create a map for these.
|
|
@@ -558,85 +497,70 @@ var handleObject = (tree, a11yStrings, atomType) => {
|
|
|
558
497
|
if (/cancel/.test(tree.label)) {
|
|
559
498
|
buildRegion(a11yStrings, function (regionStrings) {
|
|
560
499
|
regionStrings.push("start cancel");
|
|
561
|
-
|
|
500
|
+
_buildA11yStrings(tree.body, regionStrings, atomType);
|
|
562
501
|
regionStrings.push("end cancel");
|
|
563
502
|
});
|
|
564
503
|
break;
|
|
565
504
|
} else if (/box/.test(tree.label)) {
|
|
566
505
|
buildRegion(a11yStrings, function (regionStrings) {
|
|
567
506
|
regionStrings.push("start box");
|
|
568
|
-
|
|
507
|
+
_buildA11yStrings(tree.body, regionStrings, atomType);
|
|
569
508
|
regionStrings.push("end box");
|
|
570
509
|
});
|
|
571
510
|
break;
|
|
572
511
|
} else if (/sout/.test(tree.label)) {
|
|
573
512
|
buildRegion(a11yStrings, function (regionStrings) {
|
|
574
513
|
regionStrings.push("start strikeout");
|
|
575
|
-
|
|
514
|
+
_buildA11yStrings(tree.body, regionStrings, atomType);
|
|
576
515
|
regionStrings.push("end strikeout");
|
|
577
516
|
});
|
|
578
517
|
break;
|
|
579
518
|
} else if (/phase/.test(tree.label)) {
|
|
580
519
|
buildRegion(a11yStrings, function (regionStrings) {
|
|
581
520
|
regionStrings.push("start phase angle");
|
|
582
|
-
|
|
521
|
+
_buildA11yStrings(tree.body, regionStrings, atomType);
|
|
583
522
|
regionStrings.push("end phase angle");
|
|
584
523
|
});
|
|
585
524
|
break;
|
|
586
525
|
}
|
|
587
|
-
|
|
588
526
|
throw new Error("KaTeX-a11y: enclose node with " + tree.label + " not supported yet");
|
|
589
527
|
}
|
|
590
|
-
|
|
591
528
|
case "vcenter":
|
|
592
529
|
{
|
|
593
|
-
|
|
530
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
594
531
|
break;
|
|
595
532
|
}
|
|
596
|
-
|
|
597
533
|
case "vphantom":
|
|
598
534
|
{
|
|
599
535
|
throw new Error("KaTeX-a11y: vphantom not implemented yet");
|
|
600
536
|
}
|
|
601
|
-
|
|
602
|
-
case "hphantom":
|
|
603
|
-
{
|
|
604
|
-
throw new Error("KaTeX-a11y: hphantom not implemented yet");
|
|
605
|
-
}
|
|
606
|
-
|
|
607
537
|
case "operatorname":
|
|
608
538
|
{
|
|
609
|
-
|
|
539
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
610
540
|
break;
|
|
611
541
|
}
|
|
612
|
-
|
|
613
542
|
case "array":
|
|
614
543
|
{
|
|
615
544
|
throw new Error("KaTeX-a11y: array not implemented yet");
|
|
616
545
|
}
|
|
617
|
-
|
|
618
546
|
case "raw":
|
|
619
547
|
{
|
|
620
548
|
throw new Error("KaTeX-a11y: raw not implemented yet");
|
|
621
549
|
}
|
|
622
|
-
|
|
623
550
|
case "size":
|
|
624
551
|
{
|
|
625
552
|
// Although there are nodes of type "size" in the parse tree, they have
|
|
626
553
|
// no semantic meaning and should be ignored.
|
|
627
554
|
break;
|
|
628
555
|
}
|
|
629
|
-
|
|
630
556
|
case "url":
|
|
631
557
|
{
|
|
632
558
|
throw new Error("KaTeX-a11y: url not implemented yet");
|
|
633
559
|
}
|
|
634
|
-
|
|
635
560
|
case "tag":
|
|
636
561
|
{
|
|
637
562
|
throw new Error("KaTeX-a11y: tag not implemented yet");
|
|
638
563
|
}
|
|
639
|
-
|
|
640
564
|
case "verb":
|
|
641
565
|
{
|
|
642
566
|
buildString("start verbatim", "normal", a11yStrings);
|
|
@@ -644,157 +568,131 @@ var handleObject = (tree, a11yStrings, atomType) => {
|
|
|
644
568
|
buildString("end verbatim", "normal", a11yStrings);
|
|
645
569
|
break;
|
|
646
570
|
}
|
|
647
|
-
|
|
648
571
|
case "environment":
|
|
649
572
|
{
|
|
650
573
|
throw new Error("KaTeX-a11y: environment not implemented yet");
|
|
651
574
|
}
|
|
652
|
-
|
|
653
575
|
case "horizBrace":
|
|
654
576
|
{
|
|
655
577
|
buildString("start " + tree.label.slice(1), "normal", a11yStrings);
|
|
656
|
-
|
|
578
|
+
_buildA11yStrings(tree.base, a11yStrings, atomType);
|
|
657
579
|
buildString("end " + tree.label.slice(1), "normal", a11yStrings);
|
|
658
580
|
break;
|
|
659
581
|
}
|
|
660
|
-
|
|
661
582
|
case "infix":
|
|
662
583
|
{
|
|
663
584
|
// All infix nodes are replace with other nodes.
|
|
664
585
|
break;
|
|
665
586
|
}
|
|
666
|
-
|
|
667
587
|
case "includegraphics":
|
|
668
588
|
{
|
|
669
589
|
throw new Error("KaTeX-a11y: includegraphics not implemented yet");
|
|
670
590
|
}
|
|
671
|
-
|
|
672
591
|
case "font":
|
|
673
592
|
{
|
|
674
593
|
// TODO: callout the start/end of specific fonts
|
|
675
594
|
// TODO: map \BBb{N} to "the naturals" or something like that
|
|
676
|
-
|
|
595
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
677
596
|
break;
|
|
678
597
|
}
|
|
679
|
-
|
|
680
598
|
case "href":
|
|
681
599
|
{
|
|
682
600
|
throw new Error("KaTeX-a11y: href not implemented yet");
|
|
683
601
|
}
|
|
684
|
-
|
|
685
602
|
case "cr":
|
|
686
603
|
{
|
|
687
604
|
// This is used by environments.
|
|
688
605
|
throw new Error("KaTeX-a11y: cr not implemented yet");
|
|
689
606
|
}
|
|
690
|
-
|
|
691
607
|
case "underline":
|
|
692
608
|
{
|
|
693
609
|
buildRegion(a11yStrings, function (a11yStrings) {
|
|
694
610
|
a11yStrings.push("start underline");
|
|
695
|
-
|
|
611
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
696
612
|
a11yStrings.push("end underline");
|
|
697
613
|
});
|
|
698
614
|
break;
|
|
699
615
|
}
|
|
700
|
-
|
|
701
616
|
case "xArrow":
|
|
702
617
|
{
|
|
703
618
|
throw new Error("KaTeX-a11y: xArrow not implemented yet");
|
|
704
619
|
}
|
|
705
|
-
|
|
706
620
|
case "cdlabel":
|
|
707
621
|
{
|
|
708
622
|
throw new Error("KaTeX-a11y: cdlabel not implemented yet");
|
|
709
623
|
}
|
|
710
|
-
|
|
711
624
|
case "cdlabelparent":
|
|
712
625
|
{
|
|
713
626
|
throw new Error("KaTeX-a11y: cdlabelparent not implemented yet");
|
|
714
627
|
}
|
|
715
|
-
|
|
716
628
|
case "mclass":
|
|
717
629
|
{
|
|
718
630
|
// \neq and \ne are macros so we let "htmlmathml" render the mathmal
|
|
719
631
|
// side of things and extract the text from that.
|
|
720
|
-
var _atomType = tree.mclass.slice(1);
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
buildA11yStrings(tree.body, a11yStrings, _atomType);
|
|
632
|
+
var _atomType = tree.mclass.slice(1);
|
|
633
|
+
// TODO(ts): drop the leading "m" from the values in mclass
|
|
634
|
+
_buildA11yStrings(tree.body, a11yStrings, _atomType);
|
|
724
635
|
break;
|
|
725
636
|
}
|
|
726
|
-
|
|
727
637
|
case "mathchoice":
|
|
728
638
|
{
|
|
729
639
|
// TODO: track which style we're using, e.g. display, text, etc.
|
|
730
640
|
// default to text style if even that may not be the correct style
|
|
731
|
-
|
|
641
|
+
_buildA11yStrings(tree.text, a11yStrings, atomType);
|
|
732
642
|
break;
|
|
733
643
|
}
|
|
734
|
-
|
|
735
644
|
case "htmlmathml":
|
|
736
645
|
{
|
|
737
|
-
|
|
646
|
+
_buildA11yStrings(tree.mathml, a11yStrings, atomType);
|
|
738
647
|
break;
|
|
739
648
|
}
|
|
740
|
-
|
|
741
649
|
case "middle":
|
|
742
650
|
{
|
|
743
651
|
buildString(tree.delim, atomType, a11yStrings);
|
|
744
652
|
break;
|
|
745
653
|
}
|
|
746
|
-
|
|
747
654
|
case "internal":
|
|
748
655
|
{
|
|
749
656
|
// internal nodes are never included in the parse tree
|
|
750
657
|
break;
|
|
751
658
|
}
|
|
752
|
-
|
|
753
659
|
case "html":
|
|
754
660
|
{
|
|
755
|
-
|
|
661
|
+
_buildA11yStrings(tree.body, a11yStrings, atomType);
|
|
756
662
|
break;
|
|
757
663
|
}
|
|
758
|
-
|
|
759
664
|
default:
|
|
760
|
-
tree.type;
|
|
761
665
|
throw new Error("KaTeX a11y un-recognized type: " + tree.type);
|
|
762
666
|
}
|
|
763
667
|
};
|
|
764
|
-
|
|
765
|
-
var buildA11yStrings = function buildA11yStrings(tree, a11yStrings, atomType) {
|
|
668
|
+
var _buildA11yStrings = function buildA11yStrings(tree, a11yStrings, atomType) {
|
|
766
669
|
if (a11yStrings === void 0) {
|
|
767
670
|
a11yStrings = [];
|
|
768
671
|
}
|
|
769
|
-
|
|
770
672
|
if (tree instanceof Array) {
|
|
771
673
|
for (var i = 0; i < tree.length; i++) {
|
|
772
|
-
|
|
674
|
+
_buildA11yStrings(tree[i], a11yStrings, atomType);
|
|
773
675
|
}
|
|
774
676
|
} else {
|
|
775
677
|
handleObject(tree, a11yStrings, atomType);
|
|
776
678
|
}
|
|
777
|
-
|
|
778
679
|
return a11yStrings;
|
|
779
680
|
};
|
|
780
|
-
|
|
781
|
-
var flatten = function flatten(array) {
|
|
681
|
+
var _flatten = function flatten(array) {
|
|
782
682
|
var result = [];
|
|
783
683
|
array.forEach(function (item) {
|
|
784
|
-
if (item
|
|
785
|
-
result = result.concat(
|
|
684
|
+
if (Array.isArray(item)) {
|
|
685
|
+
result = result.concat(_flatten(item));
|
|
786
686
|
} else {
|
|
787
687
|
result.push(item);
|
|
788
688
|
}
|
|
789
689
|
});
|
|
790
690
|
return result;
|
|
791
691
|
};
|
|
792
|
-
|
|
793
692
|
var renderA11yString = function renderA11yString(text, settings) {
|
|
794
693
|
var tree = katex.__parse(text, settings);
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
return flatten(a11yStrings).join(", ");
|
|
694
|
+
var a11yStrings = _buildA11yStrings(tree, [], "normal");
|
|
695
|
+
return _flatten(a11yStrings).join(", ");
|
|
798
696
|
};
|
|
799
697
|
|
|
800
698
|
export { renderA11yString as default };
|