katex 0.13.22 → 0.14.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 +5 -5
- package/cli.js +17 -46
- package/contrib/copy-tex/README.md +3 -3
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +5 -5
- package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/katex.css +1 -1
- package/dist/katex.js +1769 -1614
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +2222 -2093
- package/katex.js +5 -1
- package/package.json +34 -1
- package/src/Settings.js +183 -32
- package/src/buildCommon.js +12 -12
- package/src/buildHTML.js +5 -4
- package/src/delimiter.js +11 -10
- package/src/domTree.js +2 -1
- package/src/environments/array.js +9 -9
- package/src/environments/cd.js +2 -1
- package/src/fontMetricsData.js +2 -1
- package/src/fonts/makeFF +2 -0
- package/src/functions/accent.js +4 -3
- package/src/functions/cr.js +3 -3
- package/src/functions/delimsizing.js +4 -2
- package/src/functions/enclose.js +7 -7
- package/src/functions/genfrac.js +2 -2
- package/src/functions/includegraphics.js +7 -9
- package/src/functions/lap.js +3 -2
- package/src/functions/op.js +2 -1
- package/src/functions/rule.js +10 -10
- package/src/functions/sizing.js +2 -1
- package/src/functions/sqrt.js +2 -1
- package/src/functions/supsub.js +3 -2
- package/src/functions/utils/assembleSupSub.js +6 -5
- package/src/macros.js +3 -2
- package/src/mathMLTree.js +3 -2
- package/src/metrics/extract_ttfs.py +3 -0
- package/src/stretchy.js +8 -7
- package/src/units.js +8 -0
package/katex.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import ParseError from "./src/ParseError";
|
|
12
|
-
import Settings from "./src/Settings";
|
|
12
|
+
import Settings, {SETTINGS_SCHEMA} from "./src/Settings";
|
|
13
13
|
|
|
14
14
|
import {buildTree, buildHTMLTree} from "./src/buildTree";
|
|
15
15
|
import parseTree from "./src/parseTree";
|
|
@@ -156,6 +156,10 @@ export default {
|
|
|
156
156
|
* KaTeX error, usually during parsing.
|
|
157
157
|
*/
|
|
158
158
|
ParseError,
|
|
159
|
+
/**
|
|
160
|
+
* The shema of Settings
|
|
161
|
+
*/
|
|
162
|
+
SETTINGS_SCHEMA,
|
|
159
163
|
/**
|
|
160
164
|
* Parses the given LaTeX into KaTeX's internal parse tree structure,
|
|
161
165
|
* without rendering to HTML or MathML.
|
package/package.json
CHANGED
|
@@ -1,13 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "katex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "Fast math typesetting for the web.",
|
|
5
5
|
"main": "dist/katex.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"require": "./dist/katex.js",
|
|
9
|
+
"import": "./dist/katex.mjs"
|
|
10
|
+
},
|
|
11
|
+
"./contrib/auto-render": {
|
|
12
|
+
"require": "./dist/contrib/auto-render.js",
|
|
13
|
+
"import": "./dist/contrib/auto-render.mjs"
|
|
14
|
+
},
|
|
15
|
+
"./contrib/mhchem": {
|
|
16
|
+
"require": "./dist/contrib/mhchem.js",
|
|
17
|
+
"import": "./dist/contrib/mhchem.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./contrib/copy-tex": {
|
|
20
|
+
"require": "./dist/contrib/copy-tex.js",
|
|
21
|
+
"import": "./dist/contrib/copy-tex.mjs"
|
|
22
|
+
},
|
|
23
|
+
"./contrib/mathtex-script-type": {
|
|
24
|
+
"require": "./dist/contrib/mathtex-script-type.js",
|
|
25
|
+
"import": "./dist/contrib/mathtex-script-type.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./contrib/render-a11y-string": {
|
|
28
|
+
"require": "./dist/contrib/render-a11y-string.js",
|
|
29
|
+
"import": "./dist/contrib/render-a11y-string.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./*": "./*"
|
|
32
|
+
},
|
|
6
33
|
"homepage": "https://katex.org",
|
|
7
34
|
"repository": {
|
|
8
35
|
"type": "git",
|
|
9
36
|
"url": "https://github.com/KaTeX/KaTeX.git"
|
|
10
37
|
},
|
|
38
|
+
"funding": [
|
|
39
|
+
"https://opencollective.com/katex",
|
|
40
|
+
"https://github.com/sponsors/katex"
|
|
41
|
+
],
|
|
11
42
|
"files": [
|
|
12
43
|
"katex.js",
|
|
13
44
|
"cli.js",
|
|
@@ -45,8 +76,10 @@
|
|
|
45
76
|
"css-loader": "^6.0.0",
|
|
46
77
|
"cssnano": "^5.0.0-rc.1",
|
|
47
78
|
"eslint": "^8.0.0",
|
|
79
|
+
"eslint-import-resolver-webpack": "^0.13.2",
|
|
48
80
|
"eslint-plugin-actions": "^2.0.0",
|
|
49
81
|
"eslint-plugin-flowtype": "^8.0.0",
|
|
82
|
+
"eslint-plugin-import": "^2.25.2",
|
|
50
83
|
"eslint-plugin-react": "^7.20.3",
|
|
51
84
|
"flow-bin": "^0.135.0",
|
|
52
85
|
"fs-extra": "^10.0.0",
|
package/src/Settings.js
CHANGED
|
@@ -52,23 +52,180 @@ export type TrustContextTypes = {
|
|
|
52
52
|
export type AnyTrustContext = $Values<TrustContextTypes>;
|
|
53
53
|
export type TrustFunction = (context: AnyTrustContext) => ?boolean;
|
|
54
54
|
|
|
55
|
-
export type SettingsOptions =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
export type SettingsOptions = $Shape<Settings>;
|
|
56
|
+
|
|
57
|
+
type EnumType = {| enum: string[] |};
|
|
58
|
+
type Type = "boolean" | "string" | "number" | "object" | "function" | EnumType;
|
|
59
|
+
type Schema = {
|
|
60
|
+
[$Keys<SettingsOptions>]: {
|
|
61
|
+
/**
|
|
62
|
+
* Allowed type(s) of the value.
|
|
63
|
+
*/
|
|
64
|
+
type: Type | Type[];
|
|
65
|
+
/**
|
|
66
|
+
* The default value. If not specified, false for boolean, an empty string
|
|
67
|
+
* for string, 0 for number, an empty object for object, or the first item
|
|
68
|
+
* for enum will be used. If multiple types are allowed, the first allowed
|
|
69
|
+
* type will be used for determining the default value.
|
|
70
|
+
*/
|
|
71
|
+
default?: any;
|
|
72
|
+
/**
|
|
73
|
+
* The description.
|
|
74
|
+
*/
|
|
75
|
+
description?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The function to process the option.
|
|
78
|
+
*/
|
|
79
|
+
processor?: (any) => any,
|
|
80
|
+
/**
|
|
81
|
+
* The command line argument. See Commander.js docs for more information.
|
|
82
|
+
* If not specified, the name prefixed with -- will be used. Set false not
|
|
83
|
+
* to add to the CLI.
|
|
84
|
+
*/
|
|
85
|
+
cli?: string | false;
|
|
86
|
+
/**
|
|
87
|
+
* The default value for the CLI.
|
|
88
|
+
*/
|
|
89
|
+
cliDefault?: any;
|
|
90
|
+
/**
|
|
91
|
+
* The description for the CLI. If not specified, the description for the
|
|
92
|
+
* option will be used.
|
|
93
|
+
*/
|
|
94
|
+
cliDescription?: string;
|
|
95
|
+
/**
|
|
96
|
+
* The custom argument processor for the CLI. See Commander.js docs for
|
|
97
|
+
* more information.
|
|
98
|
+
*/
|
|
99
|
+
cliProcessor?: (any, any) => any;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// TODO: automatically generate documentation
|
|
104
|
+
// TODO: check all properties on Settings exist
|
|
105
|
+
// TODO: check the type of a property on Settings matches
|
|
106
|
+
export const SETTINGS_SCHEMA: Schema = {
|
|
107
|
+
displayMode: {
|
|
108
|
+
type: "boolean",
|
|
109
|
+
description: "Render math in display mode, which puts the math in " +
|
|
110
|
+
"display style (so \\int and \\sum are large, for example), and " +
|
|
111
|
+
"centers the math on the page on its own line.",
|
|
112
|
+
cli: "-d, --display-mode",
|
|
113
|
+
},
|
|
114
|
+
output: {
|
|
115
|
+
type: {enum: ["htmlAndMathml", "html", "mathml"]},
|
|
116
|
+
description: "Determines the markup language of the output.",
|
|
117
|
+
cli: "-F, --format <type>",
|
|
118
|
+
},
|
|
119
|
+
leqno: {
|
|
120
|
+
type: "boolean",
|
|
121
|
+
description: "Render display math in leqno style (left-justified tags).",
|
|
122
|
+
},
|
|
123
|
+
fleqn: {
|
|
124
|
+
type: "boolean",
|
|
125
|
+
description: "Render display math flush left.",
|
|
126
|
+
},
|
|
127
|
+
throwOnError: {
|
|
128
|
+
type: "boolean",
|
|
129
|
+
default: true,
|
|
130
|
+
cli: "-t, --no-throw-on-error",
|
|
131
|
+
cliDescription: "Render errors (in the color given by --error-color) ins" +
|
|
132
|
+
"tead of throwing a ParseError exception when encountering an error.",
|
|
133
|
+
},
|
|
134
|
+
errorColor: {
|
|
135
|
+
type: "string",
|
|
136
|
+
default: "#cc0000",
|
|
137
|
+
cli: "-c, --error-color <color>",
|
|
138
|
+
cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " +
|
|
139
|
+
"(no #). This option determines the color of errors rendered by the " +
|
|
140
|
+
"-t option.",
|
|
141
|
+
cliProcessor: (color) => "#" + color,
|
|
142
|
+
},
|
|
143
|
+
macros: {
|
|
144
|
+
type: "object",
|
|
145
|
+
cli: "-m, --macro <def>",
|
|
146
|
+
cliDescription: "Define custom macro of the form '\\foo:expansion' (use " +
|
|
147
|
+
"multiple -m arguments for multiple macros).",
|
|
148
|
+
cliDefault: [],
|
|
149
|
+
cliProcessor: (def, defs) => {
|
|
150
|
+
defs.push(def);
|
|
151
|
+
return defs;
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
minRuleThickness: {
|
|
155
|
+
type: "number",
|
|
156
|
+
description: "Specifies a minimum thickness, in ems, for fraction lines," +
|
|
157
|
+
" `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " +
|
|
158
|
+
"`\\hdashline`, `\\underline`, `\\overline`, and the borders of " +
|
|
159
|
+
"`\\fbox`, `\\boxed`, and `\\fcolorbox`.",
|
|
160
|
+
processor: (t) => Math.max(0, t),
|
|
161
|
+
cli: "--min-rule-thickness <size>",
|
|
162
|
+
cliProcessor: parseFloat,
|
|
163
|
+
},
|
|
164
|
+
colorIsTextColor: {
|
|
165
|
+
type: "boolean",
|
|
166
|
+
description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " +
|
|
167
|
+
"instead of LaTeX's one-argument \\color mode change.",
|
|
168
|
+
cli: "-b, --color-is-text-color",
|
|
169
|
+
},
|
|
170
|
+
strict: {
|
|
171
|
+
type: [{enum: ["warn", "ignore", "error"]}, "boolean", "function"],
|
|
172
|
+
description: "Turn on strict / LaTeX faithfulness mode, which throws an " +
|
|
173
|
+
"error if the input uses features that are not supported by LaTeX.",
|
|
174
|
+
cli: "-S, --strict",
|
|
175
|
+
cliDefault: false,
|
|
176
|
+
},
|
|
177
|
+
trust: {
|
|
178
|
+
type: ["boolean", "function"],
|
|
179
|
+
description: "Trust the input, enabling all HTML features such as \\url.",
|
|
180
|
+
cli: "-T, --trust",
|
|
181
|
+
},
|
|
182
|
+
maxSize: {
|
|
183
|
+
type: "number",
|
|
184
|
+
default: Infinity,
|
|
185
|
+
description: "If non-zero, all user-specified sizes, e.g. in " +
|
|
186
|
+
"\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " +
|
|
187
|
+
"elements and spaces can be arbitrarily large",
|
|
188
|
+
processor: (s) => Math.max(0, s),
|
|
189
|
+
cli: "-s, --max-size <n>",
|
|
190
|
+
cliProcessor: parseInt,
|
|
191
|
+
},
|
|
192
|
+
maxExpand: {
|
|
193
|
+
type: "number",
|
|
194
|
+
default: 1000,
|
|
195
|
+
description: "Limit the number of macro expansions to the specified " +
|
|
196
|
+
"number, to prevent e.g. infinite macro loops. If set to Infinity, " +
|
|
197
|
+
"the macro expander will try to fully expand as in LaTeX.",
|
|
198
|
+
processor: (n) => Math.max(0, n),
|
|
199
|
+
cli: "-e, --max-expand <n>",
|
|
200
|
+
cliProcessor: (n) => (n === "Infinity" ? Infinity : parseInt(n)),
|
|
201
|
+
},
|
|
202
|
+
globalGroup: {
|
|
203
|
+
type: "boolean",
|
|
204
|
+
cli: false,
|
|
205
|
+
},
|
|
70
206
|
};
|
|
71
207
|
|
|
208
|
+
function getDefaultValue(schema): any {
|
|
209
|
+
if (schema.default) {
|
|
210
|
+
return schema.default;
|
|
211
|
+
}
|
|
212
|
+
const type = schema.type;
|
|
213
|
+
const defaultType = Array.isArray(type) ? type[0] : type;
|
|
214
|
+
if (typeof defaultType !== 'string') {
|
|
215
|
+
return defaultType.enum[0];
|
|
216
|
+
}
|
|
217
|
+
switch (defaultType) {
|
|
218
|
+
case 'boolean':
|
|
219
|
+
return false;
|
|
220
|
+
case 'string':
|
|
221
|
+
return '';
|
|
222
|
+
case 'number':
|
|
223
|
+
return 0;
|
|
224
|
+
case 'object':
|
|
225
|
+
return {};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
72
229
|
/**
|
|
73
230
|
* The main Settings object
|
|
74
231
|
*
|
|
@@ -98,23 +255,17 @@ export default class Settings {
|
|
|
98
255
|
constructor(options: SettingsOptions) {
|
|
99
256
|
// allow null options
|
|
100
257
|
options = options || {};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
this.colorIsTextColor = utils.deflt(options.colorIsTextColor, false);
|
|
113
|
-
this.strict = utils.deflt(options.strict, "warn");
|
|
114
|
-
this.trust = utils.deflt(options.trust, false);
|
|
115
|
-
this.maxSize = Math.max(0, utils.deflt(options.maxSize, Infinity));
|
|
116
|
-
this.maxExpand = Math.max(0, utils.deflt(options.maxExpand, 1000));
|
|
117
|
-
this.globalGroup = utils.deflt(options.globalGroup, false);
|
|
258
|
+
for (const prop in SETTINGS_SCHEMA) {
|
|
259
|
+
if (SETTINGS_SCHEMA.hasOwnProperty(prop)) {
|
|
260
|
+
// $FlowFixMe
|
|
261
|
+
const schema = SETTINGS_SCHEMA[prop];
|
|
262
|
+
// TODO: validate options
|
|
263
|
+
// $FlowFixMe
|
|
264
|
+
this[prop] = options[prop] !== undefined ? (schema.processor
|
|
265
|
+
? schema.processor(options[prop]) : options[prop])
|
|
266
|
+
: getDefaultValue(schema);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
118
269
|
}
|
|
119
270
|
|
|
120
271
|
/**
|
package/src/buildCommon.js
CHANGED
|
@@ -9,7 +9,7 @@ import {SymbolNode, Anchor, Span, PathNode, SvgNode, createClass} from "./domTre
|
|
|
9
9
|
import {getCharacterMetrics} from "./fontMetrics";
|
|
10
10
|
import symbols, {ligatures} from "./symbols";
|
|
11
11
|
import {wideCharacterFont} from "./wide-character";
|
|
12
|
-
import {calculateSize} from "./units";
|
|
12
|
+
import {calculateSize, makeEm} from "./units";
|
|
13
13
|
import {DocumentFragment} from "./tree";
|
|
14
14
|
|
|
15
15
|
import type Options from "./Options";
|
|
@@ -364,7 +364,7 @@ const makeLineSpan = function(
|
|
|
364
364
|
thickness || options.fontMetrics().defaultRuleThickness,
|
|
365
365
|
options.minRuleThickness,
|
|
366
366
|
);
|
|
367
|
-
line.style.borderBottomWidth = line.height
|
|
367
|
+
line.style.borderBottomWidth = makeEm(line.height);
|
|
368
368
|
line.maxFontSize = 1.0;
|
|
369
369
|
return line;
|
|
370
370
|
};
|
|
@@ -550,7 +550,7 @@ const makeVList = function(params: VListParam, options: Options): DomSpan {
|
|
|
550
550
|
}
|
|
551
551
|
pstrutSize += 2;
|
|
552
552
|
const pstrut = makeSpan(["pstrut"], []);
|
|
553
|
-
pstrut.style.height = pstrutSize
|
|
553
|
+
pstrut.style.height = makeEm(pstrutSize);
|
|
554
554
|
|
|
555
555
|
// Create a new list of actual children at the correct offsets
|
|
556
556
|
const realChildren = [];
|
|
@@ -567,7 +567,7 @@ const makeVList = function(params: VListParam, options: Options): DomSpan {
|
|
|
567
567
|
const style = child.wrapperStyle || {};
|
|
568
568
|
|
|
569
569
|
const childWrap = makeSpan(classes, [pstrut, elem], undefined, style);
|
|
570
|
-
childWrap.style.top = (-pstrutSize - currPos - elem.depth)
|
|
570
|
+
childWrap.style.top = makeEm(-pstrutSize - currPos - elem.depth);
|
|
571
571
|
if (child.marginLeft) {
|
|
572
572
|
childWrap.style.marginLeft = child.marginLeft;
|
|
573
573
|
}
|
|
@@ -586,7 +586,7 @@ const makeVList = function(params: VListParam, options: Options): DomSpan {
|
|
|
586
586
|
// This cell's bottom edge will determine the containing table's baseline
|
|
587
587
|
// without overly expanding the containing line-box.
|
|
588
588
|
const vlist = makeSpan(["vlist"], realChildren);
|
|
589
|
-
vlist.style.height = maxPos
|
|
589
|
+
vlist.style.height = makeEm(maxPos);
|
|
590
590
|
|
|
591
591
|
// A second row is used if necessary to represent the vlist's depth.
|
|
592
592
|
let rows;
|
|
@@ -598,7 +598,7 @@ const makeVList = function(params: VListParam, options: Options): DomSpan {
|
|
|
598
598
|
// So we put another empty span inside the depth strut span.
|
|
599
599
|
const emptySpan = makeSpan([], []);
|
|
600
600
|
const depthStrut = makeSpan(["vlist"], [emptySpan]);
|
|
601
|
-
depthStrut.style.height = -minPos
|
|
601
|
+
depthStrut.style.height = makeEm(-minPos);
|
|
602
602
|
|
|
603
603
|
// Safari wants the first row to have inline content; otherwise it
|
|
604
604
|
// puts the bottom of the *second* row on the baseline.
|
|
@@ -626,7 +626,7 @@ const makeGlue = (measurement: Measurement, options: Options): DomSpan => {
|
|
|
626
626
|
// Make an empty span for the space
|
|
627
627
|
const rule = makeSpan(["mspace"], [], options);
|
|
628
628
|
const size = calculateSize(measurement, options);
|
|
629
|
-
rule.style.marginRight =
|
|
629
|
+
rule.style.marginRight = makeEm(size);
|
|
630
630
|
return rule;
|
|
631
631
|
};
|
|
632
632
|
|
|
@@ -744,17 +744,17 @@ const staticSvg = function(value: string, options: Options): SvgSpan {
|
|
|
744
744
|
const [pathName, width, height] = svgData[value];
|
|
745
745
|
const path = new PathNode(pathName);
|
|
746
746
|
const svgNode = new SvgNode([path], {
|
|
747
|
-
"width": width
|
|
748
|
-
"height": height
|
|
747
|
+
"width": makeEm(width),
|
|
748
|
+
"height": makeEm(height),
|
|
749
749
|
// Override CSS rule `.katex svg { width: 100% }`
|
|
750
|
-
"style": "width:" + width
|
|
750
|
+
"style": "width:" + makeEm(width),
|
|
751
751
|
"viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
|
|
752
752
|
"preserveAspectRatio": "xMinYMin",
|
|
753
753
|
});
|
|
754
754
|
const span = makeSvgSpan(["overlay"], [svgNode], options);
|
|
755
755
|
span.height = height;
|
|
756
|
-
span.style.height = height
|
|
757
|
-
span.style.width = width
|
|
756
|
+
span.style.height = makeEm(height);
|
|
757
|
+
span.style.width = makeEm(width);
|
|
758
758
|
return span;
|
|
759
759
|
};
|
|
760
760
|
|
package/src/buildHTML.js
CHANGED
|
@@ -11,6 +11,7 @@ import Style from "./Style";
|
|
|
11
11
|
import buildCommon from "./buildCommon";
|
|
12
12
|
import {Span, Anchor} from "./domTree";
|
|
13
13
|
import utils from "./utils";
|
|
14
|
+
import {makeEm} from "./units";
|
|
14
15
|
import {spacings, tightSpacings} from "./spacingData";
|
|
15
16
|
import {_htmlGroupBuilders as groupBuilders} from "./defineFunction";
|
|
16
17
|
import {DocumentFragment} from "./tree";
|
|
@@ -299,9 +300,9 @@ function buildHTMLUnbreakable(children, options) {
|
|
|
299
300
|
// the height of the expression, and the bottom of the HTML element
|
|
300
301
|
// falls at the depth of the expression.
|
|
301
302
|
const strut = makeSpan(["strut"]);
|
|
302
|
-
strut.style.height = (body.height + body.depth)
|
|
303
|
+
strut.style.height = makeEm(body.height + body.depth);
|
|
303
304
|
if (body.depth) {
|
|
304
|
-
strut.style.verticalAlign = -body.depth
|
|
305
|
+
strut.style.verticalAlign = makeEm(-body.depth);
|
|
305
306
|
}
|
|
306
307
|
body.children.unshift(strut);
|
|
307
308
|
|
|
@@ -395,9 +396,9 @@ export default function buildHTML(tree: AnyParseNode[], options: Options): DomSp
|
|
|
395
396
|
// (the height of the enclosing htmlNode) for proper vertical alignment.
|
|
396
397
|
if (tagChild) {
|
|
397
398
|
const strut = tagChild.children[0];
|
|
398
|
-
strut.style.height = (htmlNode.height + htmlNode.depth)
|
|
399
|
+
strut.style.height = makeEm(htmlNode.height + htmlNode.depth);
|
|
399
400
|
if (htmlNode.depth) {
|
|
400
|
-
strut.style.verticalAlign = (-htmlNode.depth)
|
|
401
|
+
strut.style.verticalAlign = makeEm(-htmlNode.depth);
|
|
401
402
|
}
|
|
402
403
|
}
|
|
403
404
|
|
package/src/delimiter.js
CHANGED
|
@@ -30,6 +30,7 @@ import buildCommon from "./buildCommon";
|
|
|
30
30
|
import {getCharacterMetrics} from "./fontMetrics";
|
|
31
31
|
import symbols from "./symbols";
|
|
32
32
|
import utils from "./utils";
|
|
33
|
+
import {makeEm} from "./units";
|
|
33
34
|
import fontMetricsData from "./fontMetricsData";
|
|
34
35
|
|
|
35
36
|
import type Options from "./Options";
|
|
@@ -93,7 +94,7 @@ const centerSpan = function(
|
|
|
93
94
|
options.fontMetrics().axisHeight;
|
|
94
95
|
|
|
95
96
|
span.classes.push("delimcenter");
|
|
96
|
-
span.style.top = shift
|
|
97
|
+
span.style.top = makeEm(shift);
|
|
97
98
|
span.height -= shift;
|
|
98
99
|
span.depth += shift;
|
|
99
100
|
};
|
|
@@ -186,21 +187,21 @@ const makeInner = function(
|
|
|
186
187
|
): VListElem {
|
|
187
188
|
// Create a span with inline SVG for the inner part of a tall stacked delimiter.
|
|
188
189
|
const width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)]
|
|
189
|
-
? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4]
|
|
190
|
-
: fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4]
|
|
190
|
+
? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4]
|
|
191
|
+
: fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4];
|
|
191
192
|
const path = new PathNode("inner", innerPath(ch, Math.round(1000 * height)));
|
|
192
193
|
const svgNode = new SvgNode([path], {
|
|
193
|
-
"width": width
|
|
194
|
-
"height": height
|
|
194
|
+
"width": makeEm(width),
|
|
195
|
+
"height": makeEm(height),
|
|
195
196
|
// Override CSS rule `.katex svg { width: 100% }`
|
|
196
|
-
"style": "width:" + width
|
|
197
|
+
"style": "width:" + makeEm(width),
|
|
197
198
|
"viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height),
|
|
198
199
|
"preserveAspectRatio": "xMinYMin",
|
|
199
200
|
});
|
|
200
201
|
const span = buildCommon.makeSvgSpan([], [svgNode], options);
|
|
201
202
|
span.height = height;
|
|
202
|
-
span.style.height = height
|
|
203
|
-
span.style.width = width
|
|
203
|
+
span.style.height = makeEm(height);
|
|
204
|
+
span.style.width = makeEm(width);
|
|
204
205
|
return {type: "elem", elem: span};
|
|
205
206
|
};
|
|
206
207
|
|
|
@@ -427,7 +428,7 @@ const sqrtSvg = function(
|
|
|
427
428
|
const svg = new SvgNode([pathNode], {
|
|
428
429
|
// Note: 1000:1 ratio of viewBox to document em width.
|
|
429
430
|
"width": "400em",
|
|
430
|
-
"height": height
|
|
431
|
+
"height": makeEm(height),
|
|
431
432
|
"viewBox": "0 0 400000 " + viewBoxHeight,
|
|
432
433
|
"preserveAspectRatio": "xMinYMin slice",
|
|
433
434
|
});
|
|
@@ -514,7 +515,7 @@ const makeSqrtImage = function(
|
|
|
514
515
|
}
|
|
515
516
|
|
|
516
517
|
span.height = texHeight;
|
|
517
|
-
span.style.height = spanHeight
|
|
518
|
+
span.style.height = makeEm(spanHeight);
|
|
518
519
|
|
|
519
520
|
return {
|
|
520
521
|
span,
|
package/src/domTree.js
CHANGED
|
@@ -16,6 +16,7 @@ import utils from "./utils";
|
|
|
16
16
|
import {path} from "./svgGeometry";
|
|
17
17
|
import type Options from "./Options";
|
|
18
18
|
import {DocumentFragment} from "./tree";
|
|
19
|
+
import {makeEm} from "./units";
|
|
19
20
|
|
|
20
21
|
import type {VirtualNode} from "./tree";
|
|
21
22
|
|
|
@@ -406,7 +407,7 @@ export class SymbolNode implements HtmlDomNode {
|
|
|
406
407
|
|
|
407
408
|
if (this.italic > 0) {
|
|
408
409
|
span = document.createElement("span");
|
|
409
|
-
span.style.marginRight = this.italic
|
|
410
|
+
span.style.marginRight = makeEm(this.italic);
|
|
410
411
|
}
|
|
411
412
|
|
|
412
413
|
if (this.classes.length > 0) {
|
|
@@ -8,7 +8,7 @@ import mathMLTree from "../mathMLTree";
|
|
|
8
8
|
import ParseError from "../ParseError";
|
|
9
9
|
import {assertNodeType, assertSymbolNodeType} from "../parseNode";
|
|
10
10
|
import {checkSymbolNodeType} from "../parseNode";
|
|
11
|
-
import {calculateSize} from "../units";
|
|
11
|
+
import {calculateSize, makeEm} from "../units";
|
|
12
12
|
import utils from "../utils";
|
|
13
13
|
|
|
14
14
|
import * as html from "../buildHTML";
|
|
@@ -368,7 +368,7 @@ const htmlBuilder: HtmlBuilder<"array"> = function(group, options) {
|
|
|
368
368
|
if (!firstSeparator) {
|
|
369
369
|
colSep = buildCommon.makeSpan(["arraycolsep"], []);
|
|
370
370
|
colSep.style.width =
|
|
371
|
-
options.fontMetrics().doubleRuleSep
|
|
371
|
+
makeEm(options.fontMetrics().doubleRuleSep);
|
|
372
372
|
cols.push(colSep);
|
|
373
373
|
}
|
|
374
374
|
|
|
@@ -377,13 +377,13 @@ const htmlBuilder: HtmlBuilder<"array"> = function(group, options) {
|
|
|
377
377
|
const separator = buildCommon.makeSpan(
|
|
378
378
|
["vertical-separator"], [], options
|
|
379
379
|
);
|
|
380
|
-
separator.style.height = totalHeight
|
|
381
|
-
separator.style.borderRightWidth =
|
|
380
|
+
separator.style.height = makeEm(totalHeight);
|
|
381
|
+
separator.style.borderRightWidth = makeEm(ruleThickness);
|
|
382
382
|
separator.style.borderRightStyle = lineType;
|
|
383
|
-
separator.style.margin = `0
|
|
383
|
+
separator.style.margin = `0 ${makeEm(-ruleThickness / 2)}`;
|
|
384
384
|
const shift = totalHeight - offset;
|
|
385
385
|
if (shift) {
|
|
386
|
-
separator.style.verticalAlign = -shift
|
|
386
|
+
separator.style.verticalAlign = makeEm(-shift);
|
|
387
387
|
}
|
|
388
388
|
|
|
389
389
|
cols.push(separator);
|
|
@@ -406,7 +406,7 @@ const htmlBuilder: HtmlBuilder<"array"> = function(group, options) {
|
|
|
406
406
|
sepwidth = utils.deflt(colDescr.pregap, arraycolsep);
|
|
407
407
|
if (sepwidth !== 0) {
|
|
408
408
|
colSep = buildCommon.makeSpan(["arraycolsep"], []);
|
|
409
|
-
colSep.style.width = sepwidth
|
|
409
|
+
colSep.style.width = makeEm(sepwidth);
|
|
410
410
|
cols.push(colSep);
|
|
411
411
|
}
|
|
412
412
|
}
|
|
@@ -437,7 +437,7 @@ const htmlBuilder: HtmlBuilder<"array"> = function(group, options) {
|
|
|
437
437
|
sepwidth = utils.deflt(colDescr.postgap, arraycolsep);
|
|
438
438
|
if (sepwidth !== 0) {
|
|
439
439
|
colSep = buildCommon.makeSpan(["arraycolsep"], []);
|
|
440
|
-
colSep.style.width = sepwidth
|
|
440
|
+
colSep.style.width = makeEm(sepwidth);
|
|
441
441
|
cols.push(colSep);
|
|
442
442
|
}
|
|
443
443
|
}
|
|
@@ -523,7 +523,7 @@ const mathmlBuilder: MathMLBuilder<"array"> = function(group, options) {
|
|
|
523
523
|
const gap = (group.arraystretch === 0.5)
|
|
524
524
|
? 0.1 // {smallmatrix}, {subarray}
|
|
525
525
|
: 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
|
|
526
|
-
table.setAttribute("rowspacing", gap
|
|
526
|
+
table.setAttribute("rowspacing", makeEm(gap));
|
|
527
527
|
|
|
528
528
|
// MathML table lines go only between cells.
|
|
529
529
|
// To place a line on an edge we'll use <menclose>, if necessary.
|
package/src/environments/cd.js
CHANGED
|
@@ -6,6 +6,7 @@ import * as html from "../buildHTML";
|
|
|
6
6
|
import * as mml from "../buildMathML";
|
|
7
7
|
import {assertSymbolNodeType} from "../parseNode";
|
|
8
8
|
import ParseError from "../ParseError";
|
|
9
|
+
import {makeEm} from "../units";
|
|
9
10
|
|
|
10
11
|
import type Parser from "../Parser";
|
|
11
12
|
import type {ParseNode, AnyParseNode} from "../parseNode";
|
|
@@ -257,7 +258,7 @@ defineFunction({
|
|
|
257
258
|
const label = buildCommon.wrapFragment(
|
|
258
259
|
html.buildGroup(group.label, newOptions, options), options);
|
|
259
260
|
label.classes.push("cd-label-" + group.side);
|
|
260
|
-
label.style.bottom = (0.8 - label.depth)
|
|
261
|
+
label.style.bottom = makeEm(0.8 - label.depth);
|
|
261
262
|
// Zero out label height & depth, so vertical align of arrow is set
|
|
262
263
|
// by the arrow height, not by the label.
|
|
263
264
|
label.height = 0;
|
package/src/fontMetricsData.js
CHANGED
|
@@ -582,6 +582,7 @@ export default {
|
|
|
582
582
|
"8764": [-0.10889, 0.39111, 0, 0, 0.89444],
|
|
583
583
|
"8768": [0.19444, 0.69444, 0, 0, 0.31944],
|
|
584
584
|
"8771": [0.00222, 0.50222, 0, 0, 0.89444],
|
|
585
|
+
"8773": [0.027, 0.638, 0, 0, 0.894],
|
|
585
586
|
"8776": [0.02444, 0.52444, 0, 0, 0.89444],
|
|
586
587
|
"8781": [0.00222, 0.50222, 0, 0, 0.89444],
|
|
587
588
|
"8801": [0.00222, 0.50222, 0, 0, 0.89444],
|
|
@@ -1099,7 +1100,7 @@ export default {
|
|
|
1099
1100
|
"8764": [-0.13313, 0.36687, 0, 0, 0.77778],
|
|
1100
1101
|
"8768": [0.19444, 0.69444, 0, 0, 0.27778],
|
|
1101
1102
|
"8771": [-0.03625, 0.46375, 0, 0, 0.77778],
|
|
1102
|
-
"8773": [-0.022, 0.589, 0, 0,
|
|
1103
|
+
"8773": [-0.022, 0.589, 0, 0, 0.778],
|
|
1103
1104
|
"8776": [-0.01688, 0.48312, 0, 0, 0.77778],
|
|
1104
1105
|
"8781": [-0.03625, 0.46375, 0, 0, 0.77778],
|
|
1105
1106
|
"8784": [-0.133, 0.673, 0, 0, 0.778],
|
package/src/fonts/makeFF
CHANGED
|
@@ -1311,6 +1311,7 @@ $extra{'Main-Regular'} = {
|
|
|
1311
1311
|
'Select(0u3D)','Copy()',
|
|
1312
1312
|
'Select(0u2245)',
|
|
1313
1313
|
'PasteWithOffset(0,-111)',
|
|
1314
|
+
'SetWidth(778)',
|
|
1314
1315
|
],
|
|
1315
1316
|
|
|
1316
1317
|
bowtie => [
|
|
@@ -1607,6 +1608,7 @@ $extra{'Main-Bold'} = {
|
|
|
1607
1608
|
'Select(0u3D)','Copy()',
|
|
1608
1609
|
'Select(0u2245)',
|
|
1609
1610
|
'PasteWithOffset(0,-136)',
|
|
1611
|
+
'SetWidth(894)',
|
|
1610
1612
|
],
|
|
1611
1613
|
|
|
1612
1614
|
bowtie => [
|
package/src/functions/accent.js
CHANGED
|
@@ -6,6 +6,7 @@ import utils from "../utils";
|
|
|
6
6
|
import stretchy from "../stretchy";
|
|
7
7
|
import {assertNodeType} from "../parseNode";
|
|
8
8
|
import {assertSpan, assertSymbolDomNode} from "../domTree";
|
|
9
|
+
import {makeEm} from "../units";
|
|
9
10
|
|
|
10
11
|
import * as html from "../buildHTML";
|
|
11
12
|
import * as mml from "../buildMathML";
|
|
@@ -131,7 +132,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
131
132
|
left -= width / 2;
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
accentBody.style.left = left
|
|
135
|
+
accentBody.style.left = makeEm(left);
|
|
135
136
|
|
|
136
137
|
// \textcircled uses the \bigcirc glyph, so it needs some
|
|
137
138
|
// vertical adjustment to match LaTeX.
|
|
@@ -161,8 +162,8 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
161
162
|
wrapperClasses: ["svg-align"],
|
|
162
163
|
wrapperStyle: skew > 0
|
|
163
164
|
? {
|
|
164
|
-
width: `calc(100% - ${2 * skew}
|
|
165
|
-
marginLeft:
|
|
165
|
+
width: `calc(100% - ${makeEm(2 * skew)})`,
|
|
166
|
+
marginLeft: makeEm(2 * skew),
|
|
166
167
|
}
|
|
167
168
|
: undefined,
|
|
168
169
|
},
|