katex 0.13.23 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
- this.displayMode = utils.deflt(options.displayMode, false);
262
- this.output = utils.deflt(options.output, "htmlAndMathml");
263
- this.leqno = utils.deflt(options.leqno, false);
264
- this.fleqn = utils.deflt(options.fleqn, false);
265
- this.throwOnError = utils.deflt(options.throwOnError, true);
266
- this.errorColor = utils.deflt(options.errorColor, "#cc0000");
267
- this.macros = options.macros || {};
268
- this.minRuleThickness = Math.max(0, utils.deflt(options.minRuleThickness, 0));
269
- this.colorIsTextColor = utils.deflt(options.colorIsTextColor, false);
270
- this.strict = utils.deflt(options.strict, "warn");
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 = ({
@@ -3509,289 +3083,1279 @@ function assertSpan(group) {
3509
3083
  "8242": [0, 0.61111, 0, 0, 0.525],
3510
3084
  "9251": [0.11111, 0.21944, 0, 0, 0.525]
3511
3085
  }
3512
- });
3513
- ;// 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
+ };
3514
4015
 
4016
+ _proto2.toMarkup = function toMarkup() {
4017
+ return _toMarkup.call(this, "a");
4018
+ };
3515
4019
 
4020
+ return Anchor;
4021
+ }();
3516
4022
  /**
3517
- * This file contains metrics regarding fonts and individual symbols. The sigma
3518
- * and xi variables, as well as the metricMap map contain data extracted from
3519
- * TeX, TeX font metrics, and the TTF files. These data are then exposed via the
3520
- * `metrics` variable and the getCharacterMetrics function.
4023
+ * This node represents an image embed (<img>) element.
3521
4024
  */
3522
- // In TeX, there are actually three sets of dimensions, one for each of
3523
- // textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
3524
- // 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
3525
- // provided in the the arrays below, in that order.
3526
- //
3527
- // The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
3528
- // This was determined by running the following script:
3529
- //
3530
- // latex -interaction=nonstopmode \
3531
- // '\documentclass{article}\usepackage{amsmath}\begin{document}' \
3532
- // '$a$ \expandafter\show\the\textfont2' \
3533
- // '\expandafter\show\the\scriptfont2' \
3534
- // '\expandafter\show\the\scriptscriptfont2' \
3535
- // '\stop'
3536
- //
3537
- // The metrics themselves were retreived using the following commands:
3538
- //
3539
- // tftopl cmsy10
3540
- // tftopl cmsy7
3541
- // tftopl cmsy5
3542
- //
3543
- // The output of each of these commands is quite lengthy. The only part we
3544
- // care about is the FONTDIMEN section. Each value is measured in EMs.
3545
- var sigmasAndXis = {
3546
- slant: [0.250, 0.250, 0.250],
3547
- // sigma1
3548
- space: [0.000, 0.000, 0.000],
3549
- // sigma2
3550
- stretch: [0.000, 0.000, 0.000],
3551
- // sigma3
3552
- shrink: [0.000, 0.000, 0.000],
3553
- // sigma4
3554
- xHeight: [0.431, 0.431, 0.431],
3555
- // sigma5
3556
- quad: [1.000, 1.171, 1.472],
3557
- // sigma6
3558
- extraSpace: [0.000, 0.000, 0.000],
3559
- // sigma7
3560
- num1: [0.677, 0.732, 0.925],
3561
- // sigma8
3562
- num2: [0.394, 0.384, 0.387],
3563
- // sigma9
3564
- num3: [0.444, 0.471, 0.504],
3565
- // sigma10
3566
- denom1: [0.686, 0.752, 1.025],
3567
- // sigma11
3568
- denom2: [0.345, 0.344, 0.532],
3569
- // sigma12
3570
- sup1: [0.413, 0.503, 0.504],
3571
- // sigma13
3572
- sup2: [0.363, 0.431, 0.404],
3573
- // sigma14
3574
- sup3: [0.289, 0.286, 0.294],
3575
- // sigma15
3576
- sub1: [0.150, 0.143, 0.200],
3577
- // sigma16
3578
- sub2: [0.247, 0.286, 0.400],
3579
- // sigma17
3580
- supDrop: [0.386, 0.353, 0.494],
3581
- // sigma18
3582
- subDrop: [0.050, 0.071, 0.100],
3583
- // sigma19
3584
- delim1: [2.390, 1.700, 1.980],
3585
- // sigma20
3586
- delim2: [1.010, 1.157, 1.420],
3587
- // sigma21
3588
- axisHeight: [0.250, 0.250, 0.250],
3589
- // sigma22
3590
- // These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
3591
- // they correspond to the font parameters of the extension fonts (family 3).
3592
- // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
3593
- // match cmex7, we'd use cmex7.tfm values for script and scriptscript
3594
- // values.
3595
- defaultRuleThickness: [0.04, 0.049, 0.049],
3596
- // xi8; cmex7: 0.049
3597
- bigOpSpacing1: [0.111, 0.111, 0.111],
3598
- // xi9
3599
- bigOpSpacing2: [0.166, 0.166, 0.166],
3600
- // xi10
3601
- bigOpSpacing3: [0.2, 0.2, 0.2],
3602
- // xi11
3603
- bigOpSpacing4: [0.6, 0.611, 0.611],
3604
- // xi12; cmex7: 0.611
3605
- bigOpSpacing5: [0.1, 0.143, 0.143],
3606
- // xi13; cmex7: 0.143
3607
- // The \sqrt rule width is taken from the height of the surd character.
3608
- // Since we use the same font at all sizes, this thickness doesn't scale.
3609
- sqrtRuleThickness: [0.04, 0.04, 0.04],
3610
- // This value determines how large a pt is, for metrics which are defined
3611
- // in terms of pts.
3612
- // This value is also used in katex.less; if you change it make sure the
3613
- // values match.
3614
- ptPerEm: [10.0, 10.0, 10.0],
3615
- // The space between adjacent `|` columns in an array definition. From
3616
- // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
3617
- doubleRuleSep: [0.2, 0.2, 0.2],
3618
- // The width of separator lines in {array} environments. From
3619
- // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
3620
- arrayRuleWidth: [0.04, 0.04, 0.04],
3621
- // Two values from LaTeX source2e:
3622
- fboxsep: [0.3, 0.3, 0.3],
3623
- // 3 pt / ptPerEm
3624
- fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm
3625
4025
 
3626
- }; // This map contains a mapping from font name and character code to character
3627
- // metrics, including height, depth, italic correction, and skew (kern from the
3628
- // character to the corresponding \skewchar)
3629
- // This map is generated via `make metrics`. It should not be changed manually.
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
+ }
3630
4040
 
3631
- // These are very rough approximations. We default to Times New Roman which
3632
- // should have Latin-1 and Cyrillic characters, but may not depending on the
3633
- // operating system. The metrics do not account for extra height from the
3634
- // accents. In the case of Cyrillic characters which have both ascenders and
3635
- // descenders we prefer approximations with ascenders, primarily to prevent
3636
- // the fraction bar or root line from intersecting the glyph.
3637
- // TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
4041
+ var _proto3 = Img.prototype;
3638
4042
 
3639
- var extraCharacterMap = {
3640
- // Latin-1
3641
- 'Å': 'A',
3642
- 'Ð': 'D',
3643
- 'Þ': 'o',
3644
- 'å': 'a',
3645
- 'ð': 'd',
3646
- 'þ': 'o',
3647
- // Cyrillic
3648
- 'А': 'A',
3649
- 'Б': 'B',
3650
- 'В': 'B',
3651
- 'Г': 'F',
3652
- 'Д': 'A',
3653
- 'Е': 'E',
3654
- 'Ж': 'K',
3655
- 'З': '3',
3656
- 'И': 'N',
3657
- 'Й': 'N',
3658
- 'К': 'K',
3659
- 'Л': 'N',
3660
- 'М': 'M',
3661
- 'Н': 'H',
3662
- 'О': 'O',
3663
- 'П': 'N',
3664
- 'Р': 'P',
3665
- 'С': 'C',
3666
- 'Т': 'T',
3667
- 'У': 'y',
3668
- 'Ф': 'O',
3669
- 'Х': 'X',
3670
- 'Ц': 'U',
3671
- 'Ч': 'h',
3672
- 'Ш': 'W',
3673
- 'Щ': 'W',
3674
- 'Ъ': 'B',
3675
- 'Ы': 'X',
3676
- 'Ь': 'B',
3677
- 'Э': '3',
3678
- 'Ю': 'X',
3679
- 'Я': 'R',
3680
- 'а': 'a',
3681
- 'б': 'b',
3682
- 'в': 'a',
3683
- 'г': 'r',
3684
- 'д': 'y',
3685
- 'е': 'e',
3686
- 'ж': 'm',
3687
- 'з': 'e',
3688
- 'и': 'n',
3689
- 'й': 'n',
3690
- 'к': 'n',
3691
- 'л': 'n',
3692
- 'м': 'm',
3693
- 'н': 'n',
3694
- 'о': 'o',
3695
- 'п': 'n',
3696
- 'р': 'p',
3697
- 'с': 'c',
3698
- 'т': 'o',
3699
- 'у': 'y',
3700
- 'ф': 'b',
3701
- 'х': 'x',
3702
- 'ц': 'n',
3703
- 'ч': 'n',
3704
- 'ш': 'w',
3705
- 'щ': 'w',
3706
- 'ъ': 'a',
3707
- 'ы': 'm',
3708
- 'ь': 'a',
3709
- 'э': 'e',
3710
- 'ю': 'm',
3711
- 'я': 'r'
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
+ };
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"
3712
4090
  };
3713
-
3714
- /**
3715
- * This function adds new font metrics to default metricMap
3716
- * It can also override existing metrics
3717
- */
3718
- function setFontMetrics(fontName, metrics) {
3719
- fontMetricsData[fontName] = metrics;
3720
- }
3721
4091
  /**
3722
- * This function is a convenience function for looking up information in the
3723
- * metricMap table. It takes a character as a string, and a font.
3724
- *
3725
- * Note: the `width` property may be undefined if fontMetricsData.js wasn't
3726
- * built using `Make extended_metrics`.
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.
3727
4095
  */
3728
4096
 
3729
- function getCharacterMetrics(character, font, mode) {
3730
- if (!fontMetricsData[font]) {
3731
- throw new Error("Font metrics not found for font: " + font + ".");
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
+ }
3732
4134
  }
3733
4135
 
3734
- var ch = character.charCodeAt(0);
3735
- var metrics = fontMetricsData[font][ch];
4136
+ var _proto4 = SymbolNode.prototype;
3736
4137
 
