katex 0.16.4 → 0.16.6
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/contrib/auto-render/test/auto-render-spec.js +1 -1
- package/contrib/copy-tex/README.md +2 -2
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/contrib/mhchem/mhchem.js +2 -2
- package/contrib/render-a11y-string/render-a11y-string.js +1 -1
- package/dist/README.md +3 -3
- package/dist/contrib/mhchem.js +2 -2
- package/dist/contrib/mhchem.min.js +1 -1
- package/dist/contrib/mhchem.mjs +1 -1
- package/dist/contrib/render-a11y-string.js +1 -1
- package/dist/contrib/render-a11y-string.min.js +1 -1
- package/dist/contrib/render-a11y-string.mjs +1 -1
- package/dist/katex.css +3 -1
- package/dist/katex.js +99 -90
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +98 -90
- package/katex.js +7 -0
- package/package.json +66 -63
- package/src/MacroExpander.js +21 -22
- package/src/Parser.js +1 -1
- package/src/buildMathML.js +2 -2
- package/src/defineEnvironment.js +1 -1
- package/src/defineMacro.js +1 -1
- package/src/delimiter.js +20 -20
- package/src/environments/array.js +2 -2
- package/src/fontMetrics.js +4 -4
- package/src/functions/arrow.js +1 -1
- package/src/functions/delimsizing.js +1 -1
- package/src/katex.less +1 -1
- package/src/mathMLTree.js +2 -2
- package/src/parseNode.js +1 -1
- package/src/svgGeometry.js +51 -51
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "katex",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.6",
|
|
4
4
|
"description": "Fast math typesetting for the web.",
|
|
5
5
|
"main": "dist/katex.js",
|
|
6
6
|
"exports": {
|
|
@@ -49,78 +49,79 @@
|
|
|
49
49
|
"license": "MIT",
|
|
50
50
|
"packageManager": "yarn@3.2.2",
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@babel/core": "^7.
|
|
53
|
-
"@babel/eslint-parser": "^7.
|
|
54
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
55
|
-
"@babel/plugin-syntax-flow": "^7.
|
|
56
|
-
"@babel/plugin-transform-react-jsx": "^7.
|
|
57
|
-
"@babel/plugin-transform-runtime": "^7.10
|
|
58
|
-
"@babel/preset-env": "^7.10
|
|
59
|
-
"@babel/preset-flow": "^7.
|
|
60
|
-
"@babel/preset-react": "^7.
|
|
61
|
-
"@babel/register": "^7.
|
|
62
|
-
"@babel/runtime": "^7.
|
|
63
|
-
"@rollup/plugin-alias": "^3.1.
|
|
64
|
-
"@rollup/plugin-babel": "^5.
|
|
65
|
-
"@semantic-release/changelog": "^6.0.
|
|
66
|
-
"@semantic-release/git": "^10.0.
|
|
67
|
-
"babel-jest": "^
|
|
68
|
-
"babel-loader": "^8.
|
|
69
|
-
"babel-plugin-istanbul": "^6.
|
|
70
|
-
"babel-plugin-preval": "^5.
|
|
52
|
+
"@babel/core": "^7.18.13",
|
|
53
|
+
"@babel/eslint-parser": "^7.18.9",
|
|
54
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
55
|
+
"@babel/plugin-syntax-flow": "^7.18.6",
|
|
56
|
+
"@babel/plugin-transform-react-jsx": "^7.18.10",
|
|
57
|
+
"@babel/plugin-transform-runtime": "^7.18.10",
|
|
58
|
+
"@babel/preset-env": "^7.18.10",
|
|
59
|
+
"@babel/preset-flow": "^7.18.6",
|
|
60
|
+
"@babel/preset-react": "^7.18.6",
|
|
61
|
+
"@babel/register": "^7.18.9",
|
|
62
|
+
"@babel/runtime": "^7.18.9",
|
|
63
|
+
"@rollup/plugin-alias": "^3.1.9",
|
|
64
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
65
|
+
"@semantic-release/changelog": "^6.0.1",
|
|
66
|
+
"@semantic-release/git": "^10.0.1",
|
|
67
|
+
"babel-jest": "^29.0.1",
|
|
68
|
+
"babel-loader": "^8.2.5",
|
|
69
|
+
"babel-plugin-istanbul": "^6.1.1",
|
|
70
|
+
"babel-plugin-preval": "^5.1.0",
|
|
71
71
|
"babel-plugin-version-inline": "^1.0.0",
|
|
72
72
|
"benchmark": "^2.1.4",
|
|
73
|
-
"browserslist": "^4.
|
|
74
|
-
"browserstack-local": "^1.
|
|
75
|
-
"caniuse-lite": "^1.0.
|
|
76
|
-
"css-loader": "^6.
|
|
77
|
-
"cssnano": "^5.
|
|
78
|
-
"eslint": "^8.
|
|
73
|
+
"browserslist": "^4.21.3",
|
|
74
|
+
"browserstack-local": "^1.5.1",
|
|
75
|
+
"caniuse-lite": "^1.0.30001384",
|
|
76
|
+
"css-loader": "^6.7.1",
|
|
77
|
+
"cssnano": "^5.1.13",
|
|
78
|
+
"eslint": "^8.23.0",
|
|
79
79
|
"eslint-import-resolver-webpack": "^0.13.2",
|
|
80
80
|
"eslint-plugin-actions": "^2.0.0",
|
|
81
|
-
"eslint-plugin-flowtype": "^8.0.
|
|
82
|
-
"eslint-plugin-import": "^2.
|
|
83
|
-
"eslint-plugin-react": "^7.
|
|
81
|
+
"eslint-plugin-flowtype": "^8.0.3",
|
|
82
|
+
"eslint-plugin-import": "^2.26.0",
|
|
83
|
+
"eslint-plugin-react": "^7.31.1",
|
|
84
84
|
"flow-bin": "^0.135.0",
|
|
85
|
-
"fs-extra": "^10.
|
|
86
|
-
"got": "^11.8.
|
|
87
|
-
"husky": "^4.
|
|
88
|
-
"istanbul-lib-coverage": "^3.
|
|
85
|
+
"fs-extra": "^10.1.0",
|
|
86
|
+
"got": "^11.8.5",
|
|
87
|
+
"husky": "^4.3.8",
|
|
88
|
+
"istanbul-lib-coverage": "^3.2.0",
|
|
89
89
|
"istanbul-lib-report": "^3.0.0",
|
|
90
|
-
"istanbul-reports": "^3.
|
|
91
|
-
"jest": "^
|
|
92
|
-
"jest-diff": "^
|
|
93
|
-
"jest-
|
|
94
|
-
"jest-
|
|
95
|
-
"jest-
|
|
96
|
-
"
|
|
90
|
+
"istanbul-reports": "^3.1.5",
|
|
91
|
+
"jest": "^29.0.1",
|
|
92
|
+
"jest-diff": "^29.0.1",
|
|
93
|
+
"jest-environment-jsdom": "^29.0.1",
|
|
94
|
+
"jest-matcher-utils": "^29.0.1",
|
|
95
|
+
"jest-message-util": "^29.0.1",
|
|
96
|
+
"jest-serializer-html": "^7.1.0",
|
|
97
|
+
"js-yaml": "^4.1.0",
|
|
97
98
|
"json-stable-stringify": "^1.0.1",
|
|
98
99
|
"jspngopt": "^0.2.0",
|
|
99
|
-
"less": "^4.
|
|
100
|
-
"less-loader": "^
|
|
101
|
-
"mini-css-extract-plugin": "^2.
|
|
100
|
+
"less": "^4.1.3",
|
|
101
|
+
"less-loader": "^11.0.0",
|
|
102
|
+
"mini-css-extract-plugin": "^2.6.1",
|
|
102
103
|
"mkdirp": "^1.0.4",
|
|
103
|
-
"p-retry": "^4.6.
|
|
104
|
-
"pako": "^2.0.
|
|
105
|
-
"postcss": "^8.
|
|
104
|
+
"p-retry": "^4.6.2",
|
|
105
|
+
"pako": "^2.0.4",
|
|
106
|
+
"postcss": "^8.4.16",
|
|
106
107
|
"postcss-less": "^6.0.0",
|
|
107
|
-
"postcss-loader": "^
|
|
108
|
-
"postcss-preset-env": "^7.
|
|
109
|
-
"prettier": "^2.
|
|
110
|
-
"query-string": "^7.
|
|
108
|
+
"postcss-loader": "^7.0.1",
|
|
109
|
+
"postcss-preset-env": "^7.8.0",
|
|
110
|
+
"prettier": "^2.7.1",
|
|
111
|
+
"query-string": "^7.1.1",
|
|
111
112
|
"rimraf": "^3.0.2",
|
|
112
|
-
"rollup": "^2.
|
|
113
|
-
"selenium-webdriver": "^4.
|
|
114
|
-
"semantic-release": "^
|
|
113
|
+
"rollup": "^2.78.1",
|
|
114
|
+
"selenium-webdriver": "^4.4.0",
|
|
115
|
+
"semantic-release": "^19.0.5",
|
|
115
116
|
"sri-toolbox": "^0.2.0",
|
|
116
|
-
"style-loader": "^3.
|
|
117
|
-
"stylelint": "^14.
|
|
118
|
-
"stylelint-config-standard": "^
|
|
119
|
-
"terser-webpack-plugin": "^5.
|
|
120
|
-
"webpack": "^5.
|
|
121
|
-
"webpack-bundle-analyzer": "^4.
|
|
122
|
-
"webpack-cli": "^4.
|
|
123
|
-
"webpack-dev-server": "^4.
|
|
117
|
+
"style-loader": "^3.3.1",
|
|
118
|
+
"stylelint": "^14.11.0",
|
|
119
|
+
"stylelint-config-standard": "^28.0.0",
|
|
120
|
+
"terser-webpack-plugin": "^5.3.6",
|
|
121
|
+
"webpack": "^5.74.0",
|
|
122
|
+
"webpack-bundle-analyzer": "^4.6.1",
|
|
123
|
+
"webpack-cli": "^4.10.0",
|
|
124
|
+
"webpack-dev-server": "^4.10.1"
|
|
124
125
|
},
|
|
125
126
|
"bin": "cli.js",
|
|
126
127
|
"scripts": {
|
|
@@ -150,7 +151,7 @@
|
|
|
150
151
|
"dist:zip": "rimraf katex/ katex.tar.gz katex.zip && cp -R dist katex && tar czf katex.tar.gz katex && zip -rq katex.zip katex && rimraf katex/"
|
|
151
152
|
},
|
|
152
153
|
"dependencies": {
|
|
153
|
-
"commander": "^8.
|
|
154
|
+
"commander": "^8.3.0"
|
|
154
155
|
},
|
|
155
156
|
"husky": {
|
|
156
157
|
"hooks": {
|
|
@@ -173,7 +174,9 @@
|
|
|
173
174
|
"testMatch": [
|
|
174
175
|
"**/test/*-spec.js"
|
|
175
176
|
],
|
|
176
|
-
"
|
|
177
|
+
"testEnvironmentOptions": {
|
|
178
|
+
"url": "http://localhost/"
|
|
179
|
+
},
|
|
177
180
|
"transform": {
|
|
178
181
|
"^.+\\.js$": "babel-jest"
|
|
179
182
|
},
|
package/src/MacroExpander.js
CHANGED
|
@@ -249,22 +249,22 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
249
249
|
* Expand the next token only once if possible.
|
|
250
250
|
*
|
|
251
251
|
* If the token is expanded, the resulting tokens will be pushed onto
|
|
252
|
-
* the stack in reverse order and
|
|
253
|
-
*
|
|
252
|
+
* the stack in reverse order, and the number of such tokens will be
|
|
253
|
+
* returned. This number might be zero or positive.
|
|
254
254
|
*
|
|
255
|
-
* If not, the
|
|
256
|
-
*
|
|
257
|
-
* instead of an `Array` return value.
|
|
255
|
+
* If not, the return value is `false`, and the next token remains at the
|
|
256
|
+
* top of the stack.
|
|
258
257
|
*
|
|
259
258
|
* In either case, the next token will be on the top of the stack,
|
|
260
|
-
* or the stack will be empty
|
|
259
|
+
* or the stack will be empty (in case of empty expansion
|
|
260
|
+
* and no other tokens).
|
|
261
261
|
*
|
|
262
262
|
* Used to implement `expandAfterFuture` and `expandNextToken`.
|
|
263
263
|
*
|
|
264
264
|
* If expandableOnly, only expandable tokens are expanded and
|
|
265
265
|
* an undefined control sequence results in an error.
|
|
266
266
|
*/
|
|
267
|
-
expandOnce(expandableOnly?: boolean):
|
|
267
|
+
expandOnce(expandableOnly?: boolean): number | boolean {
|
|
268
268
|
const topToken = this.popToken();
|
|
269
269
|
const name = topToken.text;
|
|
270
270
|
const expansion = !topToken.noexpand ? this._getExpansion(name) : null;
|
|
@@ -274,7 +274,7 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
274
274
|
throw new ParseError("Undefined control sequence: " + name);
|
|
275
275
|
}
|
|
276
276
|
this.pushToken(topToken);
|
|
277
|
-
return
|
|
277
|
+
return false;
|
|
278
278
|
}
|
|
279
279
|
this.expansionCount++;
|
|
280
280
|
if (this.expansionCount > this.settings.maxExpand) {
|
|
@@ -310,7 +310,7 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
310
310
|
}
|
|
311
311
|
// Concatenate expansion onto top of stack.
|
|
312
312
|
this.pushTokens(tokens);
|
|
313
|
-
return tokens;
|
|
313
|
+
return tokens.length;
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
/**
|
|
@@ -329,15 +329,14 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
329
329
|
*/
|
|
330
330
|
expandNextToken(): Token {
|
|
331
331
|
for (;;) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if (expanded instanceof Token) {
|
|
332
|
+
if (this.expandOnce() === false) { // fully expanded
|
|
333
|
+
const token = this.stack.pop();
|
|
335
334
|
// the token after \noexpand is interpreted as if its meaning
|
|
336
335
|
// were ‘\relax’
|
|
337
|
-
if (
|
|
338
|
-
|
|
336
|
+
if (token.treatAsRelax) {
|
|
337
|
+
token.text = "\\relax";
|
|
339
338
|
}
|
|
340
|
-
return
|
|
339
|
+
return token;
|
|
341
340
|
}
|
|
342
341
|
}
|
|
343
342
|
|
|
@@ -365,15 +364,15 @@ export default class MacroExpander implements MacroContextInterface {
|
|
|
365
364
|
const oldStackLength = this.stack.length;
|
|
366
365
|
this.pushTokens(tokens);
|
|
367
366
|
while (this.stack.length > oldStackLength) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (
|
|
367
|
+
// Expand only expandable tokens
|
|
368
|
+
if (this.expandOnce(true) === false) { // fully expanded
|
|
369
|
+
const token = this.stack.pop();
|
|
370
|
+
if (token.treatAsRelax) {
|
|
372
371
|
// the expansion of \noexpand is the token itself
|
|
373
|
-
|
|
374
|
-
|
|
372
|
+
token.noexpand = false;
|
|
373
|
+
token.treatAsRelax = false;
|
|
375
374
|
}
|
|
376
|
-
output.push(
|
|
375
|
+
output.push(token);
|
|
377
376
|
}
|
|
378
377
|
}
|
|
379
378
|
return output;
|
package/src/Parser.js
CHANGED
|
@@ -178,7 +178,7 @@ export default class Parser {
|
|
|
178
178
|
* Parses an "expression", which is a list of atoms.
|
|
179
179
|
*
|
|
180
180
|
* `breakOnInfix`: Should the parsing stop when we hit infix nodes? This
|
|
181
|
-
* happens when functions have higher
|
|
181
|
+
* happens when functions have higher precedence han infix
|
|
182
182
|
* nodes in implicit parses.
|
|
183
183
|
*
|
|
184
184
|
* `breakOnTokenText`: The text of the token that the expression should end
|
package/src/buildMathML.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
/**
|
|
3
|
-
* This file converts a parse tree into a
|
|
3
|
+
* This file converts a parse tree into a corresponding MathML tree. The main
|
|
4
4
|
* entry point is the `buildMathML` function, which takes a parse tree from the
|
|
5
5
|
* parser.
|
|
6
6
|
*/
|
|
@@ -101,7 +101,7 @@ export const getVariant = function(
|
|
|
101
101
|
} else if (font === "mathfrak") {
|
|
102
102
|
return "fraktur";
|
|
103
103
|
} else if (font === "mathscr" || font === "mathcal") {
|
|
104
|
-
// MathML makes no distinction between script and
|
|
104
|
+
// MathML makes no distinction between script and calligraphic
|
|
105
105
|
return "script";
|
|
106
106
|
} else if (font === "mathsf") {
|
|
107
107
|
return "sans-serif";
|
package/src/defineEnvironment.js
CHANGED
|
@@ -42,7 +42,7 @@ type EnvProps = {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* Final
|
|
45
|
+
* Final environment spec for use at parse time.
|
|
46
46
|
* This is almost identical to `EnvDefSpec`, except it
|
|
47
47
|
* 1. includes the function handler
|
|
48
48
|
* 2. requires all arguments except argType
|
package/src/defineMacro.js
CHANGED
|
@@ -35,7 +35,7 @@ export interface MacroContextInterface {
|
|
|
35
35
|
/**
|
|
36
36
|
* Expand the next token only once if possible.
|
|
37
37
|
*/
|
|
38
|
-
expandOnce(expandableOnly?: boolean):
|
|
38
|
+
expandOnce(expandableOnly?: boolean): number | boolean;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Expand the next token only once (if possible), and return the resulting
|
package/src/delimiter.js
CHANGED
|
@@ -364,7 +364,7 @@ const makeStackedDelim = function(
|
|
|
364
364
|
middleFactor = 2; // repeat symmetrically above and below middle
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
//
|
|
367
|
+
// Calculate the minimal height that the delimiter can have.
|
|
368
368
|
// It is at least the size of the top, bottom, and optional middle combined.
|
|
369
369
|
const minHeight = topHeightTotal + bottomHeightTotal + middleHeightTotal;
|
|
370
370
|
|
|
@@ -453,7 +453,7 @@ const makeStackedDelim = function(
|
|
|
453
453
|
Style.TEXT, options, classes);
|
|
454
454
|
};
|
|
455
455
|
|
|
456
|
-
// All surds have 0.08em padding above the
|
|
456
|
+
// All surds have 0.08em padding above the vinculum inside the SVG.
|
|
457
457
|
// That keeps browser span height rounding error from pinching the line.
|
|
458
458
|
const vbPad = 80; // padding above the surd, measured inside the viewBox.
|
|
459
459
|
const emPad = 0.08; // padding, in ems, measured in the document.
|
|
@@ -462,10 +462,10 @@ const sqrtSvg = function(
|
|
|
462
462
|
sqrtName: string,
|
|
463
463
|
height: number,
|
|
464
464
|
viewBoxHeight: number,
|
|
465
|
-
|
|
465
|
+
extraVinculum: number,
|
|
466
466
|
options: Options,
|
|
467
467
|
): SvgSpan {
|
|
468
|
-
const path = sqrtPath(sqrtName,
|
|
468
|
+
const path = sqrtPath(sqrtName, extraVinculum, viewBoxHeight);
|
|
469
469
|
const pathNode = new PathNode(sqrtName, path);
|
|
470
470
|
|
|
471
471
|
const svg = new SvgNode([pathNode], {
|
|
@@ -500,9 +500,9 @@ const makeSqrtImage = function(
|
|
|
500
500
|
|
|
501
501
|
let sizeMultiplier = newOptions.sizeMultiplier; // default
|
|
502
502
|
|
|
503
|
-
// The standard sqrt SVGs each have a 0.04em thick
|
|
504
|
-
// If Settings.minRuleThickness is larger than that, we add
|
|
505
|
-
const
|
|
503
|
+
// The standard sqrt SVGs each have a 0.04em thick vinculum.
|
|
504
|
+
// If Settings.minRuleThickness is larger than that, we add extraVinculum.
|
|
505
|
+
const extraVinculum = Math.max(0,
|
|
506
506
|
options.minRuleThickness - options.fontMetrics().sqrtRuleThickness);
|
|
507
507
|
|
|
508
508
|
// Create a span containing an SVG image of a sqrt symbol.
|
|
@@ -514,22 +514,22 @@ const makeSqrtImage = function(
|
|
|
514
514
|
|
|
515
515
|
// We create viewBoxes with 80 units of "padding" above each surd.
|
|
516
516
|
// Then browser rounding error on the parent span height will not
|
|
517
|
-
// encroach on the ink of the
|
|
517
|
+
// encroach on the ink of the vinculum. But that padding is not
|
|
518
518
|
// included in the TeX-like `height` used for calculation of
|
|
519
519
|
// vertical alignment. So texHeight = span.height < span.style.height.
|
|
520
520
|
|
|
521
521
|
if (delim.type === "small") {
|
|
522
522
|
// Get an SVG that is derived from glyph U+221A in font KaTeX-Main.
|
|
523
523
|
// 1000 unit normal glyph height.
|
|
524
|
-
viewBoxHeight = 1000 + 1000 *
|
|
524
|
+
viewBoxHeight = 1000 + 1000 * extraVinculum + vbPad;
|
|
525
525
|
if (height < 1.0) {
|
|
526
526
|
sizeMultiplier = 1.0; // mimic a \textfont radical
|
|
527
527
|
} else if (height < 1.4) {
|
|
528
528
|
sizeMultiplier = 0.7; // mimic a \scriptfont radical
|
|
529
529
|
}
|
|
530
|
-
spanHeight = (1.0 +
|
|
531
|
-
texHeight = (1.00 +
|
|
532
|
-
span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight,
|
|
530
|
+
spanHeight = (1.0 + extraVinculum + emPad) / sizeMultiplier;
|
|
531
|
+
texHeight = (1.00 + extraVinculum) / sizeMultiplier;
|
|
532
|
+
span = sqrtSvg("sqrtMain", spanHeight, viewBoxHeight, extraVinculum,
|
|
533
533
|
options);
|
|
534
534
|
span.style.minWidth = "0.853em";
|
|
535
535
|
advanceWidth = 0.833 / sizeMultiplier; // from the font.
|
|
@@ -537,21 +537,21 @@ const makeSqrtImage = function(
|
|
|
537
537
|
} else if (delim.type === "large") {
|
|
538
538
|
// These SVGs come from fonts: KaTeX_Size1, _Size2, etc.
|
|
539
539
|
viewBoxHeight = (1000 + vbPad) * sizeToMaxHeight[delim.size];
|
|
540
|
-
texHeight = (sizeToMaxHeight[delim.size] +
|
|
541
|
-
spanHeight = (sizeToMaxHeight[delim.size] +
|
|
540
|
+
texHeight = (sizeToMaxHeight[delim.size] + extraVinculum) / sizeMultiplier;
|
|
541
|
+
spanHeight = (sizeToMaxHeight[delim.size] + extraVinculum + emPad)
|
|
542
542
|
/ sizeMultiplier;
|
|
543
543
|
span = sqrtSvg("sqrtSize" + delim.size, spanHeight, viewBoxHeight,
|
|
544
|
-
|
|
544
|
+
extraVinculum, options);
|
|
545
545
|
span.style.minWidth = "1.02em";
|
|
546
546
|
advanceWidth = 1.0 / sizeMultiplier; // 1.0 from the font.
|
|
547
547
|
|
|
548
548
|
} else {
|
|
549
549
|
// Tall sqrt. In TeX, this would be stacked using multiple glyphs.
|
|
550
550
|
// We'll use a single SVG to accomplish the same thing.
|
|
551
|
-
spanHeight = height +
|
|
552
|
-
texHeight = height +
|
|
553
|
-
viewBoxHeight = Math.floor(1000 * height +
|
|
554
|
-
span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight,
|
|
551
|
+
spanHeight = height + extraVinculum + emPad;
|
|
552
|
+
texHeight = height + extraVinculum;
|
|
553
|
+
viewBoxHeight = Math.floor(1000 * height + extraVinculum) + vbPad;
|
|
554
|
+
span = sqrtSvg("sqrtTall", spanHeight, viewBoxHeight, extraVinculum,
|
|
555
555
|
options);
|
|
556
556
|
span.style.minWidth = "0.742em";
|
|
557
557
|
advanceWidth = 1.056;
|
|
@@ -567,7 +567,7 @@ const makeSqrtImage = function(
|
|
|
567
567
|
// This actually should depend on the chosen font -- e.g. \boldmath
|
|
568
568
|
// should use the thicker surd symbols from e.g. KaTeX_Main-Bold, and
|
|
569
569
|
// have thicker rules.
|
|
570
|
-
ruleWidth: (options.fontMetrics().sqrtRuleThickness +
|
|
570
|
+
ruleWidth: (options.fontMetrics().sqrtRuleThickness + extraVinculum)
|
|
571
571
|
* sizeMultiplier,
|
|
572
572
|
};
|
|
573
573
|
};
|
|
@@ -573,8 +573,8 @@ const mathmlBuilder: MathMLBuilder<"array"> = function(group, options) {
|
|
|
573
573
|
// We simulate this by adding (arraystretch - 1)em to the gap. This
|
|
574
574
|
// does a reasonable job of adjusting arrays containing 1 em tall content.
|
|
575
575
|
|
|
576
|
-
// The 0.16 and 0.09 values are found
|
|
577
|
-
// similar to LaTeX and in which content does not interfere with \
|
|
576
|
+
// The 0.16 and 0.09 values are found empirically. They produce an array
|
|
577
|
+
// similar to LaTeX and in which content does not interfere with \hlines.
|
|
578
578
|
const gap = (group.arraystretch === 0.5)
|
|
579
579
|
? 0.1 // {smallmatrix}, {subarray}
|
|
580
580
|
: 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
|
package/src/fontMetrics.js
CHANGED
|
@@ -13,9 +13,9 @@ import type {Mode} from "./types";
|
|
|
13
13
|
// In TeX, there are actually three sets of dimensions, one for each of
|
|
14
14
|
// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
|
|
15
15
|
// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
|
|
16
|
-
// provided in the
|
|
16
|
+
// provided in the arrays below, in that order.
|
|
17
17
|
//
|
|
18
|
-
// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5
|
|
18
|
+
// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respectively.
|
|
19
19
|
// This was determined by running the following script:
|
|
20
20
|
//
|
|
21
21
|
// latex -interaction=nonstopmode \
|
|
@@ -25,7 +25,7 @@ import type {Mode} from "./types";
|
|
|
25
25
|
// '\expandafter\show\the\scriptscriptfont2' \
|
|
26
26
|
// '\stop'
|
|
27
27
|
//
|
|
28
|
-
// The metrics themselves were
|
|
28
|
+
// The metrics themselves were retrieved using the following commands:
|
|
29
29
|
//
|
|
30
30
|
// tftopl cmsy10
|
|
31
31
|
// tftopl cmsy7
|
|
@@ -230,7 +230,7 @@ export function getCharacterMetrics(
|
|
|
230
230
|
// So if the character is in a script we support but we
|
|
231
231
|
// don't have metrics for it, just use the metrics for
|
|
232
232
|
// the Latin capital letter M. This is close enough because
|
|
233
|
-
// we (currently) only care about the height of the
|
|
233
|
+
// we (currently) only care about the height of the glyph
|
|
234
234
|
// not its width.
|
|
235
235
|
if (supportedCodepoint(ch)) {
|
|
236
236
|
metrics = metricMap[font][77]; // 77 is the charcode for 'M'
|
package/src/functions/arrow.js
CHANGED
|
@@ -47,7 +47,7 @@ defineFunction({
|
|
|
47
47
|
};
|
|
48
48
|
},
|
|
49
49
|
// Flow is unable to correctly infer the type of `group`, even though it's
|
|
50
|
-
//
|
|
50
|
+
// unambiguously determined from the passed-in `type` above.
|
|
51
51
|
htmlBuilder(group: ParseNode<"xArrow">, options) {
|
|
52
52
|
const style = options.style;
|
|
53
53
|
|
|
@@ -342,7 +342,7 @@ defineFunction({
|
|
|
342
342
|
return middleDelim;
|
|
343
343
|
},
|
|
344
344
|
mathmlBuilder: (group, options) => {
|
|
345
|
-
// A Firefox \middle will
|
|
345
|
+
// A Firefox \middle will stretch a character vertically only if it
|
|
346
346
|
// is in the fence part of the operator dictionary at:
|
|
347
347
|
// https://www.w3.org/TR/MathML3/appendixc.html.
|
|
348
348
|
// So we need to avoid U+2223 and use plain "|" instead.
|
package/src/katex.less
CHANGED
package/src/mathMLTree.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* since we're mainly using MathML to improve accessibility, we don't manage
|
|
6
6
|
* any of the styling state that the plain DOM nodes do.
|
|
7
7
|
*
|
|
8
|
-
* The `toNode` and `toMarkup` functions work
|
|
8
|
+
* The `toNode` and `toMarkup` functions work similarly to how they do in
|
|
9
9
|
* domTree.js, creating namespaced DOM nodes and HTML text markup respectively.
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -166,7 +166,7 @@ export class TextNode implements MathDomNode {
|
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
168
|
* Converts the text node into a string
|
|
169
|
-
* (representing the text
|
|
169
|
+
* (representing the text itself).
|
|
170
170
|
*/
|
|
171
171
|
toText(): string {
|
|
172
172
|
return this.text;
|
package/src/parseNode.js
CHANGED
|
@@ -72,7 +72,7 @@ type ParseNodeTypes = {
|
|
|
72
72
|
|},
|
|
73
73
|
// To avoid requiring run-time type assertions, this more carefully captures
|
|
74
74
|
// the requirements on the fields per the op.js htmlBuilder logic:
|
|
75
|
-
// - `body` and `value` are NEVER set
|
|
75
|
+
// - `body` and `value` are NEVER set simultaneously.
|
|
76
76
|
// - When `symbol` is true, `body` is set.
|
|
77
77
|
"op": {|
|
|
78
78
|
type: "op",
|