katex 0.17.0 → 0.18.1
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/README.md +3 -3
- package/cli.js +6 -9
- package/contrib/auto-render/index.html +1 -1
- package/contrib/copy-tex/README.md +3 -3
- package/contrib/copy-tex/index.html +1 -1
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +3 -3
- package/dist/contrib/render-a11y-string.js +15 -40
- package/dist/contrib/render-a11y-string.min.js +1 -1
- package/dist/contrib/render-a11y-string.mjs +13 -33
- package/dist/katex-swap.css +159 -164
- package/dist/katex-swap.min.css +1 -1
- package/dist/katex.css +159 -164
- package/dist/katex.js +277 -421
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +279 -423
- package/package.json +14 -16
- package/src/MacroExpander.ts +10 -7
- package/src/Namespace.ts +16 -20
- package/src/Options.ts +2 -2
- package/src/Parser.ts +2 -2
- package/src/atoms.ts +22 -22
- package/src/buildCommon.ts +2 -2
- package/src/buildHTML.ts +8 -8
- package/src/buildMathML.ts +3 -3
- package/src/environments/array.ts +3 -3
- package/src/fontMetrics.ts +2 -4
- package/src/functions/accent.ts +2 -2
- package/src/functions/cr.ts +1 -1
- package/src/functions/enclose.ts +1 -1
- package/src/functions/environment.ts +1 -1
- package/src/functions/html.ts +21 -4
- package/src/functions/lap.ts +7 -7
- package/src/functions/overline.ts +1 -1
- package/src/functions/phantom.ts +2 -2
- package/src/functions/rule.ts +1 -1
- package/src/functions/sizing.ts +1 -1
- package/src/functions/smash.ts +1 -1
- package/src/functions/sqrt.ts +1 -1
- package/src/functions/symbolsSpacing.ts +20 -21
- package/src/functions/underline.ts +1 -1
- package/src/macros.ts +3 -3
- package/src/mathMLTree.ts +6 -10
- package/src/parseNode.ts +4 -4
- package/src/stretchy.ts +2 -2
- package/src/styles/katex.scss +31 -37
- package/src/wide-character.ts +2 -2
package/README.md
CHANGED
|
@@ -37,13 +37,13 @@ Try out KaTeX [on the demo page](https://katex.org/#demo)!
|
|
|
37
37
|
<!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
|
|
38
38
|
<html>
|
|
39
39
|
<head>
|
|
40
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.
|
|
40
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/katex.min.css" integrity="sha384-1vdNCNel6Tx/NQa8IR1mGOGKsbGreCkOPfbtPPnUURJ5Tu2PRVfQ/7KLZC+Pi1p1" crossorigin="anonymous">
|
|
41
41
|
|
|
42
42
|
<!-- The loading of KaTeX is deferred to speed up page rendering -->
|
|
43
|
-
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.
|
|
43
|
+
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/katex.min.js" integrity="sha384-ycJ6GAwiS15LoUPipwJOrWTvkUHl/YqELValBwI5I4awP1EeEQJYarj+w85ntcz7" crossorigin="anonymous"></script>
|
|
44
44
|
|
|
45
45
|
<!-- To automatically render math in text elements, include the auto-render extension: -->
|
|
46
|
-
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.
|
|
46
|
+
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/contrib/auto-render.min.js" integrity="sha384-bjyGPfbij8/NDKJhSGZNP/khQVgtHUE5exjm4Ydllo42FwIgYsdLO2lXGmRBf5Mz" crossorigin="anonymous"
|
|
47
47
|
onload="renderMathInElement(document.body);"></script>
|
|
48
48
|
</head>
|
|
49
49
|
...
|
package/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Simple CLI for KaTeX.
|
|
3
3
|
// Reads TeX from stdin, outputs HTML to stdout.
|
|
4
4
|
// To run this from the repository, you must first build KaTeX by running
|
|
5
|
-
// `
|
|
5
|
+
// `pnpm install` and `pnpm build`.
|
|
6
6
|
|
|
7
7
|
/* eslint no-console:0 */
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ try {
|
|
|
12
12
|
} catch (e) {
|
|
13
13
|
console.error(
|
|
14
14
|
"KaTeX could not import, likely because dist/katex.js is missing.");
|
|
15
|
-
console.error("Please run '
|
|
15
|
+
console.error("Please run 'pnpm install' and 'pnpm build' before running");
|
|
16
16
|
console.error("cli.js from the KaTeX repository.");
|
|
17
17
|
console.error();
|
|
18
18
|
throw e;
|
|
@@ -23,13 +23,10 @@ const fs = require("fs");
|
|
|
23
23
|
const {program} = require("commander");
|
|
24
24
|
program.version(version);
|
|
25
25
|
|
|
26
|
-
for (const prop
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
program.option(opt.cli || "--" + prop, opt.cliDescription ||
|
|
31
|
-
opt.description, opt.cliProcessor, opt.cliDefault);
|
|
32
|
-
}
|
|
26
|
+
for (const [prop, opt] of Object.entries(katex.SETTINGS_SCHEMA)) {
|
|
27
|
+
if (opt.cli !== false) {
|
|
28
|
+
program.option(opt.cli || "--" + prop, opt.cliDescription ||
|
|
29
|
+
opt.description, opt.cliProcessor, opt.cliDefault);
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
program.option("-f, --macro-file <path>",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<!--To run this example from a clone of the repository, run `
|
|
2
|
+
<!--To run this example from a clone of the repository, run `pnpm start`
|
|
3
3
|
in the root KaTeX directory and then visit with your web browser:
|
|
4
4
|
http://localhost:7936/contrib/auto-render/index.html
|
|
5
5
|
-->
|
|
@@ -18,13 +18,13 @@ This extension isn't part of KaTeX proper, so the script should be separately
|
|
|
18
18
|
included in the page.
|
|
19
19
|
|
|
20
20
|
```html
|
|
21
|
-
<script src="https://cdn.jsdelivr.net/npm/katex@0.
|
|
21
|
+
<script src="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/contrib/copy-tex.min.js" integrity="sha384-Pe2JWbaShhSRT0SESJ9XLPeAsi4yrNi7r/CiH0Coq7giBjK5a6Ae7XcybE8rNlQP" crossorigin="anonymous"></script>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
(Note that, as of KaTeX 0.16.0, there is no longer a corresponding CSS file.)
|
|
25
25
|
|
|
26
26
|
See [index.html](index.html) for an example.
|
|
27
|
-
(To run this example from a clone of the repository, run `
|
|
27
|
+
(To run this example from a clone of the repository, run `pnpm start`
|
|
28
28
|
in the root KaTeX directory, and then visit
|
|
29
29
|
http://localhost:7936/contrib/copy-tex/index.html
|
|
30
30
|
with your web browser.)
|
|
@@ -35,5 +35,5 @@ statement with `require('katex/contrib/copy-tex/katex2tex.js')`.
|
|
|
35
35
|
|
|
36
36
|
ECMAScript module is also available:
|
|
37
37
|
```html
|
|
38
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/katex@0.
|
|
38
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/contrib/copy-tex.mjs" integrity="sha384-PTy3nbMSATx5Ifo/k1ErbnbMVEp3koLGaqTD+zBo5H0fPFue/mKr1M3//74Fu6Tf" crossorigin="anonymous"></script>
|
|
39
39
|
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<!--To run this example from a clone of the repository, run `
|
|
2
|
+
<!--To run this example from a clone of the repository, run `pnpm start`
|
|
3
3
|
in the root KaTeX directory and then visit with your web browser:
|
|
4
4
|
http://localhost:7936/contrib/copy-tex/index.html
|
|
5
5
|
-->
|
|
@@ -11,7 +11,7 @@ included in the page, in addition to KaTeX.
|
|
|
11
11
|
Load the extension by adding the following line to your HTML file.
|
|
12
12
|
|
|
13
13
|
```html
|
|
14
|
-
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.
|
|
14
|
+
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/contrib/mathtex-script-type.min.js" integrity="sha384-W8gaN87yMtPe/iAcxlyIDA8OVOzZvVD4c/HEE6QHhIyo8yHnVSXLzzy+eNWwpivm" crossorigin="anonymous"></script>
|
|
15
15
|
```
|
|
16
16
|
You can download the script and use it locally, or from a local KaTeX installation instead.
|
|
17
17
|
|
|
@@ -23,9 +23,9 @@ Then, in the body, we use a `math/tex` script to typeset the equation `x+\sqrt{1
|
|
|
23
23
|
<!DOCTYPE html>
|
|
24
24
|
<html>
|
|
25
25
|
<head>
|
|
26
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.
|
|
27
|
-
<script src="https://cdn.jsdelivr.net/npm/katex@0.
|
|
28
|
-
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.
|
|
26
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/katex.min.css" integrity="sha384-1vdNCNel6Tx/NQa8IR1mGOGKsbGreCkOPfbtPPnUURJ5Tu2PRVfQ/7KLZC+Pi1p1" crossorigin="anonymous">
|
|
27
|
+
<script src="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/katex.min.js" integrity="sha384-ycJ6GAwiS15LoUPipwJOrWTvkUHl/YqELValBwI5I4awP1EeEQJYarj+w85ntcz7" crossorigin="anonymous"></script>
|
|
28
|
+
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/contrib/mathtex-script-type.min.js" integrity="sha384-W8gaN87yMtPe/iAcxlyIDA8OVOzZvVD4c/HEE6QHhIyo8yHnVSXLzzy+eNWwpivm" crossorigin="anonymous"></script>
|
|
29
29
|
</head>
|
|
30
30
|
<body>
|
|
31
31
|
<script type="math/tex">x+\sqrt{1-x^2}</script>
|
|
@@ -35,4 +35,4 @@ Then, in the body, we use a `math/tex` script to typeset the equation `x+\sqrt{1
|
|
|
35
35
|
|
|
36
36
|
ECMAScript module is also available:
|
|
37
37
|
```html
|
|
38
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/katex@0.
|
|
38
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/contrib/mathtex-script-type.mjs" integrity="sha384-4pY6Hczg2Rj0O1719BbDGKN5JSkitfLp1BU8Jke61b3VKMgoKu1lE6al9tMzy3q2" crossorigin="anonymous"></script>
|
package/contrib/mhchem/README.md
CHANGED
|
@@ -7,7 +7,7 @@ This extension adds to KaTeX the `\ce` and `\pu` functions from the [mhchem](htt
|
|
|
7
7
|
This extension isn't part of core KaTeX, so the script should be separately included. Write the following line into the HTML page's `<head>`. Place it *after* the line that calls `katex.js`, and if you make use of the [auto-render](https://katex.org/docs/autorender.html) extension, place it *before* the line that calls `auto-render.js`.
|
|
8
8
|
|
|
9
9
|
```html
|
|
10
|
-
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.
|
|
10
|
+
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/contrib/mhchem.min.js" integrity="sha384-fB8BH//9nBzROkMUsu/Dr35jWHIbnKesUo9rW0hfEgw8mZGnkAyBAjKX9F98OVuo" crossorigin="anonymous"></script>
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
If you remove the `defer` attribute from this tag, then you must also remove the `defer` attribute from the `<script src="https://../katex.min.js">` tag.
|
package/dist/README.md
CHANGED
|
@@ -37,13 +37,13 @@ Try out KaTeX [on the demo page](https://katex.org/#demo)!
|
|
|
37
37
|
<!-- KaTeX requires the use of the HTML5 doctype. Without it, KaTeX may not render properly -->
|
|
38
38
|
<html>
|
|
39
39
|
<head>
|
|
40
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.
|
|
40
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/katex.min.css" integrity="sha384-1vdNCNel6Tx/NQa8IR1mGOGKsbGreCkOPfbtPPnUURJ5Tu2PRVfQ/7KLZC+Pi1p1" crossorigin="anonymous">
|
|
41
41
|
|
|
42
42
|
<!-- The loading of KaTeX is deferred to speed up page rendering -->
|
|
43
|
-
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.
|
|
43
|
+
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/katex.min.js" integrity="sha384-ycJ6GAwiS15LoUPipwJOrWTvkUHl/YqELValBwI5I4awP1EeEQJYarj+w85ntcz7" crossorigin="anonymous"></script>
|
|
44
44
|
|
|
45
45
|
<!-- To automatically render math in text elements, include the auto-render extension: -->
|
|
46
|
-
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.
|
|
46
|
+
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.18.1/dist/contrib/auto-render.min.js" integrity="sha384-bjyGPfbij8/NDKJhSGZNP/khQVgtHUE5exjm4Ydllo42FwIgYsdLO2lXGmRBf5Mz" crossorigin="anonymous"
|
|
47
47
|
onload="renderMathInElement(document.body);"></script>
|
|
48
48
|
</head>
|
|
49
49
|
...
|
|
@@ -90,27 +90,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
90
90
|
* pull in `isAtom` without dragging in the ~870-line symbol tables.
|
|
91
91
|
*/
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const ATOMS = {
|
|
98
|
-
"bin": 1,
|
|
99
|
-
"close": 1,
|
|
100
|
-
"inner": 1,
|
|
101
|
-
"open": 1,
|
|
102
|
-
"punct": 1,
|
|
103
|
-
"rel": 1
|
|
104
|
-
};
|
|
105
|
-
const NON_ATOMS = {
|
|
106
|
-
"accent-token": 1,
|
|
107
|
-
"mathord": 1,
|
|
108
|
-
"op-token": 1,
|
|
109
|
-
"spacing": 1,
|
|
110
|
-
"textord": 1
|
|
111
|
-
};
|
|
93
|
+
const atomList = ["bin", "close", "inner", "open", "punct", "rel"];
|
|
94
|
+
const nonAtomList = ["accent-token", "mathord", "op-token", "spacing", "textord"];
|
|
95
|
+
const Atoms = new Set(atomList);
|
|
96
|
+
const NonAtoms = new Set(nonAtomList);
|
|
112
97
|
function isAtom(value) {
|
|
113
|
-
return value
|
|
98
|
+
return Atoms.has(value);
|
|
114
99
|
}
|
|
115
100
|
// EXTERNAL MODULE: external "katex"
|
|
116
101
|
var external_katex_ = __webpack_require__(757);
|
|
@@ -320,9 +305,7 @@ const handleObject = (tree, a11yStrings, atomType) => {
|
|
|
320
305
|
}
|
|
321
306
|
case "atom":
|
|
322
307
|
{
|
|
323
|
-
const
|
|
324
|
-
text
|
|
325
|
-
} = tree;
|
|
308
|
+
const text = tree.text;
|
|
326
309
|
switch (tree.family) {
|
|
327
310
|
case "bin":
|
|
328
311
|
{
|
|
@@ -390,10 +373,8 @@ const handleObject = (tree, a11yStrings, atomType) => {
|
|
|
390
373
|
{
|
|
391
374
|
buildRegion(a11yStrings, regionStrings => {
|
|
392
375
|
// genfrac can have unbalanced delimiters
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
rightDelim
|
|
396
|
-
} = tree;
|
|
376
|
+
const leftDelim = tree.leftDelim,
|
|
377
|
+
rightDelim = tree.rightDelim;
|
|
397
378
|
|
|
398
379
|
// NOTE: Not sure if this is a safe assumption
|
|
399
380
|
// hasBarLine true -> fraction, false -> binomial
|
|
@@ -454,10 +435,8 @@ const handleObject = (tree, a11yStrings, atomType) => {
|
|
|
454
435
|
}
|
|
455
436
|
case "op":
|
|
456
437
|
{
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
name
|
|
460
|
-
} = tree;
|
|
438
|
+
const body = tree.body,
|
|
439
|
+
name = tree.name;
|
|
461
440
|
if (body) {
|
|
462
441
|
buildA11yStrings(body, a11yStrings, atomType);
|
|
463
442
|
} else if (name) {
|
|
@@ -524,10 +503,8 @@ const handleObject = (tree, a11yStrings, atomType) => {
|
|
|
524
503
|
case "sqrt":
|
|
525
504
|
{
|
|
526
505
|
buildRegion(a11yStrings, regionStrings => {
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
index
|
|
530
|
-
} = tree;
|
|
506
|
+
const body = tree.body,
|
|
507
|
+
index = tree.index;
|
|
531
508
|
if (index) {
|
|
532
509
|
const indexString = flatten(buildA11yStrings(index, [], atomType)).join(",");
|
|
533
510
|
if (indexString === "3") {
|
|
@@ -550,11 +527,9 @@ const handleObject = (tree, a11yStrings, atomType) => {
|
|
|
550
527
|
}
|
|
551
528
|
case "supsub":
|
|
552
529
|
{
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
sup
|
|
557
|
-
} = tree;
|
|
530
|
+
const base = tree.base,
|
|
531
|
+
sub = tree.sub,
|
|
532
|
+
sup = tree.sup;
|
|
558
533
|
let isLog = false;
|
|
559
534
|
if (base) {
|
|
560
535
|
buildA11yStrings(base, a11yStrings, atomType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],r);else{var t="object"==typeof exports?r(require("katex")):r(e.katex);for(var a in t)("object"==typeof exports?exports:e)[a]=t[a]}}("undefined"!=typeof self?self:this,function(e){return function(){"use strict";var r={757:function(r){r.exports=e}},t={};function a(e){var o=t[e];if(void 0!==o)return o.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,a),n.exports}a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,{a:r}),r},a.d=function(e,r){for(var t in r)a.o(r,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};var o={};a.d(o,{default:function(){return k}});const n=
|
|
1
|
+
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],r);else{var t="object"==typeof exports?r(require("katex")):r(e.katex);for(var a in t)("object"==typeof exports?exports:e)[a]=t[a]}}("undefined"!=typeof self?self:this,function(e){return function(){"use strict";var r={757:function(r){r.exports=e}},t={};function a(e){var o=t[e];if(void 0!==o)return o.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,a),n.exports}a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,{a:r}),r},a.d=function(e,r){for(var t in r)a.o(r,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};var o={};a.d(o,{default:function(){return k}});const n=new Set(["bin","close","inner","open","punct","rel"]);new Set(["accent-token","mathord","op-token","spacing","textord"]);var s=a(757),l=a.n(s);const i={"(":"left parenthesis",")":"right parenthesis","[":"open bracket","]":"close bracket","\\{":"left brace","\\}":"right brace","\\lvert":"open vertical bar","\\rvert":"close vertical bar","|":"vertical bar","\\uparrow":"up arrow","\\Uparrow":"up arrow","\\downarrow":"down arrow","\\Downarrow":"down arrow","\\updownarrow":"up down arrow","\\leftarrow":"left arrow","\\Leftarrow":"left arrow","\\rightarrow":"right arrow","\\Rightarrow":"right arrow","\\langle":"open angle","\\rangle":"close angle","\\lfloor":"open floor","\\rfloor":"close floor","\\int":"integral","\\intop":"integral","\\lim":"limit","\\ln":"natural log","\\log":"log","\\sin":"sine","\\cos":"cosine","\\tan":"tangent","\\cot":"cotangent","\\sum":"sum","/":"slash",",":"comma",".":"point","-":"negative","+":"plus","~":"tilde",":":"colon","?":"question mark","'":"apostrophe","\\%":"percent"," ":"space","\\ ":"space","\\$":"dollar sign","\\angle":"angle","\\degree":"degree","\\circ":"circle","\\vec":"vector","\\triangle":"triangle","\\pi":"pi","\\prime":"prime","\\infty":"infinity","\\alpha":"alpha","\\beta":"beta","\\gamma":"gamma","\\omega":"omega","\\theta":"theta","\\sigma":"sigma","\\lambda":"lambda","\\tau":"tau","\\Delta":"delta","\\delta":"delta","\\mu":"mu","\\rho":"rho","\\nabla":"del","\\ell":"ell","\\ldots":"dots","\\hat":"hat","\\acute":"acute"},c={prime:"prime",degree:"degrees",circle:"degrees",2:"squared",3:"cubed"},p={"|":"open vertical bar",".":""},u={"|":"close vertical bar",".":""},d={"+":"plus","-":"minus","\\pm":"plus minus","\\cdot":"dot","*":"times","/":"divided by","\\times":"times","\\div":"divided by","\\circ":"circle","\\bullet":"bullet"},h={"=":"equals","\\approx":"approximately equals","\u2260":"does not equal","\\geq":"is greater than or equal to","\\ge":"is greater than or equal to","\\leq":"is less than or equal to","\\le":"is less than or equal to",">":"is greater than","<":"is less than","\\leftarrow":"left arrow","\\Leftarrow":"left arrow","\\rightarrow":"right arrow","\\Rightarrow":"right arrow",":":"colon"},b={"\\underleftarrow":"left arrow","\\underrightarrow":"right arrow","\\underleftrightarrow":"left-right arrow","\\undergroup":"group","\\underlinesegment":"line segment","\\utilde":"tilde"},m=(e,r,t)=>{if(!e)return;let a;a="open"===r?e in p?p[e]:i[e]||e:"close"===r?e in u?u[e]:i[e]||e:"bin"===r?d[e]||e:"rel"===r?h[e]||e:i[e]||e;const o=t[t.length-1];/^\d+$/.test(a)&&t.length>0&&"string"==typeof o&&/^\d+$/.test(o)?t[t.length-1]+=a:a&&t.push(a)},f=(e,r)=>{const t=[];e.push(t),r(t)},w=(e,r,t)=>{switch(e.type){case"accent":f(r,r=>{g(e.base,r,t),r.push("with"),m(e.label,"normal",r),r.push("on top")});break;case"accentUnder":f(r,r=>{g(e.base,r,t),r.push("with"),m(b[e.label],"normal",r),r.push("underneath")});break;case"accent-token":case"color-token":case"kern":case"leftright-right":case"size":case"infix":case"internal":break;case"atom":{const t=e.text;switch(e.family){case"bin":m(t,"bin",r);break;case"close":m(t,"close",r);break;case"inner":m(e.text,"inner",r);break;case"open":m(t,"open",r);break;case"punct":m(t,"punct",r);break;case"rel":m(t,"rel",r);break;default:throw e.family,new Error('"'+e.family+'" is not a valid atom type')}break}case"color":{const a=e.color.replace(/katex-/,"");f(r,r=>{r.push("start color "+a),g(e.body,r,t),r.push("end color "+a)});break}case"delimsizing":e.delim&&"."!==e.delim&&m(e.delim,"normal",r);break;case"genfrac":f(r,r=>{const a=e.leftDelim,o=e.rightDelim;e.hasBarLine?(r.push("start fraction"),a&&m(a,"open",r),g(e.numer,r,t),r.push("divided by"),g(e.denom,r,t),o&&m(o,"close",r),r.push("end fraction")):(r.push("start binomial"),a&&m(a,"open",r),g(e.numer,r,t),r.push("over"),g(e.denom,r,t),o&&m(o,"close",r),r.push("end binomial"))});break;case"hbox":case"lap":case"ordgroup":case"raisebox":case"sizing":case"styling":case"smash":case"vcenter":case"operatorname":case"font":case"html":g(e.body,r,t);break;case"leftright":f(r,r=>{m(e.left,"open",r),g(e.body,r,t),m(e.right,"close",r)});break;case"mathord":m(e.text,"normal",r);break;case"op":{const a=e.body,o=e.name;a?g(a,r,t):o&&m(o,"normal",r);break}case"op-token":case"textord":m(e.text,t,r);break;case"overline":f(r,function(r){r.push("start overline"),g(e.body,r,t),r.push("end overline")});break;case"pmb":r.push("bold");break;case"phantom":r.push("empty space");break;case"rule":r.push("rectangle");break;case"spacing":r.push("space");break;case"sqrt":f(r,r=>{const a=e.body,o=e.index;if(o){return"3"===y(g(o,[],t)).join(",")?(r.push("cube root of"),g(a,r,t),void r.push("end cube root")):(r.push("root"),r.push("start index"),g(o,r,t),void r.push("end index"))}r.push("square root of"),g(a,r,t),r.push("end square root")});break;case"supsub":{const a=e.base,o=e.sub,n=e.sup;let s=!1;if(a&&(g(a,r,t),s="op"===a.type&&"\\log"===a.name),o){const e=s?"base":"subscript";f(r,function(r){r.push("start "+e),g(o,r,t),r.push("end "+e)})}n&&f(r,function(e){const r=y(g(n,[],t)).join(",");r in c?e.push(c[r]):(e.push("start superscript"),g(n,e,t),e.push("end superscript"))});break}case"text":if("\\textbf"===e.font){f(r,function(r){r.push("start bold text"),g(e.body,r,t),r.push("end bold text")});break}f(r,function(r){r.push("start text"),g(e.body,r,t),r.push("end text")});break;case"enclose":if(/cancel/.test(e.label)){f(r,function(r){r.push("start cancel"),g(e.body,r,t),r.push("end cancel")});break}if(/box/.test(e.label)){f(r,function(r){r.push("start box"),g(e.body,r,t),r.push("end box")});break}if(/sout/.test(e.label)){f(r,function(r){r.push("start strikeout"),g(e.body,r,t),r.push("end strikeout")});break}if(/phase/.test(e.label)){f(r,function(r){r.push("start phase angle"),g(e.body,r,t),r.push("end phase angle")});break}throw new Error("KaTeX-a11y: enclose node with "+e.label+" not supported yet");case"vphantom":throw new Error("KaTeX-a11y: vphantom not implemented yet");case"array":throw new Error("KaTeX-a11y: array not implemented yet");case"raw":throw new Error("KaTeX-a11y: raw not implemented yet");case"url":throw new Error("KaTeX-a11y: url not implemented yet");case"tag":throw new Error("KaTeX-a11y: tag not implemented yet");case"verb":m("start verbatim","normal",r),m(e.body,"normal",r),m("end verbatim","normal",r);break;case"environment":throw new Error("KaTeX-a11y: environment not implemented yet");case"horizBrace":m("start "+e.label.slice(1),"normal",r),g(e.base,r,t),m("end "+e.label.slice(1),"normal",r);break;case"includegraphics":throw new Error("KaTeX-a11y: includegraphics not implemented yet");case"href":throw new Error("KaTeX-a11y: href not implemented yet");case"cr":throw new Error("KaTeX-a11y: cr not implemented yet");case"underline":f(r,function(r){r.push("start underline"),g(e.body,r,t),r.push("end underline")});break;case"xArrow":throw new Error("KaTeX-a11y: xArrow not implemented yet");case"cdlabel":throw new Error("KaTeX-a11y: cdlabel not implemented yet");case"cdlabelparent":throw new Error("KaTeX-a11y: cdlabelparent not implemented yet");case"mclass":{const t=e.mclass.slice(1);if("normal"!==t&&(a=t,!n.has(a)))throw new Error('Unexpected mclass atom type: "'+t+'"');g(e.body,r,t);break}case"mathchoice":g(e.text,r,t);break;case"htmlmathml":g(e.mathml,r,t);break;case"middle":m(e.delim,t,r);break;default:throw new Error("KaTeX a11y un-recognized type: "+e.type)}var a},g=function(e,r,t){if(void 0===r&&(r=[]),e instanceof Array)for(let a=0;a<e.length;a++)g(e[a],r,t);else w(e,r,t);return r},y=function(e){let r=[];return e.forEach(function(e){Array.isArray(e)?r=r.concat(y(e)):r.push(e)}),r};var k=function(e,r){const t=l().__parse(e,r),a=g(t,[],"normal");return y(a).join(", ")};return o=o.default}()});
|
|
@@ -5,20 +5,10 @@ import katex from '../katex.mjs';
|
|
|
5
5
|
* `symbols.ts` so that consumers (notably `contrib/render-a11y-string`) can
|
|
6
6
|
* pull in `isAtom` without dragging in the ~870-line symbol tables.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by
|
|
11
|
-
// looking up the `symbols` map.
|
|
12
|
-
var ATOMS = {
|
|
13
|
-
"bin": 1,
|
|
14
|
-
"close": 1,
|
|
15
|
-
"inner": 1,
|
|
16
|
-
"open": 1,
|
|
17
|
-
"punct": 1,
|
|
18
|
-
"rel": 1
|
|
19
|
-
};
|
|
8
|
+
var atomList = ["bin", "close", "inner", "open", "punct", "rel"];
|
|
9
|
+
var Atoms = new Set(atomList);
|
|
20
10
|
function isAtom(value) {
|
|
21
|
-
return value
|
|
11
|
+
return Atoms.has(value);
|
|
22
12
|
}
|
|
23
13
|
|
|
24
14
|
/**
|
|
@@ -221,9 +211,7 @@ var handleObject = (tree, a11yStrings, atomType) => {
|
|
|
221
211
|
}
|
|
222
212
|
case "atom":
|
|
223
213
|
{
|
|
224
|
-
var
|
|
225
|
-
text
|
|
226
|
-
} = tree;
|
|
214
|
+
var text = tree.text;
|
|
227
215
|
switch (tree.family) {
|
|
228
216
|
case "bin":
|
|
229
217
|
{
|
|
@@ -291,10 +279,8 @@ var handleObject = (tree, a11yStrings, atomType) => {
|
|
|
291
279
|
{
|
|
292
280
|
buildRegion(a11yStrings, regionStrings => {
|
|
293
281
|
// genfrac can have unbalanced delimiters
|
|
294
|
-
var
|
|
295
|
-
|
|
296
|
-
rightDelim
|
|
297
|
-
} = tree;
|
|
282
|
+
var leftDelim = tree.leftDelim,
|
|
283
|
+
rightDelim = tree.rightDelim;
|
|
298
284
|
// NOTE: Not sure if this is a safe assumption
|
|
299
285
|
// hasBarLine true -> fraction, false -> binomial
|
|
300
286
|
if (tree.hasBarLine) {
|
|
@@ -354,10 +340,8 @@ var handleObject = (tree, a11yStrings, atomType) => {
|
|
|
354
340
|
}
|
|
355
341
|
case "op":
|
|
356
342
|
{
|
|
357
|
-
var
|
|
358
|
-
|
|
359
|
-
name
|
|
360
|
-
} = tree;
|
|
343
|
+
var body = tree.body,
|
|
344
|
+
name = tree.name;
|
|
361
345
|
if (body) {
|
|
362
346
|
_buildA11yStrings(body, a11yStrings, atomType);
|
|
363
347
|
} else if (name) {
|
|
@@ -424,10 +408,8 @@ var handleObject = (tree, a11yStrings, atomType) => {
|
|
|
424
408
|
case "sqrt":
|
|
425
409
|
{
|
|
426
410
|
buildRegion(a11yStrings, regionStrings => {
|
|
427
|
-
var
|
|
428
|
-
|
|
429
|
-
index
|
|
430
|
-
} = tree;
|
|
411
|
+
var body = tree.body,
|
|
412
|
+
index = tree.index;
|
|
431
413
|
if (index) {
|
|
432
414
|
var indexString = _flatten(_buildA11yStrings(index, [], atomType)).join(",");
|
|
433
415
|
if (indexString === "3") {
|
|
@@ -450,11 +432,9 @@ var handleObject = (tree, a11yStrings, atomType) => {
|
|
|
450
432
|
}
|
|
451
433
|
case "supsub":
|
|
452
434
|
{
|
|
453
|
-
var
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
sup
|
|
457
|
-
} = tree;
|
|
435
|
+
var base = tree.base,
|
|
436
|
+
sub = tree.sub,
|
|
437
|
+
sup = tree.sup;
|
|
458
438
|
var isLog = false;
|
|
459
439
|
if (base) {
|
|
460
440
|
_buildA11yStrings(base, a11yStrings, atomType);
|