3737
- if (!metrics && character[0] in extraCharacterMap) {
3738
- ch = extraCharacterMap[character[0]].charCodeAt(0);
3739
- metrics = fontMetricsData[font][ch];
4138
+ _proto4.hasClass = function hasClass(className) {
4139
+ return utils.contains(this.classes, className);
3740
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
+ ;
3741
4146
 
3742
- if (!metrics && mode === 'text') {
3743
- // We don't typically have font metrics for Asian scripts.
3744
- // But since we support them in text mode, we need to return
3745
- // some sort of metrics.
3746
- // So if the character is in a script we support but we
3747
- // don't have metrics for it, just use the metrics for
3748
- // the Latin capital letter M. This is close enough because
3749
- // we (currently) only care about the height of the glpyh
3750
- // not its width.
3751
- if (supportedCodepoint(ch)) {
3752
- metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M'
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);
3753
4154
  }
3754
- }
3755
4155
 
3756
- if (metrics) {
3757
- return {
3758
- depth: metrics[0],
3759
- height: metrics[1],
3760
- italic: metrics[2],
3761
- skew: metrics[3],
3762
- width: metrics[4]
3763
- };
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
+ }
3764
4175
  }
3765
- }
3766
- var fontMetricsBySizeIndex = {};
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
+ }
4205
+
4206
+ if (styles) {
4207
+ needsSpan = true;
4208
+ markup += " style=\"" + utils.escape(styles) + "\"";
4209
+ }
4210
+
4211
+ var escaped = utils.escape(this.text);
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
+ }();
3767
4225
  /**
3768
- * Get the font metrics for a given size.
4226
+ * SVG nodes are used to render stretchy wide elements.
3769
4227
  */
3770
4228
 
3771
- function getGlobalMetrics(size) {
3772
- var sizeIndex;
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 || {};
4235
+ }
4236
+
4237
+ var _proto5 = SvgNode.prototype;
4238
+
4239
+ _proto5.toNode = function toNode() {
4240
+ var svgNS = "http://www.w3.org/2000/svg";
4241
+ var node = document.createElementNS(svgNS, "svg"); // Apply attributes
4242
+
4243
+ for (var attr in this.attributes) {
4244
+ if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
4245
+ node.setAttribute(attr, this.attributes[attr]);
4246
+ }
4247
+ }
4248
+
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
4283
+ }
4284
+
4285
+ var _proto6 = PathNode.prototype;
4286
+
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 || {};
4314
+ }
4315
+
4316
+ var _proto7 = LineNode.prototype;
3773
4317
 
3774
- if (size >= 5) {
3775
- sizeIndex = 0;
3776
- } else if (size >= 3) {
3777
- sizeIndex = 1;
3778
- } else {
3779
- sizeIndex = 2;
3780
- }
4318
+ _proto7.toNode = function toNode() {
4319
+ var svgNS = "http://www.w3.org/2000/svg";
4320
+ var node = document.createElementNS(svgNS, "line"); // Apply attributes
3781
4321
 
3782
- if (!fontMetricsBySizeIndex[sizeIndex]) {
3783
- var metrics = fontMetricsBySizeIndex[sizeIndex] = {
3784
- cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18
3785
- };
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
+ }
3786
4327
 
3787
- for (var key in sigmasAndXis) {
3788
- if (sigmasAndXis.hasOwnProperty(key)) {
3789
- metrics[key] = sigmasAndXis[key][sizeIndex];
4328
+ return node;
4329
+ };
4330
+
4331
+ _proto7.toMarkup = function toMarkup() {
4332
+ var markup = "<line";
4333
+
4334
+ for (var attr in this.attributes) {
4335
+ if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
4336
+ markup += " " + attr + "='" + this.attributes[attr] + "'";
3790
4337
  }
3791
4338
  }
3792
- }
3793
4339
 
3794
- return fontMetricsBySizeIndex[sizeIndex];
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
+ }
3795
4359
  }
3796
4360
  ;// CONCATENATED MODULE: ./src/symbols.js
3797
4361
  /**
@@ -4436,752 +5000,324 @@ defineSymbol(math, main, op, "\u222B", "\\smallint");
4436
5000
  defineSymbol(symbols_text, main, inner, "\u2026", "\\textellipsis");
4437
5001
  defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
4438
5002
  defineSymbol(symbols_text, main, inner, "\u2026", "\\ldots", true);
4439
- defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
4440
- defineSymbol(math, main, inner, "\u22EF", "\\@cdots", true);
4441
- defineSymbol(math, main, inner, "\u22F1", "\\ddots", true);
4442
- defineSymbol(math, main, textord, "\u22EE", "\\varvdots"); // \vdots is a macro
4443
-
4444
- defineSymbol(math, main, accent, "\u02CA", "\\acute");
4445
- defineSymbol(math, main, accent, "\u02CB", "\\grave");
4446
- defineSymbol(math, main, accent, "\xA8", "\\ddot");
4447
- defineSymbol(math, main, accent, "~", "\\tilde");
4448
- defineSymbol(math, main, accent, "\u02C9", "\\bar");
4449
- defineSymbol(math, main, accent, "\u02D8", "\\breve");
4450
- defineSymbol(math, main, accent, "\u02C7", "\\check");
4451
- defineSymbol(math, main, accent, "^", "\\hat");
4452
- defineSymbol(math, main, accent, "\u20D7", "\\vec");
4453
- defineSymbol(math, main, accent, "\u02D9", "\\dot");
4454
- defineSymbol(math, main, accent, "\u02DA", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA
4455
-
4456
- defineSymbol(math, main, mathord, "\uE131", "\\@imath");
4457
- defineSymbol(math, main, mathord, "\uE237", "\\@jmath");
4458
- defineSymbol(math, main, textord, "\u0131", "\u0131");
4459
- defineSymbol(math, main, textord, "\u0237", "\u0237");
4460
- defineSymbol(symbols_text, main, textord, "\u0131", "\\i", true);
4461
- defineSymbol(symbols_text, main, textord, "\u0237", "\\j", true);
4462
- defineSymbol(symbols_text, main, textord, "\xDF", "\\ss", true);
4463
- defineSymbol(symbols_text, main, textord, "\xE6", "\\ae", true);
4464
- defineSymbol(symbols_text, main, textord, "\u0153", "\\oe", true);
4465
- defineSymbol(symbols_text, main, textord, "\xF8", "\\o", true);
4466
- defineSymbol(symbols_text, main, textord, "\xC6", "\\AE", true);
4467
- defineSymbol(symbols_text, main, textord, "\u0152", "\\OE", true);
4468
- defineSymbol(symbols_text, main, textord, "\xD8", "\\O", true);
4469
- defineSymbol(symbols_text, main, accent, "\u02CA", "\\'"); // acute
4470
-
4471
- defineSymbol(symbols_text, main, accent, "\u02CB", "\\`"); // grave
4472
-
4473
- defineSymbol(symbols_text, main, accent, "\u02C6", "\\^"); // circumflex
4474
-
4475
- defineSymbol(symbols_text, main, accent, "\u02DC", "\\~"); // tilde
4476
-
4477
- defineSymbol(symbols_text, main, accent, "\u02C9", "\\="); // macron
4478
-
4479
- defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve
4480
-
4481
- defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above
4482
-
4483
- defineSymbol(symbols_text, main, accent, "\xB8", "\\c"); // cedilla
4484
-
4485
- defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above
4486
-
4487
- defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron
4488
-
4489
- defineSymbol(symbols_text, main, accent, "\xA8", '\\"'); // diaresis
4490
-
4491
- defineSymbol(symbols_text, main, accent, "\u02DD", "\\H"); // double acute
4492
-
4493
- defineSymbol(symbols_text, main, accent, "\u25EF", "\\textcircled"); // \bigcirc glyph
4494
- // These ligatures are detected and created in Parser.js's `formLigatures`.
4495
-
4496
- var ligatures = {
4497
- "--": true,
4498
- "---": true,
4499
- "``": true,
4500
- "''": true
4501
- };
4502
- defineSymbol(symbols_text, main, textord, "\u2013", "--", true);
4503
- defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash");
4504
- defineSymbol(symbols_text, main, textord, "\u2014", "---", true);
4505
- defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash");
4506
- defineSymbol(symbols_text, main, textord, "\u2018", "`", true);
4507
- defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft");
4508
- defineSymbol(symbols_text, main, textord, "\u2019", "'", true);
4509
- defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright");
4510
- defineSymbol(symbols_text, main, textord, "\u201C", "``", true);
4511
- defineSymbol(symbols_text, main, textord, "\u201C", "\\textquotedblleft");
4512
- defineSymbol(symbols_text, main, textord, "\u201D", "''", true);
4513
- defineSymbol(symbols_text, main, textord, "\u201D", "\\textquotedblright"); // \degree from gensymb package
4514
-
4515
- defineSymbol(math, main, textord, "\xB0", "\\degree", true);
4516
- defineSymbol(symbols_text, main, textord, "\xB0", "\\degree"); // \textdegree from inputenc package
4517
-
4518
- defineSymbol(symbols_text, main, textord, "\xB0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math
4519
- // mode, but among our fonts, only Main-Regular defines this character "163".
4520
-
4521
- defineSymbol(math, main, textord, "\xA3", "\\pounds");
4522
- defineSymbol(math, main, textord, "\xA3", "\\mathsterling", true);
4523
- defineSymbol(symbols_text, main, textord, "\xA3", "\\pounds");
4524
- defineSymbol(symbols_text, main, textord, "\xA3", "\\textsterling", true);
4525
- defineSymbol(math, ams, textord, "\u2720", "\\maltese");
4526
- defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards.
4527
- // All of these are textords in math mode
4528
-
4529
- var mathTextSymbols = "0123456789/@.\"";
4530
-
4531
- for (var i = 0; i < mathTextSymbols.length; i++) {
4532
- var ch = mathTextSymbols.charAt(i);
4533
- defineSymbol(math, main, textord, ch, ch);
4534
- } // All of these are textords in text mode
4535
-
4536
-
4537
- var textSymbols = "0123456789!@*()-=+\";:?/.,";
4538
-
4539
- for (var _i = 0; _i < textSymbols.length; _i++) {
4540
- var _ch = textSymbols.charAt(_i);
4541
-
4542
- defineSymbol(symbols_text, main, textord, _ch, _ch);
4543
- } // All of these are textords in text mode, and mathords in math mode
4544
-
4545
-
4546
- var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
4547
-
4548
- for (var _i2 = 0; _i2 < letters.length; _i2++) {
4549
- var _ch2 = letters.charAt(_i2);
4550
-
4551
- defineSymbol(math, main, mathord, _ch2, _ch2);
4552
- defineSymbol(symbols_text, main, textord, _ch2, _ch2);
4553
- } // Blackboard bold and script letters in Unicode range
4554
-
4555
-
4556
- defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
4557
-
4558
- defineSymbol(symbols_text, ams, textord, "C", "\u2102");
4559
- defineSymbol(math, ams, textord, "H", "\u210D");
4560
- defineSymbol(symbols_text, ams, textord, "H", "\u210D");
4561
- defineSymbol(math, ams, textord, "N", "\u2115");
4562
- defineSymbol(symbols_text, ams, textord, "N", "\u2115");
4563
- defineSymbol(math, ams, textord, "P", "\u2119");
4564
- defineSymbol(symbols_text, ams, textord, "P", "\u2119");
4565
- defineSymbol(math, ams, textord, "Q", "\u211A");
4566
- defineSymbol(symbols_text, ams, textord, "Q", "\u211A");
4567
- defineSymbol(math, ams, textord, "R", "\u211D");
4568
- defineSymbol(symbols_text, ams, textord, "R", "\u211D");
4569
- defineSymbol(math, ams, textord, "Z", "\u2124");
4570
- defineSymbol(symbols_text, ams, textord, "Z", "\u2124");
4571
- defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant
4572
-
4573
- defineSymbol(symbols_text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters.
4574
- // We support some letters in the Unicode range U+1D400 to U+1D7FF,
4575
- // Mathematical Alphanumeric Symbols.
4576
- // Some editors do not deal well with wide characters. So don't write the
4577
- // string into this file. Instead, create the string from the surrogate pair.
4578
-
4579
- var wideChar = "";
4580
-
4581
- for (var _i3 = 0; _i3 < letters.length; _i3++) {
4582
- var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair.
4583
- // 0xD835 is the high surrogate for all letters in the range we support.
4584
- // 0xDC00 is the low surrogate for bold A.
4585
-
4586
-
4587
- wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
4588
-
4589
- defineSymbol(math, main, mathord, _ch3, wideChar);
4590
- defineSymbol(symbols_text, main, textord, _ch3, wideChar);
4591
- wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic
4592
-
4593
- defineSymbol(math, main, mathord, _ch3, wideChar);
4594
- defineSymbol(symbols_text, main, textord, _ch3, wideChar);
4595
- wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic
4596
-
4597
- defineSymbol(math, main, mathord, _ch3, wideChar);
4598
- defineSymbol(symbols_text, main, textord, _ch3, wideChar);
4599
- wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur
4600
-
4601
- defineSymbol(math, main, mathord, _ch3, wideChar);
4602
- defineSymbol(symbols_text, main, textord, _ch3, wideChar);
4603
- wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif
4604
-
4605
- defineSymbol(math, main, mathord, _ch3, wideChar);
4606
- defineSymbol(symbols_text, main, textord, _ch3, wideChar);
4607
- wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold
4608
-
4609
- defineSymbol(math, main, mathord, _ch3, wideChar);
4610
- defineSymbol(symbols_text, main, textord, _ch3, wideChar);
4611
- wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic
4612
-
4613
- defineSymbol(math, main, mathord, _ch3, wideChar);
4614
- defineSymbol(symbols_text, main, textord, _ch3, wideChar);
4615
- wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace
4616
-
4617
- defineSymbol(math, main, mathord, _ch3, wideChar);
4618
- defineSymbol(symbols_text, main, textord, _ch3, wideChar);
4619
-
4620
- if (_i3 < 26) {
4621
- // KaTeX fonts have only capital letters for blackboard bold and script.
4622
- // See exception for k below.
4623
- wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck
4624
-
4625
- defineSymbol(math, main, mathord, _ch3, wideChar);
4626
- defineSymbol(symbols_text, main, textord, _ch3, wideChar);
4627
- wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script
4628
-
4629
- defineSymbol(math, main, mathord, _ch3, wideChar);
4630
- defineSymbol(symbols_text, main, textord, _ch3, wideChar);
4631
- } // TODO: Add bold script when it is supported by a KaTeX font.
4632
-
4633
- } // "k" is the only double struck lower case letter in the KaTeX fonts.
4634
-
4635
-
4636
- wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
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
4637
5007
 
4638
- defineSymbol(math, main, mathord, "k", wideChar);
4639
- defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals
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
4640
5019
 
4641
- for (var _i4 = 0; _i4 < 10; _i4++) {
4642
- var _ch4 = _i4.toString();
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
4643
5034
 
4644
- wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold
5035
+ defineSymbol(symbols_text, main, accent, "\u02CB", "\\`"); // grave
4645
5036
 
4646
- defineSymbol(math, main, mathord, _ch4, wideChar);
4647
- defineSymbol(symbols_text, main, textord, _ch4, wideChar);
4648
- wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif
5037
+ defineSymbol(symbols_text, main, accent, "\u02C6", "\\^"); // circumflex
4649
5038
 
4650
- defineSymbol(math, main, mathord, _ch4, wideChar);
4651
- defineSymbol(symbols_text, main, textord, _ch4, wideChar);
4652
- wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans
5039
+ defineSymbol(symbols_text, main, accent, "\u02DC", "\\~"); // tilde
4653
5040
 
4654
- defineSymbol(math, main, mathord, _ch4, wideChar);
4655
- defineSymbol(symbols_text, main, textord, _ch4, wideChar);
4656
- wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace
5041
+ defineSymbol(symbols_text, main, accent, "\u02C9", "\\="); // macron
4657
5042
 
4658
- defineSymbol(math, main, mathord, _ch4, wideChar);
4659
- defineSymbol(symbols_text, main, textord, _ch4, wideChar);
4660
- } // We add these Latin-1 letters as symbols for backwards-compatibility,
4661
- // but they are not actually in the font, nor are they supported by the
4662
- // Unicode accent mechanism, so they fall back to Times font and look ugly.
4663
- // TODO(edemaine): Fix this.
5043
+ defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve
4664
5044
 
5045
+ defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above
4665
5046
 
4666
- var extraLatin = "\xD0\xDE\xFE";
5047
+ defineSymbol(symbols_text, main, accent, "\xB8", "\\c"); // cedilla
4667
5048
 
4668
- for (var _i5 = 0; _i5 < extraLatin.length; _i5++) {
4669
- var _ch5 = extraLatin.charAt(_i5);
5049
+ defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above
4670
5050
 
4671
- defineSymbol(math, main, mathord, _ch5, _ch5);
4672
- defineSymbol(symbols_text, main, textord, _ch5, _ch5);
4673
- }
4674
- ;// CONCATENATED MODULE: ./src/wide-character.js
4675
- /**
4676
- * This file provides support for Unicode range U+1D400 to U+1D7FF,
4677
- * Mathematical Alphanumeric Symbols.
4678
- *
4679
- * Function wideCharacterFont takes a wide character as input and returns
4680
- * the font information necessary to render it properly.
4681
- */
5051
+ defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron
4682
5052
 
