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/dist/katex.js
CHANGED
|
@@ -229,7 +229,136 @@ var protocolFromUrl = function protocolFromUrl(url) {
|
|
|
229
229
|
|
|
230
230
|
|
|
231
231
|
|
|
232
|
+
// TODO: automatically generate documentation
|
|
233
|
+
// TODO: check all properties on Settings exist
|
|
234
|
+
// TODO: check the type of a property on Settings matches
|
|
235
|
+
var SETTINGS_SCHEMA = {
|
|
236
|
+
displayMode: {
|
|
237
|
+
type: "boolean",
|
|
238
|
+
description: "Render math in display mode, which puts the math in " + "display style (so \\int and \\sum are large, for example), and " + "centers the math on the page on its own line.",
|
|
239
|
+
cli: "-d, --display-mode"
|
|
240
|
+
},
|
|
241
|
+
output: {
|
|
242
|
+
type: {
|
|
243
|
+
enum: ["htmlAndMathml", "html", "mathml"]
|
|
244
|
+
},
|
|
245
|
+
description: "Determines the markup language of the output.",
|
|
246
|
+
cli: "-F, --format <type>"
|
|
247
|
+
},
|
|
248
|
+
leqno: {
|
|
249
|
+
type: "boolean",
|
|
250
|
+
description: "Render display math in leqno style (left-justified tags)."
|
|
251
|
+
},
|
|
252
|
+
fleqn: {
|
|
253
|
+
type: "boolean",
|
|
254
|
+
description: "Render display math flush left."
|
|
255
|
+
},
|
|
256
|
+
throwOnError: {
|
|
257
|
+
type: "boolean",
|
|
258
|
+
default: true,
|
|
259
|
+
cli: "-t, --no-throw-on-error",
|
|
260
|
+
cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error."
|
|
261
|
+
},
|
|
262
|
+
errorColor: {
|
|
263
|
+
type: "string",
|
|
264
|
+
default: "#cc0000",
|
|
265
|
+
cli: "-c, --error-color <color>",
|
|
266
|
+
cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.",
|
|
267
|
+
cliProcessor: function cliProcessor(color) {
|
|
268
|
+
return "#" + color;
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
macros: {
|
|
272
|
+
type: "object",
|
|
273
|
+
cli: "-m, --macro <def>",
|
|
274
|
+
cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).",
|
|
275
|
+
cliDefault: [],
|
|
276
|
+
cliProcessor: function cliProcessor(def, defs) {
|
|
277
|
+
defs.push(def);
|
|
278
|
+
return defs;
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
minRuleThickness: {
|
|
282
|
+
type: "number",
|
|
283
|
+
description: "Specifies a minimum thickness, in ems, for fraction lines," + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.",
|
|
284
|
+
processor: function processor(t) {
|
|
285
|
+
return Math.max(0, t);
|
|
286
|
+
},
|
|
287
|
+
cli: "--min-rule-thickness <size>",
|
|
288
|
+
cliProcessor: parseFloat
|
|
289
|
+
},
|
|
290
|
+
colorIsTextColor: {
|
|
291
|
+
type: "boolean",
|
|
292
|
+
description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.",
|
|
293
|
+
cli: "-b, --color-is-text-color"
|
|
294
|
+
},
|
|
295
|
+
strict: {
|
|
296
|
+
type: [{
|
|
297
|
+
enum: ["warn", "ignore", "error"]
|
|
298
|
+
}, "boolean", "function"],
|
|
299
|
+
description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.",
|
|
300
|
+
cli: "-S, --strict",
|
|
301
|
+
cliDefault: false
|
|
302
|
+
},
|
|
303
|
+
trust: {
|
|
304
|
+
type: ["boolean", "function"],
|
|
305
|
+
description: "Trust the input, enabling all HTML features such as \\url.",
|
|
306
|
+
cli: "-T, --trust"
|
|
307
|
+
},
|
|
308
|
+
maxSize: {
|
|
309
|
+
type: "number",
|
|
310
|
+
default: Infinity,
|
|
311
|
+
description: "If non-zero, all user-specified sizes, e.g. in " + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + "elements and spaces can be arbitrarily large",
|
|
312
|
+
processor: function processor(s) {
|
|
313
|
+
return Math.max(0, s);
|
|
314
|
+
},
|
|
315
|
+
cli: "-s, --max-size <n>",
|
|
316
|
+
cliProcessor: parseInt
|
|
317
|
+
},
|
|
318
|
+
maxExpand: {
|
|
319
|
+
type: "number",
|
|
320
|
+
default: 1000,
|
|
321
|
+
description: "Limit the number of macro expansions to the specified " + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + "the macro expander will try to fully expand as in LaTeX.",
|
|
322
|
+
processor: function processor(n) {
|
|
323
|
+
return Math.max(0, n);
|
|
324
|
+
},
|
|
325
|
+
cli: "-e, --max-expand <n>",
|
|
326
|
+
cliProcessor: function cliProcessor(n) {
|
|
327
|
+
return n === "Infinity" ? Infinity : parseInt(n);
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
globalGroup: {
|
|
331
|
+
type: "boolean",
|
|
332
|
+
cli: false
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
function getDefaultValue(schema) {
|
|
337
|
+
if (schema.default) {
|
|
338
|
+
return schema.default;
|
|
339
|
+
}
|
|
232
340
|
|
|
341
|
+
var type = schema.type;
|
|
342
|
+
var defaultType = Array.isArray(type) ? type[0] : type;
|
|
343
|
+
|
|
344
|
+
if (typeof defaultType !== 'string') {
|
|
345
|
+
return defaultType.enum[0];
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
switch (defaultType) {
|
|
349
|
+
case 'boolean':
|
|
350
|
+
return false;
|
|
351
|
+
|
|
352
|
+
case 'string':
|
|
353
|
+
return '';
|
|
354
|
+
|
|
355
|
+
case 'number':
|
|
356
|
+
return 0;
|
|
357
|
+
|
|
358
|
+
case 'object':
|
|
359
|
+
return {};
|
|
360
|
+
}
|
|
361
|
+
}
|
|
233
362
|
/**
|
|
234
363
|
* The main Settings object
|
|
235
364
|
*
|
|
@@ -240,6 +369,8 @@ var protocolFromUrl = function protocolFromUrl(url) {
|
|
|
240
369
|
* math (true), meaning that the math starts in \displaystyle
|
|
241
370
|
* and is placed in a block with vertical margin.
|
|
242
371
|
*/
|
|
372
|
+
|
|
373
|
+
|
|
243
374
|
var Settings = /*#__PURE__*/function () {
|
|
244
375
|
function Settings(options) {
|
|
245
376
|
this.displayMode = void 0;
|
|
@@ -258,20 +389,16 @@ var Settings = /*#__PURE__*/function () {
|
|
|
258
389
|
this.globalGroup = void 0;
|
|
259
390
|
// allow null options
|
|
260
391
|
options = options || {};
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
this.trust = utils.deflt(options.trust, false);
|
|
272
|
-
this.maxSize = Math.max(0, utils.deflt(options.maxSize, Infinity));
|
|
273
|
-
this.maxExpand = Math.max(0, utils.deflt(options.maxExpand, 1000));
|
|
274
|
-
this.globalGroup = utils.deflt(options.globalGroup, false);
|
|
392
|
+
|
|
393
|
+
for (var prop in SETTINGS_SCHEMA) {
|
|
394
|
+
if (SETTINGS_SCHEMA.hasOwnProperty(prop)) {
|
|
395
|
+
// $FlowFixMe
|
|
396
|
+
var schema = SETTINGS_SCHEMA[prop]; // TODO: validate options
|
|
397
|
+
// $FlowFixMe
|
|
398
|
+
|
|
399
|
+
this[prop] = options[prop] !== undefined ? schema.processor ? schema.processor(options[prop]) : options[prop] : getDefaultValue(schema);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
275
402
|
}
|
|
276
403
|
/**
|
|
277
404
|
* Report nonstrict (non-LaTeX-compatible) input.
|
|
@@ -879,559 +1006,6 @@ var DocumentFragment = /*#__PURE__*/function () {
|
|
|
879
1006
|
|
|
880
1007
|
return DocumentFragment;
|
|
881
1008
|
}();
|
|
882
|
-
;// CONCATENATED MODULE: ./src/domTree.js
|
|
883
|
-
/**
|
|
884
|
-
* These objects store the data about the DOM nodes we create, as well as some
|
|
885
|
-
* extra data. They can then be transformed into real DOM nodes with the
|
|
886
|
-
* `toNode` function or HTML markup using `toMarkup`. They are useful for both
|
|
887
|
-
* storing extra properties on the nodes, as well as providing a way to easily
|
|
888
|
-
* work with the DOM.
|
|
889
|
-
*
|
|
890
|
-
* Similar functions for working with MathML nodes exist in mathMLTree.js.
|
|
891
|
-
*
|
|
892
|
-
* TODO: refactor `span` and `anchor` into common superclass when
|
|
893
|
-
* target environments support class inheritance
|
|
894
|
-
*/
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* Create an HTML className based on a list of classes. In addition to joining
|
|
902
|
-
* with spaces, we also remove empty classes.
|
|
903
|
-
*/
|
|
904
|
-
var createClass = function createClass(classes) {
|
|
905
|
-
return classes.filter(function (cls) {
|
|
906
|
-
return cls;
|
|
907
|
-
}).join(" ");
|
|
908
|
-
};
|
|
909
|
-
|
|
910
|
-
var initNode = function initNode(classes, options, style) {
|
|
911
|
-
this.classes = classes || [];
|
|
912
|
-
this.attributes = {};
|
|
913
|
-
this.height = 0;
|
|
914
|
-
this.depth = 0;
|
|
915
|
-
this.maxFontSize = 0;
|
|
916
|
-
this.style = style || {};
|
|
917
|
-
|
|
918
|
-
if (options) {
|
|
919
|
-
if (options.style.isTight()) {
|
|
920
|
-
this.classes.push("mtight");
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
var color = options.getColor();
|
|
924
|
-
|
|
925
|
-
if (color) {
|
|
926
|
-
this.style.color = color;
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
|
-
/**
|
|
931
|
-
* Convert into an HTML node
|
|
932
|
-
*/
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
var _toNode = function toNode(tagName) {
|
|
936
|
-
var node = document.createElement(tagName); // Apply the class
|
|
937
|
-
|
|
938
|
-
node.className = createClass(this.classes); // Apply inline styles
|
|
939
|
-
|
|
940
|
-
for (var style in this.style) {
|
|
941
|
-
if (this.style.hasOwnProperty(style)) {
|
|
942
|
-
// $FlowFixMe Flow doesn't seem to understand span.style's type.
|
|
943
|
-
node.style[style] = this.style[style];
|
|
944
|
-
}
|
|
945
|
-
} // Apply attributes
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
for (var attr in this.attributes) {
|
|
949
|
-
if (this.attributes.hasOwnProperty(attr)) {
|
|
950
|
-
node.setAttribute(attr, this.attributes[attr]);
|
|
951
|
-
}
|
|
952
|
-
} // Append the children, also as HTML nodes
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
for (var i = 0; i < this.children.length; i++) {
|
|
956
|
-
node.appendChild(this.children[i].toNode());
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
return node;
|
|
960
|
-
};
|
|
961
|
-
/**
|
|
962
|
-
* Convert into an HTML markup string
|
|
963
|
-
*/
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
var _toMarkup = function toMarkup(tagName) {
|
|
967
|
-
var markup = "<" + tagName; // Add the class
|
|
968
|
-
|
|
969
|
-
if (this.classes.length) {
|
|
970
|
-
markup += " class=\"" + utils.escape(createClass(this.classes)) + "\"";
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
var styles = ""; // Add the styles, after hyphenation
|
|
974
|
-
|
|
975
|
-
for (var style in this.style) {
|
|
976
|
-
if (this.style.hasOwnProperty(style)) {
|
|
977
|
-
styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
if (styles) {
|
|
982
|
-
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
983
|
-
} // Add the attributes
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
for (var attr in this.attributes) {
|
|
987
|
-
if (this.attributes.hasOwnProperty(attr)) {
|
|
988
|
-
markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\"";
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
markup += ">"; // Add the markup of the children, also as markup
|
|
993
|
-
|
|
994
|
-
for (var i = 0; i < this.children.length; i++) {
|
|
995
|
-
markup += this.children[i].toMarkup();
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
markup += "</" + tagName + ">";
|
|
999
|
-
return markup;
|
|
1000
|
-
}; // Making the type below exact with all optional fields doesn't work due to
|
|
1001
|
-
// - https://github.com/facebook/flow/issues/4582
|
|
1002
|
-
// - https://github.com/facebook/flow/issues/5688
|
|
1003
|
-
// However, since *all* fields are optional, $Shape<> works as suggested in 5688
|
|
1004
|
-
// above.
|
|
1005
|
-
// This type does not include all CSS properties. Additional properties should
|
|
1006
|
-
// be added as needed.
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
/**
|
|
1010
|
-
* This node represents a span node, with a className, a list of children, and
|
|
1011
|
-
* an inline style. It also contains information about its height, depth, and
|
|
1012
|
-
* maxFontSize.
|
|
1013
|
-
*
|
|
1014
|
-
* Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan
|
|
1015
|
-
* otherwise. This typesafety is important when HTML builders access a span's
|
|
1016
|
-
* children.
|
|
1017
|
-
*/
|
|
1018
|
-
var Span = /*#__PURE__*/function () {
|
|
1019
|
-
function Span(classes, children, options, style) {
|
|
1020
|
-
this.children = void 0;
|
|
1021
|
-
this.attributes = void 0;
|
|
1022
|
-
this.classes = void 0;
|
|
1023
|
-
this.height = void 0;
|
|
1024
|
-
this.depth = void 0;
|
|
1025
|
-
this.width = void 0;
|
|
1026
|
-
this.maxFontSize = void 0;
|
|
1027
|
-
this.style = void 0;
|
|
1028
|
-
initNode.call(this, classes, options, style);
|
|
1029
|
-
this.children = children || [];
|
|
1030
|
-
}
|
|
1031
|
-
/**
|
|
1032
|
-
* Sets an arbitrary attribute on the span. Warning: use this wisely. Not
|
|
1033
|
-
* all browsers support attributes the same, and having too many custom
|
|
1034
|
-
* attributes is probably bad.
|
|
1035
|
-
*/
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
var _proto = Span.prototype;
|
|
1039
|
-
|
|
1040
|
-
_proto.setAttribute = function setAttribute(attribute, value) {
|
|
1041
|
-
this.attributes[attribute] = value;
|
|
1042
|
-
};
|
|
1043
|
-
|
|
1044
|
-
_proto.hasClass = function hasClass(className) {
|
|
1045
|
-
return utils.contains(this.classes, className);
|
|
1046
|
-
};
|
|
1047
|
-
|
|
1048
|
-
_proto.toNode = function toNode() {
|
|
1049
|
-
return _toNode.call(this, "span");
|
|
1050
|
-
};
|
|
1051
|
-
|
|
1052
|
-
_proto.toMarkup = function toMarkup() {
|
|
1053
|
-
return _toMarkup.call(this, "span");
|
|
1054
|
-
};
|
|
1055
|
-
|
|
1056
|
-
return Span;
|
|
1057
|
-
}();
|
|
1058
|
-
/**
|
|
1059
|
-
* This node represents an anchor (<a>) element with a hyperlink. See `span`
|
|
1060
|
-
* for further details.
|
|
1061
|
-
*/
|
|
1062
|
-
|
|
1063
|
-
var Anchor = /*#__PURE__*/function () {
|
|
1064
|
-
function Anchor(href, classes, children, options) {
|
|
1065
|
-
this.children = void 0;
|
|
1066
|
-
this.attributes = void 0;
|
|
1067
|
-
this.classes = void 0;
|
|
1068
|
-
this.height = void 0;
|
|
1069
|
-
this.depth = void 0;
|
|
1070
|
-
this.maxFontSize = void 0;
|
|
1071
|
-
this.style = void 0;
|
|
1072
|
-
initNode.call(this, classes, options);
|
|
1073
|
-
this.children = children || [];
|
|
1074
|
-
this.setAttribute('href', href);
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
var _proto2 = Anchor.prototype;
|
|
1078
|
-
|
|
1079
|
-
_proto2.setAttribute = function setAttribute(attribute, value) {
|
|
1080
|
-
this.attributes[attribute] = value;
|
|
1081
|
-
};
|
|
1082
|
-
|
|
1083
|
-
_proto2.hasClass = function hasClass(className) {
|
|
1084
|
-
return utils.contains(this.classes, className);
|
|
1085
|
-
};
|
|
1086
|
-
|
|
1087
|
-
_proto2.toNode = function toNode() {
|
|
1088
|
-
return _toNode.call(this, "a");
|
|
1089
|
-
};
|
|
1090
|
-
|
|
1091
|
-
_proto2.toMarkup = function toMarkup() {
|
|
1092
|
-
return _toMarkup.call(this, "a");
|
|
1093
|
-
};
|
|
1094
|
-
|
|
1095
|
-
return Anchor;
|
|
1096
|
-
}();
|
|
1097
|
-
/**
|
|
1098
|
-
* This node represents an image embed (<img>) element.
|
|
1099
|
-
*/
|
|
1100
|
-
|
|
1101
|
-
var Img = /*#__PURE__*/function () {
|
|
1102
|
-
function Img(src, alt, style) {
|
|
1103
|
-
this.src = void 0;
|
|
1104
|
-
this.alt = void 0;
|
|
1105
|
-
this.classes = void 0;
|
|
1106
|
-
this.height = void 0;
|
|
1107
|
-
this.depth = void 0;
|
|
1108
|
-
this.maxFontSize = void 0;
|
|
1109
|
-
this.style = void 0;
|
|
1110
|
-
this.alt = alt;
|
|
1111
|
-
this.src = src;
|
|
1112
|
-
this.classes = ["mord"];
|
|
1113
|
-
this.style = style;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
var _proto3 = Img.prototype;
|
|
1117
|
-
|
|
1118
|
-
_proto3.hasClass = function hasClass(className) {
|
|
1119
|
-
return utils.contains(this.classes, className);
|
|
1120
|
-
};
|
|
1121
|
-
|
|
1122
|
-
_proto3.toNode = function toNode() {
|
|
1123
|
-
var node = document.createElement("img");
|
|
1124
|
-
node.src = this.src;
|
|
1125
|
-
node.alt = this.alt;
|
|
1126
|
-
node.className = "mord"; // Apply inline styles
|
|
1127
|
-
|
|
1128
|
-
for (var style in this.style) {
|
|
1129
|
-
if (this.style.hasOwnProperty(style)) {
|
|
1130
|
-
// $FlowFixMe
|
|
1131
|
-
node.style[style] = this.style[style];
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
return node;
|
|
1136
|
-
};
|
|
1137
|
-
|
|
1138
|
-
_proto3.toMarkup = function toMarkup() {
|
|
1139
|
-
var markup = "<img src='" + this.src + " 'alt='" + this.alt + "' "; // Add the styles, after hyphenation
|
|
1140
|
-
|
|
1141
|
-
var styles = "";
|
|
1142
|
-
|
|
1143
|
-
for (var style in this.style) {
|
|
1144
|
-
if (this.style.hasOwnProperty(style)) {
|
|
1145
|
-
styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
if (styles) {
|
|
1150
|
-
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
markup += "'/>";
|
|
1154
|
-
return markup;
|
|
1155
|
-
};
|
|
1156
|
-
|
|
1157
|
-
return Img;
|
|
1158
|
-
}();
|
|
1159
|
-
var iCombinations = {
|
|
1160
|
-
'î': "\u0131\u0302",
|
|
1161
|
-
'ï': "\u0131\u0308",
|
|
1162
|
-
'í': "\u0131\u0301",
|
|
1163
|
-
// 'ī': '\u0131\u0304', // enable when we add Extended Latin
|
|
1164
|
-
'ì': "\u0131\u0300"
|
|
1165
|
-
};
|
|
1166
|
-
/**
|
|
1167
|
-
* A symbol node contains information about a single symbol. It either renders
|
|
1168
|
-
* to a single text node, or a span with a single text node in it, depending on
|
|
1169
|
-
* whether it has CSS classes, styles, or needs italic correction.
|
|
1170
|
-
*/
|
|
1171
|
-
|
|
1172
|
-
var SymbolNode = /*#__PURE__*/function () {
|
|
1173
|
-
function SymbolNode(text, height, depth, italic, skew, width, classes, style) {
|
|
1174
|
-
this.text = void 0;
|
|
1175
|
-
this.height = void 0;
|
|
1176
|
-
this.depth = void 0;
|
|
1177
|
-
this.italic = void 0;
|
|
1178
|
-
this.skew = void 0;
|
|
1179
|
-
this.width = void 0;
|
|
1180
|
-
this.maxFontSize = void 0;
|
|
1181
|
-
this.classes = void 0;
|
|
1182
|
-
this.style = void 0;
|
|
1183
|
-
this.text = text;
|
|
1184
|
-
this.height = height || 0;
|
|
1185
|
-
this.depth = depth || 0;
|
|
1186
|
-
this.italic = italic || 0;
|
|
1187
|
-
this.skew = skew || 0;
|
|
1188
|
-
this.width = width || 0;
|
|
1189
|
-
this.classes = classes || [];
|
|
1190
|
-
this.style = style || {};
|
|
1191
|
-
this.maxFontSize = 0; // Mark text from non-Latin scripts with specific classes so that we
|
|
1192
|
-
// can specify which fonts to use. This allows us to render these
|
|
1193
|
-
// characters with a serif font in situations where the browser would
|
|
1194
|
-
// either default to a sans serif or render a placeholder character.
|
|
1195
|
-
// We use CSS class names like cjk_fallback, hangul_fallback and
|
|
1196
|
-
// brahmic_fallback. See ./unicodeScripts.js for the set of possible
|
|
1197
|
-
// script names
|
|
1198
|
-
|
|
1199
|
-
var script = scriptFromCodepoint(this.text.charCodeAt(0));
|
|
1200
|
-
|
|
1201
|
-
if (script) {
|
|
1202
|
-
this.classes.push(script + "_fallback");
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
if (/[îïíì]/.test(this.text)) {
|
|
1206
|
-
// add ī when we add Extended Latin
|
|
1207
|
-
this.text = iCombinations[this.text];
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
var _proto4 = SymbolNode.prototype;
|
|
1212
|
-
|
|
1213
|
-
_proto4.hasClass = function hasClass(className) {
|
|
1214
|
-
return utils.contains(this.classes, className);
|
|
1215
|
-
}
|
|
1216
|
-
/**
|
|
1217
|
-
* Creates a text node or span from a symbol node. Note that a span is only
|
|
1218
|
-
* created if it is needed.
|
|
1219
|
-
*/
|
|
1220
|
-
;
|
|
1221
|
-
|
|
1222
|
-
_proto4.toNode = function toNode() {
|
|
1223
|
-
var node = document.createTextNode(this.text);
|
|
1224
|
-
var span = null;
|
|
1225
|
-
|
|
1226
|
-
if (this.italic > 0) {
|
|
1227
|
-
span = document.createElement("span");
|
|
1228
|
-
span.style.marginRight = this.italic + "em";
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
if (this.classes.length > 0) {
|
|
1232
|
-
span = span || document.createElement("span");
|
|
1233
|
-
span.className = createClass(this.classes);
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
for (var style in this.style) {
|
|
1237
|
-
if (this.style.hasOwnProperty(style)) {
|
|
1238
|
-
span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type.
|
|
1239
|
-
|
|
1240
|
-
span.style[style] = this.style[style];
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
if (span) {
|
|
1245
|
-
span.appendChild(node);
|
|
1246
|
-
return span;
|
|
1247
|
-
} else {
|
|
1248
|
-
return node;
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
/**
|
|
1252
|
-
* Creates markup for a symbol node.
|
|
1253
|
-
*/
|
|
1254
|
-
;
|
|
1255
|
-
|
|
1256
|
-
_proto4.toMarkup = function toMarkup() {
|
|
1257
|
-
// TODO(alpert): More duplication than I'd like from
|
|
1258
|
-
// span.prototype.toMarkup and symbolNode.prototype.toNode...
|
|
1259
|
-
var needsSpan = false;
|
|
1260
|
-
var markup = "<span";
|
|
1261
|
-
|
|
1262
|
-
if (this.classes.length) {
|
|
1263
|
-
needsSpan = true;
|
|
1264
|
-
markup += " class=\"";
|
|
1265
|
-
markup += utils.escape(createClass(this.classes));
|
|
1266
|
-
markup += "\"";
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
var styles = "";
|
|
1270
|
-
|
|
1271
|
-
if (this.italic > 0) {
|
|
1272
|
-
styles += "margin-right:" + this.italic + "em;";
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
for (var style in this.style) {
|
|
1276
|
-
if (this.style.hasOwnProperty(style)) {
|
|
1277
|
-
styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
if (styles) {
|
|
1282
|
-
needsSpan = true;
|
|
1283
|
-
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
var escaped = utils.escape(this.text);
|
|
1287
|
-
|
|
1288
|
-
if (needsSpan) {
|
|
1289
|
-
markup += ">";
|
|
1290
|
-
markup += escaped;
|
|
1291
|
-
markup += "</span>";
|
|
1292
|
-
return markup;
|
|
1293
|
-
} else {
|
|
1294
|
-
return escaped;
|
|
1295
|
-
}
|
|
1296
|
-
};
|
|
1297
|
-
|
|
1298
|
-
return SymbolNode;
|
|
1299
|
-
}();
|
|
1300
|
-
/**
|
|
1301
|
-
* SVG nodes are used to render stretchy wide elements.
|
|
1302
|
-
*/
|
|
1303
|
-
|
|
1304
|
-
var SvgNode = /*#__PURE__*/function () {
|
|
1305
|
-
function SvgNode(children, attributes) {
|
|
1306
|
-
this.children = void 0;
|
|
1307
|
-
this.attributes = void 0;
|
|
1308
|
-
this.children = children || [];
|
|
1309
|
-
this.attributes = attributes || {};
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
var _proto5 = SvgNode.prototype;
|
|
1313
|
-
|
|
1314
|
-
_proto5.toNode = function toNode() {
|
|
1315
|
-
var svgNS = "http://www.w3.org/2000/svg";
|
|
1316
|
-
var node = document.createElementNS(svgNS, "svg"); // Apply attributes
|
|
1317
|
-
|
|
1318
|
-
for (var attr in this.attributes) {
|
|
1319
|
-
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
1320
|
-
node.setAttribute(attr, this.attributes[attr]);
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
for (var i = 0; i < this.children.length; i++) {
|
|
1325
|
-
node.appendChild(this.children[i].toNode());
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
return node;
|
|
1329
|
-
};
|
|
1330
|
-
|
|
1331
|
-
_proto5.toMarkup = function toMarkup() {
|
|
1332
|
-
var markup = "<svg xmlns=\"http://www.w3.org/2000/svg\""; // Apply attributes
|
|
1333
|
-
|
|
1334
|
-
for (var attr in this.attributes) {
|
|
1335
|
-
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
1336
|
-
markup += " " + attr + "='" + this.attributes[attr] + "'";
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
markup += ">";
|
|
1341
|
-
|
|
1342
|
-
for (var i = 0; i < this.children.length; i++) {
|
|
1343
|
-
markup += this.children[i].toMarkup();
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
markup += "</svg>";
|
|
1347
|
-
return markup;
|
|
1348
|
-
};
|
|
1349
|
-
|
|
1350
|
-
return SvgNode;
|
|
1351
|
-
}();
|
|
1352
|
-
var PathNode = /*#__PURE__*/function () {
|
|
1353
|
-
function PathNode(pathName, alternate) {
|
|
1354
|
-
this.pathName = void 0;
|
|
1355
|
-
this.alternate = void 0;
|
|
1356
|
-
this.pathName = pathName;
|
|
1357
|
-
this.alternate = alternate; // Used only for \sqrt, \phase, & tall delims
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
var _proto6 = PathNode.prototype;
|
|
1361
|
-
|
|
1362
|
-
_proto6.toNode = function toNode() {
|
|
1363
|
-
var svgNS = "http://www.w3.org/2000/svg";
|
|
1364
|
-
var node = document.createElementNS(svgNS, "path");
|
|
1365
|
-
|
|
1366
|
-
if (this.alternate) {
|
|
1367
|
-
node.setAttribute("d", this.alternate);
|
|
1368
|
-
} else {
|
|
1369
|
-
node.setAttribute("d", path[this.pathName]);
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
return node;
|
|
1373
|
-
};
|
|
1374
|
-
|
|
1375
|
-
_proto6.toMarkup = function toMarkup() {
|
|
1376
|
-
if (this.alternate) {
|
|
1377
|
-
return "<path d='" + this.alternate + "'/>";
|
|
1378
|
-
} else {
|
|
1379
|
-
return "<path d='" + path[this.pathName] + "'/>";
|
|
1380
|
-
}
|
|
1381
|
-
};
|
|
1382
|
-
|
|
1383
|
-
return PathNode;
|
|
1384
|
-
}();
|
|
1385
|
-
var LineNode = /*#__PURE__*/function () {
|
|
1386
|
-
function LineNode(attributes) {
|
|
1387
|
-
this.attributes = void 0;
|
|
1388
|
-
this.attributes = attributes || {};
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
var _proto7 = LineNode.prototype;
|
|
1392
|
-
|
|
1393
|
-
_proto7.toNode = function toNode() {
|
|
1394
|
-
var svgNS = "http://www.w3.org/2000/svg";
|
|
1395
|
-
var node = document.createElementNS(svgNS, "line"); // Apply attributes
|
|
1396
|
-
|
|
1397
|
-
for (var attr in this.attributes) {
|
|
1398
|
-
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
1399
|
-
node.setAttribute(attr, this.attributes[attr]);
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
return node;
|
|
1404
|
-
};
|
|
1405
|
-
|
|
1406
|
-
_proto7.toMarkup = function toMarkup() {
|
|
1407
|
-
var markup = "<line";
|
|
1408
|
-
|
|
1409
|
-
for (var attr in this.attributes) {
|
|
1410
|
-
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
1411
|
-
markup += " " + attr + "='" + this.attributes[attr] + "'";
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
markup += "/>";
|
|
1416
|
-
return markup;
|
|
1417
|
-
};
|
|
1418
|
-
|
|
1419
|
-
return LineNode;
|
|
1420
|
-
}();
|
|
1421
|
-
function assertSymbolDomNode(group) {
|
|
1422
|
-
if (group instanceof SymbolNode) {
|
|
1423
|
-
return group;
|
|
1424
|
-
} else {
|
|
1425
|
-
throw new Error("Expected symbolNode but got " + String(group) + ".");
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
function assertSpan(group) {
|
|
1429
|
-
if (group instanceof Span) {
|
|
1430
|
-
return group;
|
|
1431
|
-
} else {
|
|
1432
|
-
throw new Error("Expected span<HtmlDomNode> but got " + String(group) + ".");
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
1009
|
;// CONCATENATED MODULE: ./src/fontMetricsData.js
|
|
1436
1010
|
// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY.
|
|
1437
1011
|
/* harmony default export */ var fontMetricsData = ({
|
|
@@ -2017,6 +1591,7 @@ function assertSpan(group) {
|
|
|
2017
1591
|
"8764": [-0.10889, 0.39111, 0, 0, 0.89444],
|
|
2018
1592
|
"8768": [0.19444, 0.69444, 0, 0, 0.31944],
|
|
2019
1593
|
"8771": [0.00222, 0.50222, 0, 0, 0.89444],
|
|
1594
|
+
"8773": [0.027, 0.638, 0, 0, 0.894],
|
|
2020
1595
|
"8776": [0.02444, 0.52444, 0, 0, 0.89444],
|
|
2021
1596
|
"8781": [0.00222, 0.50222, 0, 0, 0.89444],
|
|
2022
1597
|
"8801": [0.00222, 0.50222, 0, 0, 0.89444],
|
|
@@ -2534,7 +2109,7 @@ function assertSpan(group) {
|
|
|
2534
2109
|
"8764": [-0.13313, 0.36687, 0, 0, 0.77778],
|
|
2535
2110
|
"8768": [0.19444, 0.69444, 0, 0, 0.27778],
|
|
2536
2111
|
"8771": [-0.03625, 0.46375, 0, 0, 0.77778],
|
|
2537
|
-
"8773": [-0.022, 0.589, 0, 0,
|
|
2112
|
+
"8773": [-0.022, 0.589, 0, 0, 0.778],
|
|
2538
2113
|
"8776": [-0.01688, 0.48312, 0, 0, 0.77778],
|
|
2539
2114
|
"8781": [-0.03625, 0.46375, 0, 0, 0.77778],
|
|
2540
2115
|
"8784": [-0.133, 0.673, 0, 0, 0.778],
|
|
@@ -3508,289 +3083,1279 @@ function assertSpan(group) {
|
|
|
3508
3083
|
"8242": [0, 0.61111, 0, 0, 0.525],
|
|
3509
3084
|
"9251": [0.11111, 0.21944, 0, 0, 0.525]
|
|
3510
3085
|
}
|
|
3511
|
-
});
|
|
3512
|
-
;// CONCATENATED MODULE: ./src/fontMetrics.js
|
|
3086
|
+
});
|
|
3087
|
+
;// CONCATENATED MODULE: ./src/fontMetrics.js
|
|
3088
|
+
|
|
3089
|
+
|
|
3090
|
+
/**
|
|
3091
|
+
* This file contains metrics regarding fonts and individual symbols. The sigma
|
|
3092
|
+
* and xi variables, as well as the metricMap map contain data extracted from
|
|
3093
|
+
* TeX, TeX font metrics, and the TTF files. These data are then exposed via the
|
|
3094
|
+
* `metrics` variable and the getCharacterMetrics function.
|
|
3095
|
+
*/
|
|
3096
|
+
// In TeX, there are actually three sets of dimensions, one for each of
|
|
3097
|
+
// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
|
|
3098
|
+
// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
|
|
3099
|
+
// provided in the the arrays below, in that order.
|
|
3100
|
+
//
|
|
3101
|
+
// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
|
|
3102
|
+
// This was determined by running the following script:
|
|
3103
|
+
//
|
|
3104
|
+
// latex -interaction=nonstopmode \
|
|
3105
|
+
// '\documentclass{article}\usepackage{amsmath}\begin{document}' \
|
|
3106
|
+
// '$a$ \expandafter\show\the\textfont2' \
|
|
3107
|
+
// '\expandafter\show\the\scriptfont2' \
|
|
3108
|
+
// '\expandafter\show\the\scriptscriptfont2' \
|
|
3109
|
+
// '\stop'
|
|
3110
|
+
//
|
|
3111
|
+
// The metrics themselves were retreived using the following commands:
|
|
3112
|
+
//
|
|
3113
|
+
// tftopl cmsy10
|
|
3114
|
+
// tftopl cmsy7
|
|
3115
|
+
// tftopl cmsy5
|
|
3116
|
+
//
|
|
3117
|
+
// The output of each of these commands is quite lengthy. The only part we
|
|
3118
|
+
// care about is the FONTDIMEN section. Each value is measured in EMs.
|
|
3119
|
+
var sigmasAndXis = {
|
|
3120
|
+
slant: [0.250, 0.250, 0.250],
|
|
3121
|
+
// sigma1
|
|
3122
|
+
space: [0.000, 0.000, 0.000],
|
|
3123
|
+
// sigma2
|
|
3124
|
+
stretch: [0.000, 0.000, 0.000],
|
|
3125
|
+
// sigma3
|
|
3126
|
+
shrink: [0.000, 0.000, 0.000],
|
|
3127
|
+
// sigma4
|
|
3128
|
+
xHeight: [0.431, 0.431, 0.431],
|
|
3129
|
+
// sigma5
|
|
3130
|
+
quad: [1.000, 1.171, 1.472],
|
|
3131
|
+
// sigma6
|
|
3132
|
+
extraSpace: [0.000, 0.000, 0.000],
|
|
3133
|
+
// sigma7
|
|
3134
|
+
num1: [0.677, 0.732, 0.925],
|
|
3135
|
+
// sigma8
|
|
3136
|
+
num2: [0.394, 0.384, 0.387],
|
|
3137
|
+
// sigma9
|
|
3138
|
+
num3: [0.444, 0.471, 0.504],
|
|
3139
|
+
// sigma10
|
|
3140
|
+
denom1: [0.686, 0.752, 1.025],
|
|
3141
|
+
// sigma11
|
|
3142
|
+
denom2: [0.345, 0.344, 0.532],
|
|
3143
|
+
// sigma12
|
|
3144
|
+
sup1: [0.413, 0.503, 0.504],
|
|
3145
|
+
// sigma13
|
|
3146
|
+
sup2: [0.363, 0.431, 0.404],
|
|
3147
|
+
// sigma14
|
|
3148
|
+
sup3: [0.289, 0.286, 0.294],
|
|
3149
|
+
// sigma15
|
|
3150
|
+
sub1: [0.150, 0.143, 0.200],
|
|
3151
|
+
// sigma16
|
|
3152
|
+
sub2: [0.247, 0.286, 0.400],
|
|
3153
|
+
// sigma17
|
|
3154
|
+
supDrop: [0.386, 0.353, 0.494],
|
|
3155
|
+
// sigma18
|
|
3156
|
+
subDrop: [0.050, 0.071, 0.100],
|
|
3157
|
+
// sigma19
|
|
3158
|
+
delim1: [2.390, 1.700, 1.980],
|
|
3159
|
+
// sigma20
|
|
3160
|
+
delim2: [1.010, 1.157, 1.420],
|
|
3161
|
+
// sigma21
|
|
3162
|
+
axisHeight: [0.250, 0.250, 0.250],
|
|
3163
|
+
// sigma22
|
|
3164
|
+
// These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
|
|
3165
|
+
// they correspond to the font parameters of the extension fonts (family 3).
|
|
3166
|
+
// See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
|
|
3167
|
+
// match cmex7, we'd use cmex7.tfm values for script and scriptscript
|
|
3168
|
+
// values.
|
|
3169
|
+
defaultRuleThickness: [0.04, 0.049, 0.049],
|
|
3170
|
+
// xi8; cmex7: 0.049
|
|
3171
|
+
bigOpSpacing1: [0.111, 0.111, 0.111],
|
|
3172
|
+
// xi9
|
|
3173
|
+
bigOpSpacing2: [0.166, 0.166, 0.166],
|
|
3174
|
+
// xi10
|
|
3175
|
+
bigOpSpacing3: [0.2, 0.2, 0.2],
|
|
3176
|
+
// xi11
|
|
3177
|
+
bigOpSpacing4: [0.6, 0.611, 0.611],
|
|
3178
|
+
// xi12; cmex7: 0.611
|
|
3179
|
+
bigOpSpacing5: [0.1, 0.143, 0.143],
|
|
3180
|
+
// xi13; cmex7: 0.143
|
|
3181
|
+
// The \sqrt rule width is taken from the height of the surd character.
|
|
3182
|
+
// Since we use the same font at all sizes, this thickness doesn't scale.
|
|
3183
|
+
sqrtRuleThickness: [0.04, 0.04, 0.04],
|
|
3184
|
+
// This value determines how large a pt is, for metrics which are defined
|
|
3185
|
+
// in terms of pts.
|
|
3186
|
+
// This value is also used in katex.less; if you change it make sure the
|
|
3187
|
+
// values match.
|
|
3188
|
+
ptPerEm: [10.0, 10.0, 10.0],
|
|
3189
|
+
// The space between adjacent `|` columns in an array definition. From
|
|
3190
|
+
// `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
|
|
3191
|
+
doubleRuleSep: [0.2, 0.2, 0.2],
|
|
3192
|
+
// The width of separator lines in {array} environments. From
|
|
3193
|
+
// `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
|
|
3194
|
+
arrayRuleWidth: [0.04, 0.04, 0.04],
|
|
3195
|
+
// Two values from LaTeX source2e:
|
|
3196
|
+
fboxsep: [0.3, 0.3, 0.3],
|
|
3197
|
+
// 3 pt / ptPerEm
|
|
3198
|
+
fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm
|
|
3199
|
+
|
|
3200
|
+
}; // This map contains a mapping from font name and character code to character
|
|
3201
|
+
// metrics, including height, depth, italic correction, and skew (kern from the
|
|
3202
|
+
// character to the corresponding \skewchar)
|
|
3203
|
+
// This map is generated via `make metrics`. It should not be changed manually.
|
|
3204
|
+
|
|
3205
|
+
// These are very rough approximations. We default to Times New Roman which
|
|
3206
|
+
// should have Latin-1 and Cyrillic characters, but may not depending on the
|
|
3207
|
+
// operating system. The metrics do not account for extra height from the
|
|
3208
|
+
// accents. In the case of Cyrillic characters which have both ascenders and
|
|
3209
|
+
// descenders we prefer approximations with ascenders, primarily to prevent
|
|
3210
|
+
// the fraction bar or root line from intersecting the glyph.
|
|
3211
|
+
// TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
|
|
3212
|
+
|
|
3213
|
+
var extraCharacterMap = {
|
|
3214
|
+
// Latin-1
|
|
3215
|
+
'Å': 'A',
|
|
3216
|
+
'Ð': 'D',
|
|
3217
|
+
'Þ': 'o',
|
|
3218
|
+
'å': 'a',
|
|
3219
|
+
'ð': 'd',
|
|
3220
|
+
'þ': 'o',
|
|
3221
|
+
// Cyrillic
|
|
3222
|
+
'А': 'A',
|
|
3223
|
+
'Б': 'B',
|
|
3224
|
+
'В': 'B',
|
|
3225
|
+
'Г': 'F',
|
|
3226
|
+
'Д': 'A',
|
|
3227
|
+
'Е': 'E',
|
|
3228
|
+
'Ж': 'K',
|
|
3229
|
+
'З': '3',
|
|
3230
|
+
'И': 'N',
|
|
3231
|
+
'Й': 'N',
|
|
3232
|
+
'К': 'K',
|
|
3233
|
+
'Л': 'N',
|
|
3234
|
+
'М': 'M',
|
|
3235
|
+
'Н': 'H',
|
|
3236
|
+
'О': 'O',
|
|
3237
|
+
'П': 'N',
|
|
3238
|
+
'Р': 'P',
|
|
3239
|
+
'С': 'C',
|
|
3240
|
+
'Т': 'T',
|
|
3241
|
+
'У': 'y',
|
|
3242
|
+
'Ф': 'O',
|
|
3243
|
+
'Х': 'X',
|
|
3244
|
+
'Ц': 'U',
|
|
3245
|
+
'Ч': 'h',
|
|
3246
|
+
'Ш': 'W',
|
|
3247
|
+
'Щ': 'W',
|
|
3248
|
+
'Ъ': 'B',
|
|
3249
|
+
'Ы': 'X',
|
|
3250
|
+
'Ь': 'B',
|
|
3251
|
+
'Э': '3',
|
|
3252
|
+
'Ю': 'X',
|
|
3253
|
+
'Я': 'R',
|
|
3254
|
+
'а': 'a',
|
|
3255
|
+
'б': 'b',
|
|
3256
|
+
'в': 'a',
|
|
3257
|
+
'г': 'r',
|
|
3258
|
+
'д': 'y',
|
|
3259
|
+
'е': 'e',
|
|
3260
|
+
'ж': 'm',
|
|
3261
|
+
'з': 'e',
|
|
3262
|
+
'и': 'n',
|
|
3263
|
+
'й': 'n',
|
|
3264
|
+
'к': 'n',
|
|
3265
|
+
'л': 'n',
|
|
3266
|
+
'м': 'm',
|
|
3267
|
+
'н': 'n',
|
|
3268
|
+
'о': 'o',
|
|
3269
|
+
'п': 'n',
|
|
3270
|
+
'р': 'p',
|
|
3271
|
+
'с': 'c',
|
|
3272
|
+
'т': 'o',
|
|
3273
|
+
'у': 'y',
|
|
3274
|
+
'ф': 'b',
|
|
3275
|
+
'х': 'x',
|
|
3276
|
+
'ц': 'n',
|
|
3277
|
+
'ч': 'n',
|
|
3278
|
+
'ш': 'w',
|
|
3279
|
+
'щ': 'w',
|
|
3280
|
+
'ъ': 'a',
|
|
3281
|
+
'ы': 'm',
|
|
3282
|
+
'ь': 'a',
|
|
3283
|
+
'э': 'e',
|
|
3284
|
+
'ю': 'm',
|
|
3285
|
+
'я': 'r'
|
|
3286
|
+
};
|
|
3287
|
+
|
|
3288
|
+
/**
|
|
3289
|
+
* This function adds new font metrics to default metricMap
|
|
3290
|
+
* It can also override existing metrics
|
|
3291
|
+
*/
|
|
3292
|
+
function setFontMetrics(fontName, metrics) {
|
|
3293
|
+
fontMetricsData[fontName] = metrics;
|
|
3294
|
+
}
|
|
3295
|
+
/**
|
|
3296
|
+
* This function is a convenience function for looking up information in the
|
|
3297
|
+
* metricMap table. It takes a character as a string, and a font.
|
|
3298
|
+
*
|
|
3299
|
+
* Note: the `width` property may be undefined if fontMetricsData.js wasn't
|
|
3300
|
+
* built using `Make extended_metrics`.
|
|
3301
|
+
*/
|
|
3302
|
+
|
|
3303
|
+
function getCharacterMetrics(character, font, mode) {
|
|
3304
|
+
if (!fontMetricsData[font]) {
|
|
3305
|
+
throw new Error("Font metrics not found for font: " + font + ".");
|
|
3306
|
+
}
|
|
3307
|
+
|
|
3308
|
+
var ch = character.charCodeAt(0);
|
|
3309
|
+
var metrics = fontMetricsData[font][ch];
|
|
3310
|
+
|
|
3311
|
+
if (!metrics && character[0] in extraCharacterMap) {
|
|
3312
|
+
ch = extraCharacterMap[character[0]].charCodeAt(0);
|
|
3313
|
+
metrics = fontMetricsData[font][ch];
|
|
3314
|
+
}
|
|
3315
|
+
|
|
3316
|
+
if (!metrics && mode === 'text') {
|
|
3317
|
+
// We don't typically have font metrics for Asian scripts.
|
|
3318
|
+
// But since we support them in text mode, we need to return
|
|
3319
|
+
// some sort of metrics.
|
|
3320
|
+
// So if the character is in a script we support but we
|
|
3321
|
+
// don't have metrics for it, just use the metrics for
|
|
3322
|
+
// the Latin capital letter M. This is close enough because
|
|
3323
|
+
// we (currently) only care about the height of the glpyh
|
|
3324
|
+
// not its width.
|
|
3325
|
+
if (supportedCodepoint(ch)) {
|
|
3326
|
+
metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M'
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
|
|
3330
|
+
if (metrics) {
|
|
3331
|
+
return {
|
|
3332
|
+
depth: metrics[0],
|
|
3333
|
+
height: metrics[1],
|
|
3334
|
+
italic: metrics[2],
|
|
3335
|
+
skew: metrics[3],
|
|
3336
|
+
width: metrics[4]
|
|
3337
|
+
};
|
|
3338
|
+
}
|
|
3339
|
+
}
|
|
3340
|
+
var fontMetricsBySizeIndex = {};
|
|
3341
|
+
/**
|
|
3342
|
+
* Get the font metrics for a given size.
|
|
3343
|
+
*/
|
|
3344
|
+
|
|
3345
|
+
function getGlobalMetrics(size) {
|
|
3346
|
+
var sizeIndex;
|
|
3347
|
+
|
|
3348
|
+
if (size >= 5) {
|
|
3349
|
+
sizeIndex = 0;
|
|
3350
|
+
} else if (size >= 3) {
|
|
3351
|
+
sizeIndex = 1;
|
|
3352
|
+
} else {
|
|
3353
|
+
sizeIndex = 2;
|
|
3354
|
+
}
|
|
3355
|
+
|
|
3356
|
+
if (!fontMetricsBySizeIndex[sizeIndex]) {
|
|
3357
|
+
var metrics = fontMetricsBySizeIndex[sizeIndex] = {
|
|
3358
|
+
cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18
|
|
3359
|
+
};
|
|
3360
|
+
|
|
3361
|
+
for (var key in sigmasAndXis) {
|
|
3362
|
+
if (sigmasAndXis.hasOwnProperty(key)) {
|
|
3363
|
+
metrics[key] = sigmasAndXis[key][sizeIndex];
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
|
|
3368
|
+
return fontMetricsBySizeIndex[sizeIndex];
|
|
3369
|
+
}
|
|
3370
|
+
;// CONCATENATED MODULE: ./src/Options.js
|
|
3371
|
+
/**
|
|
3372
|
+
* This file contains information about the options that the Parser carries
|
|
3373
|
+
* around with it while parsing. Data is held in an `Options` object, and when
|
|
3374
|
+
* recursing, a new `Options` object can be created with the `.with*` and
|
|
3375
|
+
* `.reset` functions.
|
|
3376
|
+
*/
|
|
3377
|
+
|
|
3378
|
+
var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize].
|
|
3379
|
+
// The size mappings are taken from TeX with \normalsize=10pt.
|
|
3380
|
+
[1, 1, 1], // size1: [5, 5, 5] \tiny
|
|
3381
|
+
[2, 1, 1], // size2: [6, 5, 5]
|
|
3382
|
+
[3, 1, 1], // size3: [7, 5, 5] \scriptsize
|
|
3383
|
+
[4, 2, 1], // size4: [8, 6, 5] \footnotesize
|
|
3384
|
+
[5, 2, 1], // size5: [9, 6, 5] \small
|
|
3385
|
+
[6, 3, 1], // size6: [10, 7, 5] \normalsize
|
|
3386
|
+
[7, 4, 2], // size7: [12, 8, 6] \large
|
|
3387
|
+
[8, 6, 3], // size8: [14.4, 10, 7] \Large
|
|
3388
|
+
[9, 7, 6], // size9: [17.28, 12, 10] \LARGE
|
|
3389
|
+
[10, 8, 7], // size10: [20.74, 14.4, 12] \huge
|
|
3390
|
+
[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE
|
|
3391
|
+
];
|
|
3392
|
+
var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if
|
|
3393
|
+
// you change size indexes, change that function.
|
|
3394
|
+
0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
|
|
3395
|
+
|
|
3396
|
+
var sizeAtStyle = function sizeAtStyle(size, style) {
|
|
3397
|
+
return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
|
|
3398
|
+
}; // In these types, "" (empty string) means "no change".
|
|
3399
|
+
|
|
3400
|
+
|
|
3401
|
+
/**
|
|
3402
|
+
* This is the main options class. It contains the current style, size, color,
|
|
3403
|
+
* and font.
|
|
3404
|
+
*
|
|
3405
|
+
* Options objects should not be modified. To create a new Options with
|
|
3406
|
+
* different properties, call a `.having*` method.
|
|
3407
|
+
*/
|
|
3408
|
+
var Options = /*#__PURE__*/function () {
|
|
3409
|
+
// A font family applies to a group of fonts (i.e. SansSerif), while a font
|
|
3410
|
+
// represents a specific font (i.e. SansSerif Bold).
|
|
3411
|
+
// See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm
|
|
3412
|
+
|
|
3413
|
+
/**
|
|
3414
|
+
* The base size index.
|
|
3415
|
+
*/
|
|
3416
|
+
function Options(data) {
|
|
3417
|
+
this.style = void 0;
|
|
3418
|
+
this.color = void 0;
|
|
3419
|
+
this.size = void 0;
|
|
3420
|
+
this.textSize = void 0;
|
|
3421
|
+
this.phantom = void 0;
|
|
3422
|
+
this.font = void 0;
|
|
3423
|
+
this.fontFamily = void 0;
|
|
3424
|
+
this.fontWeight = void 0;
|
|
3425
|
+
this.fontShape = void 0;
|
|
3426
|
+
this.sizeMultiplier = void 0;
|
|
3427
|
+
this.maxSize = void 0;
|
|
3428
|
+
this.minRuleThickness = void 0;
|
|
3429
|
+
this._fontMetrics = void 0;
|
|
3430
|
+
this.style = data.style;
|
|
3431
|
+
this.color = data.color;
|
|
3432
|
+
this.size = data.size || Options.BASESIZE;
|
|
3433
|
+
this.textSize = data.textSize || this.size;
|
|
3434
|
+
this.phantom = !!data.phantom;
|
|
3435
|
+
this.font = data.font || "";
|
|
3436
|
+
this.fontFamily = data.fontFamily || "";
|
|
3437
|
+
this.fontWeight = data.fontWeight || '';
|
|
3438
|
+
this.fontShape = data.fontShape || '';
|
|
3439
|
+
this.sizeMultiplier = sizeMultipliers[this.size - 1];
|
|
3440
|
+
this.maxSize = data.maxSize;
|
|
3441
|
+
this.minRuleThickness = data.minRuleThickness;
|
|
3442
|
+
this._fontMetrics = undefined;
|
|
3443
|
+
}
|
|
3444
|
+
/**
|
|
3445
|
+
* Returns a new options object with the same properties as "this". Properties
|
|
3446
|
+
* from "extension" will be copied to the new options object.
|
|
3447
|
+
*/
|
|
3448
|
+
|
|
3449
|
+
|
|
3450
|
+
var _proto = Options.prototype;
|
|
3451
|
+
|
|
3452
|
+
_proto.extend = function extend(extension) {
|
|
3453
|
+
var data = {
|
|
3454
|
+
style: this.style,
|
|
3455
|
+
size: this.size,
|
|
3456
|
+
textSize: this.textSize,
|
|
3457
|
+
color: this.color,
|
|
3458
|
+
phantom: this.phantom,
|
|
3459
|
+
font: this.font,
|
|
3460
|
+
fontFamily: this.fontFamily,
|
|
3461
|
+
fontWeight: this.fontWeight,
|
|
3462
|
+
fontShape: this.fontShape,
|
|
3463
|
+
maxSize: this.maxSize,
|
|
3464
|
+
minRuleThickness: this.minRuleThickness
|
|
3465
|
+
};
|
|
3466
|
+
|
|
3467
|
+
for (var key in extension) {
|
|
3468
|
+
if (extension.hasOwnProperty(key)) {
|
|
3469
|
+
data[key] = extension[key];
|
|
3470
|
+
}
|
|
3471
|
+
}
|
|
3472
|
+
|
|
3473
|
+
return new Options(data);
|
|
3474
|
+
}
|
|
3475
|
+
/**
|
|
3476
|
+
* Return an options object with the given style. If `this.style === style`,
|
|
3477
|
+
* returns `this`.
|
|
3478
|
+
*/
|
|
3479
|
+
;
|
|
3480
|
+
|
|
3481
|
+
_proto.havingStyle = function havingStyle(style) {
|
|
3482
|
+
if (this.style === style) {
|
|
3483
|
+
return this;
|
|
3484
|
+
} else {
|
|
3485
|
+
return this.extend({
|
|
3486
|
+
style: style,
|
|
3487
|
+
size: sizeAtStyle(this.textSize, style)
|
|
3488
|
+
});
|
|
3489
|
+
}
|
|
3490
|
+
}
|
|
3491
|
+
/**
|
|
3492
|
+
* Return an options object with a cramped version of the current style. If
|
|
3493
|
+
* the current style is cramped, returns `this`.
|
|
3494
|
+
*/
|
|
3495
|
+
;
|
|
3496
|
+
|
|
3497
|
+
_proto.havingCrampedStyle = function havingCrampedStyle() {
|
|
3498
|
+
return this.havingStyle(this.style.cramp());
|
|
3499
|
+
}
|
|
3500
|
+
/**
|
|
3501
|
+
* Return an options object with the given size and in at least `\textstyle`.
|
|
3502
|
+
* Returns `this` if appropriate.
|
|
3503
|
+
*/
|
|
3504
|
+
;
|
|
3505
|
+
|
|
3506
|
+
_proto.havingSize = function havingSize(size) {
|
|
3507
|
+
if (this.size === size && this.textSize === size) {
|
|
3508
|
+
return this;
|
|
3509
|
+
} else {
|
|
3510
|
+
return this.extend({
|
|
3511
|
+
style: this.style.text(),
|
|
3512
|
+
size: size,
|
|
3513
|
+
textSize: size,
|
|
3514
|
+
sizeMultiplier: sizeMultipliers[size - 1]
|
|
3515
|
+
});
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
/**
|
|
3519
|
+
* Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
|
|
3520
|
+
* changes to at least `\textstyle`.
|
|
3521
|
+
*/
|
|
3522
|
+
;
|
|
3523
|
+
|
|
3524
|
+
_proto.havingBaseStyle = function havingBaseStyle(style) {
|
|
3525
|
+
style = style || this.style.text();
|
|
3526
|
+
var wantSize = sizeAtStyle(Options.BASESIZE, style);
|
|
3527
|
+
|
|
3528
|
+
if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) {
|
|
3529
|
+
return this;
|
|
3530
|
+
} else {
|
|
3531
|
+
return this.extend({
|
|
3532
|
+
style: style,
|
|
3533
|
+
size: wantSize
|
|
3534
|
+
});
|
|
3535
|
+
}
|
|
3536
|
+
}
|
|
3537
|
+
/**
|
|
3538
|
+
* Remove the effect of sizing changes such as \Huge.
|
|
3539
|
+
* Keep the effect of the current style, such as \scriptstyle.
|
|
3540
|
+
*/
|
|
3541
|
+
;
|
|
3542
|
+
|
|
3543
|
+
_proto.havingBaseSizing = function havingBaseSizing() {
|
|
3544
|
+
var size;
|
|
3545
|
+
|
|
3546
|
+
switch (this.style.id) {
|
|
3547
|
+
case 4:
|
|
3548
|
+
case 5:
|
|
3549
|
+
size = 3; // normalsize in scriptstyle
|
|
3550
|
+
|
|
3551
|
+
break;
|
|
3552
|
+
|
|
3553
|
+
case 6:
|
|
3554
|
+
case 7:
|
|
3555
|
+
size = 1; // normalsize in scriptscriptstyle
|
|
3556
|
+
|
|
3557
|
+
break;
|
|
3558
|
+
|
|
3559
|
+
default:
|
|
3560
|
+
size = 6;
|
|
3561
|
+
// normalsize in textstyle or displaystyle
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
return this.extend({
|
|
3565
|
+
style: this.style.text(),
|
|
3566
|
+
size: size
|
|
3567
|
+
});
|
|
3568
|
+
}
|
|
3569
|
+
/**
|
|
3570
|
+
* Create a new options object with the given color.
|
|
3571
|
+
*/
|
|
3572
|
+
;
|
|
3573
|
+
|
|
3574
|
+
_proto.withColor = function withColor(color) {
|
|
3575
|
+
return this.extend({
|
|
3576
|
+
color: color
|
|
3577
|
+
});
|
|
3578
|
+
}
|
|
3579
|
+
/**
|
|
3580
|
+
* Create a new options object with "phantom" set to true.
|
|
3581
|
+
*/
|
|
3582
|
+
;
|
|
3583
|
+
|
|
3584
|
+
_proto.withPhantom = function withPhantom() {
|
|
3585
|
+
return this.extend({
|
|
3586
|
+
phantom: true
|
|
3587
|
+
});
|
|
3588
|
+
}
|
|
3589
|
+
/**
|
|
3590
|
+
* Creates a new options object with the given math font or old text font.
|
|
3591
|
+
* @type {[type]}
|
|
3592
|
+
*/
|
|
3593
|
+
;
|
|
3594
|
+
|
|
3595
|
+
_proto.withFont = function withFont(font) {
|
|
3596
|
+
return this.extend({
|
|
3597
|
+
font: font
|
|
3598
|
+
});
|
|
3599
|
+
}
|
|
3600
|
+
/**
|
|
3601
|
+
* Create a new options objects with the given fontFamily.
|
|
3602
|
+
*/
|
|
3603
|
+
;
|
|
3604
|
+
|
|
3605
|
+
_proto.withTextFontFamily = function withTextFontFamily(fontFamily) {
|
|
3606
|
+
return this.extend({
|
|
3607
|
+
fontFamily: fontFamily,
|
|
3608
|
+
font: ""
|
|
3609
|
+
});
|
|
3610
|
+
}
|
|
3611
|
+
/**
|
|
3612
|
+
* Creates a new options object with the given font weight
|
|
3613
|
+
*/
|
|
3614
|
+
;
|
|
3615
|
+
|
|
3616
|
+
_proto.withTextFontWeight = function withTextFontWeight(fontWeight) {
|
|
3617
|
+
return this.extend({
|
|
3618
|
+
fontWeight: fontWeight,
|
|
3619
|
+
font: ""
|
|
3620
|
+
});
|
|
3621
|
+
}
|
|
3622
|
+
/**
|
|
3623
|
+
* Creates a new options object with the given font weight
|
|
3624
|
+
*/
|
|
3625
|
+
;
|
|
3626
|
+
|
|
3627
|
+
_proto.withTextFontShape = function withTextFontShape(fontShape) {
|
|
3628
|
+
return this.extend({
|
|
3629
|
+
fontShape: fontShape,
|
|
3630
|
+
font: ""
|
|
3631
|
+
});
|
|
3632
|
+
}
|
|
3633
|
+
/**
|
|
3634
|
+
* Return the CSS sizing classes required to switch from enclosing options
|
|
3635
|
+
* `oldOptions` to `this`. Returns an array of classes.
|
|
3636
|
+
*/
|
|
3637
|
+
;
|
|
3638
|
+
|
|
3639
|
+
_proto.sizingClasses = function sizingClasses(oldOptions) {
|
|
3640
|
+
if (oldOptions.size !== this.size) {
|
|
3641
|
+
return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
|
|
3642
|
+
} else {
|
|
3643
|
+
return [];
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
/**
|
|
3647
|
+
* Return the CSS sizing classes required to switch to the base size. Like
|
|
3648
|
+
* `this.havingSize(BASESIZE).sizingClasses(this)`.
|
|
3649
|
+
*/
|
|
3650
|
+
;
|
|
3651
|
+
|
|
3652
|
+
_proto.baseSizingClasses = function baseSizingClasses() {
|
|
3653
|
+
if (this.size !== Options.BASESIZE) {
|
|
3654
|
+
return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
|
|
3655
|
+
} else {
|
|
3656
|
+
return [];
|
|
3657
|
+
}
|
|
3658
|
+
}
|
|
3659
|
+
/**
|
|
3660
|
+
* Return the font metrics for this size.
|
|
3661
|
+
*/
|
|
3662
|
+
;
|
|
3663
|
+
|
|
3664
|
+
_proto.fontMetrics = function fontMetrics() {
|
|
3665
|
+
if (!this._fontMetrics) {
|
|
3666
|
+
this._fontMetrics = getGlobalMetrics(this.size);
|
|
3667
|
+
}
|
|
3668
|
+
|
|
3669
|
+
return this._fontMetrics;
|
|
3670
|
+
}
|
|
3671
|
+
/**
|
|
3672
|
+
* Gets the CSS color of the current options object
|
|
3673
|
+
*/
|
|
3674
|
+
;
|
|
3675
|
+
|
|
3676
|
+
_proto.getColor = function getColor() {
|
|
3677
|
+
if (this.phantom) {
|
|
3678
|
+
return "transparent";
|
|
3679
|
+
} else {
|
|
3680
|
+
return this.color;
|
|
3681
|
+
}
|
|
3682
|
+
};
|
|
3683
|
+
|
|
3684
|
+
return Options;
|
|
3685
|
+
}();
|
|
3686
|
+
|
|
3687
|
+
Options.BASESIZE = 6;
|
|
3688
|
+
/* harmony default export */ var src_Options = (Options);
|
|
3689
|
+
;// CONCATENATED MODULE: ./src/units.js
|
|
3690
|
+
/**
|
|
3691
|
+
* This file does conversion between units. In particular, it provides
|
|
3692
|
+
* calculateSize to convert other units into ems.
|
|
3693
|
+
*/
|
|
3694
|
+
|
|
3695
|
+
// This table gives the number of TeX pts in one of each *absolute* TeX unit.
|
|
3696
|
+
// Thus, multiplying a length by this number converts the length from units
|
|
3697
|
+
// into pts. Dividing the result by ptPerEm gives the number of ems
|
|
3698
|
+
// *assuming* a font size of ptPerEm (normal size, normal style).
|
|
3699
|
+
|
|
3700
|
+
var ptPerUnit = {
|
|
3701
|
+
// https://en.wikibooks.org/wiki/LaTeX/Lengths and
|
|
3702
|
+
// https://tex.stackexchange.com/a/8263
|
|
3703
|
+
"pt": 1,
|
|
3704
|
+
// TeX point
|
|
3705
|
+
"mm": 7227 / 2540,
|
|
3706
|
+
// millimeter
|
|
3707
|
+
"cm": 7227 / 254,
|
|
3708
|
+
// centimeter
|
|
3709
|
+
"in": 72.27,
|
|
3710
|
+
// inch
|
|
3711
|
+
"bp": 803 / 800,
|
|
3712
|
+
// big (PostScript) points
|
|
3713
|
+
"pc": 12,
|
|
3714
|
+
// pica
|
|
3715
|
+
"dd": 1238 / 1157,
|
|
3716
|
+
// didot
|
|
3717
|
+
"cc": 14856 / 1157,
|
|
3718
|
+
// cicero (12 didot)
|
|
3719
|
+
"nd": 685 / 642,
|
|
3720
|
+
// new didot
|
|
3721
|
+
"nc": 1370 / 107,
|
|
3722
|
+
// new cicero (12 new didot)
|
|
3723
|
+
"sp": 1 / 65536,
|
|
3724
|
+
// scaled point (TeX's internal smallest unit)
|
|
3725
|
+
// https://tex.stackexchange.com/a/41371
|
|
3726
|
+
"px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX
|
|
3727
|
+
|
|
3728
|
+
}; // Dictionary of relative units, for fast validity testing.
|
|
3729
|
+
|
|
3730
|
+
var relativeUnit = {
|
|
3731
|
+
"ex": true,
|
|
3732
|
+
"em": true,
|
|
3733
|
+
"mu": true
|
|
3734
|
+
};
|
|
3735
|
+
|
|
3736
|
+
/**
|
|
3737
|
+
* Determine whether the specified unit (either a string defining the unit
|
|
3738
|
+
* or a "size" parse node containing a unit field) is valid.
|
|
3739
|
+
*/
|
|
3740
|
+
var validUnit = function validUnit(unit) {
|
|
3741
|
+
if (typeof unit !== "string") {
|
|
3742
|
+
unit = unit.unit;
|
|
3743
|
+
}
|
|
3744
|
+
|
|
3745
|
+
return unit in ptPerUnit || unit in relativeUnit || unit === "ex";
|
|
3746
|
+
};
|
|
3747
|
+
/*
|
|
3748
|
+
* Convert a "size" parse node (with numeric "number" and string "unit" fields,
|
|
3749
|
+
* as parsed by functions.js argType "size") into a CSS em value for the
|
|
3750
|
+
* current style/scale. `options` gives the current options.
|
|
3751
|
+
*/
|
|
3752
|
+
|
|
3753
|
+
var calculateSize = function calculateSize(sizeValue, options) {
|
|
3754
|
+
var scale;
|
|
3755
|
+
|
|
3756
|
+
if (sizeValue.unit in ptPerUnit) {
|
|
3757
|
+
// Absolute units
|
|
3758
|
+
scale = ptPerUnit[sizeValue.unit] // Convert unit to pt
|
|
3759
|
+
/ options.fontMetrics().ptPerEm // Convert pt to CSS em
|
|
3760
|
+
/ options.sizeMultiplier; // Unscale to make absolute units
|
|
3761
|
+
} else if (sizeValue.unit === "mu") {
|
|
3762
|
+
// `mu` units scale with scriptstyle/scriptscriptstyle.
|
|
3763
|
+
scale = options.fontMetrics().cssEmPerMu;
|
|
3764
|
+
} else {
|
|
3765
|
+
// Other relative units always refer to the *textstyle* font
|
|
3766
|
+
// in the current size.
|
|
3767
|
+
var unitOptions;
|
|
3768
|
+
|
|
3769
|
+
if (options.style.isTight()) {
|
|
3770
|
+
// isTight() means current style is script/scriptscript.
|
|
3771
|
+
unitOptions = options.havingStyle(options.style.text());
|
|
3772
|
+
} else {
|
|
3773
|
+
unitOptions = options;
|
|
3774
|
+
} // TODO: In TeX these units are relative to the quad of the current
|
|
3775
|
+
// *text* font, e.g. cmr10. KaTeX instead uses values from the
|
|
3776
|
+
// comparably-sized *Computer Modern symbol* font. At 10pt, these
|
|
3777
|
+
// match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
|
|
3778
|
+
// cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
|
|
3779
|
+
// TeX \showlists shows a kern of 1.13889 * fontsize;
|
|
3780
|
+
// KaTeX shows a kern of 1.171 * fontsize.
|
|
3781
|
+
|
|
3782
|
+
|
|
3783
|
+
if (sizeValue.unit === "ex") {
|
|
3784
|
+
scale = unitOptions.fontMetrics().xHeight;
|
|
3785
|
+
} else if (sizeValue.unit === "em") {
|
|
3786
|
+
scale = unitOptions.fontMetrics().quad;
|
|
3787
|
+
} else {
|
|
3788
|
+
throw new src_ParseError("Invalid unit: '" + sizeValue.unit + "'");
|
|
3789
|
+
}
|
|
3790
|
+
|
|
3791
|
+
if (unitOptions !== options) {
|
|
3792
|
+
scale *= unitOptions.sizeMultiplier / options.sizeMultiplier;
|
|
3793
|
+
}
|
|
3794
|
+
}
|
|
3795
|
+
|
|
3796
|
+
return Math.min(sizeValue.number * scale, options.maxSize);
|
|
3797
|
+
};
|
|
3798
|
+
/**
|
|
3799
|
+
* Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See
|
|
3800
|
+
* https://github.com/KaTeX/KaTeX/pull/2460.
|
|
3801
|
+
*/
|
|
3802
|
+
|
|
3803
|
+
var makeEm = function makeEm(n) {
|
|
3804
|
+
return +n.toFixed(4) + "em";
|
|
3805
|
+
};
|
|
3806
|
+
;// CONCATENATED MODULE: ./src/domTree.js
|
|
3807
|
+
/**
|
|
3808
|
+
* These objects store the data about the DOM nodes we create, as well as some
|
|
3809
|
+
* extra data. They can then be transformed into real DOM nodes with the
|
|
3810
|
+
* `toNode` function or HTML markup using `toMarkup`. They are useful for both
|
|
3811
|
+
* storing extra properties on the nodes, as well as providing a way to easily
|
|
3812
|
+
* work with the DOM.
|
|
3813
|
+
*
|
|
3814
|
+
* Similar functions for working with MathML nodes exist in mathMLTree.js.
|
|
3815
|
+
*
|
|
3816
|
+
* TODO: refactor `span` and `anchor` into common superclass when
|
|
3817
|
+
* target environments support class inheritance
|
|
3818
|
+
*/
|
|
3819
|
+
|
|
3820
|
+
|
|
3821
|
+
|
|
3822
|
+
|
|
3823
|
+
|
|
3824
|
+
|
|
3825
|
+
/**
|
|
3826
|
+
* Create an HTML className based on a list of classes. In addition to joining
|
|
3827
|
+
* with spaces, we also remove empty classes.
|
|
3828
|
+
*/
|
|
3829
|
+
var createClass = function createClass(classes) {
|
|
3830
|
+
return classes.filter(function (cls) {
|
|
3831
|
+
return cls;
|
|
3832
|
+
}).join(" ");
|
|
3833
|
+
};
|
|
3834
|
+
|
|
3835
|
+
var initNode = function initNode(classes, options, style) {
|
|
3836
|
+
this.classes = classes || [];
|
|
3837
|
+
this.attributes = {};
|
|
3838
|
+
this.height = 0;
|
|
3839
|
+
this.depth = 0;
|
|
3840
|
+
this.maxFontSize = 0;
|
|
3841
|
+
this.style = style || {};
|
|
3842
|
+
|
|
3843
|
+
if (options) {
|
|
3844
|
+
if (options.style.isTight()) {
|
|
3845
|
+
this.classes.push("mtight");
|
|
3846
|
+
}
|
|
3847
|
+
|
|
3848
|
+
var color = options.getColor();
|
|
3849
|
+
|
|
3850
|
+
if (color) {
|
|
3851
|
+
this.style.color = color;
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
};
|
|
3855
|
+
/**
|
|
3856
|
+
* Convert into an HTML node
|
|
3857
|
+
*/
|
|
3858
|
+
|
|
3859
|
+
|
|
3860
|
+
var _toNode = function toNode(tagName) {
|
|
3861
|
+
var node = document.createElement(tagName); // Apply the class
|
|
3862
|
+
|
|
3863
|
+
node.className = createClass(this.classes); // Apply inline styles
|
|
3864
|
+
|
|
3865
|
+
for (var style in this.style) {
|
|
3866
|
+
if (this.style.hasOwnProperty(style)) {
|
|
3867
|
+
// $FlowFixMe Flow doesn't seem to understand span.style's type.
|
|
3868
|
+
node.style[style] = this.style[style];
|
|
3869
|
+
}
|
|
3870
|
+
} // Apply attributes
|
|
3871
|
+
|
|
3872
|
+
|
|
3873
|
+
for (var attr in this.attributes) {
|
|
3874
|
+
if (this.attributes.hasOwnProperty(attr)) {
|
|
3875
|
+
node.setAttribute(attr, this.attributes[attr]);
|
|
3876
|
+
}
|
|
3877
|
+
} // Append the children, also as HTML nodes
|
|
3878
|
+
|
|
3879
|
+
|
|
3880
|
+
for (var i = 0; i < this.children.length; i++) {
|
|
3881
|
+
node.appendChild(this.children[i].toNode());
|
|
3882
|
+
}
|
|
3883
|
+
|
|
3884
|
+
return node;
|
|
3885
|
+
};
|
|
3886
|
+
/**
|
|
3887
|
+
* Convert into an HTML markup string
|
|
3888
|
+
*/
|
|
3889
|
+
|
|
3890
|
+
|
|
3891
|
+
var _toMarkup = function toMarkup(tagName) {
|
|
3892
|
+
var markup = "<" + tagName; // Add the class
|
|
3893
|
+
|
|
3894
|
+
if (this.classes.length) {
|
|
3895
|
+
markup += " class=\"" + utils.escape(createClass(this.classes)) + "\"";
|
|
3896
|
+
}
|
|
3897
|
+
|
|
3898
|
+
var styles = ""; // Add the styles, after hyphenation
|
|
3899
|
+
|
|
3900
|
+
for (var style in this.style) {
|
|
3901
|
+
if (this.style.hasOwnProperty(style)) {
|
|
3902
|
+
styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
|
|
3906
|
+
if (styles) {
|
|
3907
|
+
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
3908
|
+
} // Add the attributes
|
|
3909
|
+
|
|
3910
|
+
|
|
3911
|
+
for (var attr in this.attributes) {
|
|
3912
|
+
if (this.attributes.hasOwnProperty(attr)) {
|
|
3913
|
+
markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\"";
|
|
3914
|
+
}
|
|
3915
|
+
}
|
|
3916
|
+
|
|
3917
|
+
markup += ">"; // Add the markup of the children, also as markup
|
|
3918
|
+
|
|
3919
|
+
for (var i = 0; i < this.children.length; i++) {
|
|
3920
|
+
markup += this.children[i].toMarkup();
|
|
3921
|
+
}
|
|
3922
|
+
|
|
3923
|
+
markup += "</" + tagName + ">";
|
|
3924
|
+
return markup;
|
|
3925
|
+
}; // Making the type below exact with all optional fields doesn't work due to
|
|
3926
|
+
// - https://github.com/facebook/flow/issues/4582
|
|
3927
|
+
// - https://github.com/facebook/flow/issues/5688
|
|
3928
|
+
// However, since *all* fields are optional, $Shape<> works as suggested in 5688
|
|
3929
|
+
// above.
|
|
3930
|
+
// This type does not include all CSS properties. Additional properties should
|
|
3931
|
+
// be added as needed.
|
|
3932
|
+
|
|
3933
|
+
|
|
3934
|
+
/**
|
|
3935
|
+
* This node represents a span node, with a className, a list of children, and
|
|
3936
|
+
* an inline style. It also contains information about its height, depth, and
|
|
3937
|
+
* maxFontSize.
|
|
3938
|
+
*
|
|
3939
|
+
* Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan
|
|
3940
|
+
* otherwise. This typesafety is important when HTML builders access a span's
|
|
3941
|
+
* children.
|
|
3942
|
+
*/
|
|
3943
|
+
var Span = /*#__PURE__*/function () {
|
|
3944
|
+
function Span(classes, children, options, style) {
|
|
3945
|
+
this.children = void 0;
|
|
3946
|
+
this.attributes = void 0;
|
|
3947
|
+
this.classes = void 0;
|
|
3948
|
+
this.height = void 0;
|
|
3949
|
+
this.depth = void 0;
|
|
3950
|
+
this.width = void 0;
|
|
3951
|
+
this.maxFontSize = void 0;
|
|
3952
|
+
this.style = void 0;
|
|
3953
|
+
initNode.call(this, classes, options, style);
|
|
3954
|
+
this.children = children || [];
|
|
3955
|
+
}
|
|
3956
|
+
/**
|
|
3957
|
+
* Sets an arbitrary attribute on the span. Warning: use this wisely. Not
|
|
3958
|
+
* all browsers support attributes the same, and having too many custom
|
|
3959
|
+
* attributes is probably bad.
|
|
3960
|
+
*/
|
|
3961
|
+
|
|
3962
|
+
|
|
3963
|
+
var _proto = Span.prototype;
|
|
3964
|
+
|
|
3965
|
+
_proto.setAttribute = function setAttribute(attribute, value) {
|
|
3966
|
+
this.attributes[attribute] = value;
|
|
3967
|
+
};
|
|
3968
|
+
|
|
3969
|
+
_proto.hasClass = function hasClass(className) {
|
|
3970
|
+
return utils.contains(this.classes, className);
|
|
3971
|
+
};
|
|
3972
|
+
|
|
3973
|
+
_proto.toNode = function toNode() {
|
|
3974
|
+
return _toNode.call(this, "span");
|
|
3975
|
+
};
|
|
3976
|
+
|
|
3977
|
+
_proto.toMarkup = function toMarkup() {
|
|
3978
|
+
return _toMarkup.call(this, "span");
|
|
3979
|
+
};
|
|
3980
|
+
|
|
3981
|
+
return Span;
|
|
3982
|
+
}();
|
|
3983
|
+
/**
|
|
3984
|
+
* This node represents an anchor (<a>) element with a hyperlink. See `span`
|
|
3985
|
+
* for further details.
|
|
3986
|
+
*/
|
|
3987
|
+
|
|
3988
|
+
var Anchor = /*#__PURE__*/function () {
|
|
3989
|
+
function Anchor(href, classes, children, options) {
|
|
3990
|
+
this.children = void 0;
|
|
3991
|
+
this.attributes = void 0;
|
|
3992
|
+
this.classes = void 0;
|
|
3993
|
+
this.height = void 0;
|
|
3994
|
+
this.depth = void 0;
|
|
3995
|
+
this.maxFontSize = void 0;
|
|
3996
|
+
this.style = void 0;
|
|
3997
|
+
initNode.call(this, classes, options);
|
|
3998
|
+
this.children = children || [];
|
|
3999
|
+
this.setAttribute('href', href);
|
|
4000
|
+
}
|
|
4001
|
+
|
|
4002
|
+
var _proto2 = Anchor.prototype;
|
|
4003
|
+
|
|
4004
|
+
_proto2.setAttribute = function setAttribute(attribute, value) {
|
|
4005
|
+
this.attributes[attribute] = value;
|
|
4006
|
+
};
|
|
4007
|
+
|
|
4008
|
+
_proto2.hasClass = function hasClass(className) {
|
|
4009
|
+
return utils.contains(this.classes, className);
|
|
4010
|
+
};
|
|
4011
|
+
|
|
4012
|
+
_proto2.toNode = function toNode() {
|
|
4013
|
+
return _toNode.call(this, "a");
|
|
4014
|
+
};
|
|
4015
|
+
|
|
4016
|
+
_proto2.toMarkup = function toMarkup() {
|
|
4017
|
+
return _toMarkup.call(this, "a");
|
|
4018
|
+
};
|
|
4019
|
+
|
|
4020
|
+
return Anchor;
|
|
4021
|
+
}();
|
|
4022
|
+
/**
|
|
4023
|
+
* This node represents an image embed (<img>) element.
|
|
4024
|
+
*/
|
|
4025
|
+
|
|
4026
|
+
var Img = /*#__PURE__*/function () {
|
|
4027
|
+
function Img(src, alt, style) {
|
|
4028
|
+
this.src = void 0;
|
|
4029
|
+
this.alt = void 0;
|
|
4030
|
+
this.classes = void 0;
|
|
4031
|
+
this.height = void 0;
|
|
4032
|
+
this.depth = void 0;
|
|
4033
|
+
this.maxFontSize = void 0;
|
|
4034
|
+
this.style = void 0;
|
|
4035
|
+
this.alt = alt;
|
|
4036
|
+
this.src = src;
|
|
4037
|
+
this.classes = ["mord"];
|
|
4038
|
+
this.style = style;
|
|
4039
|
+
}
|
|
4040
|
+
|
|
4041
|
+
var _proto3 = Img.prototype;
|
|
3513
4042
|
|
|
4043
|
+
_proto3.hasClass = function hasClass(className) {
|
|
4044
|
+
return utils.contains(this.classes, className);
|
|
4045
|
+
};
|
|
4046
|
+
|
|
4047
|
+
_proto3.toNode = function toNode() {
|
|
4048
|
+
var node = document.createElement("img");
|
|
4049
|
+
node.src = this.src;
|
|
4050
|
+
node.alt = this.alt;
|
|
4051
|
+
node.className = "mord"; // Apply inline styles
|
|
4052
|
+
|
|
4053
|
+
for (var style in this.style) {
|
|
4054
|
+
if (this.style.hasOwnProperty(style)) {
|
|
4055
|
+
// $FlowFixMe
|
|
4056
|
+
node.style[style] = this.style[style];
|
|
4057
|
+
}
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
return node;
|
|
4061
|
+
};
|
|
4062
|
+
|
|
4063
|
+
_proto3.toMarkup = function toMarkup() {
|
|
4064
|
+
var markup = "<img src='" + this.src + " 'alt='" + this.alt + "' "; // Add the styles, after hyphenation
|
|
4065
|
+
|
|
4066
|
+
var styles = "";
|
|
4067
|
+
|
|
4068
|
+
for (var style in this.style) {
|
|
4069
|
+
if (this.style.hasOwnProperty(style)) {
|
|
4070
|
+
styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
|
|
4074
|
+
if (styles) {
|
|
4075
|
+
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
4076
|
+
}
|
|
4077
|
+
|
|
4078
|
+
markup += "'/>";
|
|
4079
|
+
return markup;
|
|
4080
|
+
};
|
|
3514
4081
|
|
|
4082
|
+
return Img;
|
|
4083
|
+
}();
|
|
4084
|
+
var iCombinations = {
|
|
4085
|
+
'î': "\u0131\u0302",
|
|
4086
|
+
'ï': "\u0131\u0308",
|
|
4087
|
+
'í': "\u0131\u0301",
|
|
4088
|
+
// 'ī': '\u0131\u0304', // enable when we add Extended Latin
|
|
4089
|
+
'ì': "\u0131\u0300"
|
|
4090
|
+
};
|
|
3515
4091
|
/**
|
|
3516
|
-
*
|
|
3517
|
-
*
|
|
3518
|
-
*
|
|
3519
|
-
* `metrics` variable and the getCharacterMetrics function.
|
|
4092
|
+
* A symbol node contains information about a single symbol. It either renders
|
|
4093
|
+
* to a single text node, or a span with a single text node in it, depending on
|
|
4094
|
+
* whether it has CSS classes, styles, or needs italic correction.
|
|
3520
4095
|
*/
|
|
3521
|
-
// In TeX, there are actually three sets of dimensions, one for each of
|
|
3522
|
-
// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
|
|
3523
|
-
// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
|
|
3524
|
-
// provided in the the arrays below, in that order.
|
|
3525
|
-
//
|
|
3526
|
-
// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
|
|
3527
|
-
// This was determined by running the following script:
|
|
3528
|
-
//
|
|
3529
|
-
// latex -interaction=nonstopmode \
|
|
3530
|
-
// '\documentclass{article}\usepackage{amsmath}\begin{document}' \
|
|
3531
|
-
// '$a$ \expandafter\show\the\textfont2' \
|
|
3532
|
-
// '\expandafter\show\the\scriptfont2' \
|
|
3533
|
-
// '\expandafter\show\the\scriptscriptfont2' \
|
|
3534
|
-
// '\stop'
|
|
3535
|
-
//
|
|
3536
|
-
// The metrics themselves were retreived using the following commands:
|
|
3537
|
-
//
|
|
3538
|
-
// tftopl cmsy10
|
|
3539
|
-
// tftopl cmsy7
|
|
3540
|
-
// tftopl cmsy5
|
|
3541
|
-
//
|
|
3542
|
-
// The output of each of these commands is quite lengthy. The only part we
|
|
3543
|
-
// care about is the FONTDIMEN section. Each value is measured in EMs.
|
|
3544
|
-
var sigmasAndXis = {
|
|
3545
|
-
slant: [0.250, 0.250, 0.250],
|
|
3546
|
-
// sigma1
|
|
3547
|
-
space: [0.000, 0.000, 0.000],
|
|
3548
|
-
// sigma2
|
|
3549
|
-
stretch: [0.000, 0.000, 0.000],
|
|
3550
|
-
// sigma3
|
|
3551
|
-
shrink: [0.000, 0.000, 0.000],
|
|
3552
|
-
// sigma4
|
|
3553
|
-
xHeight: [0.431, 0.431, 0.431],
|
|
3554
|
-
// sigma5
|
|
3555
|
-
quad: [1.000, 1.171, 1.472],
|
|
3556
|
-
// sigma6
|
|
3557
|
-
extraSpace: [0.000, 0.000, 0.000],
|
|
3558
|
-
// sigma7
|
|
3559
|
-
num1: [0.677, 0.732, 0.925],
|
|
3560
|
-
// sigma8
|
|
3561
|
-
num2: [0.394, 0.384, 0.387],
|
|
3562
|
-
// sigma9
|
|
3563
|
-
num3: [0.444, 0.471, 0.504],
|
|
3564
|
-
// sigma10
|
|
3565
|
-
denom1: [0.686, 0.752, 1.025],
|
|
3566
|
-
// sigma11
|
|
3567
|
-
denom2: [0.345, 0.344, 0.532],
|
|
3568
|
-
// sigma12
|
|
3569
|
-
sup1: [0.413, 0.503, 0.504],
|
|
3570
|
-
// sigma13
|
|
3571
|
-
sup2: [0.363, 0.431, 0.404],
|
|
3572
|
-
// sigma14
|
|
3573
|
-
sup3: [0.289, 0.286, 0.294],
|
|
3574
|
-
// sigma15
|
|
3575
|
-
sub1: [0.150, 0.143, 0.200],
|
|
3576
|
-
// sigma16
|
|
3577
|
-
sub2: [0.247, 0.286, 0.400],
|
|
3578
|
-
// sigma17
|
|
3579
|
-
supDrop: [0.386, 0.353, 0.494],
|
|
3580
|
-
// sigma18
|
|
3581
|
-
subDrop: [0.050, 0.071, 0.100],
|
|
3582
|
-
// sigma19
|
|
3583
|
-
delim1: [2.390, 1.700, 1.980],
|
|
3584
|
-
// sigma20
|
|
3585
|
-
delim2: [1.010, 1.157, 1.420],
|
|
3586
|
-
// sigma21
|
|
3587
|
-
axisHeight: [0.250, 0.250, 0.250],
|
|
3588
|
-
// sigma22
|
|
3589
|
-
// These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
|
|
3590
|
-
// they correspond to the font parameters of the extension fonts (family 3).
|
|
3591
|
-
// See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
|
|
3592
|
-
// match cmex7, we'd use cmex7.tfm values for script and scriptscript
|
|
3593
|
-
// values.
|
|
3594
|
-
defaultRuleThickness: [0.04, 0.049, 0.049],
|
|
3595
|
-
// xi8; cmex7: 0.049
|
|
3596
|
-
bigOpSpacing1: [0.111, 0.111, 0.111],
|
|
3597
|
-
// xi9
|
|
3598
|
-
bigOpSpacing2: [0.166, 0.166, 0.166],
|
|
3599
|
-
// xi10
|
|
3600
|
-
bigOpSpacing3: [0.2, 0.2, 0.2],
|
|
3601
|
-
// xi11
|
|
3602
|
-
bigOpSpacing4: [0.6, 0.611, 0.611],
|
|
3603
|
-
// xi12; cmex7: 0.611
|
|
3604
|
-
bigOpSpacing5: [0.1, 0.143, 0.143],
|
|
3605
|
-
// xi13; cmex7: 0.143
|
|
3606
|
-
// The \sqrt rule width is taken from the height of the surd character.
|
|
3607
|
-
// Since we use the same font at all sizes, this thickness doesn't scale.
|
|
3608
|
-
sqrtRuleThickness: [0.04, 0.04, 0.04],
|
|
3609
|
-
// This value determines how large a pt is, for metrics which are defined
|
|
3610
|
-
// in terms of pts.
|
|
3611
|
-
// This value is also used in katex.less; if you change it make sure the
|
|
3612
|
-
// values match.
|
|
3613
|
-
ptPerEm: [10.0, 10.0, 10.0],
|
|
3614
|
-
// The space between adjacent `|` columns in an array definition. From
|
|
3615
|
-
// `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
|
|
3616
|
-
doubleRuleSep: [0.2, 0.2, 0.2],
|
|
3617
|
-
// The width of separator lines in {array} environments. From
|
|
3618
|
-
// `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
|
|
3619
|
-
arrayRuleWidth: [0.04, 0.04, 0.04],
|
|
3620
|
-
// Two values from LaTeX source2e:
|
|
3621
|
-
fboxsep: [0.3, 0.3, 0.3],
|
|
3622
|
-
// 3 pt / ptPerEm
|
|
3623
|
-
fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm
|
|
3624
4096
|
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
4097
|
+
var SymbolNode = /*#__PURE__*/function () {
|
|
4098
|
+
function SymbolNode(text, height, depth, italic, skew, width, classes, style) {
|
|
4099
|
+
this.text = void 0;
|
|
4100
|
+
this.height = void 0;
|
|
4101
|
+
this.depth = void 0;
|
|
4102
|
+
this.italic = void 0;
|
|
4103
|
+
this.skew = void 0;
|
|
4104
|
+
this.width = void 0;
|
|
4105
|
+
this.maxFontSize = void 0;
|
|
4106
|
+
this.classes = void 0;
|
|
4107
|
+
this.style = void 0;
|
|
4108
|
+
this.text = text;
|
|
4109
|
+
this.height = height || 0;
|
|
4110
|
+
this.depth = depth || 0;
|
|
4111
|
+
this.italic = italic || 0;
|
|
4112
|
+
this.skew = skew || 0;
|
|
4113
|
+
this.width = width || 0;
|
|
4114
|
+
this.classes = classes || [];
|
|
4115
|
+
this.style = style || {};
|
|
4116
|
+
this.maxFontSize = 0; // Mark text from non-Latin scripts with specific classes so that we
|
|
4117
|
+
// can specify which fonts to use. This allows us to render these
|
|
4118
|
+
// characters with a serif font in situations where the browser would
|
|
4119
|
+
// either default to a sans serif or render a placeholder character.
|
|
4120
|
+
// We use CSS class names like cjk_fallback, hangul_fallback and
|
|
4121
|
+
// brahmic_fallback. See ./unicodeScripts.js for the set of possible
|
|
4122
|
+
// script names
|
|
4123
|
+
|
|
4124
|
+
var script = scriptFromCodepoint(this.text.charCodeAt(0));
|
|
4125
|
+
|
|
4126
|
+
if (script) {
|
|
4127
|
+
this.classes.push(script + "_fallback");
|
|
4128
|
+
}
|
|
4129
|
+
|
|
4130
|
+
if (/[îïíì]/.test(this.text)) {
|
|
4131
|
+
// add ī when we add Extended Latin
|
|
4132
|
+
this.text = iCombinations[this.text];
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
|
|
4136
|
+
var _proto4 = SymbolNode.prototype;
|
|
4137
|
+
|
|
4138
|
+
_proto4.hasClass = function hasClass(className) {
|
|
4139
|
+
return utils.contains(this.classes, className);
|
|
4140
|
+
}
|
|
4141
|
+
/**
|
|
4142
|
+
* Creates a text node or span from a symbol node. Note that a span is only
|
|
4143
|
+
* created if it is needed.
|
|
4144
|
+
*/
|
|
4145
|
+
;
|
|
4146
|
+
|
|
4147
|
+
_proto4.toNode = function toNode() {
|
|
4148
|
+
var node = document.createTextNode(this.text);
|
|
4149
|
+
var span = null;
|
|
4150
|
+
|
|
4151
|
+
if (this.italic > 0) {
|
|
4152
|
+
span = document.createElement("span");
|
|
4153
|
+
span.style.marginRight = makeEm(this.italic);
|
|
4154
|
+
}
|
|
4155
|
+
|
|
4156
|
+
if (this.classes.length > 0) {
|
|
4157
|
+
span = span || document.createElement("span");
|
|
4158
|
+
span.className = createClass(this.classes);
|
|
4159
|
+
}
|
|
4160
|
+
|
|
4161
|
+
for (var style in this.style) {
|
|
4162
|
+
if (this.style.hasOwnProperty(style)) {
|
|
4163
|
+
span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type.
|
|
4164
|
+
|
|
4165
|
+
span.style[style] = this.style[style];
|
|
4166
|
+
}
|
|
4167
|
+
}
|
|
4168
|
+
|
|
4169
|
+
if (span) {
|
|
4170
|
+
span.appendChild(node);
|
|
4171
|
+
return span;
|
|
4172
|
+
} else {
|
|
4173
|
+
return node;
|
|
4174
|
+
}
|
|
4175
|
+
}
|
|
4176
|
+
/**
|
|
4177
|
+
* Creates markup for a symbol node.
|
|
4178
|
+
*/
|
|
4179
|
+
;
|
|
4180
|
+
|
|
4181
|
+
_proto4.toMarkup = function toMarkup() {
|
|
4182
|
+
// TODO(alpert): More duplication than I'd like from
|
|
4183
|
+
// span.prototype.toMarkup and symbolNode.prototype.toNode...
|
|
4184
|
+
var needsSpan = false;
|
|
4185
|
+
var markup = "<span";
|
|
4186
|
+
|
|
4187
|
+
if (this.classes.length) {
|
|
4188
|
+
needsSpan = true;
|
|
4189
|
+
markup += " class=\"";
|
|
4190
|
+
markup += utils.escape(createClass(this.classes));
|
|
4191
|
+
markup += "\"";
|
|
4192
|
+
}
|
|
4193
|
+
|
|
4194
|
+
var styles = "";
|
|
4195
|
+
|
|
4196
|
+
if (this.italic > 0) {
|
|
4197
|
+
styles += "margin-right:" + this.italic + "em;";
|
|
4198
|
+
}
|
|
4199
|
+
|
|
4200
|
+
for (var style in this.style) {
|
|
4201
|
+
if (this.style.hasOwnProperty(style)) {
|
|
4202
|
+
styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
|
|
4203
|
+
}
|
|
4204
|
+
}
|
|
3629
4205
|
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
// descenders we prefer approximations with ascenders, primarily to prevent
|
|
3635
|
-
// the fraction bar or root line from intersecting the glyph.
|
|
3636
|
-
// TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
|
|
4206
|
+
if (styles) {
|
|
4207
|
+
needsSpan = true;
|
|
4208
|
+
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
4209
|
+
}
|
|
3637
4210
|
|
|
3638
|
-
var
|
|
3639
|
-
// Latin-1
|
|
3640
|
-
'Å': 'A',
|
|
3641
|
-
'Ð': 'D',
|
|
3642
|
-
'Þ': 'o',
|
|
3643
|
-
'å': 'a',
|
|
3644
|
-
'ð': 'd',
|
|
3645
|
-
'þ': 'o',
|
|
3646
|
-
// Cyrillic
|
|
3647
|
-
'А': 'A',
|
|
3648
|
-
'Б': 'B',
|
|
3649
|
-
'В': 'B',
|
|
3650
|
-
'Г': 'F',
|
|
3651
|
-
'Д': 'A',
|
|
3652
|
-
'Е': 'E',
|
|
3653
|
-
'Ж': 'K',
|
|
3654
|
-
'З': '3',
|
|
3655
|
-
'И': 'N',
|
|
3656
|
-
'Й': 'N',
|
|
3657
|
-
'К': 'K',
|
|
3658
|
-
'Л': 'N',
|
|
3659
|
-
'М': 'M',
|
|
3660
|
-
'Н': 'H',
|
|
3661
|
-
'О': 'O',
|
|
3662
|
-
'П': 'N',
|
|
3663
|
-
'Р': 'P',
|
|
3664
|
-
'С': 'C',
|
|
3665
|
-
'Т': 'T',
|
|
3666
|
-
'У': 'y',
|
|
3667
|
-
'Ф': 'O',
|
|
3668
|
-
'Х': 'X',
|
|
3669
|
-
'Ц': 'U',
|
|
3670
|
-
'Ч': 'h',
|
|
3671
|
-
'Ш': 'W',
|
|
3672
|
-
'Щ': 'W',
|
|
3673
|
-
'Ъ': 'B',
|
|
3674
|
-
'Ы': 'X',
|
|
3675
|
-
'Ь': 'B',
|
|
3676
|
-
'Э': '3',
|
|
3677
|
-
'Ю': 'X',
|
|
3678
|
-
'Я': 'R',
|
|
3679
|
-
'а': 'a',
|
|
3680
|
-
'б': 'b',
|
|
3681
|
-
'в': 'a',
|
|
3682
|
-
'г': 'r',
|
|
3683
|
-
'д': 'y',
|
|
3684
|
-
'е': 'e',
|
|
3685
|
-
'ж': 'm',
|
|
3686
|
-
'з': 'e',
|
|
3687
|
-
'и': 'n',
|
|
3688
|
-
'й': 'n',
|
|
3689
|
-
'к': 'n',
|
|
3690
|
-
'л': 'n',
|
|
3691
|
-
'м': 'm',
|
|
3692
|
-
'н': 'n',
|
|
3693
|
-
'о': 'o',
|
|
3694
|
-
'п': 'n',
|
|
3695
|
-
'р': 'p',
|
|
3696
|
-
'с': 'c',
|
|
3697
|
-
'т': 'o',
|
|
3698
|
-
'у': 'y',
|
|
3699
|
-
'ф': 'b',
|
|
3700
|
-
'х': 'x',
|
|
3701
|
-
'ц': 'n',
|
|
3702
|
-
'ч': 'n',
|
|
3703
|
-
'ш': 'w',
|
|
3704
|
-
'щ': 'w',
|
|
3705
|
-
'ъ': 'a',
|
|
3706
|
-
'ы': 'm',
|
|
3707
|
-
'ь': 'a',
|
|
3708
|
-
'э': 'e',
|
|
3709
|
-
'ю': 'm',
|
|
3710
|
-
'я': 'r'
|
|
3711
|
-
};
|
|
4211
|
+
var escaped = utils.escape(this.text);
|
|
3712
4212
|
|
|
4213
|
+
if (needsSpan) {
|
|
4214
|
+
markup += ">";
|
|
4215
|
+
markup += escaped;
|
|
4216
|
+
markup += "</span>";
|
|
4217
|
+
return markup;
|
|
4218
|
+
} else {
|
|
4219
|
+
return escaped;
|
|
4220
|
+
}
|
|
4221
|
+
};
|
|
4222
|
+
|
|
4223
|
+
return SymbolNode;
|
|
4224
|
+
}();
|
|
3713
4225
|
/**
|
|
3714
|
-
*
|
|
3715
|
-
* It can also override existing metrics
|
|
3716
|
-
*/
|
|
3717
|
-
function setFontMetrics(fontName, metrics) {
|
|
3718
|
-
fontMetricsData[fontName] = metrics;
|
|
3719
|
-
}
|
|
3720
|
-
/**
|
|
3721
|
-
* This function is a convenience function for looking up information in the
|
|
3722
|
-
* metricMap table. It takes a character as a string, and a font.
|
|
3723
|
-
*
|
|
3724
|
-
* Note: the `width` property may be undefined if fontMetricsData.js wasn't
|
|
3725
|
-
* built using `Make extended_metrics`.
|
|
4226
|
+
* SVG nodes are used to render stretchy wide elements.
|
|
3726
4227
|
*/
|
|
3727
4228
|
|
|
3728
|
-
function
|
|
3729
|
-
|
|
3730
|
-
|
|
4229
|
+
var SvgNode = /*#__PURE__*/function () {
|
|
4230
|
+
function SvgNode(children, attributes) {
|
|
4231
|
+
this.children = void 0;
|
|
4232
|
+
this.attributes = void 0;
|
|
4233
|
+
this.children = children || [];
|
|
4234
|
+
this.attributes = attributes || {};
|
|
3731
4235
|
}
|
|
3732
4236
|
|
|
3733
|
-
var
|
|
3734
|
-
var metrics = fontMetricsData[font][ch];
|
|
4237
|
+
var _proto5 = SvgNode.prototype;
|
|
3735
4238
|
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
}
|
|
4239
|
+
_proto5.toNode = function toNode() {
|
|
4240
|
+
var svgNS = "http://www.w3.org/2000/svg";
|
|
4241
|
+
var node = document.createElementNS(svgNS, "svg"); // Apply attributes
|
|
3740
4242
|
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
// So if the character is in a script we support but we
|
|
3746
|
-
// don't have metrics for it, just use the metrics for
|
|
3747
|
-
// the Latin capital letter M. This is close enough because
|
|
3748
|
-
// we (currently) only care about the height of the glpyh
|
|
3749
|
-
// not its width.
|
|
3750
|
-
if (supportedCodepoint(ch)) {
|
|
3751
|
-
metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M'
|
|
4243
|
+
for (var attr in this.attributes) {
|
|
4244
|
+
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
4245
|
+
node.setAttribute(attr, this.attributes[attr]);
|
|
4246
|
+
}
|
|
3752
4247
|
}
|
|
3753
|
-
}
|
|
3754
4248
|
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
4249
|
+
for (var i = 0; i < this.children.length; i++) {
|
|
4250
|
+
node.appendChild(this.children[i].toNode());
|
|
4251
|
+
}
|
|
4252
|
+
|
|
4253
|
+
return node;
|
|
4254
|
+
};
|
|
4255
|
+
|
|
4256
|
+
_proto5.toMarkup = function toMarkup() {
|
|
4257
|
+
var markup = "<svg xmlns=\"http://www.w3.org/2000/svg\""; // Apply attributes
|
|
4258
|
+
|
|
4259
|
+
for (var attr in this.attributes) {
|
|
4260
|
+
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
4261
|
+
markup += " " + attr + "='" + this.attributes[attr] + "'";
|
|
4262
|
+
}
|
|
4263
|
+
}
|
|
4264
|
+
|
|
4265
|
+
markup += ">";
|
|
4266
|
+
|
|
4267
|
+
for (var i = 0; i < this.children.length; i++) {
|
|
4268
|
+
markup += this.children[i].toMarkup();
|
|
4269
|
+
}
|
|
4270
|
+
|
|
4271
|
+
markup += "</svg>";
|
|
4272
|
+
return markup;
|
|
4273
|
+
};
|
|
4274
|
+
|
|
4275
|
+
return SvgNode;
|
|
4276
|
+
}();
|
|
4277
|
+
var PathNode = /*#__PURE__*/function () {
|
|
4278
|
+
function PathNode(pathName, alternate) {
|
|
4279
|
+
this.pathName = void 0;
|
|
4280
|
+
this.alternate = void 0;
|
|
4281
|
+
this.pathName = pathName;
|
|
4282
|
+
this.alternate = alternate; // Used only for \sqrt, \phase, & tall delims
|
|
3763
4283
|
}
|
|
3764
|
-
}
|
|
3765
|
-
var fontMetricsBySizeIndex = {};
|
|
3766
|
-
/**
|
|
3767
|
-
* Get the font metrics for a given size.
|
|
3768
|
-
*/
|
|
3769
4284
|
|
|
3770
|
-
|
|
3771
|
-
var sizeIndex;
|
|
4285
|
+
var _proto6 = PathNode.prototype;
|
|
3772
4286
|
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
4287
|
+
_proto6.toNode = function toNode() {
|
|
4288
|
+
var svgNS = "http://www.w3.org/2000/svg";
|
|
4289
|
+
var node = document.createElementNS(svgNS, "path");
|
|
4290
|
+
|
|
4291
|
+
if (this.alternate) {
|
|
4292
|
+
node.setAttribute("d", this.alternate);
|
|
4293
|
+
} else {
|
|
4294
|
+
node.setAttribute("d", path[this.pathName]);
|
|
4295
|
+
}
|
|
4296
|
+
|
|
4297
|
+
return node;
|
|
4298
|
+
};
|
|
4299
|
+
|
|
4300
|
+
_proto6.toMarkup = function toMarkup() {
|
|
4301
|
+
if (this.alternate) {
|
|
4302
|
+
return "<path d='" + this.alternate + "'/>";
|
|
4303
|
+
} else {
|
|
4304
|
+
return "<path d='" + path[this.pathName] + "'/>";
|
|
4305
|
+
}
|
|
4306
|
+
};
|
|
4307
|
+
|
|
4308
|
+
return PathNode;
|
|
4309
|
+
}();
|
|
4310
|
+
var LineNode = /*#__PURE__*/function () {
|
|
4311
|
+
function LineNode(attributes) {
|
|
4312
|
+
this.attributes = void 0;
|
|
4313
|
+
this.attributes = attributes || {};
|
|
3779
4314
|
}
|
|
3780
4315
|
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
4316
|
+
var _proto7 = LineNode.prototype;
|
|
4317
|
+
|
|
4318
|
+
_proto7.toNode = function toNode() {
|
|
4319
|
+
var svgNS = "http://www.w3.org/2000/svg";
|
|
4320
|
+
var node = document.createElementNS(svgNS, "line"); // Apply attributes
|
|
4321
|
+
|
|
4322
|
+
for (var attr in this.attributes) {
|
|
4323
|
+
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
4324
|
+
node.setAttribute(attr, this.attributes[attr]);
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
|
|
4328
|
+
return node;
|
|
4329
|
+
};
|
|
4330
|
+
|
|
4331
|
+
_proto7.toMarkup = function toMarkup() {
|
|
4332
|
+
var markup = "<line";
|
|
3785
4333
|
|
|
3786
|
-
for (var
|
|
3787
|
-
if (
|
|
3788
|
-
|
|
4334
|
+
for (var attr in this.attributes) {
|
|
4335
|
+
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
4336
|
+
markup += " " + attr + "='" + this.attributes[attr] + "'";
|
|
3789
4337
|
}
|
|
3790
4338
|
}
|
|
3791
|
-
}
|
|
3792
4339
|
|
|
3793
|
-
|
|
4340
|
+
markup += "/>";
|
|
4341
|
+
return markup;
|
|
4342
|
+
};
|
|
4343
|
+
|
|
4344
|
+
return LineNode;
|
|
4345
|
+
}();
|
|
4346
|
+
function assertSymbolDomNode(group) {
|
|
4347
|
+
if (group instanceof SymbolNode) {
|
|
4348
|
+
return group;
|
|
4349
|
+
} else {
|
|
4350
|
+
throw new Error("Expected symbolNode but got " + String(group) + ".");
|
|
4351
|
+
}
|
|
4352
|
+
}
|
|
4353
|
+
function assertSpan(group) {
|
|
4354
|
+
if (group instanceof Span) {
|
|
4355
|
+
return group;
|
|
4356
|
+
} else {
|
|
4357
|
+
throw new Error("Expected span<HtmlDomNode> but got " + String(group) + ".");
|
|
4358
|
+
}
|
|
3794
4359
|
}
|
|
3795
4360
|
;// CONCATENATED MODULE: ./src/symbols.js
|
|
3796
4361
|
/**
|
|
@@ -4416,771 +4981,343 @@ defineSymbol(math, main, op, "\u2210", "\\coprod");
|
|
|
4416
4981
|
defineSymbol(math, main, op, "\u22C1", "\\bigvee");
|
|
4417
4982
|
defineSymbol(math, main, op, "\u22C0", "\\bigwedge");
|
|
4418
4983
|
defineSymbol(math, main, op, "\u2A04", "\\biguplus");
|
|
4419
|
-
defineSymbol(math, main, op, "\u22C2", "\\bigcap");
|
|
4420
|
-
defineSymbol(math, main, op, "\u22C3", "\\bigcup");
|
|
4421
|
-
defineSymbol(math, main, op, "\u222B", "\\int");
|
|
4422
|
-
defineSymbol(math, main, op, "\u222B", "\\intop");
|
|
4423
|
-
defineSymbol(math, main, op, "\u222C", "\\iint");
|
|
4424
|
-
defineSymbol(math, main, op, "\u222D", "\\iiint");
|
|
4425
|
-
defineSymbol(math, main, op, "\u220F", "\\prod");
|
|
4426
|
-
defineSymbol(math, main, op, "\u2211", "\\sum");
|
|
4427
|
-
defineSymbol(math, main, op, "\u2A02", "\\bigotimes");
|
|
4428
|
-
defineSymbol(math, main, op, "\u2A01", "\\bigoplus");
|
|
4429
|
-
defineSymbol(math, main, op, "\u2A00", "\\bigodot");
|
|
4430
|
-
defineSymbol(math, main, op, "\u222E", "\\oint");
|
|
4431
|
-
defineSymbol(math, main, op, "\u222F", "\\oiint");
|
|
4432
|
-
defineSymbol(math, main, op, "\u2230", "\\oiiint");
|
|
4433
|
-
defineSymbol(math, main, op, "\u2A06", "\\bigsqcup");
|
|
4434
|
-
defineSymbol(math, main, op, "\u222B", "\\smallint");
|
|
4435
|
-
defineSymbol(symbols_text, main, inner, "\u2026", "\\textellipsis");
|
|
4436
|
-
defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
|
|
4437
|
-
defineSymbol(symbols_text, main, inner, "\u2026", "\\ldots", true);
|
|
4438
|
-
defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
|
|
4439
|
-
defineSymbol(math, main, inner, "\u22EF", "\\@cdots", true);
|
|
4440
|
-
defineSymbol(math, main, inner, "\u22F1", "\\ddots", true);
|
|
4441
|
-
defineSymbol(math, main, textord, "\u22EE", "\\varvdots"); // \vdots is a macro
|
|
4442
|
-
|
|
4443
|
-
defineSymbol(math, main, accent, "\u02CA", "\\acute");
|
|
4444
|
-
defineSymbol(math, main, accent, "\u02CB", "\\grave");
|
|
4445
|
-
defineSymbol(math, main, accent, "\xA8", "\\ddot");
|
|
4446
|
-
defineSymbol(math, main, accent, "~", "\\tilde");
|
|
4447
|
-
defineSymbol(math, main, accent, "\u02C9", "\\bar");
|
|
4448
|
-
defineSymbol(math, main, accent, "\u02D8", "\\breve");
|
|
4449
|
-
defineSymbol(math, main, accent, "\u02C7", "\\check");
|
|
4450
|
-
defineSymbol(math, main, accent, "^", "\\hat");
|
|
4451
|
-
defineSymbol(math, main, accent, "\u20D7", "\\vec");
|
|
4452
|
-
defineSymbol(math, main, accent, "\u02D9", "\\dot");
|
|
4453
|
-
defineSymbol(math, main, accent, "\u02DA", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA
|
|
4454
|
-
|
|
4455
|
-
defineSymbol(math, main, mathord, "\uE131", "\\@imath");
|
|
4456
|
-
defineSymbol(math, main, mathord, "\uE237", "\\@jmath");
|
|
4457
|
-
defineSymbol(math, main, textord, "\u0131", "\u0131");
|
|
4458
|
-
defineSymbol(math, main, textord, "\u0237", "\u0237");
|
|
4459
|
-
defineSymbol(symbols_text, main, textord, "\u0131", "\\i", true);
|
|
4460
|
-
defineSymbol(symbols_text, main, textord, "\u0237", "\\j", true);
|
|
4461
|
-
defineSymbol(symbols_text, main, textord, "\xDF", "\\ss", true);
|
|
4462
|
-
defineSymbol(symbols_text, main, textord, "\xE6", "\\ae", true);
|
|
4463
|
-
defineSymbol(symbols_text, main, textord, "\u0153", "\\oe", true);
|
|
4464
|
-
defineSymbol(symbols_text, main, textord, "\xF8", "\\o", true);
|
|
4465
|
-
defineSymbol(symbols_text, main, textord, "\xC6", "\\AE", true);
|
|
4466
|
-
defineSymbol(symbols_text, main, textord, "\u0152", "\\OE", true);
|
|
4467
|
-
defineSymbol(symbols_text, main, textord, "\xD8", "\\O", true);
|
|
4468
|
-
defineSymbol(symbols_text, main, accent, "\u02CA", "\\'"); // acute
|
|
4469
|
-
|
|
4470
|
-
defineSymbol(symbols_text, main, accent, "\u02CB", "\\`"); // grave
|
|
4471
|
-
|
|
4472
|
-
defineSymbol(symbols_text, main, accent, "\u02C6", "\\^"); // circumflex
|
|
4473
|
-
|
|
4474
|
-
defineSymbol(symbols_text, main, accent, "\u02DC", "\\~"); // tilde
|
|
4475
|
-
|
|
4476
|
-
defineSymbol(symbols_text, main, accent, "\u02C9", "\\="); // macron
|
|
4477
|
-
|
|
4478
|
-
defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve
|
|
4479
|
-
|
|
4480
|
-
defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above
|
|
4481
|
-
|
|
4482
|
-
defineSymbol(symbols_text, main, accent, "\xB8", "\\c"); // cedilla
|
|
4483
|
-
|
|
4484
|
-
defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above
|
|
4485
|
-
|
|
4486
|
-
defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron
|
|
4487
|
-
|
|
4488
|
-
defineSymbol(symbols_text, main, accent, "\xA8", '\\"'); // diaresis
|
|
4489
|
-
|
|
4490
|
-
defineSymbol(symbols_text, main, accent, "\u02DD", "\\H"); // double acute
|
|
4491
|
-
|
|
4492
|
-
defineSymbol(symbols_text, main, accent, "\u25EF", "\\textcircled"); // \bigcirc glyph
|
|
4493
|
-
// These ligatures are detected and created in Parser.js's `formLigatures`.
|
|
4494
|
-
|
|
4495
|
-
var ligatures = {
|
|
4496
|
-
"--": true,
|
|
4497
|
-
"---": true,
|
|
4498
|
-
"``": true,
|
|
4499
|
-
"''": true
|
|
4500
|
-
};
|
|
4501
|
-
defineSymbol(symbols_text, main, textord, "\u2013", "--", true);
|
|
4502
|
-
defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash");
|
|
4503
|
-
defineSymbol(symbols_text, main, textord, "\u2014", "---", true);
|
|
4504
|
-
defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash");
|
|
4505
|
-
defineSymbol(symbols_text, main, textord, "\u2018", "`", true);
|
|
4506
|
-
defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft");
|
|
4507
|
-
defineSymbol(symbols_text, main, textord, "\u2019", "'", true);
|
|
4508
|
-
defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright");
|
|
4509
|
-
defineSymbol(symbols_text, main, textord, "\u201C", "``", true);
|
|
4510
|
-
defineSymbol(symbols_text, main, textord, "\u201C", "\\textquotedblleft");
|
|
4511
|
-
defineSymbol(symbols_text, main, textord, "\u201D", "''", true);
|
|
4512
|
-
defineSymbol(symbols_text, main, textord, "\u201D", "\\textquotedblright"); // \degree from gensymb package
|
|
4513
|
-
|
|
4514
|
-
defineSymbol(math, main, textord, "\xB0", "\\degree", true);
|
|
4515
|
-
defineSymbol(symbols_text, main, textord, "\xB0", "\\degree"); // \textdegree from inputenc package
|
|
4516
|
-
|
|
4517
|
-
defineSymbol(symbols_text, main, textord, "\xB0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math
|
|
4518
|
-
// mode, but among our fonts, only Main-Regular defines this character "163".
|
|
4519
|
-
|
|
4520
|
-
defineSymbol(math, main, textord, "\xA3", "\\pounds");
|
|
4521
|
-
defineSymbol(math, main, textord, "\xA3", "\\mathsterling", true);
|
|
4522
|
-
defineSymbol(symbols_text, main, textord, "\xA3", "\\pounds");
|
|
4523
|
-
defineSymbol(symbols_text, main, textord, "\xA3", "\\textsterling", true);
|
|
4524
|
-
defineSymbol(math, ams, textord, "\u2720", "\\maltese");
|
|
4525
|
-
defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards.
|
|
4526
|
-
// All of these are textords in math mode
|
|
4527
|
-
|
|
4528
|
-
var mathTextSymbols = "0123456789/@.\"";
|
|
4529
|
-
|
|
4530
|
-
for (var i = 0; i < mathTextSymbols.length; i++) {
|
|
4531
|
-
var ch = mathTextSymbols.charAt(i);
|
|
4532
|
-
defineSymbol(math, main, textord, ch, ch);
|
|
4533
|
-
} // All of these are textords in text mode
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
var textSymbols = "0123456789!@*()-=+\";:?/.,";
|
|
4537
|
-
|
|
4538
|
-
for (var _i = 0; _i < textSymbols.length; _i++) {
|
|
4539
|
-
var _ch = textSymbols.charAt(_i);
|
|
4540
|
-
|
|
4541
|
-
defineSymbol(symbols_text, main, textord, _ch, _ch);
|
|
4542
|
-
} // All of these are textords in text mode, and mathords in math mode
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
4546
|
-
|
|
4547
|
-
for (var _i2 = 0; _i2 < letters.length; _i2++) {
|
|
4548
|
-
var _ch2 = letters.charAt(_i2);
|
|
4549
|
-
|
|
4550
|
-
defineSymbol(math, main, mathord, _ch2, _ch2);
|
|
4551
|
-
defineSymbol(symbols_text, main, textord, _ch2, _ch2);
|
|
4552
|
-
} // Blackboard bold and script letters in Unicode range
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
|
|
4556
|
-
|
|
4557
|
-
defineSymbol(symbols_text, ams, textord, "C", "\u2102");
|
|
4558
|
-
defineSymbol(math, ams, textord, "H", "\u210D");
|
|
4559
|
-
defineSymbol(symbols_text, ams, textord, "H", "\u210D");
|
|
4560
|
-
defineSymbol(math, ams, textord, "N", "\u2115");
|
|
4561
|
-
defineSymbol(symbols_text, ams, textord, "N", "\u2115");
|
|
4562
|
-
defineSymbol(math, ams, textord, "P", "\u2119");
|
|
4563
|
-
defineSymbol(symbols_text, ams, textord, "P", "\u2119");
|
|
4564
|
-
defineSymbol(math, ams, textord, "Q", "\u211A");
|
|
4565
|
-
defineSymbol(symbols_text, ams, textord, "Q", "\u211A");
|
|
4566
|
-
defineSymbol(math, ams, textord, "R", "\u211D");
|
|
4567
|
-
defineSymbol(symbols_text, ams, textord, "R", "\u211D");
|
|
4568
|
-
defineSymbol(math, ams, textord, "Z", "\u2124");
|
|
4569
|
-
defineSymbol(symbols_text, ams, textord, "Z", "\u2124");
|
|
4570
|
-
defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant
|
|
4571
|
-
|
|
4572
|
-
defineSymbol(symbols_text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters.
|
|
4573
|
-
// We support some letters in the Unicode range U+1D400 to U+1D7FF,
|
|
4574
|
-
// Mathematical Alphanumeric Symbols.
|
|
4575
|
-
// Some editors do not deal well with wide characters. So don't write the
|
|
4576
|
-
// string into this file. Instead, create the string from the surrogate pair.
|
|
4577
|
-
|
|
4578
|
-
var wideChar = "";
|
|
4579
|
-
|
|
4580
|
-
for (var _i3 = 0; _i3 < letters.length; _i3++) {
|
|
4581
|
-
var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair.
|
|
4582
|
-
// 0xD835 is the high surrogate for all letters in the range we support.
|
|
4583
|
-
// 0xDC00 is the low surrogate for bold A.
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
|
|
4587
|
-
|
|
4588
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4589
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4590
|
-
wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic
|
|
4591
|
-
|
|
4592
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4593
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4594
|
-
wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic
|
|
4595
|
-
|
|
4596
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4597
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4598
|
-
wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur
|
|
4599
|
-
|
|
4600
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4601
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4602
|
-
wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif
|
|
4603
|
-
|
|
4604
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4605
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4606
|
-
wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold
|
|
4607
|
-
|
|
4608
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4609
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4610
|
-
wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic
|
|
4611
|
-
|
|
4612
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4613
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4614
|
-
wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace
|
|
4615
|
-
|
|
4616
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4617
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4618
|
-
|
|
4619
|
-
if (_i3 < 26) {
|
|
4620
|
-
// KaTeX fonts have only capital letters for blackboard bold and script.
|
|
4621
|
-
// See exception for k below.
|
|
4622
|
-
wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck
|
|
4623
|
-
|
|
4624
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4625
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4626
|
-
wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script
|
|
4627
|
-
|
|
4628
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4629
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4630
|
-
} // TODO: Add bold script when it is supported by a KaTeX font.
|
|
4631
|
-
|
|
4632
|
-
} // "k" is the only double struck lower case letter in the KaTeX fonts.
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
|
|
4636
|
-
|
|
4637
|
-
defineSymbol(math, main, mathord, "k", wideChar);
|
|
4638
|
-
defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals
|
|
4639
|
-
|
|
4640
|
-
for (var _i4 = 0; _i4 < 10; _i4++) {
|
|
4641
|
-
var _ch4 = _i4.toString();
|
|
4984
|
+
defineSymbol(math, main, op, "\u22C2", "\\bigcap");
|
|
4985
|
+
defineSymbol(math, main, op, "\u22C3", "\\bigcup");
|
|
4986
|
+
defineSymbol(math, main, op, "\u222B", "\\int");
|
|
4987
|
+
defineSymbol(math, main, op, "\u222B", "\\intop");
|
|
4988
|
+
defineSymbol(math, main, op, "\u222C", "\\iint");
|
|
4989
|
+
defineSymbol(math, main, op, "\u222D", "\\iiint");
|
|
4990
|
+
defineSymbol(math, main, op, "\u220F", "\\prod");
|
|
4991
|
+
defineSymbol(math, main, op, "\u2211", "\\sum");
|
|
4992
|
+
defineSymbol(math, main, op, "\u2A02", "\\bigotimes");
|
|
4993
|
+
defineSymbol(math, main, op, "\u2A01", "\\bigoplus");
|
|
4994
|
+
defineSymbol(math, main, op, "\u2A00", "\\bigodot");
|
|
4995
|
+
defineSymbol(math, main, op, "\u222E", "\\oint");
|
|
4996
|
+
defineSymbol(math, main, op, "\u222F", "\\oiint");
|
|
4997
|
+
defineSymbol(math, main, op, "\u2230", "\\oiiint");
|
|
4998
|
+
defineSymbol(math, main, op, "\u2A06", "\\bigsqcup");
|
|
4999
|
+
defineSymbol(math, main, op, "\u222B", "\\smallint");
|
|
5000
|
+
defineSymbol(symbols_text, main, inner, "\u2026", "\\textellipsis");
|
|
5001
|
+
defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
|
|
5002
|
+
defineSymbol(symbols_text, main, inner, "\u2026", "\\ldots", true);
|
|
5003
|
+
defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
|
|
5004
|
+
defineSymbol(math, main, inner, "\u22EF", "\\@cdots", true);
|
|
5005
|
+
defineSymbol(math, main, inner, "\u22F1", "\\ddots", true);
|
|
5006
|
+
defineSymbol(math, main, textord, "\u22EE", "\\varvdots"); // \vdots is a macro
|
|
4642
5007
|
|
|
4643
|
-
|
|
5008
|
+
defineSymbol(math, main, accent, "\u02CA", "\\acute");
|
|
5009
|
+
defineSymbol(math, main, accent, "\u02CB", "\\grave");
|
|
5010
|
+
defineSymbol(math, main, accent, "\xA8", "\\ddot");
|
|
5011
|
+
defineSymbol(math, main, accent, "~", "\\tilde");
|
|
5012
|
+
defineSymbol(math, main, accent, "\u02C9", "\\bar");
|
|
5013
|
+
defineSymbol(math, main, accent, "\u02D8", "\\breve");
|
|
5014
|
+
defineSymbol(math, main, accent, "\u02C7", "\\check");
|
|
5015
|
+
defineSymbol(math, main, accent, "^", "\\hat");
|
|
5016
|
+
defineSymbol(math, main, accent, "\u20D7", "\\vec");
|
|
5017
|
+
defineSymbol(math, main, accent, "\u02D9", "\\dot");
|
|
5018
|
+
defineSymbol(math, main, accent, "\u02DA", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA
|
|
4644
5019
|
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
5020
|
+
defineSymbol(math, main, mathord, "\uE131", "\\@imath");
|
|
5021
|
+
defineSymbol(math, main, mathord, "\uE237", "\\@jmath");
|
|
5022
|
+
defineSymbol(math, main, textord, "\u0131", "\u0131");
|
|
5023
|
+
defineSymbol(math, main, textord, "\u0237", "\u0237");
|
|
5024
|
+
defineSymbol(symbols_text, main, textord, "\u0131", "\\i", true);
|
|
5025
|
+
defineSymbol(symbols_text, main, textord, "\u0237", "\\j", true);
|
|
5026
|
+
defineSymbol(symbols_text, main, textord, "\xDF", "\\ss", true);
|
|
5027
|
+
defineSymbol(symbols_text, main, textord, "\xE6", "\\ae", true);
|
|
5028
|
+
defineSymbol(symbols_text, main, textord, "\u0153", "\\oe", true);
|
|
5029
|
+
defineSymbol(symbols_text, main, textord, "\xF8", "\\o", true);
|
|
5030
|
+
defineSymbol(symbols_text, main, textord, "\xC6", "\\AE", true);
|
|
5031
|
+
defineSymbol(symbols_text, main, textord, "\u0152", "\\OE", true);
|
|
5032
|
+
defineSymbol(symbols_text, main, textord, "\xD8", "\\O", true);
|
|
5033
|
+
defineSymbol(symbols_text, main, accent, "\u02CA", "\\'"); // acute
|
|
4648
5034
|
|
|
4649
|
-
|
|
4650
|
-
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
4651
|
-
wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans
|
|
5035
|
+
defineSymbol(symbols_text, main, accent, "\u02CB", "\\`"); // grave
|
|
4652
5036
|
|
|
4653
|
-
|
|
4654
|
-
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
4655
|
-
wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace
|
|
5037
|
+
defineSymbol(symbols_text, main, accent, "\u02C6", "\\^"); // circumflex
|
|
4656
5038
|
|
|
4657
|
-
|
|
4658
|
-
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
4659
|
-
} // We add these Latin-1 letters as symbols for backwards-compatibility,
|
|
4660
|
-
// but they are not actually in the font, nor are they supported by the
|
|
4661
|
-
// Unicode accent mechanism, so they fall back to Times font and look ugly.
|
|
4662
|
-
// TODO(edemaine): Fix this.
|
|
5039
|
+
defineSymbol(symbols_text, main, accent, "\u02DC", "\\~"); // tilde
|
|
4663
5040
|
|
|
5041
|
+
defineSymbol(symbols_text, main, accent, "\u02C9", "\\="); // macron
|
|
4664
5042
|
|
|
4665
|
-
|
|
5043
|
+
defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve
|
|
4666
5044
|
|
|
4667
|
-
|
|
4668
|
-
var _ch5 = extraLatin.charAt(_i5);
|
|
5045
|
+
defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above
|
|
4669
5046
|
|
|
4670
|
-
|
|
4671
|
-
defineSymbol(symbols_text, main, textord, _ch5, _ch5);
|
|
4672
|
-
}
|
|
4673
|
-
;// CONCATENATED MODULE: ./src/wide-character.js
|
|
4674
|
-
/**
|
|
4675
|
-
* This file provides support for Unicode range U+1D400 to U+1D7FF,
|
|
4676
|
-
* Mathematical Alphanumeric Symbols.
|
|
4677
|
-
*
|
|
4678
|
-
* Function wideCharacterFont takes a wide character as input and returns
|
|
4679
|
-
* the font information necessary to render it properly.
|
|
4680
|
-
*/
|
|
5047
|
+
defineSymbol(symbols_text, main, accent, "\xB8", "\\c"); // cedilla
|
|
4681
5048
|
|
|
4682
|
-
|
|
4683
|
-
* Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
4684
|
-
* That document sorts characters into groups by font type, say bold or italic.
|
|
4685
|
-
*
|
|
4686
|
-
* In the arrays below, each subarray consists three elements:
|
|
4687
|
-
* * The CSS class of that group when in math mode.
|
|
4688
|
-
* * The CSS class of that group when in text mode.
|
|
4689
|
-
* * The font name, so that KaTeX can get font metrics.
|
|
4690
|
-
*/
|
|
5049
|
+
defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above
|
|
4691
5050
|
|
|
4692
|
-
|
|
4693
|
-
["mathbf", "textbf", "Main-Bold"], // a-z bold upright
|
|
4694
|
-
["mathnormal", "textit", "Math-Italic"], // A-Z italic
|
|
4695
|
-
["mathnormal", "textit", "Math-Italic"], // a-z italic
|
|
4696
|
-
["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic
|
|
4697
|
-
["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic
|
|
4698
|
-
// Map fancy A-Z letters to script, not calligraphic.
|
|
4699
|
-
// This aligns with unicode-math and math fonts (except Cambria Math).
|
|
4700
|
-
["mathscr", "textscr", "Script-Regular"], // A-Z script
|
|
4701
|
-
["", "", ""], // a-z script. No font
|
|
4702
|
-
["", "", ""], // A-Z bold script. No font
|
|
4703
|
-
["", "", ""], // a-z bold script. No font
|
|
4704
|
-
["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur
|
|
4705
|
-
["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur
|
|
4706
|
-
["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
|
|
4707
|
-
["mathbb", "textbb", "AMS-Regular"], // k double-struck
|
|
4708
|
-
["", "", ""], // A-Z bold Fraktur No font metrics
|
|
4709
|
-
["", "", ""], // a-z bold Fraktur. No font.
|
|
4710
|
-
["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
|
|
4711
|
-
["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
|
|
4712
|
-
["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif
|
|
4713
|
-
["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif
|
|
4714
|
-
["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif
|
|
4715
|
-
["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif
|
|
4716
|
-
["", "", ""], // A-Z bold italic sans. No font
|
|
4717
|
-
["", "", ""], // a-z bold italic sans. No font
|
|
4718
|
-
["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace
|
|
4719
|
-
["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace
|
|
4720
|
-
];
|
|
4721
|
-
var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold
|
|
4722
|
-
["", "", ""], // 0-9 double-struck. No KaTeX font.
|
|
4723
|
-
["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif
|
|
4724
|
-
["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif
|
|
4725
|
-
["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace
|
|
4726
|
-
];
|
|
4727
|
-
var wideCharacterFont = function wideCharacterFont(wideChar, mode) {
|
|
4728
|
-
// IE doesn't support codePointAt(). So work with the surrogate pair.
|
|
4729
|
-
var H = wideChar.charCodeAt(0); // high surrogate
|
|
5051
|
+
defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron
|
|
4730
5052
|
|
|
4731
|
-
|
|
5053
|
+
defineSymbol(symbols_text, main, accent, "\xA8", '\\"'); // diaresis
|
|
4732
5054
|
|
|
4733
|
-
|
|
4734
|
-
var j = mode === "math" ? 0 : 1; // column index for CSS class.
|
|
5055
|
+
defineSymbol(symbols_text, main, accent, "\u02DD", "\\H"); // double acute
|
|
4735
5056
|
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
// So we can calculate the relevant row. No traverse necessary.
|
|
4739
|
-
var i = Math.floor((codePoint - 0x1D400) / 26);
|
|
4740
|
-
return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]];
|
|
4741
|
-
} else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) {
|
|
4742
|
-
// Numerals, ten per row.
|
|
4743
|
-
var _i = Math.floor((codePoint - 0x1D7CE) / 10);
|
|
5057
|
+
defineSymbol(symbols_text, main, accent, "\u25EF", "\\textcircled"); // \bigcirc glyph
|
|
5058
|
+
// These ligatures are detected and created in Parser.js's `formLigatures`.
|
|
4744
5059
|
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
// Greek letters. Not supported, yet.
|
|
4751
|
-
return ["", ""];
|
|
4752
|
-
} else {
|
|
4753
|
-
// We don't support any wide characters outside 1D400–1D7FF.
|
|
4754
|
-
throw new src_ParseError("Unsupported character: " + wideChar);
|
|
4755
|
-
}
|
|
5060
|
+
var ligatures = {
|
|
5061
|
+
"--": true,
|
|
5062
|
+
"---": true,
|
|
5063
|
+
"``": true,
|
|
5064
|
+
"''": true
|
|
4756
5065
|
};
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
[3, 1, 1], // size3: [7, 5, 5] \scriptsize
|
|
4770
|
-
[4, 2, 1], // size4: [8, 6, 5] \footnotesize
|
|
4771
|
-
[5, 2, 1], // size5: [9, 6, 5] \small
|
|
4772
|
-
[6, 3, 1], // size6: [10, 7, 5] \normalsize
|
|
4773
|
-
[7, 4, 2], // size7: [12, 8, 6] \large
|
|
4774
|
-
[8, 6, 3], // size8: [14.4, 10, 7] \Large
|
|
4775
|
-
[9, 7, 6], // size9: [17.28, 12, 10] \LARGE
|
|
4776
|
-
[10, 8, 7], // size10: [20.74, 14.4, 12] \huge
|
|
4777
|
-
[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE
|
|
4778
|
-
];
|
|
4779
|
-
var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if
|
|
4780
|
-
// you change size indexes, change that function.
|
|
4781
|
-
0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
|
|
4782
|
-
|
|
4783
|
-
var sizeAtStyle = function sizeAtStyle(size, style) {
|
|
4784
|
-
return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
|
|
4785
|
-
}; // In these types, "" (empty string) means "no change".
|
|
5066
|
+
defineSymbol(symbols_text, main, textord, "\u2013", "--", true);
|
|
5067
|
+
defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash");
|
|
5068
|
+
defineSymbol(symbols_text, main, textord, "\u2014", "---", true);
|
|
5069
|
+
defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash");
|
|
5070
|
+
defineSymbol(symbols_text, main, textord, "\u2018", "`", true);
|
|
5071
|
+
defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft");
|
|
5072
|
+
defineSymbol(symbols_text, main, textord, "\u2019", "'", true);
|
|
5073
|
+
defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright");
|
|
5074
|
+
defineSymbol(symbols_text, main, textord, "\u201C", "``", true);
|
|
5075
|
+
defineSymbol(symbols_text, main, textord, "\u201C", "\\textquotedblleft");
|
|
5076
|
+
defineSymbol(symbols_text, main, textord, "\u201D", "''", true);
|
|
5077
|
+
defineSymbol(symbols_text, main, textord, "\u201D", "\\textquotedblright"); // \degree from gensymb package
|
|
4786
5078
|
|
|
5079
|
+
defineSymbol(math, main, textord, "\xB0", "\\degree", true);
|
|
5080
|
+
defineSymbol(symbols_text, main, textord, "\xB0", "\\degree"); // \textdegree from inputenc package
|
|
4787
5081
|
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
* and font.
|
|
4791
|
-
*
|
|
4792
|
-
* Options objects should not be modified. To create a new Options with
|
|
4793
|
-
* different properties, call a `.having*` method.
|
|
4794
|
-
*/
|
|
4795
|
-
var Options = /*#__PURE__*/function () {
|
|
4796
|
-
// A font family applies to a group of fonts (i.e. SansSerif), while a font
|
|
4797
|
-
// represents a specific font (i.e. SansSerif Bold).
|
|
4798
|
-
// See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm
|
|
5082
|
+
defineSymbol(symbols_text, main, textord, "\xB0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math
|
|
5083
|
+
// mode, but among our fonts, only Main-Regular defines this character "163".
|
|
4799
5084
|
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
this.textSize = void 0;
|
|
4808
|
-
this.phantom = void 0;
|
|
4809
|
-
this.font = void 0;
|
|
4810
|
-
this.fontFamily = void 0;
|
|
4811
|
-
this.fontWeight = void 0;
|
|
4812
|
-
this.fontShape = void 0;
|
|
4813
|
-
this.sizeMultiplier = void 0;
|
|
4814
|
-
this.maxSize = void 0;
|
|
4815
|
-
this.minRuleThickness = void 0;
|
|
4816
|
-
this._fontMetrics = void 0;
|
|
4817
|
-
this.style = data.style;
|
|
4818
|
-
this.color = data.color;
|
|
4819
|
-
this.size = data.size || Options.BASESIZE;
|
|
4820
|
-
this.textSize = data.textSize || this.size;
|
|
4821
|
-
this.phantom = !!data.phantom;
|
|
4822
|
-
this.font = data.font || "";
|
|
4823
|
-
this.fontFamily = data.fontFamily || "";
|
|
4824
|
-
this.fontWeight = data.fontWeight || '';
|
|
4825
|
-
this.fontShape = data.fontShape || '';
|
|
4826
|
-
this.sizeMultiplier = sizeMultipliers[this.size - 1];
|
|
4827
|
-
this.maxSize = data.maxSize;
|
|
4828
|
-
this.minRuleThickness = data.minRuleThickness;
|
|
4829
|
-
this._fontMetrics = undefined;
|
|
4830
|
-
}
|
|
4831
|
-
/**
|
|
4832
|
-
* Returns a new options object with the same properties as "this". Properties
|
|
4833
|
-
* from "extension" will be copied to the new options object.
|
|
4834
|
-
*/
|
|
5085
|
+
defineSymbol(math, main, textord, "\xA3", "\\pounds");
|
|
5086
|
+
defineSymbol(math, main, textord, "\xA3", "\\mathsterling", true);
|
|
5087
|
+
defineSymbol(symbols_text, main, textord, "\xA3", "\\pounds");
|
|
5088
|
+
defineSymbol(symbols_text, main, textord, "\xA3", "\\textsterling", true);
|
|
5089
|
+
defineSymbol(math, ams, textord, "\u2720", "\\maltese");
|
|
5090
|
+
defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards.
|
|
5091
|
+
// All of these are textords in math mode
|
|
4835
5092
|
|
|
5093
|
+
var mathTextSymbols = "0123456789/@.\"";
|
|
4836
5094
|
|
|
4837
|
-
|
|
5095
|
+
for (var i = 0; i < mathTextSymbols.length; i++) {
|
|
5096
|
+
var ch = mathTextSymbols.charAt(i);
|
|
5097
|
+
defineSymbol(math, main, textord, ch, ch);
|
|
5098
|
+
} // All of these are textords in text mode
|
|
4838
5099
|
|
|
4839
|
-
_proto.extend = function extend(extension) {
|
|
4840
|
-
var data = {
|
|
4841
|
-
style: this.style,
|
|
4842
|
-
size: this.size,
|
|
4843
|
-
textSize: this.textSize,
|
|
4844
|
-
color: this.color,
|
|
4845
|
-
phantom: this.phantom,
|
|
4846
|
-
font: this.font,
|
|
4847
|
-
fontFamily: this.fontFamily,
|
|
4848
|
-
fontWeight: this.fontWeight,
|
|
4849
|
-
fontShape: this.fontShape,
|
|
4850
|
-
maxSize: this.maxSize,
|
|
4851
|
-
minRuleThickness: this.minRuleThickness
|
|
4852
|
-
};
|
|
4853
5100
|
|
|
4854
|
-
|
|
4855
|
-
if (extension.hasOwnProperty(key)) {
|
|
4856
|
-
data[key] = extension[key];
|
|
4857
|
-
}
|
|
4858
|
-
}
|
|
5101
|
+
var textSymbols = "0123456789!@*()-=+\";:?/.,";
|
|
4859
5102
|
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
/**
|
|
4863
|
-
* Return an options object with the given style. If `this.style === style`,
|
|
4864
|
-
* returns `this`.
|
|
4865
|
-
*/
|
|
4866
|
-
;
|
|
5103
|
+
for (var _i = 0; _i < textSymbols.length; _i++) {
|
|
5104
|
+
var _ch = textSymbols.charAt(_i);
|
|
4867
5105
|
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
return this;
|
|
4871
|
-
} else {
|
|
4872
|
-
return this.extend({
|
|
4873
|
-
style: style,
|
|
4874
|
-
size: sizeAtStyle(this.textSize, style)
|
|
4875
|
-
});
|
|
4876
|
-
}
|
|
4877
|
-
}
|
|
4878
|
-
/**
|
|
4879
|
-
* Return an options object with a cramped version of the current style. If
|
|
4880
|
-
* the current style is cramped, returns `this`.
|
|
4881
|
-
*/
|
|
4882
|
-
;
|
|
5106
|
+
defineSymbol(symbols_text, main, textord, _ch, _ch);
|
|
5107
|
+
} // All of these are textords in text mode, and mathords in math mode
|
|
4883
5108
|
|
|
4884
|
-
_proto.havingCrampedStyle = function havingCrampedStyle() {
|
|
4885
|
-
return this.havingStyle(this.style.cramp());
|
|
4886
|
-
}
|
|
4887
|
-
/**
|
|
4888
|
-
* Return an options object with the given size and in at least `\textstyle`.
|
|
4889
|
-
* Returns `this` if appropriate.
|
|
4890
|
-
*/
|
|
4891
|
-
;
|
|
4892
5109
|
|
|
4893
|
-
|
|
4894
|
-
if (this.size === size && this.textSize === size) {
|
|
4895
|
-
return this;
|
|
4896
|
-
} else {
|
|
4897
|
-
return this.extend({
|
|
4898
|
-
style: this.style.text(),
|
|
4899
|
-
size: size,
|
|
4900
|
-
textSize: size,
|
|
4901
|
-
sizeMultiplier: sizeMultipliers[size - 1]
|
|
4902
|
-
});
|
|
4903
|
-
}
|
|
4904
|
-
}
|
|
4905
|
-
/**
|
|
4906
|
-
* Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
|
|
4907
|
-
* changes to at least `\textstyle`.
|
|
4908
|
-
*/
|
|
4909
|
-
;
|
|
5110
|
+
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
4910
5111
|
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
var wantSize = sizeAtStyle(Options.BASESIZE, style);
|
|
5112
|
+
for (var _i2 = 0; _i2 < letters.length; _i2++) {
|
|
5113
|
+
var _ch2 = letters.charAt(_i2);
|
|
4914
5114
|
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
return this.extend({
|
|
4919
|
-
style: style,
|
|
4920
|
-
size: wantSize
|
|
4921
|
-
});
|
|
4922
|
-
}
|
|
4923
|
-
}
|
|
4924
|
-
/**
|
|
4925
|
-
* Remove the effect of sizing changes such as \Huge.
|
|
4926
|
-
* Keep the effect of the current style, such as \scriptstyle.
|
|
4927
|
-
*/
|
|
4928
|
-
;
|
|
5115
|
+
defineSymbol(math, main, mathord, _ch2, _ch2);
|
|
5116
|
+
defineSymbol(symbols_text, main, textord, _ch2, _ch2);
|
|
5117
|
+
} // Blackboard bold and script letters in Unicode range
|
|
4929
5118
|
|
|
4930
|
-
_proto.havingBaseSizing = function havingBaseSizing() {
|
|
4931
|
-
var size;
|
|
4932
5119
|
|
|
4933
|
-
|
|
4934
|
-
case 4:
|
|
4935
|
-
case 5:
|
|
4936
|
-
size = 3; // normalsize in scriptstyle
|
|
5120
|
+
defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
|
|
4937
5121
|
|
|
4938
|
-
|
|
5122
|
+
defineSymbol(symbols_text, ams, textord, "C", "\u2102");
|
|
5123
|
+
defineSymbol(math, ams, textord, "H", "\u210D");
|
|
5124
|
+
defineSymbol(symbols_text, ams, textord, "H", "\u210D");
|
|
5125
|
+
defineSymbol(math, ams, textord, "N", "\u2115");
|
|
5126
|
+
defineSymbol(symbols_text, ams, textord, "N", "\u2115");
|
|
5127
|
+
defineSymbol(math, ams, textord, "P", "\u2119");
|
|
5128
|
+
defineSymbol(symbols_text, ams, textord, "P", "\u2119");
|
|
5129
|
+
defineSymbol(math, ams, textord, "Q", "\u211A");
|
|
5130
|
+
defineSymbol(symbols_text, ams, textord, "Q", "\u211A");
|
|
5131
|
+
defineSymbol(math, ams, textord, "R", "\u211D");
|
|
5132
|
+
defineSymbol(symbols_text, ams, textord, "R", "\u211D");
|
|
5133
|
+
defineSymbol(math, ams, textord, "Z", "\u2124");
|
|
5134
|
+
defineSymbol(symbols_text, ams, textord, "Z", "\u2124");
|
|
5135
|
+
defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant
|
|
4939
5136
|
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
5137
|
+
defineSymbol(symbols_text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters.
|
|
5138
|
+
// We support some letters in the Unicode range U+1D400 to U+1D7FF,
|
|
5139
|
+
// Mathematical Alphanumeric Symbols.
|
|
5140
|
+
// Some editors do not deal well with wide characters. So don't write the
|
|
5141
|
+
// string into this file. Instead, create the string from the surrogate pair.
|
|
4943
5142
|
|
|
4944
|
-
|
|
5143
|
+
var wideChar = "";
|
|
4945
5144
|
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
5145
|
+
for (var _i3 = 0; _i3 < letters.length; _i3++) {
|
|
5146
|
+
var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair.
|
|
5147
|
+
// 0xD835 is the high surrogate for all letters in the range we support.
|
|
5148
|
+
// 0xDC00 is the low surrogate for bold A.
|
|
4950
5149
|
|
|
4951
|
-
return this.extend({
|
|
4952
|
-
style: this.style.text(),
|
|
4953
|
-
size: size
|
|
4954
|
-
});
|
|
4955
|
-
}
|
|
4956
|
-
/**
|
|
4957
|
-
* Create a new options object with the given color.
|
|
4958
|
-
*/
|
|
4959
|
-
;
|
|
4960
5150
|
|
|
4961
|
-
|
|
4962
|
-
return this.extend({
|
|
4963
|
-
color: color
|
|
4964
|
-
});
|
|
4965
|
-
}
|
|
4966
|
-
/**
|
|
4967
|
-
* Create a new options object with "phantom" set to true.
|
|
4968
|
-
*/
|
|
4969
|
-
;
|
|
5151
|
+
wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
|
|
4970
5152
|
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
});
|
|
4975
|
-
}
|
|
4976
|
-
/**
|
|
4977
|
-
* Creates a new options object with the given math font or old text font.
|
|
4978
|
-
* @type {[type]}
|
|
4979
|
-
*/
|
|
4980
|
-
;
|
|
5153
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5154
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5155
|
+
wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic
|
|
4981
5156
|
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
});
|
|
4986
|
-
}
|
|
4987
|
-
/**
|
|
4988
|
-
* Create a new options objects with the given fontFamily.
|
|
4989
|
-
*/
|
|
4990
|
-
;
|
|
5157
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5158
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5159
|
+
wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic
|
|
4991
5160
|
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
font: ""
|
|
4996
|
-
});
|
|
4997
|
-
}
|
|
4998
|
-
/**
|
|
4999
|
-
* Creates a new options object with the given font weight
|
|
5000
|
-
*/
|
|
5001
|
-
;
|
|
5161
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5162
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5163
|
+
wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur
|
|
5002
5164
|
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
font: ""
|
|
5007
|
-
});
|
|
5008
|
-
}
|
|
5009
|
-
/**
|
|
5010
|
-
* Creates a new options object with the given font weight
|
|
5011
|
-
*/
|
|
5012
|
-
;
|
|
5165
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5166
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5167
|
+
wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif
|
|
5013
5168
|
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
;
|
|
5169
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5170
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5171
|
+
wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold
|
|
5172
|
+
|
|
5173
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5174
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5175
|
+
wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic
|
|
5176
|
+
|
|
5177
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5178
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5179
|
+
wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace
|
|
5180
|
+
|
|
5181
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5182
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5183
|
+
|
|
5184
|
+
if (_i3 < 26) {
|
|
5185
|
+
// KaTeX fonts have only capital letters for blackboard bold and script.
|
|
5186
|
+
// See exception for k below.
|
|
5187
|
+
wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck
|
|
5188
|
+
|
|
5189
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5190
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5191
|
+
wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script
|
|
5192
|
+
|
|
5193
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5194
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5195
|
+
} // TODO: Add bold script when it is supported by a KaTeX font.
|
|
5196
|
+
|
|
5197
|
+
} // "k" is the only double struck lower case letter in the KaTeX fonts.
|
|
5025
5198
|
|
|
5026
|
-
_proto.sizingClasses = function sizingClasses(oldOptions) {
|
|
5027
|
-
if (oldOptions.size !== this.size) {
|
|
5028
|
-
return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
|
|
5029
|
-
} else {
|
|
5030
|
-
return [];
|
|
5031
|
-
}
|
|
5032
|
-
}
|
|
5033
|
-
/**
|
|
5034
|
-
* Return the CSS sizing classes required to switch to the base size. Like
|
|
5035
|
-
* `this.havingSize(BASESIZE).sizingClasses(this)`.
|
|
5036
|
-
*/
|
|
5037
|
-
;
|
|
5038
5199
|
|
|
5039
|
-
|
|
5040
|
-
if (this.size !== Options.BASESIZE) {
|
|
5041
|
-
return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
|
|
5042
|
-
} else {
|
|
5043
|
-
return [];
|
|
5044
|
-
}
|
|
5045
|
-
}
|
|
5046
|
-
/**
|
|
5047
|
-
* Return the font metrics for this size.
|
|
5048
|
-
*/
|
|
5049
|
-
;
|
|
5200
|
+
wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
|
|
5050
5201
|
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
this._fontMetrics = getGlobalMetrics(this.size);
|
|
5054
|
-
}
|
|
5202
|
+
defineSymbol(math, main, mathord, "k", wideChar);
|
|
5203
|
+
defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals
|
|
5055
5204
|
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
/**
|
|
5059
|
-
* Gets the CSS color of the current options object
|
|
5060
|
-
*/
|
|
5061
|
-
;
|
|
5205
|
+
for (var _i4 = 0; _i4 < 10; _i4++) {
|
|
5206
|
+
var _ch4 = _i4.toString();
|
|
5062
5207
|
|
|
5063
|
-
|
|
5064
|
-
if (this.phantom) {
|
|
5065
|
-
return "transparent";
|
|
5066
|
-
} else {
|
|
5067
|
-
return this.color;
|
|
5068
|
-
}
|
|
5069
|
-
};
|
|
5208
|
+
wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold
|
|
5070
5209
|
|
|
5071
|
-
|
|
5072
|
-
|
|
5210
|
+
defineSymbol(math, main, mathord, _ch4, wideChar);
|
|
5211
|
+
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
5212
|
+
wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif
|
|
5073
5213
|
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
/**
|
|
5078
|
-
* This file does conversion between units. In particular, it provides
|
|
5079
|
-
* calculateSize to convert other units into ems.
|
|
5080
|
-
*/
|
|
5214
|
+
defineSymbol(math, main, mathord, _ch4, wideChar);
|
|
5215
|
+
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
5216
|
+
wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans
|
|
5081
5217
|
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
// *assuming* a font size of ptPerEm (normal size, normal style).
|
|
5218
|
+
defineSymbol(math, main, mathord, _ch4, wideChar);
|
|
5219
|
+
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
5220
|
+
wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace
|
|
5086
5221
|
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
// millimeter
|
|
5094
|
-
"cm": 7227 / 254,
|
|
5095
|
-
// centimeter
|
|
5096
|
-
"in": 72.27,
|
|
5097
|
-
// inch
|
|
5098
|
-
"bp": 803 / 800,
|
|
5099
|
-
// big (PostScript) points
|
|
5100
|
-
"pc": 12,
|
|
5101
|
-
// pica
|
|
5102
|
-
"dd": 1238 / 1157,
|
|
5103
|
-
// didot
|
|
5104
|
-
"cc": 14856 / 1157,
|
|
5105
|
-
// cicero (12 didot)
|
|
5106
|
-
"nd": 685 / 642,
|
|
5107
|
-
// new didot
|
|
5108
|
-
"nc": 1370 / 107,
|
|
5109
|
-
// new cicero (12 new didot)
|
|
5110
|
-
"sp": 1 / 65536,
|
|
5111
|
-
// scaled point (TeX's internal smallest unit)
|
|
5112
|
-
// https://tex.stackexchange.com/a/41371
|
|
5113
|
-
"px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX
|
|
5222
|
+
defineSymbol(math, main, mathord, _ch4, wideChar);
|
|
5223
|
+
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
5224
|
+
} // We add these Latin-1 letters as symbols for backwards-compatibility,
|
|
5225
|
+
// but they are not actually in the font, nor are they supported by the
|
|
5226
|
+
// Unicode accent mechanism, so they fall back to Times font and look ugly.
|
|
5227
|
+
// TODO(edemaine): Fix this.
|
|
5114
5228
|
|
|
5115
|
-
}; // Dictionary of relative units, for fast validity testing.
|
|
5116
5229
|
|
|
5117
|
-
var
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
};
|
|
5230
|
+
var extraLatin = "\xD0\xDE\xFE";
|
|
5231
|
+
|
|
5232
|
+
for (var _i5 = 0; _i5 < extraLatin.length; _i5++) {
|
|
5233
|
+
var _ch5 = extraLatin.charAt(_i5);
|
|
5122
5234
|
|
|
5235
|
+
defineSymbol(math, main, mathord, _ch5, _ch5);
|
|
5236
|
+
defineSymbol(symbols_text, main, textord, _ch5, _ch5);
|
|
5237
|
+
}
|
|
5238
|
+
;// CONCATENATED MODULE: ./src/wide-character.js
|
|
5123
5239
|
/**
|
|
5124
|
-
*
|
|
5125
|
-
*
|
|
5240
|
+
* This file provides support for Unicode range U+1D400 to U+1D7FF,
|
|
5241
|
+
* Mathematical Alphanumeric Symbols.
|
|
5242
|
+
*
|
|
5243
|
+
* Function wideCharacterFont takes a wide character as input and returns
|
|
5244
|
+
* the font information necessary to render it properly.
|
|
5126
5245
|
*/
|
|
5127
|
-
var validUnit = function validUnit(unit) {
|
|
5128
|
-
if (typeof unit !== "string") {
|
|
5129
|
-
unit = unit.unit;
|
|
5130
|
-
}
|
|
5131
5246
|
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
*
|
|
5136
|
-
*
|
|
5137
|
-
*
|
|
5247
|
+
/**
|
|
5248
|
+
* Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
5249
|
+
* That document sorts characters into groups by font type, say bold or italic.
|
|
5250
|
+
*
|
|
5251
|
+
* In the arrays below, each subarray consists three elements:
|
|
5252
|
+
* * The CSS class of that group when in math mode.
|
|
5253
|
+
* * The CSS class of that group when in text mode.
|
|
5254
|
+
* * The font name, so that KaTeX can get font metrics.
|
|
5138
5255
|
*/
|
|
5139
5256
|
|
|
5140
|
-
var
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5257
|
+
var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright
|
|
5258
|
+
["mathbf", "textbf", "Main-Bold"], // a-z bold upright
|
|
5259
|
+
["mathnormal", "textit", "Math-Italic"], // A-Z italic
|
|
5260
|
+
["mathnormal", "textit", "Math-Italic"], // a-z italic
|
|
5261
|
+
["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic
|
|
5262
|
+
["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic
|
|
5263
|
+
// Map fancy A-Z letters to script, not calligraphic.
|
|
5264
|
+
// This aligns with unicode-math and math fonts (except Cambria Math).
|
|
5265
|
+
["mathscr", "textscr", "Script-Regular"], // A-Z script
|
|
5266
|
+
["", "", ""], // a-z script. No font
|
|
5267
|
+
["", "", ""], // A-Z bold script. No font
|
|
5268
|
+
["", "", ""], // a-z bold script. No font
|
|
5269
|
+
["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur
|
|
5270
|
+
["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur
|
|
5271
|
+
["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
|
|
5272
|
+
["mathbb", "textbb", "AMS-Regular"], // k double-struck
|
|
5273
|
+
["", "", ""], // A-Z bold Fraktur No font metrics
|
|
5274
|
+
["", "", ""], // a-z bold Fraktur. No font.
|
|
5275
|
+
["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
|
|
5276
|
+
["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
|
|
5277
|
+
["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif
|
|
5278
|
+
["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif
|
|
5279
|
+
["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif
|
|
5280
|
+
["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif
|
|
5281
|
+
["", "", ""], // A-Z bold italic sans. No font
|
|
5282
|
+
["", "", ""], // a-z bold italic sans. No font
|
|
5283
|
+
["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace
|
|
5284
|
+
["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace
|
|
5285
|
+
];
|
|
5286
|
+
var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold
|
|
5287
|
+
["", "", ""], // 0-9 double-struck. No KaTeX font.
|
|
5288
|
+
["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif
|
|
5289
|
+
["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif
|
|
5290
|
+
["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace
|
|
5291
|
+
];
|
|
5292
|
+
var wideCharacterFont = function wideCharacterFont(wideChar, mode) {
|
|
5293
|
+
// IE doesn't support codePointAt(). So work with the surrogate pair.
|
|
5294
|
+
var H = wideChar.charCodeAt(0); // high surrogate
|
|
5155
5295
|
|
|
5156
|
-
|
|
5157
|
-
// isTight() means current style is script/scriptscript.
|
|
5158
|
-
unitOptions = options.havingStyle(options.style.text());
|
|
5159
|
-
} else {
|
|
5160
|
-
unitOptions = options;
|
|
5161
|
-
} // TODO: In TeX these units are relative to the quad of the current
|
|
5162
|
-
// *text* font, e.g. cmr10. KaTeX instead uses values from the
|
|
5163
|
-
// comparably-sized *Computer Modern symbol* font. At 10pt, these
|
|
5164
|
-
// match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
|
|
5165
|
-
// cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
|
|
5166
|
-
// TeX \showlists shows a kern of 1.13889 * fontsize;
|
|
5167
|
-
// KaTeX shows a kern of 1.171 * fontsize.
|
|
5296
|
+
var L = wideChar.charCodeAt(1); // low surrogate
|
|
5168
5297
|
|
|
5298
|
+
var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000;
|
|
5299
|
+
var j = mode === "math" ? 0 : 1; // column index for CSS class.
|
|
5169
5300
|
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5301
|
+
if (0x1D400 <= codePoint && codePoint < 0x1D6A4) {
|
|
5302
|
+
// wideLatinLetterData contains exactly 26 chars on each row.
|
|
5303
|
+
// So we can calculate the relevant row. No traverse necessary.
|
|
5304
|
+
var i = Math.floor((codePoint - 0x1D400) / 26);
|
|
5305
|
+
return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]];
|
|
5306
|
+
} else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) {
|
|
5307
|
+
// Numerals, ten per row.
|
|
5308
|
+
var _i = Math.floor((codePoint - 0x1D7CE) / 10);
|
|
5177
5309
|
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5310
|
+
return [wideNumeralData[_i][2], wideNumeralData[_i][j]];
|
|
5311
|
+
} else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) {
|
|
5312
|
+
// dotless i or j
|
|
5313
|
+
return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]];
|
|
5314
|
+
} else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) {
|
|
5315
|
+
// Greek letters. Not supported, yet.
|
|
5316
|
+
return ["", ""];
|
|
5317
|
+
} else {
|
|
5318
|
+
// We don't support any wide characters outside 1D400–1D7FF.
|
|
5319
|
+
throw new src_ParseError("Unsupported character: " + wideChar);
|
|
5181
5320
|
}
|
|
5182
|
-
|
|
5183
|
-
return Math.min(sizeValue.number * scale, options.maxSize);
|
|
5184
5321
|
};
|
|
5185
5322
|
;// CONCATENATED MODULE: ./src/buildCommon.js
|
|
5186
5323
|
/* eslint no-console:0 */
|
|
@@ -5501,7 +5638,7 @@ var makeSvgSpan = function makeSvgSpan(classes, children, options, style) {
|
|
|
5501
5638
|
var makeLineSpan = function makeLineSpan(className, options, thickness) {
|
|
5502
5639
|
var line = makeSpan([className], [], options);
|
|
5503
5640
|
line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness);
|
|
5504
|
-
line.style.borderBottomWidth = line.height
|
|
5641
|
+
line.style.borderBottomWidth = makeEm(line.height);
|
|
5505
5642
|
line.maxFontSize = 1.0;
|
|
5506
5643
|
return line;
|
|
5507
5644
|
};
|
|
@@ -5641,7 +5778,7 @@ var makeVList = function makeVList(params, options) {
|
|
|
5641
5778
|
|
|
5642
5779
|
pstrutSize += 2;
|
|
5643
5780
|
var pstrut = makeSpan(["pstrut"], []);
|
|
5644
|
-
pstrut.style.height = pstrutSize
|
|
5781
|
+
pstrut.style.height = makeEm(pstrutSize); // Create a new list of actual children at the correct offsets
|
|
5645
5782
|
|
|
5646
5783
|
var realChildren = [];
|
|
5647
5784
|
var minPos = depth;
|
|
@@ -5658,7 +5795,7 @@ var makeVList = function makeVList(params, options) {
|
|
|
5658
5795
|
var classes = _child.wrapperClasses || [];
|
|
5659
5796
|
var style = _child.wrapperStyle || {};
|
|
5660
5797
|
var childWrap = makeSpan(classes, [pstrut, _elem], undefined, style);
|
|
5661
|
-
childWrap.style.top = -pstrutSize - currPos - _elem.depth
|
|
5798
|
+
childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth);
|
|
5662
5799
|
|
|
5663
5800
|
if (_child.marginLeft) {
|
|
5664
5801
|
childWrap.style.marginLeft = _child.marginLeft;
|
|
@@ -5680,7 +5817,7 @@ var makeVList = function makeVList(params, options) {
|
|
|
5680
5817
|
|
|
5681
5818
|
|
|
5682
5819
|
var vlist = makeSpan(["vlist"], realChildren);
|
|
5683
|
-
vlist.style.height = maxPos
|
|
5820
|
+
vlist.style.height = makeEm(maxPos); // A second row is used if necessary to represent the vlist's depth.
|
|
5684
5821
|
|
|
5685
5822
|
var rows;
|
|
5686
5823
|
|
|
@@ -5692,7 +5829,7 @@ var makeVList = function makeVList(params, options) {
|
|
|
5692
5829
|
// So we put another empty span inside the depth strut span.
|
|
5693
5830
|
var emptySpan = makeSpan([], []);
|
|
5694
5831
|
var depthStrut = makeSpan(["vlist"], [emptySpan]);
|
|
5695
|
-
depthStrut.style.height = -minPos
|
|
5832
|
+
depthStrut.style.height = makeEm(-minPos); // Safari wants the first row to have inline content; otherwise it
|
|
5696
5833
|
// puts the bottom of the *second* row on the baseline.
|
|
5697
5834
|
|
|
5698
5835
|
var topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200B")]);
|
|
@@ -5719,7 +5856,7 @@ var makeGlue = function makeGlue(measurement, options) {
|
|
|
5719
5856
|
// Make an empty span for the space
|
|
5720
5857
|
var rule = makeSpan(["mspace"], [], options);
|
|
5721
5858
|
var size = calculateSize(measurement, options);
|
|
5722
|
-
rule.style.marginRight = size
|
|
5859
|
+
rule.style.marginRight = makeEm(size);
|
|
5723
5860
|
return rule;
|
|
5724
5861
|
}; // Takes font options, and returns the appropriate fontLookup name
|
|
5725
5862
|
|
|
@@ -5841,17 +5978,17 @@ var staticSvg = function staticSvg(value, options) {
|
|
|
5841
5978
|
height = _svgData$value[2];
|
|
5842
5979
|
var path = new PathNode(pathName);
|
|
5843
5980
|
var svgNode = new SvgNode([path], {
|
|
5844
|
-
"width": width
|
|
5845
|
-
"height": height
|
|
5981
|
+
"width": makeEm(width),
|
|
5982
|
+
"height": makeEm(height),
|
|
5846
5983
|
// Override CSS rule `.katex svg { width: 100% }`
|
|
5847
|
-
"style": "width:" + width
|
|
5984
|
+
"style": "width:" + makeEm(width),
|
|
5848
5985
|
"viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
|
|
5849
5986
|
"preserveAspectRatio": "xMinYMin"
|
|
5850
5987
|
});
|
|
5851
5988
|
var span = makeSvgSpan(["overlay"], [svgNode], options);
|
|
5852
5989
|
span.height = height;
|
|
5853
|
-
span.style.height = height
|
|
5854
|
-
span.style.width = width
|
|
5990
|
+
span.style.height = makeEm(height);
|
|
5991
|
+
span.style.width = makeEm(width);
|
|
5855
5992
|
return span;
|
|
5856
5993
|
};
|
|
5857
5994
|
|
|
@@ -6080,6 +6217,7 @@ var ordargument = function ordargument(arg) {
|
|
|
6080
6217
|
|
|
6081
6218
|
|
|
6082
6219
|
|
|
6220
|
+
|
|
6083
6221
|
var buildHTML_makeSpan = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`)
|
|
6084
6222
|
// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6,
|
|
6085
6223
|
// and the text before Rule 19.
|
|
@@ -6339,10 +6477,10 @@ function buildHTMLUnbreakable(children, options) {
|
|
|
6339
6477
|
// falls at the depth of the expression.
|
|
6340
6478
|
|
|
6341
6479
|
var strut = buildHTML_makeSpan(["strut"]);
|
|
6342
|
-
strut.style.height = body.height + body.depth
|
|
6480
|
+
strut.style.height = makeEm(body.height + body.depth);
|
|
6343
6481
|
|
|
6344
6482
|
if (body.depth) {
|
|
6345
|
-
strut.style.verticalAlign = -body.depth
|
|
6483
|
+
strut.style.verticalAlign = makeEm(-body.depth);
|
|
6346
6484
|
}
|
|
6347
6485
|
|
|
6348
6486
|
body.children.unshift(strut);
|
|
@@ -6438,10 +6576,10 @@ function buildHTML(tree, options) {
|
|
|
6438
6576
|
|
|
6439
6577
|
if (tagChild) {
|
|
6440
6578
|
var strut = tagChild.children[0];
|
|
6441
|
-
strut.style.height = htmlNode.height + htmlNode.depth
|
|
6579
|
+
strut.style.height = makeEm(htmlNode.height + htmlNode.depth);
|
|
6442
6580
|
|
|
6443
6581
|
if (htmlNode.depth) {
|
|
6444
|
-
strut.style.verticalAlign = -htmlNode.depth
|
|
6582
|
+
strut.style.verticalAlign = makeEm(-htmlNode.depth);
|
|
6445
6583
|
}
|
|
6446
6584
|
}
|
|
6447
6585
|
|
|
@@ -6460,6 +6598,7 @@ function buildHTML(tree, options) {
|
|
|
6460
6598
|
|
|
6461
6599
|
|
|
6462
6600
|
|
|
6601
|
+
|
|
6463
6602
|
function newDocumentFragment(children) {
|
|
6464
6603
|
return new DocumentFragment(children);
|
|
6465
6604
|
}
|
|
@@ -6654,7 +6793,7 @@ var SpaceNode = /*#__PURE__*/function () {
|
|
|
6654
6793
|
return document.createTextNode(this.character);
|
|
6655
6794
|
} else {
|
|
6656
6795
|
var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace");
|
|
6657
|
-
node.setAttribute("width", this.width
|
|
6796
|
+
node.setAttribute("width", makeEm(this.width));
|
|
6658
6797
|
return node;
|
|
6659
6798
|
}
|
|
6660
6799
|
}
|
|
@@ -6667,7 +6806,7 @@ var SpaceNode = /*#__PURE__*/function () {
|
|
|
6667
6806
|
if (this.character) {
|
|
6668
6807
|
return "<mtext>" + this.character + "</mtext>";
|
|
6669
6808
|
} else {
|
|
6670
|
-
return "<mspace width=\"" + this.width + "
|
|
6809
|
+
return "<mspace width=\"" + makeEm(this.width) + "\"/>";
|
|
6671
6810
|
}
|
|
6672
6811
|
}
|
|
6673
6812
|
/**
|
|
@@ -7016,6 +7155,7 @@ var buildHTMLTree = function buildHTMLTree(tree, expression, settings) {
|
|
|
7016
7155
|
|
|
7017
7156
|
|
|
7018
7157
|
|
|
7158
|
+
|
|
7019
7159
|
var stretchyCodePoint = {
|
|
7020
7160
|
widehat: "^",
|
|
7021
7161
|
widecheck: "ˇ",
|
|
@@ -7213,7 +7353,7 @@ var svgSpan = function svgSpan(group, options) {
|
|
|
7213
7353
|
var path = new PathNode(pathName);
|
|
7214
7354
|
var svgNode = new SvgNode([path], {
|
|
7215
7355
|
"width": "100%",
|
|
7216
|
-
"height": _height
|
|
7356
|
+
"height": makeEm(_height),
|
|
7217
7357
|
"viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight,
|
|
7218
7358
|
"preserveAspectRatio": "none"
|
|
7219
7359
|
});
|
|
@@ -7255,7 +7395,7 @@ var svgSpan = function svgSpan(group, options) {
|
|
|
7255
7395
|
|
|
7256
7396
|
var _svgNode = new SvgNode([_path], {
|
|
7257
7397
|
"width": "400em",
|
|
7258
|
-
"height": _height2
|
|
7398
|
+
"height": makeEm(_height2),
|
|
7259
7399
|
"viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight,
|
|
7260
7400
|
"preserveAspectRatio": aligns[i] + " slice"
|
|
7261
7401
|
});
|
|
@@ -7269,7 +7409,7 @@ var svgSpan = function svgSpan(group, options) {
|
|
|
7269
7409
|
height: _height2
|
|
7270
7410
|
};
|
|
7271
7411
|
} else {
|
|
7272
|
-
_span.style.height = _height2
|
|
7412
|
+
_span.style.height = makeEm(_height2);
|
|
7273
7413
|
spans.push(_span);
|
|
7274
7414
|
}
|
|
7275
7415
|
}
|
|
@@ -7291,10 +7431,10 @@ var svgSpan = function svgSpan(group, options) {
|
|
|
7291
7431
|
|
|
7292
7432
|
|
|
7293
7433
|
span.height = height;
|
|
7294
|
-
span.style.height = height
|
|
7434
|
+
span.style.height = makeEm(height);
|
|
7295
7435
|
|
|
7296
7436
|
if (minWidth > 0) {
|
|
7297
|
-
span.style.minWidth = minWidth
|
|
7437
|
+
span.style.minWidth = makeEm(minWidth);
|
|
7298
7438
|
}
|
|
7299
7439
|
|
|
7300
7440
|
return span;
|
|
@@ -7343,13 +7483,13 @@ var encloseSpan = function encloseSpan(inner, label, topPad, bottomPad, options)
|
|
|
7343
7483
|
|
|
7344
7484
|
var svgNode = new SvgNode(lines, {
|
|
7345
7485
|
"width": "100%",
|
|
7346
|
-
"height": totalHeight
|
|
7486
|
+
"height": makeEm(totalHeight)
|
|
7347
7487
|
});
|
|
7348
7488
|
img = buildCommon.makeSvgSpan([], [svgNode], options);
|
|
7349
7489
|
}
|
|
7350
7490
|
|
|
7351
7491
|
img.height = totalHeight;
|
|
7352
|
-
img.style.height = totalHeight
|
|
7492
|
+
img.style.height = makeEm(totalHeight);
|
|
7353
7493
|
return img;
|
|
7354
7494
|
};
|
|
7355
7495
|
|
|
@@ -7410,6 +7550,7 @@ function checkSymbolNodeType(node) {
|
|
|
7410
7550
|
|
|
7411
7551
|
|
|
7412
7552
|
|
|
7553
|
+
|
|
7413
7554
|
// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but
|
|
7414
7555
|
// also "supsub" since an accent can affect super/subscripting.
|
|
7415
7556
|
var htmlBuilder = function htmlBuilder(grp, options) {
|
|
@@ -7521,7 +7662,7 @@ var htmlBuilder = function htmlBuilder(grp, options) {
|
|
|
7521
7662
|
left -= width / 2;
|
|
7522
7663
|
}
|
|
7523
7664
|
|
|
7524
|
-
accentBody.style.left = left
|
|
7665
|
+
accentBody.style.left = makeEm(left); // \textcircled uses the \bigcirc glyph, so it needs some
|
|
7525
7666
|
// vertical adjustment to match LaTeX.
|
|
7526
7667
|
|
|
7527
7668
|
if (group.label === "\\textcircled") {
|
|
@@ -7553,8 +7694,8 @@ var htmlBuilder = function htmlBuilder(grp, options) {
|
|
|
7553
7694
|
elem: accentBody,
|
|
7554
7695
|
wrapperClasses: ["svg-align"],
|
|
7555
7696
|
wrapperStyle: skew > 0 ? {
|
|
7556
|
-
width: "calc(100% - " + 2 * skew + "
|
|
7557
|
-
marginLeft: 2 * skew
|
|
7697
|
+
width: "calc(100% - " + makeEm(2 * skew) + ")",
|
|
7698
|
+
marginLeft: makeEm(2 * skew)
|
|
7558
7699
|
} : undefined
|
|
7559
7700
|
}]
|
|
7560
7701
|
}, options);
|
|
@@ -7843,6 +7984,7 @@ defineFunction({
|
|
|
7843
7984
|
|
|
7844
7985
|
|
|
7845
7986
|
|
|
7987
|
+
|
|
7846
7988
|
var cdArrowFunctionName = {
|
|
7847
7989
|
">": "\\\\cdrightarrow",
|
|
7848
7990
|
"<": "\\\\cdleftarrow",
|
|
@@ -8105,7 +8247,7 @@ defineFunction({
|
|
|
8105
8247
|
var newOptions = options.havingStyle(options.style.sup());
|
|
8106
8248
|
var label = buildCommon.wrapFragment(buildGroup(group.label, newOptions, options), options);
|
|
8107
8249
|
label.classes.push("cd-label-" + group.side);
|
|
8108
|
-
label.style.bottom = 0.8 - label.depth
|
|
8250
|
+
label.style.bottom = makeEm(0.8 - label.depth); // Zero out label height & depth, so vertical align of arrow is set
|
|
8109
8251
|
// by the arrow height, not by the label.
|
|
8110
8252
|
|
|
8111
8253
|
label.height = 0;
|
|
@@ -8316,7 +8458,7 @@ defineFunction({
|
|
|
8316
8458
|
span.classes.push("newline");
|
|
8317
8459
|
|
|
8318
8460
|
if (group.size) {
|
|
8319
|
-
span.style.marginTop = calculateSize(group.size, options)
|
|
8461
|
+
span.style.marginTop = makeEm(calculateSize(group.size, options));
|
|
8320
8462
|
}
|
|
8321
8463
|
}
|
|
8322
8464
|
|
|
@@ -8329,7 +8471,7 @@ defineFunction({
|
|
|
8329
8471
|
node.setAttribute("linebreak", "newline");
|
|
8330
8472
|
|
|
8331
8473
|
if (group.size) {
|
|
8332
|
-
node.setAttribute("height", calculateSize(group.size, options)
|
|
8474
|
+
node.setAttribute("height", makeEm(calculateSize(group.size, options)));
|
|
8333
8475
|
}
|
|
8334
8476
|
}
|
|
8335
8477
|
|
|
@@ -8595,6 +8737,7 @@ defineFunction({
|
|
|
8595
8737
|
|
|
8596
8738
|
|
|
8597
8739
|
|
|
8740
|
+
|
|
8598
8741
|
/**
|
|
8599
8742
|
* Get the metrics for a given symbol and font, after transformation (i.e.
|
|
8600
8743
|
* after following replacement from symbols.js)
|
|
@@ -8629,7 +8772,7 @@ var centerSpan = function centerSpan(span, options, style) {
|
|
|
8629
8772
|
var newOptions = options.havingBaseStyle(style);
|
|
8630
8773
|
var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight;
|
|
8631
8774
|
span.classes.push("delimcenter");
|
|
8632
|
-
span.style.top = shift
|
|
8775
|
+
span.style.top = makeEm(shift);
|
|
8633
8776
|
span.height -= shift;
|
|
8634
8777
|
span.depth += shift;
|
|
8635
8778
|
};
|
|
@@ -8702,20 +8845,20 @@ var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) {
|
|
|
8702
8845
|
|
|
8703
8846
|
var makeInner = function makeInner(ch, height, options) {
|
|
8704
8847
|
// Create a span with inline SVG for the inner part of a tall stacked delimiter.
|
|
8705
|
-
var width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4]
|
|
8848
|
+
var width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4] : fontMetricsData["Size1-Regular"][ch.charCodeAt(0)][4];
|
|
8706
8849
|
var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height)));
|
|
8707
8850
|
var svgNode = new SvgNode([path], {
|
|
8708
|
-
"width": width
|
|
8709
|
-
"height": height
|
|
8851
|
+
"width": makeEm(width),
|
|
8852
|
+
"height": makeEm(height),
|
|
8710
8853
|
// Override CSS rule `.katex svg { width: 100% }`
|
|
8711
|
-
"style": "width:" + width
|
|
8854
|
+
"style": "width:" + makeEm(width),
|
|
8712
8855
|
"viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height),
|
|
8713
8856
|
"preserveAspectRatio": "xMinYMin"
|
|
8714
8857
|
});
|
|
8715
8858
|
var span = buildCommon.makeSvgSpan([], [svgNode], options);
|
|
8716
8859
|
span.height = height;
|
|
8717
|
-
span.style.height = height
|
|
8718
|
-
span.style.width = width
|
|
8860
|
+
span.style.height = makeEm(height);
|
|
8861
|
+
span.style.width = makeEm(width);
|
|
8719
8862
|
return {
|
|
8720
8863
|
type: "elem",
|
|
8721
8864
|
elem: span
|
|
@@ -8924,7 +9067,7 @@ var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum,
|
|
|
8924
9067
|
var svg = new SvgNode([pathNode], {
|
|
8925
9068
|
// Note: 1000:1 ratio of viewBox to document em width.
|
|
8926
9069
|
"width": "400em",
|
|
8927
|
-
"height": height
|
|
9070
|
+
"height": makeEm(height),
|
|
8928
9071
|
"viewBox": "0 0 400000 " + viewBoxHeight,
|
|
8929
9072
|
"preserveAspectRatio": "xMinYMin slice"
|
|
8930
9073
|
});
|
|
@@ -8993,7 +9136,7 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
|
|
|
8993
9136
|
}
|
|
8994
9137
|
|
|
8995
9138
|
span.height = texHeight;
|
|
8996
|
-
span.style.height = spanHeight
|
|
9139
|
+
span.style.height = makeEm(spanHeight);
|
|
8997
9140
|
return {
|
|
8998
9141
|
span: span,
|
|
8999
9142
|
advanceWidth: advanceWidth,
|
|
@@ -9249,6 +9392,7 @@ var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, optio
|
|
|
9249
9392
|
|
|
9250
9393
|
|
|
9251
9394
|
|
|
9395
|
+
|
|
9252
9396
|
// Extra data needed for the delimiter handler down below
|
|
9253
9397
|
var delimiterSizes = {
|
|
9254
9398
|
"\\bigl": {
|
|
@@ -9378,8 +9522,9 @@ defineFunction({
|
|
|
9378
9522
|
}
|
|
9379
9523
|
|
|
9380
9524
|
node.setAttribute("stretchy", "true");
|
|
9381
|
-
|
|
9382
|
-
node.setAttribute("
|
|
9525
|
+
var size = makeEm(delimiter.sizeToMaxHeight[group.size]);
|
|
9526
|
+
node.setAttribute("minsize", size);
|
|
9527
|
+
node.setAttribute("maxsize", size);
|
|
9383
9528
|
return node;
|
|
9384
9529
|
}
|
|
9385
9530
|
});
|
|
@@ -9638,19 +9783,19 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
9638
9783
|
scale = scale / newOptions.sizeMultiplier;
|
|
9639
9784
|
var angleHeight = inner.height + inner.depth + lineWeight + clearance; // Reserve a left pad for the angle.
|
|
9640
9785
|
|
|
9641
|
-
inner.style.paddingLeft = angleHeight / 2 + lineWeight
|
|
9786
|
+
inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); // Create an SVG
|
|
9642
9787
|
|
|
9643
9788
|
var viewBoxHeight = Math.floor(1000 * angleHeight * scale);
|
|
9644
9789
|
var path = phasePath(viewBoxHeight);
|
|
9645
9790
|
var svgNode = new SvgNode([new PathNode("phase", path)], {
|
|
9646
9791
|
"width": "400em",
|
|
9647
|
-
"height": viewBoxHeight / 1000
|
|
9792
|
+
"height": makeEm(viewBoxHeight / 1000),
|
|
9648
9793
|
"viewBox": "0 0 400000 " + viewBoxHeight,
|
|
9649
9794
|
"preserveAspectRatio": "xMinYMin slice"
|
|
9650
9795
|
}); // Wrap it in a span with overflow: hidden.
|
|
9651
9796
|
|
|
9652
9797
|
img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options);
|
|
9653
|
-
img.style.height = angleHeight
|
|
9798
|
+
img.style.height = makeEm(angleHeight);
|
|
9654
9799
|
imgShift = inner.depth + lineWeight + clearance;
|
|
9655
9800
|
} else {
|
|
9656
9801
|
// Add horizontal padding
|
|
@@ -9689,10 +9834,10 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
9689
9834
|
|
|
9690
9835
|
if (/fbox|boxed|fcolorbox/.test(label)) {
|
|
9691
9836
|
img.style.borderStyle = "solid";
|
|
9692
|
-
img.style.borderWidth = ruleThickness
|
|
9837
|
+
img.style.borderWidth = makeEm(ruleThickness);
|
|
9693
9838
|
} else if (label === "angl" && ruleThickness !== 0.049) {
|
|
9694
|
-
img.style.borderTopWidth = ruleThickness
|
|
9695
|
-
img.style.borderRightWidth = ruleThickness
|
|
9839
|
+
img.style.borderTopWidth = makeEm(ruleThickness);
|
|
9840
|
+
img.style.borderRightWidth = makeEm(ruleThickness);
|
|
9696
9841
|
}
|
|
9697
9842
|
|
|
9698
9843
|
imgShift = inner.depth + bottomPad;
|
|
@@ -10309,22 +10454,22 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
10309
10454
|
// between them.
|
|
10310
10455
|
if (!firstSeparator) {
|
|
10311
10456
|
colSep = buildCommon.makeSpan(["arraycolsep"], []);
|
|
10312
|
-
colSep.style.width = options.fontMetrics().doubleRuleSep
|
|
10457
|
+
colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep);
|
|
10313
10458
|
cols.push(colSep);
|
|
10314
10459
|
}
|
|
10315
10460
|
|
|
10316
10461
|
if (colDescr.separator === "|" || colDescr.separator === ":") {
|
|
10317
10462
|
var lineType = colDescr.separator === "|" ? "solid" : "dashed";
|
|
10318
10463
|
var separator = buildCommon.makeSpan(["vertical-separator"], [], options);
|
|
10319
|
-
separator.style.height = totalHeight
|
|
10320
|
-
separator.style.borderRightWidth = ruleThickness
|
|
10464
|
+
separator.style.height = makeEm(totalHeight);
|
|
10465
|
+
separator.style.borderRightWidth = makeEm(ruleThickness);
|
|
10321
10466
|
separator.style.borderRightStyle = lineType;
|
|
10322
|
-
separator.style.margin = "0
|
|
10467
|
+
separator.style.margin = "0 " + makeEm(-ruleThickness / 2);
|
|
10323
10468
|
|
|
10324
10469
|
var _shift = totalHeight - offset;
|
|
10325
10470
|
|
|
10326
10471
|
if (_shift) {
|
|
10327
|
-
separator.style.verticalAlign = -_shift
|
|
10472
|
+
separator.style.verticalAlign = makeEm(-_shift);
|
|
10328
10473
|
}
|
|
10329
10474
|
|
|
10330
10475
|
cols.push(separator);
|
|
@@ -10348,7 +10493,7 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
10348
10493
|
|
|
10349
10494
|
if (sepwidth !== 0) {
|
|
10350
10495
|
colSep = buildCommon.makeSpan(["arraycolsep"], []);
|
|
10351
|
-
colSep.style.width = sepwidth
|
|
10496
|
+
colSep.style.width = makeEm(sepwidth);
|
|
10352
10497
|
cols.push(colSep);
|
|
10353
10498
|
}
|
|
10354
10499
|
}
|
|
@@ -10386,7 +10531,7 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
10386
10531
|
|
|
10387
10532
|
if (sepwidth !== 0) {
|
|
10388
10533
|
colSep = buildCommon.makeSpan(["arraycolsep"], []);
|
|
10389
|
-
colSep.style.width = sepwidth
|
|
10534
|
+
colSep.style.width = makeEm(sepwidth);
|
|
10390
10535
|
cols.push(colSep);
|
|
10391
10536
|
}
|
|
10392
10537
|
}
|
|
@@ -10486,7 +10631,7 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) {
|
|
|
10486
10631
|
|
|
10487
10632
|
var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray}
|
|
10488
10633
|
: 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
|
|
10489
|
-
table.setAttribute("rowspacing", gap
|
|
10634
|
+
table.setAttribute("rowspacing", makeEm(gap)); // MathML table lines go only between cells.
|
|
10490
10635
|
// To place a line on an edge we'll use <menclose>, if necessary.
|
|
10491
10636
|
|
|
10492
10637
|
var menclose = "";
|
|
@@ -11563,7 +11708,7 @@ var genfrac_mathmlBuilder = function mathmlBuilder(group, options) {
|
|
|
11563
11708
|
node.setAttribute("linethickness", "0px");
|
|
11564
11709
|
} else if (group.barSize) {
|
|
11565
11710
|
var ruleWidth = calculateSize(group.barSize, options);
|
|
11566
|
-
node.setAttribute("linethickness", ruleWidth
|
|
11711
|
+
node.setAttribute("linethickness", makeEm(ruleWidth));
|
|
11567
11712
|
}
|
|
11568
11713
|
|
|
11569
11714
|
var style = adjustStyle(group.size, options.style);
|
|
@@ -12424,7 +12569,6 @@ defineFunction({
|
|
|
12424
12569
|
|
|
12425
12570
|
if (group.totalheight.number > 0) {
|
|
12426
12571
|
depth = calculateSize(group.totalheight, options) - height;
|
|
12427
|
-
depth = Number(depth.toFixed(2));
|
|
12428
12572
|
}
|
|
12429
12573
|
|
|
12430
12574
|
var width = 0;
|
|
@@ -12434,15 +12578,15 @@ defineFunction({
|
|
|
12434
12578
|
}
|
|
12435
12579
|
|
|
12436
12580
|
var style = {
|
|
12437
|
-
height: height + depth
|
|
12581
|
+
height: makeEm(height + depth)
|
|
12438
12582
|
};
|
|
12439
12583
|
|
|
12440
12584
|
if (width > 0) {
|
|
12441
|
-
style.width = width
|
|
12585
|
+
style.width = makeEm(width);
|
|
12442
12586
|
}
|
|
12443
12587
|
|
|
12444
12588
|
if (depth > 0) {
|
|
12445
|
-
style.verticalAlign = -depth
|
|
12589
|
+
style.verticalAlign = makeEm(-depth);
|
|
12446
12590
|
}
|
|
12447
12591
|
|
|
12448
12592
|
var node = new Img(group.src, group.alt, style);
|
|
@@ -12458,15 +12602,14 @@ defineFunction({
|
|
|
12458
12602
|
|
|
12459
12603
|
if (group.totalheight.number > 0) {
|
|
12460
12604
|
depth = calculateSize(group.totalheight, options) - height;
|
|
12461
|
-
|
|
12462
|
-
node.setAttribute("valign", "-" + depth + "em");
|
|
12605
|
+
node.setAttribute("valign", makeEm(-depth));
|
|
12463
12606
|
}
|
|
12464
12607
|
|
|
12465
|
-
node.setAttribute("height", height + depth
|
|
12608
|
+
node.setAttribute("height", makeEm(height + depth));
|
|
12466
12609
|
|
|
12467
12610
|
if (group.width.number > 0) {
|
|
12468
12611
|
var width = calculateSize(group.width, options);
|
|
12469
|
-
node.setAttribute("width", width
|
|
12612
|
+
node.setAttribute("width", makeEm(width));
|
|
12470
12613
|
}
|
|
12471
12614
|
|
|
12472
12615
|
node.setAttribute("src", group.src);
|
|
@@ -12537,6 +12680,7 @@ defineFunction({
|
|
|
12537
12680
|
|
|
12538
12681
|
|
|
12539
12682
|
|
|
12683
|
+
|
|
12540
12684
|
defineFunction({
|
|
12541
12685
|
type: "lap",
|
|
12542
12686
|
names: ["\\mathllap", "\\mathrlap", "\\mathclap"],
|
|
@@ -12576,10 +12720,10 @@ defineFunction({
|
|
|
12576
12720
|
// This code resolved issue #1153
|
|
12577
12721
|
|
|
12578
12722
|
var strut = buildCommon.makeSpan(["strut"]);
|
|
12579
|
-
strut.style.height = node.height + node.depth
|
|
12723
|
+
strut.style.height = makeEm(node.height + node.depth);
|
|
12580
12724
|
|
|
12581
12725
|
if (node.depth) {
|
|
12582
|
-
strut.style.verticalAlign = -node.depth
|
|
12726
|
+
strut.style.verticalAlign = makeEm(-node.depth);
|
|
12583
12727
|
}
|
|
12584
12728
|
|
|
12585
12729
|
node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall.
|
|
@@ -12702,7 +12846,8 @@ defineFunction({
|
|
|
12702
12846
|
|
|
12703
12847
|
|
|
12704
12848
|
|
|
12705
|
-
// For an operator with limits, assemble the base, sup, and sub into a span.
|
|
12849
|
+
// For an operator with limits, assemble the base, sup, and sub into a span.
|
|
12850
|
+
|
|
12706
12851
|
var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift) {
|
|
12707
12852
|
base = buildCommon.makeSpan([], [base]);
|
|
12708
12853
|
var subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup);
|
|
@@ -12742,7 +12887,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12742
12887
|
}, {
|
|
12743
12888
|
type: "elem",
|
|
12744
12889
|
elem: sub.elem,
|
|
12745
|
-
marginLeft: -slant
|
|
12890
|
+
marginLeft: makeEm(-slant)
|
|
12746
12891
|
}, {
|
|
12747
12892
|
type: "kern",
|
|
12748
12893
|
size: sub.kern
|
|
@@ -12755,7 +12900,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12755
12900
|
}, {
|
|
12756
12901
|
type: "elem",
|
|
12757
12902
|
elem: sup.elem,
|
|
12758
|
-
marginLeft: slant
|
|
12903
|
+
marginLeft: makeEm(slant)
|
|
12759
12904
|
}, {
|
|
12760
12905
|
type: "kern",
|
|
12761
12906
|
size: options.fontMetrics().bigOpSpacing5
|
|
@@ -12776,7 +12921,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12776
12921
|
}, {
|
|
12777
12922
|
type: "elem",
|
|
12778
12923
|
elem: sub.elem,
|
|
12779
|
-
marginLeft: -slant
|
|
12924
|
+
marginLeft: makeEm(-slant)
|
|
12780
12925
|
}, {
|
|
12781
12926
|
type: "kern",
|
|
12782
12927
|
size: sub.kern
|
|
@@ -12800,7 +12945,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12800
12945
|
}, {
|
|
12801
12946
|
type: "elem",
|
|
12802
12947
|
elem: sup.elem,
|
|
12803
|
-
marginLeft: slant
|
|
12948
|
+
marginLeft: makeEm(slant)
|
|
12804
12949
|
}, {
|
|
12805
12950
|
type: "kern",
|
|
12806
12951
|
size: options.fontMetrics().bigOpSpacing5
|
|
@@ -12819,7 +12964,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12819
12964
|
// A negative margin-left was applied to the lower limit.
|
|
12820
12965
|
// Avoid an overlap by placing a spacer on the left on the group.
|
|
12821
12966
|
var spacer = buildCommon.makeSpan(["mspace"], [], options);
|
|
12822
|
-
spacer.style.marginRight = slant
|
|
12967
|
+
spacer.style.marginRight = makeEm(slant);
|
|
12823
12968
|
parts.unshift(spacer);
|
|
12824
12969
|
}
|
|
12825
12970
|
|
|
@@ -12837,6 +12982,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12837
12982
|
|
|
12838
12983
|
|
|
12839
12984
|
|
|
12985
|
+
|
|
12840
12986
|
// Most operators have a large successor symbol, but these don't.
|
|
12841
12987
|
var noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also
|
|
12842
12988
|
// "supsub" since some of them (like \int) can affect super/subscripting.
|
|
@@ -12950,7 +13096,7 @@ var op_htmlBuilder = function htmlBuilder(grp, options) {
|
|
|
12950
13096
|
} else {
|
|
12951
13097
|
if (baseShift) {
|
|
12952
13098
|
base.style.position = "relative";
|
|
12953
|
-
base.style.top = baseShift
|
|
13099
|
+
base.style.top = makeEm(baseShift);
|
|
12954
13100
|
}
|
|
12955
13101
|
|
|
12956
13102
|
return base;
|
|
@@ -13575,9 +13721,9 @@ defineFunction({
|
|
|
13575
13721
|
var height = calculateSize(group.height, options);
|
|
13576
13722
|
var shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size
|
|
13577
13723
|
|
|
13578
|
-
rule.style.borderRightWidth = width
|
|
13579
|
-
rule.style.borderTopWidth = height
|
|
13580
|
-
rule.style.bottom = shift
|
|
13724
|
+
rule.style.borderRightWidth = makeEm(width);
|
|
13725
|
+
rule.style.borderTopWidth = makeEm(height);
|
|
13726
|
+
rule.style.bottom = makeEm(shift); // Record the height and width
|
|
13581
13727
|
|
|
13582
13728
|
rule.width = width;
|
|
13583
13729
|
rule.height = height + shift;
|
|
@@ -13595,18 +13741,18 @@ defineFunction({
|
|
|
13595
13741
|
var color = options.color && options.getColor() || "black";
|
|
13596
13742
|
var rule = new mathMLTree.MathNode("mspace");
|
|
13597
13743
|
rule.setAttribute("mathbackground", color);
|
|
13598
|
-
rule.setAttribute("width", width
|
|
13599
|
-
rule.setAttribute("height", height
|
|
13744
|
+
rule.setAttribute("width", makeEm(width));
|
|
13745
|
+
rule.setAttribute("height", makeEm(height));
|
|
13600
13746
|
var wrapper = new mathMLTree.MathNode("mpadded", [rule]);
|
|
13601
13747
|
|
|
13602
13748
|
if (shift >= 0) {
|
|
13603
|
-
wrapper.setAttribute("height",
|
|
13749
|
+
wrapper.setAttribute("height", makeEm(shift));
|
|
13604
13750
|
} else {
|
|
13605
|
-
wrapper.setAttribute("height", shift
|
|
13606
|
-
wrapper.setAttribute("depth",
|
|
13751
|
+
wrapper.setAttribute("height", makeEm(shift));
|
|
13752
|
+
wrapper.setAttribute("depth", makeEm(-shift));
|
|
13607
13753
|
}
|
|
13608
13754
|
|
|
13609
|
-
wrapper.setAttribute("voffset", shift
|
|
13755
|
+
wrapper.setAttribute("voffset", makeEm(shift));
|
|
13610
13756
|
return wrapper;
|
|
13611
13757
|
}
|
|
13612
13758
|
});
|
|
@@ -13616,6 +13762,7 @@ defineFunction({
|
|
|
13616
13762
|
|
|
13617
13763
|
|
|
13618
13764
|
|
|
13765
|
+
|
|
13619
13766
|
function sizingGroup(value, options, baseOptions) {
|
|
13620
13767
|
var inner = buildExpression(value, options, false);
|
|
13621
13768
|
var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize
|
|
@@ -13677,7 +13824,7 @@ defineFunction({
|
|
|
13677
13824
|
// that we're passing an options parameter we should be able to fix
|
|
13678
13825
|
// this.
|
|
13679
13826
|
|
|
13680
|
-
node.setAttribute("mathsize", newOptions.sizeMultiplier
|
|
13827
|
+
node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier));
|
|
13681
13828
|
return node;
|
|
13682
13829
|
}
|
|
13683
13830
|
});
|
|
@@ -13801,6 +13948,7 @@ defineFunction({
|
|
|
13801
13948
|
|
|
13802
13949
|
|
|
13803
13950
|
|
|
13951
|
+
|
|
13804
13952
|
defineFunction({
|
|
13805
13953
|
type: "sqrt",
|
|
13806
13954
|
names: ["\\sqrt"],
|
|
@@ -13859,7 +14007,7 @@ defineFunction({
|
|
|
13859
14007
|
|
|
13860
14008
|
|
|
13861
14009
|
var imgShift = img.height - inner.height - lineClearance - ruleWidth;
|
|
13862
|
-
inner.style.paddingLeft = advanceWidth
|
|
14010
|
+
inner.style.paddingLeft = makeEm(advanceWidth); // Overlay the image and the argument.
|
|
13863
14011
|
|
|
13864
14012
|
var body = buildCommon.makeVList({
|
|
13865
14013
|
positionType: "firstBaseline",
|
|
@@ -13987,6 +14135,7 @@ defineFunction({
|
|
|
13987
14135
|
|
|
13988
14136
|
|
|
13989
14137
|
|
|
14138
|
+
|
|
13990
14139
|
/**
|
|
13991
14140
|
* Sometimes, groups perform special rules when they have superscripts or
|
|
13992
14141
|
* subscripts attached to them. This function lets the `supsub` group know that
|
|
@@ -14078,7 +14227,7 @@ defineFunctionBuilders({
|
|
|
14078
14227
|
|
|
14079
14228
|
|
|
14080
14229
|
var multiplier = options.sizeMultiplier;
|
|
14081
|
-
var marginRight = 0.5 / metrics.ptPerEm / multiplier
|
|
14230
|
+
var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier);
|
|
14082
14231
|
var marginLeft = null;
|
|
14083
14232
|
|
|
14084
14233
|
if (subm) {
|
|
@@ -14089,7 +14238,7 @@ defineFunctionBuilders({
|
|
|
14089
14238
|
|
|
14090
14239
|
if (base instanceof SymbolNode || isOiint) {
|
|
14091
14240
|
// $FlowFixMe
|
|
14092
|
-
marginLeft = -base.italic
|
|
14241
|
+
marginLeft = makeEm(-base.italic);
|
|
14093
14242
|
}
|
|
14094
14243
|
}
|
|
14095
14244
|
|
|
@@ -15056,6 +15205,7 @@ var macros = _macros;
|
|
|
15056
15205
|
|
|
15057
15206
|
|
|
15058
15207
|
|
|
15208
|
+
|
|
15059
15209
|
//////////////////////////////////////////////////////////////////////
|
|
15060
15210
|
// macro tools
|
|
15061
15211
|
|
|
@@ -15677,7 +15827,7 @@ defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5e
|
|
|
15677
15827
|
// We compute the corresponding \raisebox when A is rendered in \normalsize
|
|
15678
15828
|
// \scriptstyle, which has a scale factor of 0.7 (see Options.js).
|
|
15679
15829
|
|
|
15680
|
-
var latexRaiseA = fontMetricsData["Main-Regular"]["T".charCodeAt(0)][1] - 0.7 * fontMetricsData["Main-Regular"]["A".charCodeAt(0)][1]
|
|
15830
|
+
var latexRaiseA = makeEm(fontMetricsData["Main-Regular"]["T".charCodeAt(0)][1] - 0.7 * fontMetricsData["Main-Regular"]["A".charCodeAt(0)][1]);
|
|
15681
15831
|
defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo
|
|
15682
15832
|
|
|
15683
15833
|
defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
|
|
@@ -18102,7 +18252,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
|
|
|
18102
18252
|
/**
|
|
18103
18253
|
* Current KaTeX version
|
|
18104
18254
|
*/
|
|
18105
|
-
version: "0.
|
|
18255
|
+
version: "0.14.1",
|
|
18106
18256
|
|
|
18107
18257
|
/**
|
|
18108
18258
|
* Renders the given LaTeX into an HTML+MathML combination, and adds
|
|
@@ -18121,6 +18271,11 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
|
|
|
18121
18271
|
*/
|
|
18122
18272
|
ParseError: src_ParseError,
|
|
18123
18273
|
|
|
18274
|
+
/**
|
|
18275
|
+
* The shema of Settings
|
|
18276
|
+
*/
|
|
18277
|
+
SETTINGS_SCHEMA: SETTINGS_SCHEMA,
|
|
18278
|
+
|
|
18124
18279
|
/**
|
|
18125
18280
|
* Parses the given LaTeX into KaTeX's internal parse tree structure,
|
|
18126
18281
|
* without rendering to HTML or MathML.
|