4683
- /**
4684
- * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf
4685
- * That document sorts characters into groups by font type, say bold or italic.
4686
- *
4687
- * In the arrays below, each subarray consists three elements:
4688
- * * The CSS class of that group when in math mode.
4689
- * * The CSS class of that group when in text mode.
4690
- * * The font name, so that KaTeX can get font metrics.
4691
- */
5053
+ defineSymbol(symbols_text, main, accent, "\xA8", '\\"'); // diaresis
4692
5054
 
4693
- var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright
4694
- ["mathbf", "textbf", "Main-Bold"], // a-z bold upright
4695
- ["mathnormal", "textit", "Math-Italic"], // A-Z italic
4696
- ["mathnormal", "textit", "Math-Italic"], // a-z italic
4697
- ["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic
4698
- ["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic
4699
- // Map fancy A-Z letters to script, not calligraphic.
4700
- // This aligns with unicode-math and math fonts (except Cambria Math).
4701
- ["mathscr", "textscr", "Script-Regular"], // A-Z script
4702
- ["", "", ""], // a-z script. No font
4703
- ["", "", ""], // A-Z bold script. No font
4704
- ["", "", ""], // a-z bold script. No font
4705
- ["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur
4706
- ["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur
4707
- ["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
4708
- ["mathbb", "textbb", "AMS-Regular"], // k double-struck
4709
- ["", "", ""], // A-Z bold Fraktur No font metrics
4710
- ["", "", ""], // a-z bold Fraktur. No font.
4711
- ["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
4712
- ["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
4713
- ["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif
4714
- ["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif
4715
- ["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif
4716
- ["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif
4717
- ["", "", ""], // A-Z bold italic sans. No font
4718
- ["", "", ""], // a-z bold italic sans. No font
4719
- ["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace
4720
- ["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace
4721
- ];
4722
- var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold
4723
- ["", "", ""], // 0-9 double-struck. No KaTeX font.
4724
- ["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif
4725
- ["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif
4726
- ["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace
4727
- ];
4728
- var wideCharacterFont = function wideCharacterFont(wideChar, mode) {
4729
- // IE doesn't support codePointAt(). So work with the surrogate pair.
4730
- var H = wideChar.charCodeAt(0); // high surrogate
5055
+ defineSymbol(symbols_text, main, accent, "\u02DD", "\\H"); // double acute
4731
5056
 
4732
- var L = wideChar.charCodeAt(1); // low surrogate
5057
+ defineSymbol(symbols_text, main, accent, "\u25EF", "\\textcircled"); // \bigcirc glyph
5058
+ // These ligatures are detected and created in Parser.js's `formLigatures`.
4733
5059
 
4734
- var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000;
4735
- var j = mode === "math" ? 0 : 1; // column index for CSS class.
5060
+ var ligatures = {
5061
+ "--": true,
5062
+ "---": true,
5063
+ "``": true,
5064
+ "''": true
5065
+ };
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
4736
5078
 
4737
- if (0x1D400 <= codePoint && codePoint < 0x1D6A4) {
4738
- // wideLatinLetterData contains exactly 26 chars on each row.
4739
- // So we can calculate the relevant row. No traverse necessary.
4740
- var i = Math.floor((codePoint - 0x1D400) / 26);
4741
- return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]];
4742
- } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) {
4743
- // Numerals, ten per row.
4744
- var _i = Math.floor((codePoint - 0x1D7CE) / 10);
5079
+ defineSymbol(math, main, textord, "\xB0", "\\degree", true);
5080
+ defineSymbol(symbols_text, main, textord, "\xB0", "\\degree"); // \textdegree from inputenc package
4745
5081
 
4746
- return [wideNumeralData[_i][2], wideNumeralData[_i][j]];
4747
- } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) {
4748
- // dotless i or j
4749
- return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]];
4750
- } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) {
4751
- // Greek letters. Not supported, yet.
4752
- return ["", ""];
4753
- } else {
4754
- // We don't support any wide characters outside 1D400–1D7FF.
4755
- throw new src_ParseError("Unsupported character: " + wideChar);
4756
- }
4757
- };
4758
- ;// CONCATENATED MODULE: ./src/Options.js
4759
- /**
4760
- * This file contains information about the options that the Parser carries
4761
- * around with it while parsing. Data is held in an `Options` object, and when
4762
- * recursing, a new `Options` object can be created with the `.with*` and
4763
- * `.reset` functions.
4764
- */
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".
4765
5084
 
4766
- var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize].
4767
- // The size mappings are taken from TeX with \normalsize=10pt.
4768
- [1, 1, 1], // size1: [5, 5, 5] \tiny
4769
- [2, 1, 1], // size2: [6, 5, 5]
4770
- [3, 1, 1], // size3: [7, 5, 5] \scriptsize
4771
- [4, 2, 1], // size4: [8, 6, 5] \footnotesize
4772
- [5, 2, 1], // size5: [9, 6, 5] \small
4773
- [6, 3, 1], // size6: [10, 7, 5] \normalsize
4774
- [7, 4, 2], // size7: [12, 8, 6] \large
4775
- [8, 6, 3], // size8: [14.4, 10, 7] \Large
4776
- [9, 7, 6], // size9: [17.28, 12, 10] \LARGE
4777
- [10, 8, 7], // size10: [20.74, 14.4, 12] \huge
4778
- [11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE
4779
- ];
4780
- var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if
4781
- // you change size indexes, change that function.
4782
- 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
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
4783
5092
 
4784
- var sizeAtStyle = function sizeAtStyle(size, style) {
4785
- return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
4786
- }; // In these types, "" (empty string) means "no change".
5093
+ var mathTextSymbols = "0123456789/@.\"";
4787
5094
 
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
4788
5099
 
4789
- /**
4790
- * This is the main options class. It contains the current style, size, color,
4791
- * and font.
4792
- *
4793
- * Options objects should not be modified. To create a new Options with
4794
- * different properties, call a `.having*` method.
4795
- */
4796
- var Options = /*#__PURE__*/function () {
4797
- // A font family applies to a group of fonts (i.e. SansSerif), while a font
4798
- // represents a specific font (i.e. SansSerif Bold).
4799
- // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm
4800
5100
 
4801
- /**
4802
- * The base size index.
4803
- */
4804
- function Options(data) {
4805
- this.style = void 0;
4806
- this.color = void 0;
4807
- this.size = void 0;
4808
- this.textSize = void 0;
4809
- this.phantom = void 0;
4810
- this.font = void 0;
4811
- this.fontFamily = void 0;
4812
- this.fontWeight = void 0;
4813
- this.fontShape = void 0;
4814
- this.sizeMultiplier = void 0;
4815
- this.maxSize = void 0;
4816
- this.minRuleThickness = void 0;
4817
- this._fontMetrics = void 0;
4818
- this.style = data.style;
4819
- this.color = data.color;
4820
- this.size = data.size || Options.BASESIZE;
4821
- this.textSize = data.textSize || this.size;
4822
- this.phantom = !!data.phantom;
4823
- this.font = data.font || "";
4824
- this.fontFamily = data.fontFamily || "";
4825
- this.fontWeight = data.fontWeight || '';
4826
- this.fontShape = data.fontShape || '';
4827
- this.sizeMultiplier = sizeMultipliers[this.size - 1];
4828
- this.maxSize = data.maxSize;
4829
- this.minRuleThickness = data.minRuleThickness;
4830
- this._fontMetrics = undefined;
4831
- }
4832
- /**
4833
- * Returns a new options object with the same properties as "this". Properties
4834
- * from "extension" will be copied to the new options object.
4835
- */
5101
+ var textSymbols = "0123456789!@*()-=+\";:?/.,";
4836
5102
 
5103
+ for (var _i = 0; _i < textSymbols.length; _i++) {
5104
+ var _ch = textSymbols.charAt(_i);
4837
5105
 
4838
- var _proto = Options.prototype;
5106
+ defineSymbol(symbols_text, main, textord, _ch, _ch);
5107
+ } // All of these are textords in text mode, and mathords in math mode
4839
5108
 
4840
- _proto.extend = function extend(extension) {
4841
- var data = {
4842
- style: this.style,
4843
- size: this.size,
4844
- textSize: this.textSize,
4845
- color: this.color,
4846
- phantom: this.phantom,
4847
- font: this.font,
4848
- fontFamily: this.fontFamily,
4849
- fontWeight: this.fontWeight,
4850
- fontShape: this.fontShape,
4851
- maxSize: this.maxSize,
4852
- minRuleThickness: this.minRuleThickness
4853
- };
4854
5109
 
4855
- for (var key in extension) {
4856
- if (extension.hasOwnProperty(key)) {
4857
- data[key] = extension[key];
4858
- }
4859
- }
5110
+ var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
4860
5111
 
4861
- return new Options(data);
4862
- }
4863
- /**
4864
- * Return an options object with the given style. If `this.style === style`,
4865
- * returns `this`.
4866
- */
4867
- ;
5112
+ for (var _i2 = 0; _i2 < letters.length; _i2++) {
5113
+ var _ch2 = letters.charAt(_i2);
4868
5114
 
4869
- _proto.havingStyle = function havingStyle(style) {
4870
- if (this.style === style) {
4871
- return this;
4872
- } else {
4873
- return this.extend({
4874
- style: style,
4875
- size: sizeAtStyle(this.textSize, style)
4876
- });
4877
- }
4878
- }
4879
- /**
4880
- * Return an options object with a cramped version of the current style. If
4881
- * the current style is cramped, returns `this`.
4882
- */
4883
- ;
5115
+ defineSymbol(math, main, mathord, _ch2, _ch2);
5116
+ defineSymbol(symbols_text, main, textord, _ch2, _ch2);
5117
+ } // Blackboard bold and script letters in Unicode range
4884
5118
 
4885
- _proto.havingCrampedStyle = function havingCrampedStyle() {
4886
- return this.havingStyle(this.style.cramp());
4887
- }
4888
- /**
4889
- * Return an options object with the given size and in at least `\textstyle`.
4890
- * Returns `this` if appropriate.
4891
- */
4892
- ;
4893
5119
 
4894
- _proto.havingSize = function havingSize(size) {
4895
- if (this.size === size && this.textSize === size) {
4896
- return this;
4897
- } else {
4898
- return this.extend({
4899
- style: this.style.text(),
4900
- size: size,
4901
- textSize: size,
4902
- sizeMultiplier: sizeMultipliers[size - 1]
4903
- });
4904
- }
4905
- }
4906
- /**
4907
- * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
4908
- * changes to at least `\textstyle`.
4909
- */
4910
- ;
5120
+ defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
4911
5121
 
4912
- _proto.havingBaseStyle = function havingBaseStyle(style) {
4913
- style = style || this.style.text();
4914
- var wantSize = sizeAtStyle(Options.BASESIZE, style);
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
4915
5136
 
4916
- if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) {
4917
- return this;
4918
- } else {
4919
- return this.extend({
4920
- style: style,
4921
- size: wantSize
4922
- });
4923
- }
4924
- }
4925
- /**
4926
- * Remove the effect of sizing changes such as \Huge.
4927
- * Keep the effect of the current style, such as \scriptstyle.
4928
- */
4929
- ;
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.
4930
5142
 
4931
- _proto.havingBaseSizing = function havingBaseSizing() {
4932
- var size;
5143
+ var wideChar = "";
4933
5144
 
4934
- switch (this.style.id) {
4935
- case 4:
4936
- case 5:
4937
- size = 3; // normalsize in scriptstyle
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.
4938
5149
 
4939
- break;
4940
5150
 
4941
- case 6:
4942
- case 7:
4943
- size = 1; // normalsize in scriptscriptstyle
5151
+ wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
4944
5152
 
4945
- break;
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
4946
5156
 
4947
- default:
4948
- size = 6;
4949
- // normalsize in textstyle or displaystyle
4950
- }
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
4951
5160
 
4952
- return this.extend({
4953
- style: this.style.text(),
4954
- size: size
4955
- });
4956
- }
4957
- /**
4958
- * Create a new options object with the given color.
4959
- */
4960
- ;
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
4961
5164
 
4962
- _proto.withColor = function withColor(color) {
4963
- return this.extend({
4964
- color: color
4965
- });
4966
- }
4967
- /**
4968
- * Create a new options object with "phantom" set to true.
4969
- */
4970
- ;
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
4971
5168
 
4972
- _proto.withPhantom = function withPhantom() {
4973
- return this.extend({
4974
- phantom: true
4975
- });
4976
- }
4977
- /**
4978
- * Creates a new options object with the given math font or old text font.
4979
- * @type {[type]}
4980
- */
4981
- ;
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
4982
5172
 
4983
- _proto.withFont = function withFont(font) {
4984
- return this.extend({
4985
- font: font
4986
- });
4987
- }
4988
- /**
4989
- * Create a new options objects with the given fontFamily.
4990
- */
4991
- ;
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
4992
5176
 
4993
- _proto.withTextFontFamily = function withTextFontFamily(fontFamily) {
4994
- return this.extend({
4995
- fontFamily: fontFamily,
4996
- font: ""
4997
- });
4998
- }
4999
- /**
5000
- * Creates a new options object with the given font weight
5001
- */
5002
- ;
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
5003
5180
 
5004
- _proto.withTextFontWeight = function withTextFontWeight(fontWeight) {
5005
- return this.extend({
5006
- fontWeight: fontWeight,
5007
- font: ""
5008
- });
5009
- }
5010
- /**
5011
- * Creates a new options object with the given font weight
5012
- */
5013
- ;
5181
+ defineSymbol(math, main, mathord, _ch3, wideChar);
5182
+ defineSymbol(symbols_text, main, textord, _ch3, wideChar);
5014
5183
 
5015
- _proto.withTextFontShape = function withTextFontShape(fontShape) {
5016
- return this.extend({
5017
- fontShape: fontShape,
5018
- font: ""
5019
- });
5020
- }
5021
- /**
5022
- * Return the CSS sizing classes required to switch from enclosing options
5023
- * `oldOptions` to `this`. Returns an array of classes.
5024
- */
5025
- ;
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
5026
5188
 
5027
- _proto.sizingClasses = function sizingClasses(oldOptions) {
5028
- if (oldOptions.size !== this.size) {
5029
- return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
5030
- } else {
5031
- return [];
5032
- }
5033
- }
5034
- /**
5035
- * Return the CSS sizing classes required to switch to the base size. Like
5036
- * `this.havingSize(BASESIZE).sizingClasses(this)`.
5037
- */
5038
- ;
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
5039
5192
 
5040
- _proto.baseSizingClasses = function baseSizingClasses() {
5041
- if (this.size !== Options.BASESIZE) {
5042
- return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
5043
- } else {
5044
- return [];
5045
- }
5046
- }
5047
- /**
5048
- * Return the font metrics for this size.
5049
- */
5050
- ;
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.
5051
5196
 
5052
- _proto.fontMetrics = function fontMetrics() {
5053
- if (!this._fontMetrics) {
5054
- this._fontMetrics = getGlobalMetrics(this.size);
5055
- }
5197
+ } // "k" is the only double struck lower case letter in the KaTeX fonts.
5056
5198
 
5057
- return this._fontMetrics;
5058
- }
5059
- /**
5060
- * Gets the CSS color of the current options object
5061
- */
5062
- ;
5063
5199
 
5064
- _proto.getColor = function getColor() {
5065
- if (this.phantom) {
5066
- return "transparent";
5067
- } else {
5068
- return this.color;
5069
- }
5070
- };
5200
+ wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
5071
5201
 
5072
- return Options;
5073
- }();
5202
+ defineSymbol(math, main, mathord, "k", wideChar);
5203
+ defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals
5074
5204
 
5075
- Options.BASESIZE = 6;
5076
- /* harmony default export */ var src_Options = (Options);
5077
- ;// CONCATENATED MODULE: ./src/units.js
5078
- /**
5079
- * This file does conversion between units. In particular, it provides
5080
- * calculateSize to convert other units into ems.
5081
- */
5205
+ for (var _i4 = 0; _i4 < 10; _i4++) {
5206
+ var _ch4 = _i4.toString();
5082
5207
 
5083
- // This table gives the number of TeX pts in one of each *absolute* TeX unit.
5084
- // Thus, multiplying a length by this number converts the length from units
5085
- // into pts. Dividing the result by ptPerEm gives the number of ems
5086
- // *assuming* a font size of ptPerEm (normal size, normal style).
5208
+ wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold
5087
5209
 
5088
- var ptPerUnit = {
5089
- // https://en.wikibooks.org/wiki/LaTeX/Lengths and
5090
- // https://tex.stackexchange.com/a/8263
5091
- "pt": 1,
5092
- // TeX point
5093
- "mm": 7227 / 2540,
5094
- // millimeter
5095
- "cm": 7227 / 254,
5096
- // centimeter
5097
- "in": 72.27,
5098
- // inch
5099
- "bp": 803 / 800,
5100
- // big (PostScript) points
5101
- "pc": 12,
5102
- // pica
5103
- "dd": 1238 / 1157,
5104
- // didot
5105
- "cc": 14856 / 1157,
5106
- // cicero (12 didot)
5107
- "nd": 685 / 642,
5108
- // new didot
5109
- "nc": 1370 / 107,
5110
- // new cicero (12 new didot)
5111
- "sp": 1 / 65536,
5112
- // scaled point (TeX's internal smallest unit)
5113
- // https://tex.stackexchange.com/a/41371
5114
- "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX
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
5115
5213
 
5116
- }; // Dictionary of relative units, for fast validity testing.
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
5117
5217
 
5118
- var relativeUnit = {
5119
- "ex": true,
5120
- "em": true,
5121
- "mu": true
5122
- };
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
5123
5221
 
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.
5228
+
5229
+
5230
+ var extraLatin = "\xD0\xDE\xFE";
5231
+
5232
+ for (var _i5 = 0; _i5 < extraLatin.length; _i5++) {
5233
+ var _ch5 = extraLatin.charAt(_i5);
5234
+
5235
+ defineSymbol(math, main, mathord, _ch5, _ch5);
5236
+ defineSymbol(symbols_text, main, textord, _ch5, _ch5);
5237
+ }
5238
+ ;// CONCATENATED MODULE: ./src/wide-character.js
5124
5239
  /**
5125
- * Determine whether the specified unit (either a string defining the unit
5126
- * or a "size" parse node containing a unit field) is valid.
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.
5127
5245
  */
5128
- var validUnit = function validUnit(unit) {
5129
- if (typeof unit !== "string") {
5130
- unit = unit.unit;
5131
- }
5132
5246
 
5133
- return unit in ptPerUnit || unit in relativeUnit || unit === "ex";
5134
- };
5135
- /*
5136
- * Convert a "size" parse node (with numeric "number" and string "unit" fields,
5137
- * as parsed by functions.js argType "size") into a CSS em value for the
5138
- * current style/scale. `options` gives the current options.
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.
5139
5255
  */
5140
5256
 
5141
- var calculateSize = function calculateSize(sizeValue, options) {
5142
- var scale;
5143
-
5144
- if (sizeValue.unit in ptPerUnit) {
5145
- // Absolute units
5146
- scale = ptPerUnit[sizeValue.unit] // Convert unit to pt
5147
- / options.fontMetrics().ptPerEm // Convert pt to CSS em
5148
- / options.sizeMultiplier; // Unscale to make absolute units
5149
- } else if (sizeValue.unit === "mu") {
5150
- // `mu` units scale with scriptstyle/scriptscriptstyle.
5151
- scale = options.fontMetrics().cssEmPerMu;
5152
- } else {
5153
- // Other relative units always refer to the *textstyle* font
5154
- // in the current size.
5155
- var unitOptions;
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
5156
5295
 
5157
- if (options.style.isTight()) {
5158
- // isTight() means current style is script/scriptscript.
5159
- unitOptions = options.havingStyle(options.style.text());
5160
- } else {
5161
- unitOptions = options;
5162
- } // TODO: In TeX these units are relative to the quad of the current
5163
- // *text* font, e.g. cmr10. KaTeX instead uses values from the
5164
- // comparably-sized *Computer Modern symbol* font. At 10pt, these
5165
- // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
5166
- // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
5167
- // TeX \showlists shows a kern of 1.13889 * fontsize;
5168
- // KaTeX shows a kern of 1.171 * fontsize.
5296
+ var L = wideChar.charCodeAt(1); // low surrogate
5169
5297
 
5298
+ var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000;
5299
+ var j = mode === "math" ? 0 : 1; // column index for CSS class.
5170
5300
 
5171
- if (sizeValue.unit === "ex") {
5172
- scale = unitOptions.fontMetrics().xHeight;
5173
- } else if (sizeValue.unit === "em") {
5174
- scale = unitOptions.fontMetrics().quad;
5175
- } else {
5176
- throw new src_ParseError("Invalid unit: '" + sizeValue.unit + "'");
5177
- }
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);
5178
5309
 
5179
- if (unitOptions !== options) {
5180
- scale *= unitOptions.sizeMultiplier / options.sizeMultiplier;
5181
- }
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);
5182
5320
  }
5183
-
5184
- return Math.min(sizeValue.number * scale, options.maxSize);
5185
5321
  };
5186
5322
  ;// CONCATENATED MODULE: ./src/buildCommon.js
5187
5323
  /* eslint no-console:0 */
@@ -5502,7 +5638,7 @@ var makeSvgSpan = function makeSvgSpan(classes, children, options, style) {
5502
5638
  var makeLineSpan = function makeLineSpan(className, options, thickness) {
5503
5639
  var line = makeSpan([className], [], options);
5504
5640
  line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness);
5505
- line.style.borderBottomWidth = line.height + "em";
5641
+ line.style.borderBottomWidth = makeEm(line.height);
5506
5642
  line.maxFontSize = 1.0;
5507
5643
  return line;
5508
5644
  };
@@ -5642,7 +5778,7 @@ var makeVList = function makeVList(params, options) {
5642
5778
 
5643
5779
  pstrutSize += 2;
5644
5780
  var pstrut = makeSpan(["pstrut"], []);
5645
- pstrut.style.height = pstrutSize + "em"; // Create a new list of actual children at the correct offsets
5781
+ pstrut.style.height = makeEm(pstrutSize); // Create a new list of actual children at the correct offsets
5646
5782
 
5647
5783
  var realChildren = [];
5648
5784
  var minPos = depth;
@@ -5659,7 +5795,7 @@ var makeVList = function makeVList(params, options) {
5659
5795
  var classes = _child.wrapperClasses || [];
5660
5796
  var style = _child.wrapperStyle || {};
5661
5797
  var childWrap = makeSpan(classes, [pstrut, _elem], undefined, style);
5662
- childWrap.style.top = -pstrutSize - currPos - _elem.depth + "em";
5798
+ childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth);
5663
5799
 
5664
5800
  if (_child.marginLeft) {
5665
5801
  childWrap.style.marginLeft = _child.marginLeft;
@@ -5681,7 +5817,7 @@ var makeVList = function makeVList(params, options) {
5681
5817
 
5682
5818
 
5683
5819
  var vlist = makeSpan(["vlist"], realChildren);
5684
- vlist.style.height = maxPos + "em"; // A second row is used if necessary to represent the vlist's depth.
5820
+ vlist.style.height = makeEm(maxPos); // A second row is used if necessary to represent the vlist's depth.
5685
5821
 
5686
5822
  var rows;
5687
5823
 
@@ -5693,7 +5829,7 @@ var makeVList = function makeVList(params, options) {
5693
5829
  // So we put another empty span inside the depth strut span.
5694
5830
  var emptySpan = makeSpan([], []);
5695
5831
  var depthStrut = makeSpan(["vlist"], [emptySpan]);
5696
- depthStrut.style.height = -minPos + "em"; // Safari wants the first row to have inline content; otherwise it
5832
+ depthStrut.style.height = makeEm(-minPos); // Safari wants the first row to have inline content; otherwise it
5697
5833
  // puts the bottom of the *second* row on the baseline.
5698
5834
 
5699
5835
  var topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200B")]);
@@ -5720,7 +5856,7 @@ var makeGlue = function makeGlue(measurement, options) {
5720
5856
  // Make an empty span for the space
5721
5857
  var rule = makeSpan(["mspace"], [], options);
5722
5858
  var size = calculateSize(measurement, options);
5723
- rule.style.marginRight = size + "em";
5859
+ rule.style.marginRight = makeEm(size);
5724
5860
  return rule;
5725
5861
  }; // Takes font options, and returns the appropriate fontLookup name
5726
5862
 
@@ -5842,17 +5978,17 @@ var staticSvg = function staticSvg(value, options) {
5842
5978
  height = _svgData$value[2];
5843
5979
  var path = new PathNode(pathName);
5844
5980
  var svgNode = new SvgNode([path], {
5845
- "width": width + "em",
5846
- "height": height + "em",
5981
+ "width": makeEm(width),
5982
+ "height": makeEm(height),
5847
5983
  // Override CSS rule `.katex svg { width: 100% }`
5848
- "style": "width:" + width + "em",
5984
+ "style": "width:" + makeEm(width),
5849
5985
  "viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
5850
5986
  "preserveAspectRatio": "xMinYMin"
5851
5987
  });
5852
5988
  var span = makeSvgSpan(["overlay"], [svgNode], options);
5853
5989
  span.height = height;
5854
- span.style.height = height + "em";
5855
- span.style.width = width + "em";
5990
+ span.style.height = makeEm(height);
5991
+ span.style.width = makeEm(width);
5856
5992
  return span;
5857
5993
  };
5858
5994
 
@@ -6081,6 +6217,7 @@ var ordargument = function ordargument(arg) {
6081
6217
 
6082
6218
 
6083
6219
 
6220
+
6084
6221
  var buildHTML_makeSpan = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`)
6085
6222
  // depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6,
6086
6223
  // and the text before Rule 19.
@@ -6340,10 +6477,10 @@ function buildHTMLUnbreakable(children, options) {
6340
6477
  // falls at the depth of the expression.
6341
6478
 
6342
6479
  var strut = buildHTML_makeSpan(["strut"]);
6343
- strut.style.height = body.height + body.depth + "em";
6480
+ strut.style.height = makeEm(body.height + body.depth);
6344
6481
 
6345
6482
  if (body.depth) {
6346
- strut.style.verticalAlign = -body.depth + "em";
6483
+ strut.style.verticalAlign = makeEm(-body.depth);
6347
6484
  }
6348
6485
 
6349
6486
  body.children.unshift(strut);
@@ -6439,10 +6576,10 @@ function buildHTML(tree, options) {
6439
6576
 
6440
6577
  if (tagChild) {
6441
6578
  var strut = tagChild.children[0];
6442
- strut.style.height = htmlNode.height + htmlNode.depth + "em";
6579
+ strut.style.height = makeEm(htmlNode.height + htmlNode.depth);
6443
6580
 
6444
6581
  if (htmlNode.depth) {
6445
- strut.style.verticalAlign = -htmlNode.depth + "em";
6582
+ strut.style.verticalAlign = makeEm(-htmlNode.depth);
6446
6583
  }
6447
6584
  }
6448
6585
 
@@ -6461,6 +6598,7 @@ function buildHTML(tree, options) {
6461
6598
 
6462
6599
 
6463
6600
 
6601
+
6464
6602
  function newDocumentFragment(children) {
6465
6603
  return new DocumentFragment(children);
6466
6604
  }
@@ -6655,7 +6793,7 @@ var SpaceNode = /*#__PURE__*/function () {
6655
6793
  return document.createTextNode(this.character);
6656
6794
  } else {
6657
6795
  var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace");
6658
- node.setAttribute("width", this.width + "em");
6796
+ node.setAttribute("width", makeEm(this.width));
6659
6797
  return node;
6660
6798
  }
6661
6799
  }
@@ -6668,7 +6806,7 @@ var SpaceNode = /*#__PURE__*/function () {
6668
6806
  if (this.character) {
6669
6807
  return "<mtext>" + this.character + "</mtext>";
6670
6808
  } else {
6671
- return "<mspace width=\"" + this.width + "em\"/>";
6809
+ return "<mspace width=\"" + makeEm(this.width) + "\"/>";
6672
6810
  }
6673
6811
  }
6674
6812
  /**
@@ -7017,6 +7155,7 @@ var buildHTMLTree = function buildHTMLTree(tree, expression, settings) {
7017
7155
 
7018
7156
 
7019
7157
 
7158
+
7020
7159
  var stretchyCodePoint = {
7021
7160
  widehat: "^",
7022
7161
  widecheck: "ˇ",
@@ -7214,7 +7353,7 @@ var svgSpan = function svgSpan(group, options) {
7214
7353
  var path = new PathNode(pathName);
7215
7354
  var svgNode = new SvgNode([path], {
7216
7355
  "width": "100%",
7217
- "height": _height + "em",
7356
+ "height": makeEm(_height),
7218
7357
  "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight,
7219
7358
  "preserveAspectRatio": "none"
7220
7359
  });
@@ -7256,7 +7395,7 @@ var svgSpan = function svgSpan(group, options) {
7256
7395
 
7257
7396
  var _svgNode = new SvgNode([_path], {
7258
7397
  "width": "400em",
7259
- "height": _height2 + "em",
7398
+ "height": makeEm(_height2),
7260
7399
  "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight,
7261
7400
  "preserveAspectRatio": aligns[i] + " slice"
7262
7401
  });
@@ -7270,7 +7409,7 @@ var svgSpan = function svgSpan(group, options) {
7270
7409
  height: _height2
7271
7410
  };
7272
7411
  } else {
7273
- _span.style.height = _height2 + "em";
7412
+ _span.style.height = makeEm(_height2);
7274
7413
  spans.push(_span);
7275
7414
  }
7276
7415
  }
@@ -7292,10 +7431,10 @@ var svgSpan = function svgSpan(group, options) {
7292
7431
 
7293
7432
 
7294
7433
  span.height = height;
7295
- span.style.height = height + "em";
7434
+ span.style.height = makeEm(height);
7296
7435
 
7297
7436
  if (minWidth > 0) {
7298
- span.style.minWidth = minWidth + "em";
7437
+ span.style.minWidth = makeEm(minWidth);
7299
7438
  }
7300
7439
 
7301
7440
  return span;
@@ -7344,13 +7483,13 @@ var encloseSpan = function encloseSpan(inner, label, topPad, bottomPad, options)
7344
7483
 
7345
7484
  var svgNode = new SvgNode(lines, {
7346
7485
  "width": "100%",
7347
- "height": totalHeight + "em"
7486
+ "height": makeEm(totalHeight)
7348
7487
  });
7349
7488
  img = buildCommon.makeSvgSpan([], [svgNode], options);
7350
7489
  }
7351
7490
 
7352
7491
  img.height = totalHeight;
7353
- img.style.height = totalHeight + "em";
7492
+ img.style.height = makeEm(totalHeight);
7354
7493
  return img;
7355
7494
  };
7356
7495
 
@@ -7411,6 +7550,7 @@ function checkSymbolNodeType(node) {
7411
7550
 
7412
7551
 
7413
7552
 
7553
+
7414
7554
  // NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but
7415
7555
  // also "supsub" since an accent can affect super/subscripting.
7416
7556
  var htmlBuilder = function htmlBuilder(grp, options) {
@@ -7522,7 +7662,7 @@ var htmlBuilder = function htmlBuilder(grp, options) {
7522
7662
  left -= width / 2;
7523
7663
  }
7524
7664
 
7525
- accentBody.style.left = left + "em"; // \textcircled uses the \bigcirc glyph, so it needs some
7665
+ accentBody.style.left = makeEm(left); // \textcircled uses the \bigcirc glyph, so it needs some
7526
7666
  // vertical adjustment to match LaTeX.
7527
7667
 
7528
7668
  if (group.label === "\\textcircled") {
@@ -7554,8 +7694,8 @@ var htmlBuilder = function htmlBuilder(grp, options) {
7554
7694
  elem: accentBody,
7555
7695
  wrapperClasses: ["svg-align"],
7556
7696
  wrapperStyle: skew > 0 ? {
7557
- width: "calc(100% - " + 2 * skew + "em)",
7558
- marginLeft: 2 * skew + "em"
7697
+ width: "calc(100% - " + makeEm(2 * skew) + ")",
7698
+ marginLeft: makeEm(2 * skew)
7559
7699
  } : undefined
7560
7700
  }]
7561
7701
  }, options);
@@ -7844,6 +7984,7 @@ defineFunction({
7844
7984
 
7845
7985
 
7846
7986
 
7987
+
7847
7988
  var cdArrowFunctionName = {
7848
7989
  ">": "\\\\cdrightarrow",
7849
7990
  "<": "\\\\cdleftarrow",
@@ -8106,7 +8247,7 @@ defineFunction({
8106
8247
  var newOptions = options.havingStyle(options.style.sup());
8107
8248
  var label = buildCommon.wrapFragment(buildGroup(group.label, newOptions, options), options);
8108
8249
  label.classes.push("cd-label-" + group.side);
8109
- label.style.bottom = 0.8 - label.depth + "em"; // Zero out label height & depth, so vertical align of arrow is set
8250
+ label.style.bottom = makeEm(0.8 - label.depth); // Zero out label height & depth, so vertical align of arrow is set
8110
8251
  // by the arrow height, not by the label.
8111
8252
 
8112
8253
  label.height = 0;
@@ -8317,7 +8458,7 @@ defineFunction({
8317
8458
  span.classes.push("newline");
8318
8459
 
8319
8460
  if (group.size) {
8320
- span.style.marginTop = calculateSize(group.size, options) + "em";
8461
+ span.style.marginTop = makeEm(calculateSize(group.size, options));
8321
8462
  }
8322
8463
  }
8323
8464
 
@@ -8330,7 +8471,7 @@ defineFunction({
8330
8471
  node.setAttribute("linebreak", "newline");
8331
8472
 
8332
8473
  if (group.size) {
8333
- node.setAttribute("height", calculateSize(group.size, options) + "em");
8474
+ node.setAttribute("height", makeEm(calculateSize(group.size, options)));
8334
8475
  }
8335
8476
  }
8336
8477
 
@@ -8596,6 +8737,7 @@ defineFunction({
8596
8737
 
8597
8738
 
8598
8739
 
8740
+
8599
8741
  /**
8600
8742
  * Get the metrics for a given symbol and font, after transformation (i.e.
8601
8743
  * after following replacement from symbols.js)
@@ -8630,7 +8772,7 @@ var centerSpan = function centerSpan(span, options, style) {
8630
8772
  var newOptions = options.havingBaseStyle(style);
8631
8773
  var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight;
8632
8774
  span.classes.push("delimcenter");
8633
- span.style.top = shift + "em";
8775
+ span.style.top = makeEm(shift);
8634
8776
  span.height -= shift;
8635
8777
  span.depth += shift;
8636
8778
  };
@@ -8703,20 +8845,20 @@ var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) {
8703
8845
 
8704
8846
  var makeInner = function makeInner(ch, height, options) {
8705
8847
  // Create a span with inline SVG for the inner part of a tall stacked delimiter.
8706
- var width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4].toFixed(3) : fontMetricsData["Size1-Regular"][ch.charCodeAt(0)][4].toFixed(3);
8848
+ var width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4] : fontMetricsData["Size1-Regular"][ch.charCodeAt(0)][4];
8707
8849
  var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height)));
8708
8850
  var svgNode = new SvgNode([path], {
8709
- "width": width + "em",
8710
- "height": height + "em",
8851
+ "width": makeEm(width),
8852
+ "height": makeEm(height),
8711
8853
  // Override CSS rule `.katex svg { width: 100% }`
8712
- "style": "width:" + width + "em",
8854
+ "style": "width:" + makeEm(width),
8713
8855
  "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height),
8714
8856
  "preserveAspectRatio": "xMinYMin"
8715
8857
  });
8716
8858
  var span = buildCommon.makeSvgSpan([], [svgNode], options);
8717
8859
  span.height = height;
8718
- span.style.height = height + "em";
8719
- span.style.width = width + "em";
8860
+ span.style.height = makeEm(height);
8861
+ span.style.width = makeEm(width);
8720
8862
  return {
8721
8863
  type: "elem",
8722
8864
  elem: span
@@ -8925,7 +9067,7 @@ var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum,
8925
9067
  var svg = new SvgNode([pathNode], {
8926
9068
  // Note: 1000:1 ratio of viewBox to document em width.
8927
9069
  "width": "400em",
8928
- "height": height + "em",
9070
+ "height": makeEm(height),
8929
9071
  "viewBox": "0 0 400000 " + viewBoxHeight,
8930
9072
  "preserveAspectRatio": "xMinYMin slice"
8931
9073
  });
@@ -8994,7 +9136,7 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
8994
9136
  }
8995
9137
 
8996
9138
  span.height = texHeight;
8997
- span.style.height = spanHeight + "em";
9139
+ span.style.height = makeEm(spanHeight);
8998
9140
  return {
8999
9141
  span: span,
9000
9142
  advanceWidth: advanceWidth,
@@ -9250,6 +9392,7 @@ var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, optio
9250
9392
 
9251
9393
 
9252
9394
 
9395
+
9253
9396
  // Extra data needed for the delimiter handler down below
9254
9397
  var delimiterSizes = {
9255
9398
  "\\bigl": {
@@ -9379,8 +9522,9 @@ defineFunction({
9379
9522
  }
9380
9523
 
9381
9524
  node.setAttribute("stretchy", "true");
9382
- node.setAttribute("minsize", delimiter.sizeToMaxHeight[group.size] + "em");
9383
- node.setAttribute("maxsize", delimiter.sizeToMaxHeight[group.size] + "em");
9525
+ var size = makeEm(delimiter.sizeToMaxHeight[group.size]);
9526
+ node.setAttribute("minsize", size);
9527
+ node.setAttribute("maxsize", size);
9384
9528
  return node;
9385
9529
  }
9386
9530
  });
@@ -9639,19 +9783,19 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) {
9639
9783
  scale = scale / newOptions.sizeMultiplier;
9640
9784
  var angleHeight = inner.height + inner.depth + lineWeight + clearance; // Reserve a left pad for the angle.
9641
9785
 
9642
- inner.style.paddingLeft = angleHeight / 2 + lineWeight + "em"; // Create an SVG
9786
+ inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); // Create an SVG
9643
9787
 
9644
9788
  var viewBoxHeight = Math.floor(1000 * angleHeight * scale);
9645
9789
  var path = phasePath(viewBoxHeight);
9646
9790
  var svgNode = new SvgNode([new PathNode("phase", path)], {
9647
9791
  "width": "400em",
9648
- "height": viewBoxHeight / 1000 + "em",
9792
+ "height": makeEm(viewBoxHeight / 1000),
9649
9793
  "viewBox": "0 0 400000 " + viewBoxHeight,
9650
9794
  "preserveAspectRatio": "xMinYMin slice"
9651
9795
  }); // Wrap it in a span with overflow: hidden.
9652
9796
 
9653
9797
  img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options);
9654
- img.style.height = angleHeight + "em";
9798
+ img.style.height = makeEm(angleHeight);
9655
9799
  imgShift = inner.depth + lineWeight + clearance;
9656
9800
  } else {
9657
9801
  // Add horizontal padding
@@ -9690,10 +9834,10 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) {
9690
9834
 
9691
9835
  if (/fbox|boxed|fcolorbox/.test(label)) {
9692
9836
  img.style.borderStyle = "solid";
9693
- img.style.borderWidth = ruleThickness + "em";
9837
+ img.style.borderWidth = makeEm(ruleThickness);
9694
9838
  } else if (label === "angl" && ruleThickness !== 0.049) {
9695
- img.style.borderTopWidth = ruleThickness + "em";
9696
- img.style.borderRightWidth = ruleThickness + "em";
9839
+ img.style.borderTopWidth = makeEm(ruleThickness);
9840
+ img.style.borderRightWidth = makeEm(ruleThickness);
9697
9841
  }
9698
9842
 
9699
9843
  imgShift = inner.depth + bottomPad;
@@ -10310,22 +10454,22 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
10310
10454
  // between them.
10311
10455
  if (!firstSeparator) {
10312
10456
  colSep = buildCommon.makeSpan(["arraycolsep"], []);
10313
- colSep.style.width = options.fontMetrics().doubleRuleSep + "em";
10457
+ colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep);
10314
10458
  cols.push(colSep);
10315
10459
  }
10316
10460
 
10317
10461
  if (colDescr.separator === "|" || colDescr.separator === ":") {
10318
10462
  var lineType = colDescr.separator === "|" ? "solid" : "dashed";
10319
10463
  var separator = buildCommon.makeSpan(["vertical-separator"], [], options);
10320
- separator.style.height = totalHeight + "em";
10321
- separator.style.borderRightWidth = ruleThickness + "em";
10464
+ separator.style.height = makeEm(totalHeight);
10465
+ separator.style.borderRightWidth = makeEm(ruleThickness);
10322
10466
  separator.style.borderRightStyle = lineType;
10323
- separator.style.margin = "0 -" + ruleThickness / 2 + "em";
10467
+ separator.style.margin = "0 " + makeEm(-ruleThickness / 2);
10324
10468
 
10325
10469
  var _shift = totalHeight - offset;
10326
10470
 
10327
10471
  if (_shift) {
10328
- separator.style.verticalAlign = -_shift + "em";
10472
+ separator.style.verticalAlign = makeEm(-_shift);
10329
10473
  }
10330
10474
 
10331
10475
  cols.push(separator);
@@ -10349,7 +10493,7 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
10349
10493
 
10350
10494
  if (sepwidth !== 0) {
10351
10495
  colSep = buildCommon.makeSpan(["arraycolsep"], []);
10352
- colSep.style.width = sepwidth + "em";
10496
+ colSep.style.width = makeEm(sepwidth);
10353
10497
  cols.push(colSep);
10354
10498
  }
10355
10499
  }
@@ -10387,7 +10531,7 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
10387
10531
 
10388
10532
  if (sepwidth !== 0) {
10389
10533
  colSep = buildCommon.makeSpan(["arraycolsep"], []);
10390
- colSep.style.width = sepwidth + "em";
10534
+ colSep.style.width = makeEm(sepwidth);
10391
10535
  cols.push(colSep);
10392
10536
  }
10393
10537
  }
@@ -10487,7 +10631,7 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) {
10487
10631
 
10488
10632
  var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray}
10489
10633
  : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
10490
- table.setAttribute("rowspacing", gap.toFixed(4) + "em"); // MathML table lines go only between cells.
10634
+ table.setAttribute("rowspacing", makeEm(gap)); // MathML table lines go only between cells.
10491
10635
  // To place a line on an edge we'll use <menclose>, if necessary.
10492
10636
 
10493
10637
  var menclose = "";
@@ -11564,7 +11708,7 @@ var genfrac_mathmlBuilder = function mathmlBuilder(group, options) {
11564
11708
  node.setAttribute("linethickness", "0px");
11565
11709
  } else if (group.barSize) {
11566
11710
  var ruleWidth = calculateSize(group.barSize, options);
11567
- node.setAttribute("linethickness", ruleWidth + "em");
11711
+ node.setAttribute("linethickness", makeEm(ruleWidth));
11568
11712
  }
11569
11713
 
11570
11714
  var style = adjustStyle(group.size, options.style);
@@ -12425,7 +12569,6 @@ defineFunction({
12425
12569
 
12426
12570
  if (group.totalheight.number > 0) {
12427
12571
  depth = calculateSize(group.totalheight, options) - height;
12428
- depth = Number(depth.toFixed(2));
12429
12572
  }
12430
12573
 
12431
12574
  var width = 0;
@@ -12435,15 +12578,15 @@ defineFunction({
12435
12578
  }
12436
12579
 
12437
12580
  var style = {
12438
- height: height + depth + "em"
12581
+ height: makeEm(height + depth)
12439
12582
  };
12440
12583
 
12441
12584
  if (width > 0) {
12442
- style.width = width + "em";
12585
+ style.width = makeEm(width);
12443
12586
  }
12444
12587
 
12445
12588
  if (depth > 0) {
12446
- style.verticalAlign = -depth + "em";
12589
+ style.verticalAlign = makeEm(-depth);
12447
12590
  }
12448
12591
 
12449
12592
  var node = new Img(group.src, group.alt, style);
@@ -12459,15 +12602,14 @@ defineFunction({
12459
12602
 
12460
12603
  if (group.totalheight.number > 0) {
12461
12604
  depth = calculateSize(group.totalheight, options) - height;
12462
- depth = depth.toFixed(2);
12463
- node.setAttribute("valign", "-" + depth + "em");
12605
+ node.setAttribute("valign", makeEm(-depth));
12464
12606
  }
12465
12607
 
12466
- node.setAttribute("height", height + depth + "em");
12608
+ node.setAttribute("height", makeEm(height + depth));
12467
12609
 
12468
12610
  if (group.width.number > 0) {
12469
12611
  var width = calculateSize(group.width, options);
12470
- node.setAttribute("width", width + "em");
12612
+ node.setAttribute("width", makeEm(width));
12471
12613
  }
12472
12614
 
12473
12615
  node.setAttribute("src", group.src);
@@ -12538,6 +12680,7 @@ defineFunction({
12538
12680
 
12539
12681
 
12540
12682
 
12683
+
12541
12684
  defineFunction({
12542
12685
  type: "lap",
12543
12686
  names: ["\\mathllap", "\\mathrlap", "\\mathclap"],
@@ -12577,10 +12720,10 @@ defineFunction({
12577
12720
  // This code resolved issue #1153
12578
12721
 
12579
12722
  var strut = buildCommon.makeSpan(["strut"]);
12580
- strut.style.height = node.height + node.depth + "em";
12723
+ strut.style.height = makeEm(node.height + node.depth);
12581
12724
 
12582
12725
  if (node.depth) {
12583
- strut.style.verticalAlign = -node.depth + "em";
12726
+ strut.style.verticalAlign = makeEm(-node.depth);
12584
12727
  }
12585
12728
 
12586
12729
  node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall.
@@ -12703,7 +12846,8 @@ defineFunction({
12703
12846
 
12704
12847
 
12705
12848
 
12706
- // 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
+
12707
12851
  var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift) {
12708
12852
  base = buildCommon.makeSpan([], [base]);
12709
12853
  var subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup);
@@ -12743,7 +12887,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
12743
12887
  }, {
12744
12888
  type: "elem",
12745
12889
  elem: sub.elem,
12746
- marginLeft: -slant + "em"
12890
+ marginLeft: makeEm(-slant)
12747
12891
  }, {
12748
12892
  type: "kern",
12749
12893
  size: sub.kern
@@ -12756,7 +12900,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
12756
12900
  }, {
12757
12901
  type: "elem",
12758
12902
  elem: sup.elem,
12759
- marginLeft: slant + "em"
12903
+ marginLeft: makeEm(slant)
12760
12904
  }, {
12761
12905
  type: "kern",
12762
12906
  size: options.fontMetrics().bigOpSpacing5
@@ -12777,7 +12921,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
12777
12921
  }, {
12778
12922
  type: "elem",
12779
12923
  elem: sub.elem,
12780
- marginLeft: -slant + "em"
12924
+ marginLeft: makeEm(-slant)
12781
12925
  }, {
12782
12926
  type: "kern",
12783
12927
  size: sub.kern
@@ -12801,7 +12945,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
12801
12945
  }, {
12802
12946
  type: "elem",
12803
12947
  elem: sup.elem,
12804
- marginLeft: slant + "em"
12948
+ marginLeft: makeEm(slant)
12805
12949
  }, {
12806
12950
  type: "kern",
12807
12951
  size: options.fontMetrics().bigOpSpacing5
@@ -12820,7 +12964,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
12820
12964
  // A negative margin-left was applied to the lower limit.
12821
12965
  // Avoid an overlap by placing a spacer on the left on the group.
12822
12966
  var spacer = buildCommon.makeSpan(["mspace"], [], options);
12823
- spacer.style.marginRight = slant + "em";
12967
+ spacer.style.marginRight = makeEm(slant);
12824
12968
  parts.unshift(spacer);
12825
12969
  }
12826
12970
 
@@ -12838,6 +12982,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
12838
12982
 
12839
12983
 
12840
12984
 
12985
+
12841
12986
  // Most operators have a large successor symbol, but these don't.
12842
12987
  var noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also
12843
12988
  // "supsub" since some of them (like \int) can affect super/subscripting.
@@ -12951,7 +13096,7 @@ var op_htmlBuilder = function htmlBuilder(grp, options) {
12951
13096
  } else {
12952
13097
  if (baseShift) {
12953
13098
  base.style.position = "relative";
12954
- base.style.top = baseShift + "em";
13099
+ base.style.top = makeEm(baseShift);
12955
13100
  }
12956
13101
 
12957
13102
  return base;
@@ -13541,6 +13686,23 @@ defineFunction({
13541
13686
  return node;
13542
13687
  }
13543
13688
  });
13689
+ ;// CONCATENATED MODULE: ./src/functions/relax.js
13690
+
13691
+ defineFunction({
13692
+ type: "internal",
13693
+ names: ["\\relax"],
13694
+ props: {
13695
+ numArgs: 0,
13696
+ allowedInText: true
13697
+ },
13698
+ handler: function handler(_ref) {
13699
+ var parser = _ref.parser;
13700
+ return {
13701
+ type: "internal",
13702
+ mode: parser.mode
13703
+ };
13704
+ }
13705
+ });
13544
13706
  ;// CONCATENATED MODULE: ./src/functions/rule.js
13545
13707
 
13546
13708
 
@@ -13576,9 +13738,9 @@ defineFunction({
13576
13738
  var height = calculateSize(group.height, options);
13577
13739
  var shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size
13578
13740
 
13579
- rule.style.borderRightWidth = width + "em";
13580
- rule.style.borderTopWidth = height + "em";
13581
- rule.style.bottom = shift + "em"; // Record the height and width
13741
+ rule.style.borderRightWidth = makeEm(width);
13742
+ rule.style.borderTopWidth = makeEm(height);
13743
+ rule.style.bottom = makeEm(shift); // Record the height and width
13582
13744
 
13583
13745
  rule.width = width;
13584
13746
  rule.height = height + shift;
@@ -13596,18 +13758,18 @@ defineFunction({
13596
13758
  var color = options.color && options.getColor() || "black";
13597
13759
  var rule = new mathMLTree.MathNode("mspace");
13598
13760
  rule.setAttribute("mathbackground", color);
13599
- rule.setAttribute("width", width + "em");
13600
- rule.setAttribute("height", height + "em");
13761
+ rule.setAttribute("width", makeEm(width));
13762
+ rule.setAttribute("height", makeEm(height));
13601
13763
  var wrapper = new mathMLTree.MathNode("mpadded", [rule]);
13602
13764
 
13603
13765
  if (shift >= 0) {
13604
- wrapper.setAttribute("height", "+" + shift + "em");
13766
+ wrapper.setAttribute("height", makeEm(shift));
13605
13767
  } else {
13606
- wrapper.setAttribute("height", shift + "em");
13607
- wrapper.setAttribute("depth", "+" + -shift + "em");
13768
+ wrapper.setAttribute("height", makeEm(shift));
13769
+ wrapper.setAttribute("depth", makeEm(-shift));
13608
13770
  }
13609
13771
 
13610
- wrapper.setAttribute("voffset", shift + "em");
13772
+ wrapper.setAttribute("voffset", makeEm(shift));
13611
13773
  return wrapper;
13612
13774
  }
13613
13775
  });
@@ -13617,6 +13779,7 @@ defineFunction({
13617
13779
 
13618
13780
 
13619
13781
 
13782
+
13620
13783
  function sizingGroup(value, options, baseOptions) {
13621
13784
  var inner = buildExpression(value, options, false);
13622
13785
  var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize
@@ -13678,7 +13841,7 @@ defineFunction({
13678
13841
  // that we're passing an options parameter we should be able to fix
13679
13842
  // this.
13680
13843
 
13681
- node.setAttribute("mathsize", newOptions.sizeMultiplier + "em");
13844
+ node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier));
13682
13845
  return node;
13683
13846
  }
13684
13847
  });
@@ -13802,6 +13965,7 @@ defineFunction({
13802
13965
 
13803
13966
 
13804
13967
 
13968
+
13805
13969
  defineFunction({
13806
13970
  type: "sqrt",
13807
13971
  names: ["\\sqrt"],
@@ -13860,7 +14024,7 @@ defineFunction({
13860
14024
 
13861
14025
 
13862
14026
  var imgShift = img.height - inner.height - lineClearance - ruleWidth;
13863
- inner.style.paddingLeft = advanceWidth + "em"; // Overlay the image and the argument.
14027
+ inner.style.paddingLeft = makeEm(advanceWidth); // Overlay the image and the argument.
13864
14028
 
13865
14029
  var body = buildCommon.makeVList({
13866
14030
  positionType: "firstBaseline",
@@ -13988,6 +14152,7 @@ defineFunction({
13988
14152
 
13989
14153
 
13990
14154
 
14155
+
13991
14156
  /**
13992
14157
  * Sometimes, groups perform special rules when they have superscripts or
13993
14158
  * subscripts attached to them. This function lets the `supsub` group know that
@@ -14079,7 +14244,7 @@ defineFunctionBuilders({
14079
14244
 
14080
14245
 
14081
14246
  var multiplier = options.sizeMultiplier;
14082
- var marginRight = 0.5 / metrics.ptPerEm / multiplier + "em";
14247
+ var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier);
14083
14248
  var marginLeft = null;
14084
14249
 
14085
14250
  if (subm) {
@@ -14090,7 +14255,7 @@ defineFunctionBuilders({
14090
14255
 
14091
14256
  if (base instanceof SymbolNode || isOiint) {
14092
14257
  // $FlowFixMe
14093
- marginLeft = -base.italic + "em";
14258
+ marginLeft = makeEm(-base.italic);
14094
14259
  }
14095
14260
  }
14096
14261
 
@@ -14679,6 +14844,7 @@ var functions = _functions;
14679
14844
 
14680
14845
 
14681
14846
 
14847
+
14682
14848
 
14683
14849
 
14684
14850
  ;// CONCATENATED MODULE: ./src/SourceLocation.js
@@ -15057,6 +15223,7 @@ var macros = _macros;
15057
15223
 
15058
15224
 
15059
15225
 
15226
+
15060
15227
  //////////////////////////////////////////////////////////////////////
15061
15228
  // macro tools
15062
15229
 
@@ -15434,7 +15601,7 @@ defineMacro("\\varOmega", "\\mathit{\\Omega}"); //\newcommand{\substack}[1]{\sub
15434
15601
  defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
15435
15602
  // \mkern-\thinmuskip{:}\mskip6muplus1mu\relax}
15436
15603
 
15437
- defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
15604
+ defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
15438
15605
 
15439
15606
  defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); // \def\iff{\DOTSB\;\Longleftrightarrow\;}
15440
15607
  // \def\implies{\DOTSB\;\Longrightarrow\;}
@@ -15678,7 +15845,7 @@ defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5e
15678
15845
  // We compute the corresponding \raisebox when A is rendered in \normalsize
15679
15846
  // \scriptstyle, which has a scale factor of 0.7 (see Options.js).
15680
15847
 
15681
- var latexRaiseA = fontMetricsData["Main-Regular"]["T".charCodeAt(0)][1] - 0.7 * fontMetricsData["Main-Regular"]["A".charCodeAt(0)][1] + "em";
15848
+ var latexRaiseA = makeEm(fontMetricsData["Main-Regular"]["T".charCodeAt(0)][1] - 0.7 * fontMetricsData["Main-Regular"]["A".charCodeAt(0)][1]);
15682
15849
  defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo
15683
15850
 
15684
15851
  defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
@@ -15968,8 +16135,6 @@ defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}");
15968
16135
  // List of commands that act like macros but aren't defined as a macro,
15969
16136
  // function, or symbol. Used in `isDefined`.
15970
16137
  var implicitCommands = {
15971
- "\\relax": true,
15972
- // MacroExpander.js
15973
16138
  "^": true,
15974
16139
  // Parser.js
15975
16140
  "_": true,
@@ -16340,15 +16505,13 @@ var MacroExpander = /*#__PURE__*/function () {
16340
16505
  var expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded.
16341
16506
 
16342
16507
  if (expanded instanceof Token) {
16343
- // \relax stops the expansion, but shouldn't get returned (a
16344
- // null return value couldn't get implemented as a function).
16345
16508
  // the token after \noexpand is interpreted as if its meaning
16346
16509
  // were ‘\relax’
16347
- if (expanded.text === "\\relax" || expanded.treatAsRelax) {
16348
- this.stack.pop();
16349
- } else {
16350
- return this.stack.pop(); // === expanded
16510
+ if (expanded.treatAsRelax) {
16511
+ expanded.text = "\\relax";
16351
16512
  }
16513
+
16514
+ return this.stack.pop(); // === expanded
16352
16515
  }
16353
16516
  } // Flow unable to figure out that this pathway is impossible.
16354
16517
  // https://github.com/facebook/flow/issues/4808
@@ -18103,7 +18266,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
18103
18266
  /**
18104
18267
  * Current KaTeX version
18105
18268
  */
18106
- version: "0.13.23",
18269
+ version: "0.15.0",
18107
18270
 
18108
18271
  /**
18109
18272
  * Renders the given LaTeX into an HTML+MathML combination, and adds
@@ -18122,6 +18285,11 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
18122
18285
  */
18123
18286
  ParseError: src_ParseError,
18124
18287
 
18288
+ /**
18289
+ * The shema of Settings
18290
+ */
18291
+ SETTINGS_SCHEMA: SETTINGS_SCHEMA,
18292
+
18125
18293
  /**
18126
18294
  * Parses the given LaTeX into KaTeX's internal parse tree structure,
18127
18295
  * without rendering to HTML or MathML.