katex 0.13.23 → 0.13.24

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.mjs CHANGED
@@ -892,532 +892,6 @@ class DocumentFragment {
892
892
 
893
893
  }
894
894
 
895
- /**
896
- * These objects store the data about the DOM nodes we create, as well as some
897
- * extra data. They can then be transformed into real DOM nodes with the
898
- * `toNode` function or HTML markup using `toMarkup`. They are useful for both
899
- * storing extra properties on the nodes, as well as providing a way to easily
900
- * work with the DOM.
901
- *
902
- * Similar functions for working with MathML nodes exist in mathMLTree.js.
903
- *
904
- * TODO: refactor `span` and `anchor` into common superclass when
905
- * target environments support class inheritance
906
- */
907
-
908
- /**
909
- * Create an HTML className based on a list of classes. In addition to joining
910
- * with spaces, we also remove empty classes.
911
- */
912
- var createClass = function createClass(classes) {
913
- return classes.filter(cls => cls).join(" ");
914
- };
915
-
916
- var initNode = function initNode(classes, options, style) {
917
- this.classes = classes || [];
918
- this.attributes = {};
919
- this.height = 0;
920
- this.depth = 0;
921
- this.maxFontSize = 0;
922
- this.style = style || {};
923
-
924
- if (options) {
925
- if (options.style.isTight()) {
926
- this.classes.push("mtight");
927
- }
928
-
929
- var color = options.getColor();
930
-
931
- if (color) {
932
- this.style.color = color;
933
- }
934
- }
935
- };
936
- /**
937
- * Convert into an HTML node
938
- */
939
-
940
-
941
- var toNode = function toNode(tagName) {
942
- var node = document.createElement(tagName); // Apply the class
943
-
944
- node.className = createClass(this.classes); // Apply inline styles
945
-
946
- for (var style in this.style) {
947
- if (this.style.hasOwnProperty(style)) {
948
- // $FlowFixMe Flow doesn't seem to understand span.style's type.
949
- node.style[style] = this.style[style];
950
- }
951
- } // Apply attributes
952
-
953
-
954
- for (var attr in this.attributes) {
955
- if (this.attributes.hasOwnProperty(attr)) {
956
- node.setAttribute(attr, this.attributes[attr]);
957
- }
958
- } // Append the children, also as HTML nodes
959
-
960
-
961
- for (var i = 0; i < this.children.length; i++) {
962
- node.appendChild(this.children[i].toNode());
963
- }
964
-
965
- return node;
966
- };
967
- /**
968
- * Convert into an HTML markup string
969
- */
970
-
971
-
972
- var toMarkup = function toMarkup(tagName) {
973
- var markup = "<" + tagName; // Add the class
974
-
975
- if (this.classes.length) {
976
- markup += " class=\"" + utils.escape(createClass(this.classes)) + "\"";
977
- }
978
-
979
- var styles = ""; // Add the styles, after hyphenation
980
-
981
- for (var style in this.style) {
982
- if (this.style.hasOwnProperty(style)) {
983
- styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
984
- }
985
- }
986
-
987
- if (styles) {
988
- markup += " style=\"" + utils.escape(styles) + "\"";
989
- } // Add the attributes
990
-
991
-
992
- for (var attr in this.attributes) {
993
- if (this.attributes.hasOwnProperty(attr)) {
994
- markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\"";
995
- }
996
- }
997
-
998
- markup += ">"; // Add the markup of the children, also as markup
999
-
1000
- for (var i = 0; i < this.children.length; i++) {
1001
- markup += this.children[i].toMarkup();
1002
- }
1003
-
1004
- markup += "</" + tagName + ">";
1005
- return markup;
1006
- }; // Making the type below exact with all optional fields doesn't work due to
1007
- // - https://github.com/facebook/flow/issues/4582
1008
- // - https://github.com/facebook/flow/issues/5688
1009
- // However, since *all* fields are optional, $Shape<> works as suggested in 5688
1010
- // above.
1011
- // This type does not include all CSS properties. Additional properties should
1012
- // be added as needed.
1013
-
1014
-
1015
- /**
1016
- * This node represents a span node, with a className, a list of children, and
1017
- * an inline style. It also contains information about its height, depth, and
1018
- * maxFontSize.
1019
- *
1020
- * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan
1021
- * otherwise. This typesafety is important when HTML builders access a span's
1022
- * children.
1023
- */
1024
- class Span {
1025
- constructor(classes, children, options, style) {
1026
- this.children = void 0;
1027
- this.attributes = void 0;
1028
- this.classes = void 0;
1029
- this.height = void 0;
1030
- this.depth = void 0;
1031
- this.width = void 0;
1032
- this.maxFontSize = void 0;
1033
- this.style = void 0;
1034
- initNode.call(this, classes, options, style);
1035
- this.children = children || [];
1036
- }
1037
- /**
1038
- * Sets an arbitrary attribute on the span. Warning: use this wisely. Not
1039
- * all browsers support attributes the same, and having too many custom
1040
- * attributes is probably bad.
1041
- */
1042
-
1043
-
1044
- setAttribute(attribute, value) {
1045
- this.attributes[attribute] = value;
1046
- }
1047
-
1048
- hasClass(className) {
1049
- return utils.contains(this.classes, className);
1050
- }
1051
-
1052
- toNode() {
1053
- return toNode.call(this, "span");
1054
- }
1055
-
1056
- toMarkup() {
1057
- return toMarkup.call(this, "span");
1058
- }
1059
-
1060
- }
1061
- /**
1062
- * This node represents an anchor (<a>) element with a hyperlink. See `span`
1063
- * for further details.
1064
- */
1065
-
1066
- class Anchor {
1067
- constructor(href, classes, children, options) {
1068
- this.children = void 0;
1069
- this.attributes = void 0;
1070
- this.classes = void 0;
1071
- this.height = void 0;
1072
- this.depth = void 0;
1073
- this.maxFontSize = void 0;
1074
- this.style = void 0;
1075
- initNode.call(this, classes, options);
1076
- this.children = children || [];
1077
- this.setAttribute('href', href);
1078
- }
1079
-
1080
- setAttribute(attribute, value) {
1081
- this.attributes[attribute] = value;
1082
- }
1083
-
1084
- hasClass(className) {
1085
- return utils.contains(this.classes, className);
1086
- }
1087
-
1088
- toNode() {
1089
- return toNode.call(this, "a");
1090
- }
1091
-
1092
- toMarkup() {
1093
- return toMarkup.call(this, "a");
1094
- }
1095
-
1096
- }
1097
- /**
1098
- * This node represents an image embed (<img>) element.
1099
- */
1100
-
1101
- class Img {
1102
- constructor(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
- hasClass(className) {
1117
- return utils.contains(this.classes, className);
1118
- }
1119
-
1120
- toNode() {
1121
- var node = document.createElement("img");
1122
- node.src = this.src;
1123
- node.alt = this.alt;
1124
- node.className = "mord"; // Apply inline styles
1125
-
1126
- for (var style in this.style) {
1127
- if (this.style.hasOwnProperty(style)) {
1128
- // $FlowFixMe
1129
- node.style[style] = this.style[style];
1130
- }
1131
- }
1132
-
1133
- return node;
1134
- }
1135
-
1136
- toMarkup() {
1137
- var markup = "<img src='" + this.src + " 'alt='" + this.alt + "' "; // Add the styles, after hyphenation
1138
-
1139
- var styles = "";
1140
-
1141
- for (var style in this.style) {
1142
- if (this.style.hasOwnProperty(style)) {
1143
- styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
1144
- }
1145
- }
1146
-
1147
- if (styles) {
1148
- markup += " style=\"" + utils.escape(styles) + "\"";
1149
- }
1150
-
1151
- markup += "'/>";
1152
- return markup;
1153
- }
1154
-
1155
- }
1156
- var iCombinations = {
1157
- 'î': '\u0131\u0302',
1158
- 'ï': '\u0131\u0308',
1159
- 'í': '\u0131\u0301',
1160
- // 'ī': '\u0131\u0304', // enable when we add Extended Latin
1161
- 'ì': '\u0131\u0300'
1162
- };
1163
- /**
1164
- * A symbol node contains information about a single symbol. It either renders
1165
- * to a single text node, or a span with a single text node in it, depending on
1166
- * whether it has CSS classes, styles, or needs italic correction.
1167
- */
1168
-
1169
- class SymbolNode {
1170
- constructor(text, height, depth, italic, skew, width, classes, style) {
1171
- this.text = void 0;
1172
- this.height = void 0;
1173
- this.depth = void 0;
1174
- this.italic = void 0;
1175
- this.skew = void 0;
1176
- this.width = void 0;
1177
- this.maxFontSize = void 0;
1178
- this.classes = void 0;
1179
- this.style = void 0;
1180
- this.text = text;
1181
- this.height = height || 0;
1182
- this.depth = depth || 0;
1183
- this.italic = italic || 0;
1184
- this.skew = skew || 0;
1185
- this.width = width || 0;
1186
- this.classes = classes || [];
1187
- this.style = style || {};
1188
- this.maxFontSize = 0; // Mark text from non-Latin scripts with specific classes so that we
1189
- // can specify which fonts to use. This allows us to render these
1190
- // characters with a serif font in situations where the browser would
1191
- // either default to a sans serif or render a placeholder character.
1192
- // We use CSS class names like cjk_fallback, hangul_fallback and
1193
- // brahmic_fallback. See ./unicodeScripts.js for the set of possible
1194
- // script names
1195
-
1196
- var script = scriptFromCodepoint(this.text.charCodeAt(0));
1197
-
1198
- if (script) {
1199
- this.classes.push(script + "_fallback");
1200
- }
1201
-
1202
- if (/[îïíì]/.test(this.text)) {
1203
- // add ī when we add Extended Latin
1204
- this.text = iCombinations[this.text];
1205
- }
1206
- }
1207
-
1208
- hasClass(className) {
1209
- return utils.contains(this.classes, className);
1210
- }
1211
- /**
1212
- * Creates a text node or span from a symbol node. Note that a span is only
1213
- * created if it is needed.
1214
- */
1215
-
1216
-
1217
- toNode() {
1218
- var node = document.createTextNode(this.text);
1219
- var span = null;
1220
-
1221
- if (this.italic > 0) {
1222
- span = document.createElement("span");
1223
- span.style.marginRight = this.italic + "em";
1224
- }
1225
-
1226
- if (this.classes.length > 0) {
1227
- span = span || document.createElement("span");
1228
- span.className = createClass(this.classes);
1229
- }
1230
-
1231
- for (var style in this.style) {
1232
- if (this.style.hasOwnProperty(style)) {
1233
- span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type.
1234
-
1235
- span.style[style] = this.style[style];
1236
- }
1237
- }
1238
-
1239
- if (span) {
1240
- span.appendChild(node);
1241
- return span;
1242
- } else {
1243
- return node;
1244
- }
1245
- }
1246
- /**
1247
- * Creates markup for a symbol node.
1248
- */
1249
-
1250
-
1251
- toMarkup() {
1252
- // TODO(alpert): More duplication than I'd like from
1253
- // span.prototype.toMarkup and symbolNode.prototype.toNode...
1254
- var needsSpan = false;
1255
- var markup = "<span";
1256
-
1257
- if (this.classes.length) {
1258
- needsSpan = true;
1259
- markup += " class=\"";
1260
- markup += utils.escape(createClass(this.classes));
1261
- markup += "\"";
1262
- }
1263
-
1264
- var styles = "";
1265
-
1266
- if (this.italic > 0) {
1267
- styles += "margin-right:" + this.italic + "em;";
1268
- }
1269
-
1270
- for (var style in this.style) {
1271
- if (this.style.hasOwnProperty(style)) {
1272
- styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
1273
- }
1274
- }
1275
-
1276
- if (styles) {
1277
- needsSpan = true;
1278
- markup += " style=\"" + utils.escape(styles) + "\"";
1279
- }
1280
-
1281
- var escaped = utils.escape(this.text);
1282
-
1283
- if (needsSpan) {
1284
- markup += ">";
1285
- markup += escaped;
1286
- markup += "</span>";
1287
- return markup;
1288
- } else {
1289
- return escaped;
1290
- }
1291
- }
1292
-
1293
- }
1294
- /**
1295
- * SVG nodes are used to render stretchy wide elements.
1296
- */
1297
-
1298
- class SvgNode {
1299
- constructor(children, attributes) {
1300
- this.children = void 0;
1301
- this.attributes = void 0;
1302
- this.children = children || [];
1303
- this.attributes = attributes || {};
1304
- }
1305
-
1306
- toNode() {
1307
- var svgNS = "http://www.w3.org/2000/svg";
1308
- var node = document.createElementNS(svgNS, "svg"); // Apply attributes
1309
-
1310
- for (var attr in this.attributes) {
1311
- if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
1312
- node.setAttribute(attr, this.attributes[attr]);
1313
- }
1314
- }
1315
-
1316
- for (var i = 0; i < this.children.length; i++) {
1317
- node.appendChild(this.children[i].toNode());
1318
- }
1319
-
1320
- return node;
1321
- }
1322
-
1323
- toMarkup() {
1324
- var markup = "<svg xmlns=\"http://www.w3.org/2000/svg\""; // Apply attributes
1325
-
1326
- for (var attr in this.attributes) {
1327
- if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
1328
- markup += " " + attr + "='" + this.attributes[attr] + "'";
1329
- }
1330
- }
1331
-
1332
- markup += ">";
1333
-
1334
- for (var i = 0; i < this.children.length; i++) {
1335
- markup += this.children[i].toMarkup();
1336
- }
1337
-
1338
- markup += "</svg>";
1339
- return markup;
1340
- }
1341
-
1342
- }
1343
- class PathNode {
1344
- constructor(pathName, alternate) {
1345
- this.pathName = void 0;
1346
- this.alternate = void 0;
1347
- this.pathName = pathName;
1348
- this.alternate = alternate; // Used only for \sqrt, \phase, & tall delims
1349
- }
1350
-
1351
- toNode() {
1352
- var svgNS = "http://www.w3.org/2000/svg";
1353
- var node = document.createElementNS(svgNS, "path");
1354
-
1355
- if (this.alternate) {
1356
- node.setAttribute("d", this.alternate);
1357
- } else {
1358
- node.setAttribute("d", path[this.pathName]);
1359
- }
1360
-
1361
- return node;
1362
- }
1363
-
1364
- toMarkup() {
1365
- if (this.alternate) {
1366
- return "<path d='" + this.alternate + "'/>";
1367
- } else {
1368
- return "<path d='" + path[this.pathName] + "'/>";
1369
- }
1370
- }
1371
-
1372
- }
1373
- class LineNode {
1374
- constructor(attributes) {
1375
- this.attributes = void 0;
1376
- this.attributes = attributes || {};
1377
- }
1378
-
1379
- toNode() {
1380
- var svgNS = "http://www.w3.org/2000/svg";
1381
- var node = document.createElementNS(svgNS, "line"); // Apply attributes
1382
-
1383
- for (var attr in this.attributes) {
1384
- if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
1385
- node.setAttribute(attr, this.attributes[attr]);
1386
- }
1387
- }
1388
-
1389
- return node;
1390
- }
1391
-
1392
- toMarkup() {
1393
- var markup = "<line";
1394
-
1395
- for (var attr in this.attributes) {
1396
- if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
1397
- markup += " " + attr + "='" + this.attributes[attr] + "'";
1398
- }
1399
- }
1400
-
1401
- markup += "/>";
1402
- return markup;
1403
- }
1404
-
1405
- }
1406
- function assertSymbolDomNode(group) {
1407
- if (group instanceof SymbolNode) {
1408
- return group;
1409
- } else {
1410
- throw new Error("Expected symbolNode but got " + String(group) + ".");
1411
- }
1412
- }
1413
- function assertSpan(group) {
1414
- if (group instanceof Span) {
1415
- return group;
1416
- } else {
1417
- throw new Error("Expected span<HtmlDomNode> but got " + String(group) + ".");
1418
- }
1419
- }
1420
-
1421
895
  // This file is GENERATED by buildMetrics.sh. DO NOT MODIFY.
1422
896
  var fontMetricsData = {
1423
897
  "AMS-Regular": {
@@ -3497,1660 +2971,2194 @@ var fontMetricsData = {
3497
2971
  };
3498
2972
 
3499
2973
  /**
3500
- * This file contains metrics regarding fonts and individual symbols. The sigma
3501
- * and xi variables, as well as the metricMap map contain data extracted from
3502
- * TeX, TeX font metrics, and the TTF files. These data are then exposed via the
3503
- * `metrics` variable and the getCharacterMetrics function.
2974
+ * This file contains metrics regarding fonts and individual symbols. The sigma
2975
+ * and xi variables, as well as the metricMap map contain data extracted from
2976
+ * TeX, TeX font metrics, and the TTF files. These data are then exposed via the
2977
+ * `metrics` variable and the getCharacterMetrics function.
2978
+ */
2979
+ // In TeX, there are actually three sets of dimensions, one for each of
2980
+ // textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
2981
+ // 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
2982
+ // provided in the the arrays below, in that order.
2983
+ //
2984
+ // The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
2985
+ // This was determined by running the following script:
2986
+ //
2987
+ // latex -interaction=nonstopmode \
2988
+ // '\documentclass{article}\usepackage{amsmath}\begin{document}' \
2989
+ // '$a$ \expandafter\show\the\textfont2' \
2990
+ // '\expandafter\show\the\scriptfont2' \
2991
+ // '\expandafter\show\the\scriptscriptfont2' \
2992
+ // '\stop'
2993
+ //
2994
+ // The metrics themselves were retreived using the following commands:
2995
+ //
2996
+ // tftopl cmsy10
2997
+ // tftopl cmsy7
2998
+ // tftopl cmsy5
2999
+ //
3000
+ // The output of each of these commands is quite lengthy. The only part we
3001
+ // care about is the FONTDIMEN section. Each value is measured in EMs.
3002
+ var sigmasAndXis = {
3003
+ slant: [0.250, 0.250, 0.250],
3004
+ // sigma1
3005
+ space: [0.000, 0.000, 0.000],
3006
+ // sigma2
3007
+ stretch: [0.000, 0.000, 0.000],
3008
+ // sigma3
3009
+ shrink: [0.000, 0.000, 0.000],
3010
+ // sigma4
3011
+ xHeight: [0.431, 0.431, 0.431],
3012
+ // sigma5
3013
+ quad: [1.000, 1.171, 1.472],
3014
+ // sigma6
3015
+ extraSpace: [0.000, 0.000, 0.000],
3016
+ // sigma7
3017
+ num1: [0.677, 0.732, 0.925],
3018
+ // sigma8
3019
+ num2: [0.394, 0.384, 0.387],
3020
+ // sigma9
3021
+ num3: [0.444, 0.471, 0.504],
3022
+ // sigma10
3023
+ denom1: [0.686, 0.752, 1.025],
3024
+ // sigma11
3025
+ denom2: [0.345, 0.344, 0.532],
3026
+ // sigma12
3027
+ sup1: [0.413, 0.503, 0.504],
3028
+ // sigma13
3029
+ sup2: [0.363, 0.431, 0.404],
3030
+ // sigma14
3031
+ sup3: [0.289, 0.286, 0.294],
3032
+ // sigma15
3033
+ sub1: [0.150, 0.143, 0.200],
3034
+ // sigma16
3035
+ sub2: [0.247, 0.286, 0.400],
3036
+ // sigma17
3037
+ supDrop: [0.386, 0.353, 0.494],
3038
+ // sigma18
3039
+ subDrop: [0.050, 0.071, 0.100],
3040
+ // sigma19
3041
+ delim1: [2.390, 1.700, 1.980],
3042
+ // sigma20
3043
+ delim2: [1.010, 1.157, 1.420],
3044
+ // sigma21
3045
+ axisHeight: [0.250, 0.250, 0.250],
3046
+ // sigma22
3047
+ // These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
3048
+ // they correspond to the font parameters of the extension fonts (family 3).
3049
+ // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
3050
+ // match cmex7, we'd use cmex7.tfm values for script and scriptscript
3051
+ // values.
3052
+ defaultRuleThickness: [0.04, 0.049, 0.049],
3053
+ // xi8; cmex7: 0.049
3054
+ bigOpSpacing1: [0.111, 0.111, 0.111],
3055
+ // xi9
3056
+ bigOpSpacing2: [0.166, 0.166, 0.166],
3057
+ // xi10
3058
+ bigOpSpacing3: [0.2, 0.2, 0.2],
3059
+ // xi11
3060
+ bigOpSpacing4: [0.6, 0.611, 0.611],
3061
+ // xi12; cmex7: 0.611
3062
+ bigOpSpacing5: [0.1, 0.143, 0.143],
3063
+ // xi13; cmex7: 0.143
3064
+ // The \sqrt rule width is taken from the height of the surd character.
3065
+ // Since we use the same font at all sizes, this thickness doesn't scale.
3066
+ sqrtRuleThickness: [0.04, 0.04, 0.04],
3067
+ // This value determines how large a pt is, for metrics which are defined
3068
+ // in terms of pts.
3069
+ // This value is also used in katex.less; if you change it make sure the
3070
+ // values match.
3071
+ ptPerEm: [10.0, 10.0, 10.0],
3072
+ // The space between adjacent `|` columns in an array definition. From
3073
+ // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
3074
+ doubleRuleSep: [0.2, 0.2, 0.2],
3075
+ // The width of separator lines in {array} environments. From
3076
+ // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
3077
+ arrayRuleWidth: [0.04, 0.04, 0.04],
3078
+ // Two values from LaTeX source2e:
3079
+ fboxsep: [0.3, 0.3, 0.3],
3080
+ // 3 pt / ptPerEm
3081
+ fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm
3082
+
3083
+ }; // This map contains a mapping from font name and character code to character
3084
+ // should have Latin-1 and Cyrillic characters, but may not depending on the
3085
+ // operating system. The metrics do not account for extra height from the
3086
+ // accents. In the case of Cyrillic characters which have both ascenders and
3087
+ // descenders we prefer approximations with ascenders, primarily to prevent
3088
+ // the fraction bar or root line from intersecting the glyph.
3089
+ // TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
3090
+
3091
+ var extraCharacterMap = {
3092
+ // Latin-1
3093
+ 'Å': 'A',
3094
+ 'Ð': 'D',
3095
+ 'Þ': 'o',
3096
+ 'å': 'a',
3097
+ 'ð': 'd',
3098
+ 'þ': 'o',
3099
+ // Cyrillic
3100
+ 'А': 'A',
3101
+ 'Б': 'B',
3102
+ 'В': 'B',
3103
+ 'Г': 'F',
3104
+ 'Д': 'A',
3105
+ 'Е': 'E',
3106
+ 'Ж': 'K',
3107
+ 'З': '3',
3108
+ 'И': 'N',
3109
+ 'Й': 'N',
3110
+ 'К': 'K',
3111
+ 'Л': 'N',
3112
+ 'М': 'M',
3113
+ 'Н': 'H',
3114
+ 'О': 'O',
3115
+ 'П': 'N',
3116
+ 'Р': 'P',
3117
+ 'С': 'C',
3118
+ 'Т': 'T',
3119
+ 'У': 'y',
3120
+ 'Ф': 'O',
3121
+ 'Х': 'X',
3122
+ 'Ц': 'U',
3123
+ 'Ч': 'h',
3124
+ 'Ш': 'W',
3125
+ 'Щ': 'W',
3126
+ 'Ъ': 'B',
3127
+ 'Ы': 'X',
3128
+ 'Ь': 'B',
3129
+ 'Э': '3',
3130
+ 'Ю': 'X',
3131
+ 'Я': 'R',
3132
+ 'а': 'a',
3133
+ 'б': 'b',
3134
+ 'в': 'a',
3135
+ 'г': 'r',
3136
+ 'д': 'y',
3137
+ 'е': 'e',
3138
+ 'ж': 'm',
3139
+ 'з': 'e',
3140
+ 'и': 'n',
3141
+ 'й': 'n',
3142
+ 'к': 'n',
3143
+ 'л': 'n',
3144
+ 'м': 'm',
3145
+ 'н': 'n',
3146
+ 'о': 'o',
3147
+ 'п': 'n',
3148
+ 'р': 'p',
3149
+ 'с': 'c',
3150
+ 'т': 'o',
3151
+ 'у': 'y',
3152
+ 'ф': 'b',
3153
+ 'х': 'x',
3154
+ 'ц': 'n',
3155
+ 'ч': 'n',
3156
+ 'ш': 'w',
3157
+ 'щ': 'w',
3158
+ 'ъ': 'a',
3159
+ 'ы': 'm',
3160
+ 'ь': 'a',
3161
+ 'э': 'e',
3162
+ 'ю': 'm',
3163
+ 'я': 'r'
3164
+ };
3165
+
3166
+ /**
3167
+ * This function adds new font metrics to default metricMap
3168
+ * It can also override existing metrics
3169
+ */
3170
+ function setFontMetrics(fontName, metrics) {
3171
+ fontMetricsData[fontName] = metrics;
3172
+ }
3173
+ /**
3174
+ * This function is a convenience function for looking up information in the
3175
+ * metricMap table. It takes a character as a string, and a font.
3176
+ *
3177
+ * Note: the `width` property may be undefined if fontMetricsData.js wasn't
3178
+ * built using `Make extended_metrics`.
3179
+ */
3180
+
3181
+ function getCharacterMetrics(character, font, mode) {
3182
+ if (!fontMetricsData[font]) {
3183
+ throw new Error("Font metrics not found for font: " + font + ".");
3184
+ }
3185
+
3186
+ var ch = character.charCodeAt(0);
3187
+ var metrics = fontMetricsData[font][ch];
3188
+
3189
+ if (!metrics && character[0] in extraCharacterMap) {
3190
+ ch = extraCharacterMap[character[0]].charCodeAt(0);
3191
+ metrics = fontMetricsData[font][ch];
3192
+ }
3193
+
3194
+ if (!metrics && mode === 'text') {
3195
+ // We don't typically have font metrics for Asian scripts.
3196
+ // But since we support them in text mode, we need to return
3197
+ // some sort of metrics.
3198
+ // So if the character is in a script we support but we
3199
+ // don't have metrics for it, just use the metrics for
3200
+ // the Latin capital letter M. This is close enough because
3201
+ // we (currently) only care about the height of the glpyh
3202
+ // not its width.
3203
+ if (supportedCodepoint(ch)) {
3204
+ metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M'
3205
+ }
3206
+ }
3207
+
3208
+ if (metrics) {
3209
+ return {
3210
+ depth: metrics[0],
3211
+ height: metrics[1],
3212
+ italic: metrics[2],
3213
+ skew: metrics[3],
3214
+ width: metrics[4]
3215
+ };
3216
+ }
3217
+ }
3218
+ var fontMetricsBySizeIndex = {};
3219
+ /**
3220
+ * Get the font metrics for a given size.
3221
+ */
3222
+
3223
+ function getGlobalMetrics(size) {
3224
+ var sizeIndex;
3225
+
3226
+ if (size >= 5) {
3227
+ sizeIndex = 0;
3228
+ } else if (size >= 3) {
3229
+ sizeIndex = 1;
3230
+ } else {
3231
+ sizeIndex = 2;
3232
+ }
3233
+
3234
+ if (!fontMetricsBySizeIndex[sizeIndex]) {
3235
+ var metrics = fontMetricsBySizeIndex[sizeIndex] = {
3236
+ cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18
3237
+ };
3238
+
3239
+ for (var key in sigmasAndXis) {
3240
+ if (sigmasAndXis.hasOwnProperty(key)) {
3241
+ metrics[key] = sigmasAndXis[key][sizeIndex];
3242
+ }
3243
+ }
3244
+ }
3245
+
3246
+ return fontMetricsBySizeIndex[sizeIndex];
3247
+ }
3248
+
3249
+ /**
3250
+ * This file contains information about the options that the Parser carries
3251
+ * around with it while parsing. Data is held in an `Options` object, and when
3252
+ * recursing, a new `Options` object can be created with the `.with*` and
3253
+ * `.reset` functions.
3254
+ */
3255
+ var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize].
3256
+ // The size mappings are taken from TeX with \normalsize=10pt.
3257
+ [1, 1, 1], // size1: [5, 5, 5] \tiny
3258
+ [2, 1, 1], // size2: [6, 5, 5]
3259
+ [3, 1, 1], // size3: [7, 5, 5] \scriptsize
3260
+ [4, 2, 1], // size4: [8, 6, 5] \footnotesize
3261
+ [5, 2, 1], // size5: [9, 6, 5] \small
3262
+ [6, 3, 1], // size6: [10, 7, 5] \normalsize
3263
+ [7, 4, 2], // size7: [12, 8, 6] \large
3264
+ [8, 6, 3], // size8: [14.4, 10, 7] \Large
3265
+ [9, 7, 6], // size9: [17.28, 12, 10] \LARGE
3266
+ [10, 8, 7], // size10: [20.74, 14.4, 12] \huge
3267
+ [11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE
3268
+ ];
3269
+ var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if
3270
+ // you change size indexes, change that function.
3271
+ 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
3272
+
3273
+ var sizeAtStyle = function sizeAtStyle(size, style) {
3274
+ return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
3275
+ }; // In these types, "" (empty string) means "no change".
3276
+
3277
+
3278
+ /**
3279
+ * This is the main options class. It contains the current style, size, color,
3280
+ * and font.
3281
+ *
3282
+ * Options objects should not be modified. To create a new Options with
3283
+ * different properties, call a `.having*` method.
3284
+ */
3285
+ class Options {
3286
+ // A font family applies to a group of fonts (i.e. SansSerif), while a font
3287
+ // represents a specific font (i.e. SansSerif Bold).
3288
+ // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm
3289
+
3290
+ /**
3291
+ * The base size index.
3292
+ */
3293
+ constructor(data) {
3294
+ this.style = void 0;
3295
+ this.color = void 0;
3296
+ this.size = void 0;
3297
+ this.textSize = void 0;
3298
+ this.phantom = void 0;
3299
+ this.font = void 0;
3300
+ this.fontFamily = void 0;
3301
+ this.fontWeight = void 0;
3302
+ this.fontShape = void 0;
3303
+ this.sizeMultiplier = void 0;
3304
+ this.maxSize = void 0;
3305
+ this.minRuleThickness = void 0;
3306
+ this._fontMetrics = void 0;
3307
+ this.style = data.style;
3308
+ this.color = data.color;
3309
+ this.size = data.size || Options.BASESIZE;
3310
+ this.textSize = data.textSize || this.size;
3311
+ this.phantom = !!data.phantom;
3312
+ this.font = data.font || "";
3313
+ this.fontFamily = data.fontFamily || "";
3314
+ this.fontWeight = data.fontWeight || '';
3315
+ this.fontShape = data.fontShape || '';
3316
+ this.sizeMultiplier = sizeMultipliers[this.size - 1];
3317
+ this.maxSize = data.maxSize;
3318
+ this.minRuleThickness = data.minRuleThickness;
3319
+ this._fontMetrics = undefined;
3320
+ }
3321
+ /**
3322
+ * Returns a new options object with the same properties as "this". Properties
3323
+ * from "extension" will be copied to the new options object.
3324
+ */
3325
+
3326
+
3327
+ extend(extension) {
3328
+ var data = {
3329
+ style: this.style,
3330
+ size: this.size,
3331
+ textSize: this.textSize,
3332
+ color: this.color,
3333
+ phantom: this.phantom,
3334
+ font: this.font,
3335
+ fontFamily: this.fontFamily,
3336
+ fontWeight: this.fontWeight,
3337
+ fontShape: this.fontShape,
3338
+ maxSize: this.maxSize,
3339
+ minRuleThickness: this.minRuleThickness
3340
+ };
3341
+
3342
+ for (var key in extension) {
3343
+ if (extension.hasOwnProperty(key)) {
3344
+ data[key] = extension[key];
3345
+ }
3346
+ }
3347
+
3348
+ return new Options(data);
3349
+ }
3350
+ /**
3351
+ * Return an options object with the given style. If `this.style === style`,
3352
+ * returns `this`.
3353
+ */
3354
+
3355
+
3356
+ havingStyle(style) {
3357
+ if (this.style === style) {
3358
+ return this;
3359
+ } else {
3360
+ return this.extend({
3361
+ style: style,
3362
+ size: sizeAtStyle(this.textSize, style)
3363
+ });
3364
+ }
3365
+ }
3366
+ /**
3367
+ * Return an options object with a cramped version of the current style. If
3368
+ * the current style is cramped, returns `this`.
3369
+ */
3370
+
3371
+
3372
+ havingCrampedStyle() {
3373
+ return this.havingStyle(this.style.cramp());
3374
+ }
3375
+ /**
3376
+ * Return an options object with the given size and in at least `\textstyle`.
3377
+ * Returns `this` if appropriate.
3378
+ */
3379
+
3380
+
3381
+ havingSize(size) {
3382
+ if (this.size === size && this.textSize === size) {
3383
+ return this;
3384
+ } else {
3385
+ return this.extend({
3386
+ style: this.style.text(),
3387
+ size: size,
3388
+ textSize: size,
3389
+ sizeMultiplier: sizeMultipliers[size - 1]
3390
+ });
3391
+ }
3392
+ }
3393
+ /**
3394
+ * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
3395
+ * changes to at least `\textstyle`.
3396
+ */
3397
+
3398
+
3399
+ havingBaseStyle(style) {
3400
+ style = style || this.style.text();
3401
+ var wantSize = sizeAtStyle(Options.BASESIZE, style);
3402
+
3403
+ if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) {
3404
+ return this;
3405
+ } else {
3406
+ return this.extend({
3407
+ style: style,
3408
+ size: wantSize
3409
+ });
3410
+ }
3411
+ }
3412
+ /**
3413
+ * Remove the effect of sizing changes such as \Huge.
3414
+ * Keep the effect of the current style, such as \scriptstyle.
3415
+ */
3416
+
3417
+
3418
+ havingBaseSizing() {
3419
+ var size;
3420
+
3421
+ switch (this.style.id) {
3422
+ case 4:
3423
+ case 5:
3424
+ size = 3; // normalsize in scriptstyle
3425
+
3426
+ break;
3427
+
3428
+ case 6:
3429
+ case 7:
3430
+ size = 1; // normalsize in scriptscriptstyle
3431
+
3432
+ break;
3433
+
3434
+ default:
3435
+ size = 6;
3436
+ // normalsize in textstyle or displaystyle
3437
+ }
3438
+
3439
+ return this.extend({
3440
+ style: this.style.text(),
3441
+ size: size
3442
+ });
3443
+ }
3444
+ /**
3445
+ * Create a new options object with the given color.
3446
+ */
3447
+
3448
+
3449
+ withColor(color) {
3450
+ return this.extend({
3451
+ color: color
3452
+ });
3453
+ }
3454
+ /**
3455
+ * Create a new options object with "phantom" set to true.
3456
+ */
3457
+
3458
+
3459
+ withPhantom() {
3460
+ return this.extend({
3461
+ phantom: true
3462
+ });
3463
+ }
3464
+ /**
3465
+ * Creates a new options object with the given math font or old text font.
3466
+ * @type {[type]}
3467
+ */
3468
+
3469
+
3470
+ withFont(font) {
3471
+ return this.extend({
3472
+ font
3473
+ });
3474
+ }
3475
+ /**
3476
+ * Create a new options objects with the given fontFamily.
3477
+ */
3478
+
3479
+
3480
+ withTextFontFamily(fontFamily) {
3481
+ return this.extend({
3482
+ fontFamily,
3483
+ font: ""
3484
+ });
3485
+ }
3486
+ /**
3487
+ * Creates a new options object with the given font weight
3488
+ */
3489
+
3490
+
3491
+ withTextFontWeight(fontWeight) {
3492
+ return this.extend({
3493
+ fontWeight,
3494
+ font: ""
3495
+ });
3496
+ }
3497
+ /**
3498
+ * Creates a new options object with the given font weight
3499
+ */
3500
+
3501
+
3502
+ withTextFontShape(fontShape) {
3503
+ return this.extend({
3504
+ fontShape,
3505
+ font: ""
3506
+ });
3507
+ }
3508
+ /**
3509
+ * Return the CSS sizing classes required to switch from enclosing options
3510
+ * `oldOptions` to `this`. Returns an array of classes.
3511
+ */
3512
+
3513
+
3514
+ sizingClasses(oldOptions) {
3515
+ if (oldOptions.size !== this.size) {
3516
+ return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
3517
+ } else {
3518
+ return [];
3519
+ }
3520
+ }
3521
+ /**
3522
+ * Return the CSS sizing classes required to switch to the base size. Like
3523
+ * `this.havingSize(BASESIZE).sizingClasses(this)`.
3524
+ */
3525
+
3526
+
3527
+ baseSizingClasses() {
3528
+ if (this.size !== Options.BASESIZE) {
3529
+ return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
3530
+ } else {
3531
+ return [];
3532
+ }
3533
+ }
3534
+ /**
3535
+ * Return the font metrics for this size.
3536
+ */
3537
+
3538
+
3539
+ fontMetrics() {
3540
+ if (!this._fontMetrics) {
3541
+ this._fontMetrics = getGlobalMetrics(this.size);
3542
+ }
3543
+
3544
+ return this._fontMetrics;
3545
+ }
3546
+ /**
3547
+ * Gets the CSS color of the current options object
3548
+ */
3549
+
3550
+
3551
+ getColor() {
3552
+ if (this.phantom) {
3553
+ return "transparent";
3554
+ } else {
3555
+ return this.color;
3556
+ }
3557
+ }
3558
+
3559
+ }
3560
+
3561
+ Options.BASESIZE = 6;
3562
+
3563
+ /**
3564
+ * This file does conversion between units. In particular, it provides
3565
+ * calculateSize to convert other units into ems.
3566
+ */
3567
+ // Thus, multiplying a length by this number converts the length from units
3568
+ // into pts. Dividing the result by ptPerEm gives the number of ems
3569
+ // *assuming* a font size of ptPerEm (normal size, normal style).
3570
+
3571
+ var ptPerUnit = {
3572
+ // https://en.wikibooks.org/wiki/LaTeX/Lengths and
3573
+ // https://tex.stackexchange.com/a/8263
3574
+ "pt": 1,
3575
+ // TeX point
3576
+ "mm": 7227 / 2540,
3577
+ // millimeter
3578
+ "cm": 7227 / 254,
3579
+ // centimeter
3580
+ "in": 72.27,
3581
+ // inch
3582
+ "bp": 803 / 800,
3583
+ // big (PostScript) points
3584
+ "pc": 12,
3585
+ // pica
3586
+ "dd": 1238 / 1157,
3587
+ // didot
3588
+ "cc": 14856 / 1157,
3589
+ // cicero (12 didot)
3590
+ "nd": 685 / 642,
3591
+ // new didot
3592
+ "nc": 1370 / 107,
3593
+ // new cicero (12 new didot)
3594
+ "sp": 1 / 65536,
3595
+ // scaled point (TeX's internal smallest unit)
3596
+ // https://tex.stackexchange.com/a/41371
3597
+ "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX
3598
+
3599
+ }; // Dictionary of relative units, for fast validity testing.
3600
+
3601
+ var relativeUnit = {
3602
+ "ex": true,
3603
+ "em": true,
3604
+ "mu": true
3605
+ };
3606
+
3607
+ /**
3608
+ * Determine whether the specified unit (either a string defining the unit
3609
+ * or a "size" parse node containing a unit field) is valid.
3610
+ */
3611
+ var validUnit = function validUnit(unit) {
3612
+ if (typeof unit !== "string") {
3613
+ unit = unit.unit;
3614
+ }
3615
+
3616
+ return unit in ptPerUnit || unit in relativeUnit || unit === "ex";
3617
+ };
3618
+ /*
3619
+ * Convert a "size" parse node (with numeric "number" and string "unit" fields,
3620
+ * as parsed by functions.js argType "size") into a CSS em value for the
3621
+ * current style/scale. `options` gives the current options.
3622
+ */
3623
+
3624
+ var calculateSize = function calculateSize(sizeValue, options) {
3625
+ var scale;
3626
+
3627
+ if (sizeValue.unit in ptPerUnit) {
3628
+ // Absolute units
3629
+ scale = ptPerUnit[sizeValue.unit] // Convert unit to pt
3630
+ / options.fontMetrics().ptPerEm // Convert pt to CSS em
3631
+ / options.sizeMultiplier; // Unscale to make absolute units
3632
+ } else if (sizeValue.unit === "mu") {
3633
+ // `mu` units scale with scriptstyle/scriptscriptstyle.
3634
+ scale = options.fontMetrics().cssEmPerMu;
3635
+ } else {
3636
+ // Other relative units always refer to the *textstyle* font
3637
+ // in the current size.
3638
+ var unitOptions;
3639
+
3640
+ if (options.style.isTight()) {
3641
+ // isTight() means current style is script/scriptscript.
3642
+ unitOptions = options.havingStyle(options.style.text());
3643
+ } else {
3644
+ unitOptions = options;
3645
+ } // TODO: In TeX these units are relative to the quad of the current
3646
+ // *text* font, e.g. cmr10. KaTeX instead uses values from the
3647
+ // comparably-sized *Computer Modern symbol* font. At 10pt, these
3648
+ // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
3649
+ // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
3650
+ // TeX \showlists shows a kern of 1.13889 * fontsize;
3651
+ // KaTeX shows a kern of 1.171 * fontsize.
3652
+
3653
+
3654
+ if (sizeValue.unit === "ex") {
3655
+ scale = unitOptions.fontMetrics().xHeight;
3656
+ } else if (sizeValue.unit === "em") {
3657
+ scale = unitOptions.fontMetrics().quad;
3658
+ } else {
3659
+ throw new ParseError("Invalid unit: '" + sizeValue.unit + "'");
3660
+ }
3661
+
3662
+ if (unitOptions !== options) {
3663
+ scale *= unitOptions.sizeMultiplier / options.sizeMultiplier;
3664
+ }
3665
+ }
3666
+
3667
+ return Math.min(sizeValue.number * scale, options.maxSize);
3668
+ };
3669
+ /**
3670
+ * Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See
3671
+ * https://github.com/KaTeX/KaTeX/pull/2460.
3504
3672
  */
3505
- // In TeX, there are actually three sets of dimensions, one for each of
3506
- // textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
3507
- // 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
3508
- // provided in the the arrays below, in that order.
3509
- //
3510
- // The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
3511
- // This was determined by running the following script:
3512
- //
3513
- // latex -interaction=nonstopmode \
3514
- // '\documentclass{article}\usepackage{amsmath}\begin{document}' \
3515
- // '$a$ \expandafter\show\the\textfont2' \
3516
- // '\expandafter\show\the\scriptfont2' \
3517
- // '\expandafter\show\the\scriptscriptfont2' \
3518
- // '\stop'
3519
- //
3520
- // The metrics themselves were retreived using the following commands:
3521
- //
3522
- // tftopl cmsy10
3523
- // tftopl cmsy7
3524
- // tftopl cmsy5
3525
- //
3526
- // The output of each of these commands is quite lengthy. The only part we
3527
- // care about is the FONTDIMEN section. Each value is measured in EMs.
3528
- var sigmasAndXis = {
3529
- slant: [0.250, 0.250, 0.250],
3530
- // sigma1
3531
- space: [0.000, 0.000, 0.000],
3532
- // sigma2
3533
- stretch: [0.000, 0.000, 0.000],
3534
- // sigma3
3535
- shrink: [0.000, 0.000, 0.000],
3536
- // sigma4
3537
- xHeight: [0.431, 0.431, 0.431],
3538
- // sigma5
3539
- quad: [1.000, 1.171, 1.472],
3540
- // sigma6
3541
- extraSpace: [0.000, 0.000, 0.000],
3542
- // sigma7
3543
- num1: [0.677, 0.732, 0.925],
3544
- // sigma8
3545
- num2: [0.394, 0.384, 0.387],
3546
- // sigma9
3547
- num3: [0.444, 0.471, 0.504],
3548
- // sigma10
3549
- denom1: [0.686, 0.752, 1.025],
3550
- // sigma11
3551
- denom2: [0.345, 0.344, 0.532],
3552
- // sigma12
3553
- sup1: [0.413, 0.503, 0.504],
3554
- // sigma13
3555
- sup2: [0.363, 0.431, 0.404],
3556
- // sigma14
3557
- sup3: [0.289, 0.286, 0.294],
3558
- // sigma15
3559
- sub1: [0.150, 0.143, 0.200],
3560
- // sigma16
3561
- sub2: [0.247, 0.286, 0.400],
3562
- // sigma17
3563
- supDrop: [0.386, 0.353, 0.494],
3564
- // sigma18
3565
- subDrop: [0.050, 0.071, 0.100],
3566
- // sigma19
3567
- delim1: [2.390, 1.700, 1.980],
3568
- // sigma20
3569
- delim2: [1.010, 1.157, 1.420],
3570
- // sigma21
3571
- axisHeight: [0.250, 0.250, 0.250],
3572
- // sigma22
3573
- // These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
3574
- // they correspond to the font parameters of the extension fonts (family 3).
3575
- // See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
3576
- // match cmex7, we'd use cmex7.tfm values for script and scriptscript
3577
- // values.
3578
- defaultRuleThickness: [0.04, 0.049, 0.049],
3579
- // xi8; cmex7: 0.049
3580
- bigOpSpacing1: [0.111, 0.111, 0.111],
3581
- // xi9
3582
- bigOpSpacing2: [0.166, 0.166, 0.166],
3583
- // xi10
3584
- bigOpSpacing3: [0.2, 0.2, 0.2],
3585
- // xi11
3586
- bigOpSpacing4: [0.6, 0.611, 0.611],
3587
- // xi12; cmex7: 0.611
3588
- bigOpSpacing5: [0.1, 0.143, 0.143],
3589
- // xi13; cmex7: 0.143
3590
- // The \sqrt rule width is taken from the height of the surd character.
3591
- // Since we use the same font at all sizes, this thickness doesn't scale.
3592
- sqrtRuleThickness: [0.04, 0.04, 0.04],
3593
- // This value determines how large a pt is, for metrics which are defined
3594
- // in terms of pts.
3595
- // This value is also used in katex.less; if you change it make sure the
3596
- // values match.
3597
- ptPerEm: [10.0, 10.0, 10.0],
3598
- // The space between adjacent `|` columns in an array definition. From
3599
- // `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
3600
- doubleRuleSep: [0.2, 0.2, 0.2],
3601
- // The width of separator lines in {array} environments. From
3602
- // `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
3603
- arrayRuleWidth: [0.04, 0.04, 0.04],
3604
- // Two values from LaTeX source2e:
3605
- fboxsep: [0.3, 0.3, 0.3],
3606
- // 3 pt / ptPerEm
3607
- fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm
3608
3673
 
3609
- }; // This map contains a mapping from font name and character code to character
3610
- // should have Latin-1 and Cyrillic characters, but may not depending on the
3611
- // operating system. The metrics do not account for extra height from the
3612
- // accents. In the case of Cyrillic characters which have both ascenders and
3613
- // descenders we prefer approximations with ascenders, primarily to prevent
3614
- // the fraction bar or root line from intersecting the glyph.
3615
- // TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
3616
-
3617
- var extraCharacterMap = {
3618
- // Latin-1
3619
- 'Å': 'A',
3620
- 'Ð': 'D',
3621
- 'Þ': 'o',
3622
- 'å': 'a',
3623
- 'ð': 'd',
3624
- 'þ': 'o',
3625
- // Cyrillic
3626
- 'А': 'A',
3627
- 'Б': 'B',
3628
- 'В': 'B',
3629
- 'Г': 'F',
3630
- 'Д': 'A',
3631
- 'Е': 'E',
3632
- 'Ж': 'K',
3633
- 'З': '3',
3634
- 'И': 'N',
3635
- 'Й': 'N',
3636
- 'К': 'K',
3637
- 'Л': 'N',
3638
- 'М': 'M',
3639
- 'Н': 'H',
3640
- 'О': 'O',
3641
- 'П': 'N',
3642
- 'Р': 'P',
3643
- 'С': 'C',
3644
- 'Т': 'T',
3645
- 'У': 'y',
3646
- 'Ф': 'O',
3647
- 'Х': 'X',
3648
- 'Ц': 'U',
3649
- 'Ч': 'h',
3650
- 'Ш': 'W',
3651
- 'Щ': 'W',
3652
- 'Ъ': 'B',
3653
- 'Ы': 'X',
3654
- 'Ь': 'B',
3655
- 'Э': '3',
3656
- 'Ю': 'X',
3657
- 'Я': 'R',
3658
- 'а': 'a',
3659
- 'б': 'b',
3660
- 'в': 'a',
3661
- 'г': 'r',
3662
- 'д': 'y',
3663
- 'е': 'e',
3664
- 'ж': 'm',
3665
- 'з': 'e',
3666
- 'и': 'n',
3667
- 'й': 'n',
3668
- 'к': 'n',
3669
- 'л': 'n',
3670
- 'м': 'm',
3671
- 'н': 'n',
3672
- 'о': 'o',
3673
- 'п': 'n',
3674
- 'р': 'p',
3675
- 'с': 'c',
3676
- 'т': 'o',
3677
- 'у': 'y',
3678
- 'ф': 'b',
3679
- 'х': 'x',
3680
- 'ц': 'n',
3681
- 'ч': 'n',
3682
- 'ш': 'w',
3683
- 'щ': 'w',
3684
- 'ъ': 'a',
3685
- 'ы': 'm',
3686
- 'ь': 'a',
3687
- 'э': 'e',
3688
- 'ю': 'm',
3689
- 'я': 'r'
3674
+ var makeEm = function makeEm(n) {
3675
+ return +n.toFixed(4) + "em";
3690
3676
  };
3691
3677
 
3692
3678
  /**
3693
- * This function adds new font metrics to default metricMap
3694
- * It can also override existing metrics
3679
+ * These objects store the data about the DOM nodes we create, as well as some
3680
+ * extra data. They can then be transformed into real DOM nodes with the
3681
+ * `toNode` function or HTML markup using `toMarkup`. They are useful for both
3682
+ * storing extra properties on the nodes, as well as providing a way to easily
3683
+ * work with the DOM.
3684
+ *
3685
+ * Similar functions for working with MathML nodes exist in mathMLTree.js.
3686
+ *
3687
+ * TODO: refactor `span` and `anchor` into common superclass when
3688
+ * target environments support class inheritance
3695
3689
  */
3696
- function setFontMetrics(fontName, metrics) {
3697
- fontMetricsData[fontName] = metrics;
3698
- }
3690
+
3699
3691
  /**
3700
- * This function is a convenience function for looking up information in the
3701
- * metricMap table. It takes a character as a string, and a font.
3702
- *
3703
- * Note: the `width` property may be undefined if fontMetricsData.js wasn't
3704
- * built using `Make extended_metrics`.
3692
+ * Create an HTML className based on a list of classes. In addition to joining
3693
+ * with spaces, we also remove empty classes.
3705
3694
  */
3695
+ var createClass = function createClass(classes) {
3696
+ return classes.filter(cls => cls).join(" ");
3697
+ };
3706
3698
 
3707
- function getCharacterMetrics(character, font, mode) {
3708
- if (!fontMetricsData[font]) {
3709
- throw new Error("Font metrics not found for font: " + font + ".");
3710
- }
3699
+ var initNode = function initNode(classes, options, style) {
3700
+ this.classes = classes || [];
3701
+ this.attributes = {};
3702
+ this.height = 0;
3703
+ this.depth = 0;
3704
+ this.maxFontSize = 0;
3705
+ this.style = style || {};
3711
3706
 
3712
- var ch = character.charCodeAt(0);
3713
- var metrics = fontMetricsData[font][ch];
3707
+ if (options) {
3708
+ if (options.style.isTight()) {
3709
+ this.classes.push("mtight");
3710
+ }
3714
3711
 
3715
- if (!metrics && character[0] in extraCharacterMap) {
3716
- ch = extraCharacterMap[character[0]].charCodeAt(0);
3717
- metrics = fontMetricsData[font][ch];
3718
- }
3712
+ var color = options.getColor();
3719
3713
 
3720
- if (!metrics && mode === 'text') {
3721
- // We don't typically have font metrics for Asian scripts.
3722
- // But since we support them in text mode, we need to return
3723
- // some sort of metrics.
3724
- // So if the character is in a script we support but we
3725
- // don't have metrics for it, just use the metrics for
3726
- // the Latin capital letter M. This is close enough because
3727
- // we (currently) only care about the height of the glpyh
3728
- // not its width.
3729
- if (supportedCodepoint(ch)) {
3730
- metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M'
3714
+ if (color) {
3715
+ this.style.color = color;
3731
3716
  }
3732
3717
  }
3733
-
3734
- if (metrics) {
3735
- return {
3736
- depth: metrics[0],
3737
- height: metrics[1],
3738
- italic: metrics[2],
3739
- skew: metrics[3],
3740
- width: metrics[4]
3741
- };
3742
- }
3743
- }
3744
- var fontMetricsBySizeIndex = {};
3718
+ };
3745
3719
  /**
3746
- * Get the font metrics for a given size.
3720
+ * Convert into an HTML node
3747
3721
  */
3748
3722
 
3749
- function getGlobalMetrics(size) {
3750
- var sizeIndex;
3751
3723
 
3752
- if (size >= 5) {
3753
- sizeIndex = 0;
3754
- } else if (size >= 3) {
3755
- sizeIndex = 1;
3756
- } else {
3757
- sizeIndex = 2;
3758
- }
3724
+ var toNode = function toNode(tagName) {
3725
+ var node = document.createElement(tagName); // Apply the class
3759
3726
 
3760
- if (!fontMetricsBySizeIndex[sizeIndex]) {
3761
- var metrics = fontMetricsBySizeIndex[sizeIndex] = {
3762
- cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18
3763
- };
3727
+ node.className = createClass(this.classes); // Apply inline styles
3764
3728
 
3765
- for (var key in sigmasAndXis) {
3766
- if (sigmasAndXis.hasOwnProperty(key)) {
3767
- metrics[key] = sigmasAndXis[key][sizeIndex];
3768
- }
3729
+ for (var style in this.style) {
3730
+ if (this.style.hasOwnProperty(style)) {
3731
+ // $FlowFixMe Flow doesn't seem to understand span.style's type.
3732
+ node.style[style] = this.style[style];
3769
3733
  }
3770
- }
3734
+ } // Apply attributes
3771
3735
 
3772
- return fontMetricsBySizeIndex[sizeIndex];
3773
- }
3774
3736
 
3775
- /**
3776
- * This file holds a list of all no-argument functions and single-character
3777
- * symbols (like 'a' or ';').
3778
- *
3779
- * For each of the symbols, there are three properties they can have:
3780
- * - font (required): the font to be used for this symbol. Either "main" (the
3781
- normal font), or "ams" (the ams fonts).
3782
- * - group (required): the ParseNode group type the symbol should have (i.e.
3783
- "textord", "mathord", etc).
3784
- See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types
3785
- * - replace: the character that this symbol or function should be
3786
- * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi
3787
- * character in the main font).
3788
- *
3789
- * The outermost map in the table indicates what mode the symbols should be
3790
- * accepted in (e.g. "math" or "text").
3791
- */
3792
- // Some of these have a "-token" suffix since these are also used as `ParseNode`
3793
- // types for raw text tokens, and we want to avoid conflicts with higher-level
3794
- // `ParseNode` types. These `ParseNode`s are constructed within `Parser` by
3795
- // looking up the `symbols` map.
3796
- var ATOMS = {
3797
- "bin": 1,
3798
- "close": 1,
3799
- "inner": 1,
3800
- "open": 1,
3801
- "punct": 1,
3802
- "rel": 1
3803
- };
3804
- var NON_ATOMS = {
3805
- "accent-token": 1,
3806
- "mathord": 1,
3807
- "op-token": 1,
3808
- "spacing": 1,
3809
- "textord": 1
3810
- };
3811
- var symbols = {
3812
- "math": {},
3813
- "text": {}
3814
- };
3815
- /** `acceptUnicodeChar = true` is only applicable if `replace` is set. */
3737
+ for (var attr in this.attributes) {
3738
+ if (this.attributes.hasOwnProperty(attr)) {
3739
+ node.setAttribute(attr, this.attributes[attr]);
3740
+ }
3741
+ } // Append the children, also as HTML nodes
3816
3742
 
3817
- function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) {
3818
- symbols[mode][name] = {
3819
- font,
3820
- group,
3821
- replace
3822
- };
3823
3743
 
3824
- if (acceptUnicodeChar && replace) {
3825
- symbols[mode][replace] = symbols[mode][name];
3744
+ for (var i = 0; i < this.children.length; i++) {
3745
+ node.appendChild(this.children[i].toNode());
3826
3746
  }
3827
- } // Some abbreviations for commonly used strings.
3828
- // This helps minify the code, and also spotting typos using jshint.
3829
- // modes:
3830
-
3831
- var math = "math";
3832
- var text = "text"; // fonts:
3833
-
3834
- var main = "main";
3835
- var ams = "ams"; // groups:
3836
-
3837
- var accent = "accent-token";
3838
- var bin = "bin";
3839
- var close = "close";
3840
- var inner = "inner";
3841
- var mathord = "mathord";
3842
- var op = "op-token";
3843
- var open = "open";
3844
- var punct = "punct";
3845
- var rel = "rel";
3846
- var spacing = "spacing";
3847
- var textord = "textord"; // Now comes the symbol table
3848
- // Relation Symbols
3849
3747
 
3850
- defineSymbol(math, main, rel, "\u2261", "\\equiv", true);
3851
- defineSymbol(math, main, rel, "\u227a", "\\prec", true);
3852
- defineSymbol(math, main, rel, "\u227b", "\\succ", true);
3853
- defineSymbol(math, main, rel, "\u223c", "\\sim", true);
3854
- defineSymbol(math, main, rel, "\u22a5", "\\perp");
3855
- defineSymbol(math, main, rel, "\u2aaf", "\\preceq", true);
3856
- defineSymbol(math, main, rel, "\u2ab0", "\\succeq", true);
3857
- defineSymbol(math, main, rel, "\u2243", "\\simeq", true);
3858
- defineSymbol(math, main, rel, "\u2223", "\\mid", true);
3859
- defineSymbol(math, main, rel, "\u226a", "\\ll", true);
3860
- defineSymbol(math, main, rel, "\u226b", "\\gg", true);
3861
- defineSymbol(math, main, rel, "\u224d", "\\asymp", true);
3862
- defineSymbol(math, main, rel, "\u2225", "\\parallel");
3863
- defineSymbol(math, main, rel, "\u22c8", "\\bowtie", true);
3864
- defineSymbol(math, main, rel, "\u2323", "\\smile", true);
3865
- defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true);
3866
- defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true);
3867
- defineSymbol(math, main, rel, "\u2250", "\\doteq", true);
3868
- defineSymbol(math, main, rel, "\u2322", "\\frown", true);
3869
- defineSymbol(math, main, rel, "\u220b", "\\ni", true);
3870
- defineSymbol(math, main, rel, "\u221d", "\\propto", true);
3871
- defineSymbol(math, main, rel, "\u22a2", "\\vdash", true);
3872
- defineSymbol(math, main, rel, "\u22a3", "\\dashv", true);
3873
- defineSymbol(math, main, rel, "\u220b", "\\owns"); // Punctuation
3748
+ return node;
3749
+ };
3750
+ /**
3751
+ * Convert into an HTML markup string
3752
+ */
3874
3753
 
3875
- defineSymbol(math, main, punct, "\u002e", "\\ldotp");
3876
- defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); // Misc Symbols
3877
3754
 
3878
- defineSymbol(math, main, textord, "\u0023", "\\#");
3879
- defineSymbol(text, main, textord, "\u0023", "\\#");
3880
- defineSymbol(math, main, textord, "\u0026", "\\&");
3881
- defineSymbol(text, main, textord, "\u0026", "\\&");
3882
- defineSymbol(math, main, textord, "\u2135", "\\aleph", true);
3883
- defineSymbol(math, main, textord, "\u2200", "\\forall", true);
3884
- defineSymbol(math, main, textord, "\u210f", "\\hbar", true);
3885
- defineSymbol(math, main, textord, "\u2203", "\\exists", true);
3886
- defineSymbol(math, main, textord, "\u2207", "\\nabla", true);
3887
- defineSymbol(math, main, textord, "\u266d", "\\flat", true);
3888
- defineSymbol(math, main, textord, "\u2113", "\\ell", true);
3889
- defineSymbol(math, main, textord, "\u266e", "\\natural", true);
3890
- defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true);
3891
- defineSymbol(math, main, textord, "\u2118", "\\wp", true);
3892
- defineSymbol(math, main, textord, "\u266f", "\\sharp", true);
3893
- defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true);
3894
- defineSymbol(math, main, textord, "\u211c", "\\Re", true);
3895
- defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true);
3896
- defineSymbol(math, main, textord, "\u2111", "\\Im", true);
3897
- defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true);
3898
- defineSymbol(math, main, textord, "\u00a7", "\\S", true);
3899
- defineSymbol(text, main, textord, "\u00a7", "\\S");
3900
- defineSymbol(math, main, textord, "\u00b6", "\\P", true);
3901
- defineSymbol(text, main, textord, "\u00b6", "\\P"); // Math and Text
3755
+ var toMarkup = function toMarkup(tagName) {
3756
+ var markup = "<" + tagName; // Add the class
3902
3757
 
3903
- defineSymbol(math, main, textord, "\u2020", "\\dag");
3904
- defineSymbol(text, main, textord, "\u2020", "\\dag");
3905
- defineSymbol(text, main, textord, "\u2020", "\\textdagger");
3906
- defineSymbol(math, main, textord, "\u2021", "\\ddag");
3907
- defineSymbol(text, main, textord, "\u2021", "\\ddag");
3908
- defineSymbol(text, main, textord, "\u2021", "\\textdaggerdbl"); // Large Delimiters
3758
+ if (this.classes.length) {
3759
+ markup += " class=\"" + utils.escape(createClass(this.classes)) + "\"";
3760
+ }
3909
3761
 
3910
- defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true);
3911
- defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true);
3912
- defineSymbol(math, main, close, "\u27ef", "\\rgroup", true);
3913
- defineSymbol(math, main, open, "\u27ee", "\\lgroup", true); // Binary Operators
3762
+ var styles = ""; // Add the styles, after hyphenation
3914
3763
 
3915
- defineSymbol(math, main, bin, "\u2213", "\\mp", true);
3916
- defineSymbol(math, main, bin, "\u2296", "\\ominus", true);
3917
- defineSymbol(math, main, bin, "\u228e", "\\uplus", true);
3918
- defineSymbol(math, main, bin, "\u2293", "\\sqcap", true);
3919
- defineSymbol(math, main, bin, "\u2217", "\\ast");
3920
- defineSymbol(math, main, bin, "\u2294", "\\sqcup", true);
3921
- defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true);
3922
- defineSymbol(math, main, bin, "\u2219", "\\bullet");
3923
- defineSymbol(math, main, bin, "\u2021", "\\ddagger");
3924
- defineSymbol(math, main, bin, "\u2240", "\\wr", true);
3925
- defineSymbol(math, main, bin, "\u2a3f", "\\amalg");
3926
- defineSymbol(math, main, bin, "\u0026", "\\And"); // from amsmath
3927
- // Arrow Symbols
3764
+ for (var style in this.style) {
3765
+ if (this.style.hasOwnProperty(style)) {
3766
+ styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
3767
+ }
3768
+ }
3928
3769
 
3929
- defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow", true);
3930
- defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow", true);
3931
- defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow", true);
3932
- defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow", true);
3933
- defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow", true);
3934
- defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow", true);
3935
- defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true);
3936
- defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow", true);
3937
- defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow", true);
3938
- defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow", true);
3939
- defineSymbol(math, main, rel, "\u21a6", "\\mapsto", true);
3940
- defineSymbol(math, main, rel, "\u27fc", "\\longmapsto", true);
3941
- defineSymbol(math, main, rel, "\u2197", "\\nearrow", true);
3942
- defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow", true);
3943
- defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow", true);
3944
- defineSymbol(math, main, rel, "\u2198", "\\searrow", true);
3945
- defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup", true);
3946
- defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup", true);
3947
- defineSymbol(math, main, rel, "\u2199", "\\swarrow", true);
3948
- defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown", true);
3949
- defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true);
3950
- defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true);
3951
- defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true); // AMS Negated Binary Relations
3770
+ if (styles) {
3771
+ markup += " style=\"" + utils.escape(styles) + "\"";
3772
+ } // Add the attributes
3952
3773
 
3953
- defineSymbol(math, ams, rel, "\u226e", "\\nless", true); // Symbol names preceeded by "@" each have a corresponding macro.
3954
3774
 
3955
- defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant");
3956
- defineSymbol(math, ams, rel, "\ue011", "\\@nleqq");
3957
- defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true);
3958
- defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true);
3959
- defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq");
3960
- defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true);
3961
- defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true);
3962
- defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); // unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym.
3775
+ for (var attr in this.attributes) {
3776
+ if (this.attributes.hasOwnProperty(attr)) {
3777
+ markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\"";
3778
+ }
3779
+ }
3963
3780
 
3964
- defineSymbol(math, ams, rel, "\u22e0", "\\npreceq", true);
3965
- defineSymbol(math, ams, rel, "\u22e8", "\\precnsim", true);
3966
- defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox", true);
3967
- defineSymbol(math, ams, rel, "\u2241", "\\nsim", true);
3968
- defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid");
3969
- defineSymbol(math, ams, rel, "\u2224", "\\nmid", true);
3970
- defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true);
3971
- defineSymbol(math, ams, rel, "\u22ad", "\\nvDash", true);
3972
- defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft");
3973
- defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq", true);
3974
- defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true);
3975
- defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq");
3976
- defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true);
3977
- defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq");
3978
- defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true);
3979
- defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant");
3980
- defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq");
3981
- defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true);
3982
- defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true);
3983
- defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq");
3984
- defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true);
3985
- defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true);
3986
- defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); // unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym.
3781
+ markup += ">"; // Add the markup of the children, also as markup
3987
3782
 
3988
- defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq", true);
3989
- defineSymbol(math, ams, rel, "\u22e9", "\\succnsim", true);
3990
- defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox", true); // unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym.
3783
+ for (var i = 0; i < this.children.length; i++) {
3784
+ markup += this.children[i].toMarkup();
3785
+ }
3991
3786
 
3992
- defineSymbol(math, ams, rel, "\u2246", "\\ncong", true);
3993
- defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel");
3994
- defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true);
3995
- defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true);
3996
- defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright");
3997
- defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true);
3998
- defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq");
3999
- defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true);
4000
- defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq");
4001
- defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true);
4002
- defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq");
4003
- defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true);
4004
- defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true);
4005
- defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true);
4006
- defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq");
4007
- defineSymbol(math, ams, bin, "\u22b4", "\\unlhd");
4008
- defineSymbol(math, ams, bin, "\u22b5", "\\unrhd"); // AMS Negated Arrows
3787
+ markup += "</" + tagName + ">";
3788
+ return markup;
3789
+ }; // Making the type below exact with all optional fields doesn't work due to
3790
+ // - https://github.com/facebook/flow/issues/4582
3791
+ // - https://github.com/facebook/flow/issues/5688
3792
+ // However, since *all* fields are optional, $Shape<> works as suggested in 5688
3793
+ // above.
3794
+ // This type does not include all CSS properties. Additional properties should
3795
+ // be added as needed.
4009
3796
 
4010
- defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow", true);
4011
- defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow", true);
4012
- defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow", true);
4013
- defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow", true);
4014
- defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow", true);
4015
- defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow", true); // AMS Misc
4016
3797
 
4017
- defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle");
4018
- defineSymbol(math, ams, textord, "\u210f", "\\hslash");
4019
- defineSymbol(math, ams, textord, "\u25bd", "\\triangledown");
4020
- defineSymbol(math, ams, textord, "\u25ca", "\\lozenge");
4021
- defineSymbol(math, ams, textord, "\u24c8", "\\circledS");
4022
- defineSymbol(math, ams, textord, "\u00ae", "\\circledR");
4023
- defineSymbol(text, ams, textord, "\u00ae", "\\circledR");
4024
- defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true);
4025
- defineSymbol(math, ams, textord, "\u2204", "\\nexists");
4026
- defineSymbol(math, ams, textord, "\u2127", "\\mho");
4027
- defineSymbol(math, ams, textord, "\u2132", "\\Finv", true);
4028
- defineSymbol(math, ams, textord, "\u2141", "\\Game", true);
4029
- defineSymbol(math, ams, textord, "\u2035", "\\backprime");
4030
- defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle");
4031
- defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown");
4032
- defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare");
4033
- defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge");
4034
- defineSymbol(math, ams, textord, "\u2605", "\\bigstar");
4035
- defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true);
4036
- defineSymbol(math, ams, textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 to \matheth. We map to AMS function \eth
3798
+ /**
3799
+ * This node represents a span node, with a className, a list of children, and
3800
+ * an inline style. It also contains information about its height, depth, and
3801
+ * maxFontSize.
3802
+ *
3803
+ * Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan
3804
+ * otherwise. This typesafety is important when HTML builders access a span's
3805
+ * children.
3806
+ */
3807
+ class Span {
3808
+ constructor(classes, children, options, style) {
3809
+ this.children = void 0;
3810
+ this.attributes = void 0;
3811
+ this.classes = void 0;
3812
+ this.height = void 0;
3813
+ this.depth = void 0;
3814
+ this.width = void 0;
3815
+ this.maxFontSize = void 0;
3816
+ this.style = void 0;
3817
+ initNode.call(this, classes, options, style);
3818
+ this.children = children || [];
3819
+ }
3820
+ /**
3821
+ * Sets an arbitrary attribute on the span. Warning: use this wisely. Not
3822
+ * all browsers support attributes the same, and having too many custom
3823
+ * attributes is probably bad.
3824
+ */
4037
3825
 
4038
- defineSymbol(math, ams, textord, "\u00f0", "\\eth", true);
4039
- defineSymbol(text, main, textord, "\u00f0", "\u00f0");
4040
- defineSymbol(math, ams, textord, "\u2571", "\\diagup");
4041
- defineSymbol(math, ams, textord, "\u2572", "\\diagdown");
4042
- defineSymbol(math, ams, textord, "\u25a1", "\\square");
4043
- defineSymbol(math, ams, textord, "\u25a1", "\\Box");
4044
- defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); // unicode-math maps U+A5 to \mathyen. We map to AMS function \yen
4045
3826
 
4046
- defineSymbol(math, ams, textord, "\u00a5", "\\yen", true);
4047
- defineSymbol(text, ams, textord, "\u00a5", "\\yen", true);
4048
- defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true);
4049
- defineSymbol(text, ams, textord, "\u2713", "\\checkmark"); // AMS Hebrew
3827
+ setAttribute(attribute, value) {
3828
+ this.attributes[attribute] = value;
3829
+ }
4050
3830
 
4051
- defineSymbol(math, ams, textord, "\u2136", "\\beth", true);
4052
- defineSymbol(math, ams, textord, "\u2138", "\\daleth", true);
4053
- defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); // AMS Greek
3831
+ hasClass(className) {
3832
+ return utils.contains(this.classes, className);
3833
+ }
4054
3834
 
4055
- defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true);
4056
- defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); // AMS Delimiters
3835
+ toNode() {
3836
+ return toNode.call(this, "span");
3837
+ }
4057
3838
 
4058
- defineSymbol(math, ams, open, "\u250c", "\\@ulcorner", true);
4059
- defineSymbol(math, ams, close, "\u2510", "\\@urcorner", true);
4060
- defineSymbol(math, ams, open, "\u2514", "\\@llcorner", true);
4061
- defineSymbol(math, ams, close, "\u2518", "\\@lrcorner", true); // AMS Binary Relations
3839
+ toMarkup() {
3840
+ return toMarkup.call(this, "span");
3841
+ }
4062
3842
 
4063
- defineSymbol(math, ams, rel, "\u2266", "\\leqq", true);
4064
- defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true);
4065
- defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless", true);
4066
- defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true);
4067
- defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox", true);
4068
- defineSymbol(math, ams, rel, "\u224a", "\\approxeq", true);
4069
- defineSymbol(math, ams, bin, "\u22d6", "\\lessdot");
4070
- defineSymbol(math, ams, rel, "\u22d8", "\\lll", true);
4071
- defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true);
4072
- defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr", true);
4073
- defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr", true);
4074
- defineSymbol(math, ams, rel, "\u2251", "\\doteqdot");
4075
- defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true);
4076
- defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true);
4077
- defineSymbol(math, ams, rel, "\u223d", "\\backsim", true);
4078
- defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq", true);
4079
- defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq", true);
4080
- defineSymbol(math, ams, rel, "\u22d0", "\\Subset", true);
4081
- defineSymbol(math, ams, rel, "\u228f", "\\sqsubset", true);
4082
- defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq", true);
4083
- defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec", true);
4084
- defineSymbol(math, ams, rel, "\u227e", "\\precsim", true);
4085
- defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox", true);
4086
- defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft");
4087
- defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq");
4088
- defineSymbol(math, ams, rel, "\u22a8", "\\vDash", true);
4089
- defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash", true);
4090
- defineSymbol(math, ams, rel, "\u2323", "\\smallsmile");
4091
- defineSymbol(math, ams, rel, "\u2322", "\\smallfrown");
4092
- defineSymbol(math, ams, rel, "\u224f", "\\bumpeq", true);
4093
- defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq", true);
4094
- defineSymbol(math, ams, rel, "\u2267", "\\geqq", true);
4095
- defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant", true);
4096
- defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr", true);
4097
- defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true);
4098
- defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox", true);
4099
- defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot");
4100
- defineSymbol(math, ams, rel, "\u22d9", "\\ggg", true);
4101
- defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true);
4102
- defineSymbol(math, ams, rel, "\u22db", "\\gtreqless", true);
4103
- defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless", true);
4104
- defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true);
4105
- defineSymbol(math, ams, rel, "\u2257", "\\circeq", true);
4106
- defineSymbol(math, ams, rel, "\u225c", "\\triangleq", true);
4107
- defineSymbol(math, ams, rel, "\u223c", "\\thicksim");
4108
- defineSymbol(math, ams, rel, "\u2248", "\\thickapprox");
4109
- defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq", true);
4110
- defineSymbol(math, ams, rel, "\u22d1", "\\Supset", true);
4111
- defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true);
4112
- defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq", true);
4113
- defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc", true);
4114
- defineSymbol(math, ams, rel, "\u227f", "\\succsim", true);
4115
- defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox", true);
4116
- defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright");
4117
- defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq");
4118
- defineSymbol(math, ams, rel, "\u22a9", "\\Vdash", true);
4119
- defineSymbol(math, ams, rel, "\u2223", "\\shortmid");
4120
- defineSymbol(math, ams, rel, "\u2225", "\\shortparallel");
4121
- defineSymbol(math, ams, rel, "\u226c", "\\between", true);
4122
- defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork", true);
4123
- defineSymbol(math, ams, rel, "\u221d", "\\varpropto");
4124
- defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft"); // unicode-math says that \therefore is a mathord atom.
4125
- // We kept the amssymb atom type, which is rel.
3843
+ }
3844
+ /**
3845
+ * This node represents an anchor (<a>) element with a hyperlink. See `span`
3846
+ * for further details.
3847
+ */
3848
+
3849
+ class Anchor {
3850
+ constructor(href, classes, children, options) {
3851
+ this.children = void 0;
3852
+ this.attributes = void 0;
3853
+ this.classes = void 0;
3854
+ this.height = void 0;
3855
+ this.depth = void 0;
3856
+ this.maxFontSize = void 0;
3857
+ this.style = void 0;
3858
+ initNode.call(this, classes, options);
3859
+ this.children = children || [];
3860
+ this.setAttribute('href', href);
3861
+ }
4126
3862
 
4127
- defineSymbol(math, ams, rel, "\u2234", "\\therefore", true);
4128
- defineSymbol(math, ams, rel, "\u220d", "\\backepsilon");
4129
- defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright"); // unicode-math says that \because is a mathord atom.
4130
- // We kept the amssymb atom type, which is rel.
3863
+ setAttribute(attribute, value) {
3864
+ this.attributes[attribute] = value;
3865
+ }
4131
3866
 
4132
- defineSymbol(math, ams, rel, "\u2235", "\\because", true);
4133
- defineSymbol(math, ams, rel, "\u22d8", "\\llless");
4134
- defineSymbol(math, ams, rel, "\u22d9", "\\gggtr");
4135
- defineSymbol(math, ams, bin, "\u22b2", "\\lhd");
4136
- defineSymbol(math, ams, bin, "\u22b3", "\\rhd");
4137
- defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true);
4138
- defineSymbol(math, main, rel, "\u22c8", "\\Join");
4139
- defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); // AMS Binary Operators
3867
+ hasClass(className) {
3868
+ return utils.contains(this.classes, className);
3869
+ }
4140
3870
 
4141
- defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true);
4142
- defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus");
4143
- defineSymbol(math, ams, bin, "\u22d2", "\\Cap", true);
4144
- defineSymbol(math, ams, bin, "\u22d3", "\\Cup", true);
4145
- defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge", true);
4146
- defineSymbol(math, ams, bin, "\u229f", "\\boxminus", true);
4147
- defineSymbol(math, ams, bin, "\u229e", "\\boxplus", true);
4148
- defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes", true);
4149
- defineSymbol(math, ams, bin, "\u22c9", "\\ltimes", true);
4150
- defineSymbol(math, ams, bin, "\u22ca", "\\rtimes", true);
4151
- defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes", true);
4152
- defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes", true);
4153
- defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge", true);
4154
- defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee", true);
4155
- defineSymbol(math, ams, bin, "\u229d", "\\circleddash", true);
4156
- defineSymbol(math, ams, bin, "\u229b", "\\circledast", true);
4157
- defineSymbol(math, ams, bin, "\u22c5", "\\centerdot");
4158
- defineSymbol(math, ams, bin, "\u22ba", "\\intercal", true);
4159
- defineSymbol(math, ams, bin, "\u22d2", "\\doublecap");
4160
- defineSymbol(math, ams, bin, "\u22d3", "\\doublecup");
4161
- defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes", true); // AMS Arrows
4162
- // Note: unicode-math maps \u21e2 to their own function \rightdasharrow.
4163
- // We'll map it to AMS function \dashrightarrow. It produces the same atom.
3871
+ toNode() {
3872
+ return toNode.call(this, "a");
3873
+ }
4164
3874
 
4165
- defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow", true); // unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym.
3875
+ toMarkup() {
3876
+ return toMarkup.call(this, "a");
3877
+ }
4166
3878
 
4167
- defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow", true);
4168
- defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows", true);
4169
- defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows", true);
4170
- defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow", true);
4171
- defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow", true);
4172
- defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail", true);
4173
- defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft", true);
4174
- defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons", true);
4175
- defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft", true); // unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym.
3879
+ }
3880
+ /**
3881
+ * This node represents an image embed (<img>) element.
3882
+ */
4176
3883
 
4177
- defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft", true);
4178
- defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true);
4179
- defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true);
4180
- defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true);
4181
- defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true);
4182
- defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font
3884
+ class Img {
3885
+ constructor(src, alt, style) {
3886
+ this.src = void 0;
3887
+ this.alt = void 0;
3888
+ this.classes = void 0;
3889
+ this.height = void 0;
3890
+ this.depth = void 0;
3891
+ this.maxFontSize = void 0;
3892
+ this.style = void 0;
3893
+ this.alt = alt;
3894
+ this.src = src;
3895
+ this.classes = ["mord"];
3896
+ this.style = style;
3897
+ }
4183
3898
 
4184
- defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font
3899
+ hasClass(className) {
3900
+ return utils.contains(this.classes, className);
3901
+ }
4185
3902
 
4186
- defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true);
4187
- defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true);
4188
- defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true);
4189
- defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows", true);
4190
- defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow", true);
4191
- defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail", true);
4192
- defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright", true);
4193
- defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright", true); // unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym.
3903
+ toNode() {
3904
+ var node = document.createElement("img");
3905
+ node.src = this.src;
3906
+ node.alt = this.alt;
3907
+ node.className = "mord"; // Apply inline styles
4194
3908
 
4195
- defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright", true);
4196
- defineSymbol(math, ams, rel, "\u21b1", "\\Rsh", true);
4197
- defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows", true);
4198
- defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright", true);
4199
- defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright", true);
4200
- defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow", true);
4201
- defineSymbol(math, ams, rel, "\u21dd", "\\leadsto");
4202
- defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true);
4203
- defineSymbol(math, ams, rel, "\u21be", "\\restriction");
4204
- defineSymbol(math, main, textord, "\u2018", "`");
4205
- defineSymbol(math, main, textord, "$", "\\$");
4206
- defineSymbol(text, main, textord, "$", "\\$");
4207
- defineSymbol(text, main, textord, "$", "\\textdollar");
4208
- defineSymbol(math, main, textord, "%", "\\%");
4209
- defineSymbol(text, main, textord, "%", "\\%");
4210
- defineSymbol(math, main, textord, "_", "\\_");
4211
- defineSymbol(text, main, textord, "_", "\\_");
4212
- defineSymbol(text, main, textord, "_", "\\textunderscore");
4213
- defineSymbol(math, main, textord, "\u2220", "\\angle", true);
4214
- defineSymbol(math, main, textord, "\u221e", "\\infty", true);
4215
- defineSymbol(math, main, textord, "\u2032", "\\prime");
4216
- defineSymbol(math, main, textord, "\u25b3", "\\triangle");
4217
- defineSymbol(math, main, textord, "\u0393", "\\Gamma", true);
4218
- defineSymbol(math, main, textord, "\u0394", "\\Delta", true);
4219
- defineSymbol(math, main, textord, "\u0398", "\\Theta", true);
4220
- defineSymbol(math, main, textord, "\u039b", "\\Lambda", true);
4221
- defineSymbol(math, main, textord, "\u039e", "\\Xi", true);
4222
- defineSymbol(math, main, textord, "\u03a0", "\\Pi", true);
4223
- defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true);
4224
- defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true);
4225
- defineSymbol(math, main, textord, "\u03a6", "\\Phi", true);
4226
- defineSymbol(math, main, textord, "\u03a8", "\\Psi", true);
4227
- defineSymbol(math, main, textord, "\u03a9", "\\Omega", true);
4228
- defineSymbol(math, main, textord, "A", "\u0391");
4229
- defineSymbol(math, main, textord, "B", "\u0392");
4230
- defineSymbol(math, main, textord, "E", "\u0395");
4231
- defineSymbol(math, main, textord, "Z", "\u0396");
4232
- defineSymbol(math, main, textord, "H", "\u0397");
4233
- defineSymbol(math, main, textord, "I", "\u0399");
4234
- defineSymbol(math, main, textord, "K", "\u039A");
4235
- defineSymbol(math, main, textord, "M", "\u039C");
4236
- defineSymbol(math, main, textord, "N", "\u039D");
4237
- defineSymbol(math, main, textord, "O", "\u039F");
4238
- defineSymbol(math, main, textord, "P", "\u03A1");
4239
- defineSymbol(math, main, textord, "T", "\u03A4");
4240
- defineSymbol(math, main, textord, "X", "\u03A7");
4241
- defineSymbol(math, main, textord, "\u00ac", "\\neg", true);
4242
- defineSymbol(math, main, textord, "\u00ac", "\\lnot");
4243
- defineSymbol(math, main, textord, "\u22a4", "\\top");
4244
- defineSymbol(math, main, textord, "\u22a5", "\\bot");
4245
- defineSymbol(math, main, textord, "\u2205", "\\emptyset");
4246
- defineSymbol(math, ams, textord, "\u2205", "\\varnothing");
4247
- defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true);
4248
- defineSymbol(math, main, mathord, "\u03b2", "\\beta", true);
4249
- defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true);
4250
- defineSymbol(math, main, mathord, "\u03b4", "\\delta", true);
4251
- defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true);
4252
- defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true);
4253
- defineSymbol(math, main, mathord, "\u03b7", "\\eta", true);
4254
- defineSymbol(math, main, mathord, "\u03b8", "\\theta", true);
4255
- defineSymbol(math, main, mathord, "\u03b9", "\\iota", true);
4256
- defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true);
4257
- defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true);
4258
- defineSymbol(math, main, mathord, "\u03bc", "\\mu", true);
4259
- defineSymbol(math, main, mathord, "\u03bd", "\\nu", true);
4260
- defineSymbol(math, main, mathord, "\u03be", "\\xi", true);
4261
- defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true);
4262
- defineSymbol(math, main, mathord, "\u03c0", "\\pi", true);
4263
- defineSymbol(math, main, mathord, "\u03c1", "\\rho", true);
4264
- defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true);
4265
- defineSymbol(math, main, mathord, "\u03c4", "\\tau", true);
4266
- defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true);
4267
- defineSymbol(math, main, mathord, "\u03d5", "\\phi", true);
4268
- defineSymbol(math, main, mathord, "\u03c7", "\\chi", true);
4269
- defineSymbol(math, main, mathord, "\u03c8", "\\psi", true);
4270
- defineSymbol(math, main, mathord, "\u03c9", "\\omega", true);
4271
- defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true);
4272
- defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true);
4273
- defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true);
4274
- defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true);
4275
- defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true);
4276
- defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true);
4277
- defineSymbol(math, main, bin, "\u2217", "*", true);
4278
- defineSymbol(math, main, bin, "+", "+");
4279
- defineSymbol(math, main, bin, "\u2212", "-", true);
4280
- defineSymbol(math, main, bin, "\u22c5", "\\cdot", true);
4281
- defineSymbol(math, main, bin, "\u2218", "\\circ");
4282
- defineSymbol(math, main, bin, "\u00f7", "\\div", true);
4283
- defineSymbol(math, main, bin, "\u00b1", "\\pm", true);
4284
- defineSymbol(math, main, bin, "\u00d7", "\\times", true);
4285
- defineSymbol(math, main, bin, "\u2229", "\\cap", true);
4286
- defineSymbol(math, main, bin, "\u222a", "\\cup", true);
4287
- defineSymbol(math, main, bin, "\u2216", "\\setminus");
4288
- defineSymbol(math, main, bin, "\u2227", "\\land");
4289
- defineSymbol(math, main, bin, "\u2228", "\\lor");
4290
- defineSymbol(math, main, bin, "\u2227", "\\wedge", true);
4291
- defineSymbol(math, main, bin, "\u2228", "\\vee", true);
4292
- defineSymbol(math, main, textord, "\u221a", "\\surd");
4293
- defineSymbol(math, main, open, "\u27e8", "\\langle", true);
4294
- defineSymbol(math, main, open, "\u2223", "\\lvert");
4295
- defineSymbol(math, main, open, "\u2225", "\\lVert");
4296
- defineSymbol(math, main, close, "?", "?");
4297
- defineSymbol(math, main, close, "!", "!");
4298
- defineSymbol(math, main, close, "\u27e9", "\\rangle", true);
4299
- defineSymbol(math, main, close, "\u2223", "\\rvert");
4300
- defineSymbol(math, main, close, "\u2225", "\\rVert");
4301
- defineSymbol(math, main, rel, "=", "=");
4302
- defineSymbol(math, main, rel, ":", ":");
4303
- defineSymbol(math, main, rel, "\u2248", "\\approx", true);
4304
- defineSymbol(math, main, rel, "\u2245", "\\cong", true);
4305
- defineSymbol(math, main, rel, "\u2265", "\\ge");
4306
- defineSymbol(math, main, rel, "\u2265", "\\geq", true);
4307
- defineSymbol(math, main, rel, "\u2190", "\\gets");
4308
- defineSymbol(math, main, rel, ">", "\\gt", true);
4309
- defineSymbol(math, main, rel, "\u2208", "\\in", true);
4310
- defineSymbol(math, main, rel, "\ue020", "\\@not");
4311
- defineSymbol(math, main, rel, "\u2282", "\\subset", true);
4312
- defineSymbol(math, main, rel, "\u2283", "\\supset", true);
4313
- defineSymbol(math, main, rel, "\u2286", "\\subseteq", true);
4314
- defineSymbol(math, main, rel, "\u2287", "\\supseteq", true);
4315
- defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true);
4316
- defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true);
4317
- defineSymbol(math, main, rel, "\u22a8", "\\models");
4318
- defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true);
4319
- defineSymbol(math, main, rel, "\u2264", "\\le");
4320
- defineSymbol(math, main, rel, "\u2264", "\\leq", true);
4321
- defineSymbol(math, main, rel, "<", "\\lt", true);
4322
- defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true);
4323
- defineSymbol(math, main, rel, "\u2192", "\\to");
4324
- defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true);
4325
- defineSymbol(math, ams, rel, "\u2270", "\\nleq", true);
4326
- defineSymbol(math, main, spacing, "\u00a0", "\\ ");
4327
- defineSymbol(math, main, spacing, "\u00a0", "\\space"); // Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{%
3909
+ for (var style in this.style) {
3910
+ if (this.style.hasOwnProperty(style)) {
3911
+ // $FlowFixMe
3912
+ node.style[style] = this.style[style];
3913
+ }
3914
+ }
3915
+
3916
+ return node;
3917
+ }
3918
+
3919
+ toMarkup() {
3920
+ var markup = "<img src='" + this.src + " 'alt='" + this.alt + "' "; // Add the styles, after hyphenation
3921
+
3922
+ var styles = "";
3923
+
3924
+ for (var style in this.style) {
3925
+ if (this.style.hasOwnProperty(style)) {
3926
+ styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
3927
+ }
3928
+ }
4328
3929
 
4329
- defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace");
4330
- defineSymbol(text, main, spacing, "\u00a0", "\\ ");
4331
- defineSymbol(text, main, spacing, "\u00a0", " ");
4332
- defineSymbol(text, main, spacing, "\u00a0", "\\space");
4333
- defineSymbol(text, main, spacing, "\u00a0", "\\nobreakspace");
4334
- defineSymbol(math, main, spacing, null, "\\nobreak");
4335
- defineSymbol(math, main, spacing, null, "\\allowbreak");
4336
- defineSymbol(math, main, punct, ",", ",");
4337
- defineSymbol(math, main, punct, ";", ";");
4338
- defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true);
4339
- defineSymbol(math, ams, bin, "\u22bb", "\\veebar", true);
4340
- defineSymbol(math, main, bin, "\u2299", "\\odot", true);
4341
- defineSymbol(math, main, bin, "\u2295", "\\oplus", true);
4342
- defineSymbol(math, main, bin, "\u2297", "\\otimes", true);
4343
- defineSymbol(math, main, textord, "\u2202", "\\partial", true);
4344
- defineSymbol(math, main, bin, "\u2298", "\\oslash", true);
4345
- defineSymbol(math, ams, bin, "\u229a", "\\circledcirc", true);
4346
- defineSymbol(math, ams, bin, "\u22a1", "\\boxdot", true);
4347
- defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup");
4348
- defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown");
4349
- defineSymbol(math, main, bin, "\u2020", "\\dagger");
4350
- defineSymbol(math, main, bin, "\u22c4", "\\diamond");
4351
- defineSymbol(math, main, bin, "\u22c6", "\\star");
4352
- defineSymbol(math, main, bin, "\u25c3", "\\triangleleft");
4353
- defineSymbol(math, main, bin, "\u25b9", "\\triangleright");
4354
- defineSymbol(math, main, open, "{", "\\{");
4355
- defineSymbol(text, main, textord, "{", "\\{");
4356
- defineSymbol(text, main, textord, "{", "\\textbraceleft");
4357
- defineSymbol(math, main, close, "}", "\\}");
4358
- defineSymbol(text, main, textord, "}", "\\}");
4359
- defineSymbol(text, main, textord, "}", "\\textbraceright");
4360
- defineSymbol(math, main, open, "{", "\\lbrace");
4361
- defineSymbol(math, main, close, "}", "\\rbrace");
4362
- defineSymbol(math, main, open, "[", "\\lbrack", true);
4363
- defineSymbol(text, main, textord, "[", "\\lbrack", true);
4364
- defineSymbol(math, main, close, "]", "\\rbrack", true);
4365
- defineSymbol(text, main, textord, "]", "\\rbrack", true);
4366
- defineSymbol(math, main, open, "(", "\\lparen", true);
4367
- defineSymbol(math, main, close, ")", "\\rparen", true);
4368
- defineSymbol(text, main, textord, "<", "\\textless", true); // in T1 fontenc
3930
+ if (styles) {
3931
+ markup += " style=\"" + utils.escape(styles) + "\"";
3932
+ }
4369
3933
 
4370
- defineSymbol(text, main, textord, ">", "\\textgreater", true); // in T1 fontenc
3934
+ markup += "'/>";
3935
+ return markup;
3936
+ }
4371
3937
 
4372
- defineSymbol(math, main, open, "\u230a", "\\lfloor", true);
4373
- defineSymbol(math, main, close, "\u230b", "\\rfloor", true);
4374
- defineSymbol(math, main, open, "\u2308", "\\lceil", true);
4375
- defineSymbol(math, main, close, "\u2309", "\\rceil", true);
4376
- defineSymbol(math, main, textord, "\\", "\\backslash");
4377
- defineSymbol(math, main, textord, "\u2223", "|");
4378
- defineSymbol(math, main, textord, "\u2223", "\\vert");
4379
- defineSymbol(text, main, textord, "|", "\\textbar", true); // in T1 fontenc
3938
+ }
3939
+ var iCombinations = {
3940
+ 'î': '\u0131\u0302',
3941
+ 'ï': '\u0131\u0308',
3942
+ 'í': '\u0131\u0301',
3943
+ // 'ī': '\u0131\u0304', // enable when we add Extended Latin
3944
+ 'ì': '\u0131\u0300'
3945
+ };
3946
+ /**
3947
+ * A symbol node contains information about a single symbol. It either renders
3948
+ * to a single text node, or a span with a single text node in it, depending on
3949
+ * whether it has CSS classes, styles, or needs italic correction.
3950
+ */
4380
3951
 
4381
- defineSymbol(math, main, textord, "\u2225", "\\|");
4382
- defineSymbol(math, main, textord, "\u2225", "\\Vert");
4383
- defineSymbol(text, main, textord, "\u2225", "\\textbardbl");
4384
- defineSymbol(text, main, textord, "~", "\\textasciitilde");
4385
- defineSymbol(text, main, textord, "\\", "\\textbackslash");
4386
- defineSymbol(text, main, textord, "^", "\\textasciicircum");
4387
- defineSymbol(math, main, rel, "\u2191", "\\uparrow", true);
4388
- defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true);
4389
- defineSymbol(math, main, rel, "\u2193", "\\downarrow", true);
4390
- defineSymbol(math, main, rel, "\u21d3", "\\Downarrow", true);
4391
- defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true);
4392
- defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow", true);
4393
- defineSymbol(math, main, op, "\u2210", "\\coprod");
4394
- defineSymbol(math, main, op, "\u22c1", "\\bigvee");
4395
- defineSymbol(math, main, op, "\u22c0", "\\bigwedge");
4396
- defineSymbol(math, main, op, "\u2a04", "\\biguplus");
4397
- defineSymbol(math, main, op, "\u22c2", "\\bigcap");
4398
- defineSymbol(math, main, op, "\u22c3", "\\bigcup");
4399
- defineSymbol(math, main, op, "\u222b", "\\int");
4400
- defineSymbol(math, main, op, "\u222b", "\\intop");
4401
- defineSymbol(math, main, op, "\u222c", "\\iint");
4402
- defineSymbol(math, main, op, "\u222d", "\\iiint");
4403
- defineSymbol(math, main, op, "\u220f", "\\prod");
4404
- defineSymbol(math, main, op, "\u2211", "\\sum");
4405
- defineSymbol(math, main, op, "\u2a02", "\\bigotimes");
4406
- defineSymbol(math, main, op, "\u2a01", "\\bigoplus");
4407
- defineSymbol(math, main, op, "\u2a00", "\\bigodot");
4408
- defineSymbol(math, main, op, "\u222e", "\\oint");
4409
- defineSymbol(math, main, op, "\u222f", "\\oiint");
4410
- defineSymbol(math, main, op, "\u2230", "\\oiiint");
4411
- defineSymbol(math, main, op, "\u2a06", "\\bigsqcup");
4412
- defineSymbol(math, main, op, "\u222b", "\\smallint");
4413
- defineSymbol(text, main, inner, "\u2026", "\\textellipsis");
4414
- defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
4415
- defineSymbol(text, main, inner, "\u2026", "\\ldots", true);
4416
- defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
4417
- defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true);
4418
- defineSymbol(math, main, inner, "\u22f1", "\\ddots", true);
4419
- defineSymbol(math, main, textord, "\u22ee", "\\varvdots"); // \vdots is a macro
3952
+ class SymbolNode {
3953
+ constructor(text, height, depth, italic, skew, width, classes, style) {
3954
+ this.text = void 0;
3955
+ this.height = void 0;
3956
+ this.depth = void 0;
3957
+ this.italic = void 0;
3958
+ this.skew = void 0;
3959
+ this.width = void 0;
3960
+ this.maxFontSize = void 0;
3961
+ this.classes = void 0;
3962
+ this.style = void 0;
3963
+ this.text = text;
3964
+ this.height = height || 0;
3965
+ this.depth = depth || 0;
3966
+ this.italic = italic || 0;
3967
+ this.skew = skew || 0;
3968
+ this.width = width || 0;
3969
+ this.classes = classes || [];
3970
+ this.style = style || {};
3971
+ this.maxFontSize = 0; // Mark text from non-Latin scripts with specific classes so that we
3972
+ // can specify which fonts to use. This allows us to render these
3973
+ // characters with a serif font in situations where the browser would
3974
+ // either default to a sans serif or render a placeholder character.
3975
+ // We use CSS class names like cjk_fallback, hangul_fallback and
3976
+ // brahmic_fallback. See ./unicodeScripts.js for the set of possible
3977
+ // script names
4420
3978
 
4421
- defineSymbol(math, main, accent, "\u02ca", "\\acute");
4422
- defineSymbol(math, main, accent, "\u02cb", "\\grave");
4423
- defineSymbol(math, main, accent, "\u00a8", "\\ddot");
4424
- defineSymbol(math, main, accent, "\u007e", "\\tilde");
4425
- defineSymbol(math, main, accent, "\u02c9", "\\bar");
4426
- defineSymbol(math, main, accent, "\u02d8", "\\breve");
4427
- defineSymbol(math, main, accent, "\u02c7", "\\check");
4428
- defineSymbol(math, main, accent, "\u005e", "\\hat");
4429
- defineSymbol(math, main, accent, "\u20d7", "\\vec");
4430
- defineSymbol(math, main, accent, "\u02d9", "\\dot");
4431
- defineSymbol(math, main, accent, "\u02da", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA
3979
+ var script = scriptFromCodepoint(this.text.charCodeAt(0));
4432
3980
 
4433
- defineSymbol(math, main, mathord, "\ue131", "\\@imath");
4434
- defineSymbol(math, main, mathord, "\ue237", "\\@jmath");
4435
- defineSymbol(math, main, textord, "\u0131", "\u0131");
4436
- defineSymbol(math, main, textord, "\u0237", "\u0237");
4437
- defineSymbol(text, main, textord, "\u0131", "\\i", true);
4438
- defineSymbol(text, main, textord, "\u0237", "\\j", true);
4439
- defineSymbol(text, main, textord, "\u00df", "\\ss", true);
4440
- defineSymbol(text, main, textord, "\u00e6", "\\ae", true);
4441
- defineSymbol(text, main, textord, "\u0153", "\\oe", true);
4442
- defineSymbol(text, main, textord, "\u00f8", "\\o", true);
4443
- defineSymbol(text, main, textord, "\u00c6", "\\AE", true);
4444
- defineSymbol(text, main, textord, "\u0152", "\\OE", true);
4445
- defineSymbol(text, main, textord, "\u00d8", "\\O", true);
4446
- defineSymbol(text, main, accent, "\u02ca", "\\'"); // acute
3981
+ if (script) {
3982
+ this.classes.push(script + "_fallback");
3983
+ }
4447
3984
 
4448
- defineSymbol(text, main, accent, "\u02cb", "\\`"); // grave
3985
+ if (/[îïíì]/.test(this.text)) {
3986
+ // add ī when we add Extended Latin
3987
+ this.text = iCombinations[this.text];
3988
+ }
3989
+ }
4449
3990
 
4450
- defineSymbol(text, main, accent, "\u02c6", "\\^"); // circumflex
3991
+ hasClass(className) {
3992
+ return utils.contains(this.classes, className);
3993
+ }
3994
+ /**
3995
+ * Creates a text node or span from a symbol node. Note that a span is only
3996
+ * created if it is needed.
3997
+ */
4451
3998
 
4452
- defineSymbol(text, main, accent, "\u02dc", "\\~"); // tilde
4453
3999
 
4454
- defineSymbol(text, main, accent, "\u02c9", "\\="); // macron
4000
+ toNode() {
4001
+ var node = document.createTextNode(this.text);
4002
+ var span = null;
4455
4003
 
4456
- defineSymbol(text, main, accent, "\u02d8", "\\u"); // breve
4004
+ if (this.italic > 0) {
4005
+ span = document.createElement("span");
4006
+ span.style.marginRight = makeEm(this.italic);
4007
+ }
4008
+
4009
+ if (this.classes.length > 0) {
4010
+ span = span || document.createElement("span");
4011
+ span.className = createClass(this.classes);
4012
+ }
4013
+
4014
+ for (var style in this.style) {
4015
+ if (this.style.hasOwnProperty(style)) {
4016
+ span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type.
4017
+
4018
+ span.style[style] = this.style[style];
4019
+ }
4020
+ }
4021
+
4022
+ if (span) {
4023
+ span.appendChild(node);
4024
+ return span;
4025
+ } else {
4026
+ return node;
4027
+ }
4028
+ }
4029
+ /**
4030
+ * Creates markup for a symbol node.
4031
+ */
4032
+
4033
+
4034
+ toMarkup() {
4035
+ // TODO(alpert): More duplication than I'd like from
4036
+ // span.prototype.toMarkup and symbolNode.prototype.toNode...
4037
+ var needsSpan = false;
4038
+ var markup = "<span";
4039
+
4040
+ if (this.classes.length) {
4041
+ needsSpan = true;
4042
+ markup += " class=\"";
4043
+ markup += utils.escape(createClass(this.classes));
4044
+ markup += "\"";
4045
+ }
4046
+
4047
+ var styles = "";
4048
+
4049
+ if (this.italic > 0) {
4050
+ styles += "margin-right:" + this.italic + "em;";
4051
+ }
4052
+
4053
+ for (var style in this.style) {
4054
+ if (this.style.hasOwnProperty(style)) {
4055
+ styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
4056
+ }
4057
+ }
4058
+
4059
+ if (styles) {
4060
+ needsSpan = true;
4061
+ markup += " style=\"" + utils.escape(styles) + "\"";
4062
+ }
4063
+
4064
+ var escaped = utils.escape(this.text);
4065
+
4066
+ if (needsSpan) {
4067
+ markup += ">";
4068
+ markup += escaped;
4069
+ markup += "</span>";
4070
+ return markup;
4071
+ } else {
4072
+ return escaped;
4073
+ }
4074
+ }
4075
+
4076
+ }
4077
+ /**
4078
+ * SVG nodes are used to render stretchy wide elements.
4079
+ */
4457
4080
 
4458
- defineSymbol(text, main, accent, "\u02d9", "\\."); // dot above
4081
+ class SvgNode {
4082
+ constructor(children, attributes) {
4083
+ this.children = void 0;
4084
+ this.attributes = void 0;
4085
+ this.children = children || [];
4086
+ this.attributes = attributes || {};
4087
+ }
4459
4088
 
4460
- defineSymbol(text, main, accent, "\u00b8", "\\c"); // cedilla
4089
+ toNode() {
4090
+ var svgNS = "http://www.w3.org/2000/svg";
4091
+ var node = document.createElementNS(svgNS, "svg"); // Apply attributes
4461
4092
 
4462
- defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above
4093
+ for (var attr in this.attributes) {
4094
+ if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
4095
+ node.setAttribute(attr, this.attributes[attr]);
4096
+ }
4097
+ }
4463
4098
 
4464
- defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron
4099
+ for (var i = 0; i < this.children.length; i++) {
4100
+ node.appendChild(this.children[i].toNode());
4101
+ }
4465
4102
 
4466
- defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaresis
4103
+ return node;
4104
+ }
4467
4105
 
4468
- defineSymbol(text, main, accent, "\u02dd", "\\H"); // double acute
4106
+ toMarkup() {
4107
+ var markup = "<svg xmlns=\"http://www.w3.org/2000/svg\""; // Apply attributes
4469
4108
 
4470
- defineSymbol(text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph
4471
- // These ligatures are detected and created in Parser.js's `formLigatures`.
4109
+ for (var attr in this.attributes) {
4110
+ if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
4111
+ markup += " " + attr + "='" + this.attributes[attr] + "'";
4112
+ }
4113
+ }
4472
4114
 
4473
- var ligatures = {
4474
- "--": true,
4475
- "---": true,
4476
- "``": true,
4477
- "''": true
4478
- };
4479
- defineSymbol(text, main, textord, "\u2013", "--", true);
4480
- defineSymbol(text, main, textord, "\u2013", "\\textendash");
4481
- defineSymbol(text, main, textord, "\u2014", "---", true);
4482
- defineSymbol(text, main, textord, "\u2014", "\\textemdash");
4483
- defineSymbol(text, main, textord, "\u2018", "`", true);
4484
- defineSymbol(text, main, textord, "\u2018", "\\textquoteleft");
4485
- defineSymbol(text, main, textord, "\u2019", "'", true);
4486
- defineSymbol(text, main, textord, "\u2019", "\\textquoteright");
4487
- defineSymbol(text, main, textord, "\u201c", "``", true);
4488
- defineSymbol(text, main, textord, "\u201c", "\\textquotedblleft");
4489
- defineSymbol(text, main, textord, "\u201d", "''", true);
4490
- defineSymbol(text, main, textord, "\u201d", "\\textquotedblright"); // \degree from gensymb package
4115
+ markup += ">";
4491
4116
 
4492
- defineSymbol(math, main, textord, "\u00b0", "\\degree", true);
4493
- defineSymbol(text, main, textord, "\u00b0", "\\degree"); // \textdegree from inputenc package
4117
+ for (var i = 0; i < this.children.length; i++) {
4118
+ markup += this.children[i].toMarkup();
4119
+ }
4494
4120
 
4495
- defineSymbol(text, main, textord, "\u00b0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math
4496
- // mode, but among our fonts, only Main-Regular defines this character "163".
4121
+ markup += "</svg>";
4122
+ return markup;
4123
+ }
4497
4124
 
4498
- defineSymbol(math, main, textord, "\u00a3", "\\pounds");
4499
- defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true);
4500
- defineSymbol(text, main, textord, "\u00a3", "\\pounds");
4501
- defineSymbol(text, main, textord, "\u00a3", "\\textsterling", true);
4502
- defineSymbol(math, ams, textord, "\u2720", "\\maltese");
4503
- defineSymbol(text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards.
4504
- // All of these are textords in math mode
4125
+ }
4126
+ class PathNode {
4127
+ constructor(pathName, alternate) {
4128
+ this.pathName = void 0;
4129
+ this.alternate = void 0;
4130
+ this.pathName = pathName;
4131
+ this.alternate = alternate; // Used only for \sqrt, \phase, & tall delims
4132
+ }
4505
4133
 
4506
- var mathTextSymbols = "0123456789/@.\"";
4134
+ toNode() {
4135
+ var svgNS = "http://www.w3.org/2000/svg";
4136
+ var node = document.createElementNS(svgNS, "path");
4507
4137
 
4508
- for (var i = 0; i < mathTextSymbols.length; i++) {
4509
- var ch = mathTextSymbols.charAt(i);
4510
- defineSymbol(math, main, textord, ch, ch);
4511
- } // All of these are textords in text mode
4138
+ if (this.alternate) {
4139
+ node.setAttribute("d", this.alternate);
4140
+ } else {
4141
+ node.setAttribute("d", path[this.pathName]);
4142
+ }
4512
4143
 
4144
+ return node;
4145
+ }
4513
4146
 
4514
- var textSymbols = "0123456789!@*()-=+\";:?/.,";
4147
+ toMarkup() {
4148
+ if (this.alternate) {
4149
+ return "<path d='" + this.alternate + "'/>";
4150
+ } else {
4151
+ return "<path d='" + path[this.pathName] + "'/>";
4152
+ }
4153
+ }
4515
4154
 
4516
- for (var _i = 0; _i < textSymbols.length; _i++) {
4517
- var _ch = textSymbols.charAt(_i);
4155
+ }
4156
+ class LineNode {
4157
+ constructor(attributes) {
4158
+ this.attributes = void 0;
4159
+ this.attributes = attributes || {};
4160
+ }
4518
4161
 
4519
- defineSymbol(text, main, textord, _ch, _ch);
4520
- } // All of these are textords in text mode, and mathords in math mode
4162
+ toNode() {
4163
+ var svgNS = "http://www.w3.org/2000/svg";
4164
+ var node = document.createElementNS(svgNS, "line"); // Apply attributes
4521
4165
 
4166
+ for (var attr in this.attributes) {
4167
+ if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
4168
+ node.setAttribute(attr, this.attributes[attr]);
4169
+ }
4170
+ }
4522
4171
 
4523
- var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
4172
+ return node;
4173
+ }
4524
4174
 
4525
- for (var _i2 = 0; _i2 < letters.length; _i2++) {
4526
- var _ch2 = letters.charAt(_i2);
4175
+ toMarkup() {
4176
+ var markup = "<line";
4527
4177
 
4528
- defineSymbol(math, main, mathord, _ch2, _ch2);
4529
- defineSymbol(text, main, textord, _ch2, _ch2);
4530
- } // Blackboard bold and script letters in Unicode range
4178
+ for (var attr in this.attributes) {
4179
+ if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
4180
+ markup += " " + attr + "='" + this.attributes[attr] + "'";
4181
+ }
4182
+ }
4531
4183
 
4184
+ markup += "/>";
4185
+ return markup;
4186
+ }
4532
4187
 
4533
- defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
4188
+ }
4189
+ function assertSymbolDomNode(group) {
4190
+ if (group instanceof SymbolNode) {
4191
+ return group;
4192
+ } else {
4193
+ throw new Error("Expected symbolNode but got " + String(group) + ".");
4194
+ }
4195
+ }
4196
+ function assertSpan(group) {
4197
+ if (group instanceof Span) {
4198
+ return group;
4199
+ } else {
4200
+ throw new Error("Expected span<HtmlDomNode> but got " + String(group) + ".");
4201
+ }
4202
+ }
4534
4203
 
4535
- defineSymbol(text, ams, textord, "C", "\u2102");
4536
- defineSymbol(math, ams, textord, "H", "\u210D");
4537
- defineSymbol(text, ams, textord, "H", "\u210D");
4538
- defineSymbol(math, ams, textord, "N", "\u2115");
4539
- defineSymbol(text, ams, textord, "N", "\u2115");
4540
- defineSymbol(math, ams, textord, "P", "\u2119");
4541
- defineSymbol(text, ams, textord, "P", "\u2119");
4542
- defineSymbol(math, ams, textord, "Q", "\u211A");
4543
- defineSymbol(text, ams, textord, "Q", "\u211A");
4544
- defineSymbol(math, ams, textord, "R", "\u211D");
4545
- defineSymbol(text, ams, textord, "R", "\u211D");
4546
- defineSymbol(math, ams, textord, "Z", "\u2124");
4547
- defineSymbol(text, ams, textord, "Z", "\u2124");
4548
- defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant
4204
+ /**
4205
+ * This file holds a list of all no-argument functions and single-character
4206
+ * symbols (like 'a' or ';').
4207
+ *
4208
+ * For each of the symbols, there are three properties they can have:
4209
+ * - font (required): the font to be used for this symbol. Either "main" (the
4210
+ normal font), or "ams" (the ams fonts).
4211
+ * - group (required): the ParseNode group type the symbol should have (i.e.
4212
+ "textord", "mathord", etc).
4213
+ See https://github.com/KaTeX/KaTeX/wiki/Examining-TeX#group-types
4214
+ * - replace: the character that this symbol or function should be
4215
+ * replaced with (i.e. "\phi" has a replace value of "\u03d5", the phi
4216
+ * character in the main font).
4217
+ *
4218
+ * The outermost map in the table indicates what mode the symbols should be
4219
+ * accepted in (e.g. "math" or "text").
4220
+ */
4221
+ // Some of these have a "-token" suffix since these are also used as `ParseNode`
4222
+ // types for raw text tokens, and we want to avoid conflicts with higher-level
4223
+ // `ParseNode` types. These `ParseNode`s are constructed within `Parser` by
4224
+ // looking up the `symbols` map.
4225
+ var ATOMS = {
4226
+ "bin": 1,
4227
+ "close": 1,
4228
+ "inner": 1,
4229
+ "open": 1,
4230
+ "punct": 1,
4231
+ "rel": 1
4232
+ };
4233
+ var NON_ATOMS = {
4234
+ "accent-token": 1,
4235
+ "mathord": 1,
4236
+ "op-token": 1,
4237
+ "spacing": 1,
4238
+ "textord": 1
4239
+ };
4240
+ var symbols = {
4241
+ "math": {},
4242
+ "text": {}
4243
+ };
4244
+ /** `acceptUnicodeChar = true` is only applicable if `replace` is set. */
4549
4245
 
4550
- defineSymbol(text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters.
4551
- // We support some letters in the Unicode range U+1D400 to U+1D7FF,
4552
- // Mathematical Alphanumeric Symbols.
4553
- // Some editors do not deal well with wide characters. So don't write the
4554
- // string into this file. Instead, create the string from the surrogate pair.
4246
+ function defineSymbol(mode, font, group, replace, name, acceptUnicodeChar) {
4247
+ symbols[mode][name] = {
4248
+ font,
4249
+ group,
4250
+ replace
4251
+ };
4555
4252
 
4556
- var wideChar = "";
4253
+ if (acceptUnicodeChar && replace) {
4254
+ symbols[mode][replace] = symbols[mode][name];
4255
+ }
4256
+ } // Some abbreviations for commonly used strings.
4257
+ // This helps minify the code, and also spotting typos using jshint.
4258
+ // modes:
4557
4259
 
4558
- for (var _i3 = 0; _i3 < letters.length; _i3++) {
4559
- var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair.
4560
- // 0xD835 is the high surrogate for all letters in the range we support.
4561
- // 0xDC00 is the low surrogate for bold A.
4260
+ var math = "math";
4261
+ var text = "text"; // fonts:
4562
4262
 
4263
+ var main = "main";
4264
+ var ams = "ams"; // groups:
4563
4265
 
4564
- wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
4266
+ var accent = "accent-token";
4267
+ var bin = "bin";
4268
+ var close = "close";
4269
+ var inner = "inner";
4270
+ var mathord = "mathord";
4271
+ var op = "op-token";
4272
+ var open = "open";
4273
+ var punct = "punct";
4274
+ var rel = "rel";
4275
+ var spacing = "spacing";
4276
+ var textord = "textord"; // Now comes the symbol table
4277
+ // Relation Symbols
4565
4278
 
4566
- defineSymbol(math, main, mathord, _ch3, wideChar);
4567
- defineSymbol(text, main, textord, _ch3, wideChar);
4568
- wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic
4279
+ defineSymbol(math, main, rel, "\u2261", "\\equiv", true);
4280
+ defineSymbol(math, main, rel, "\u227a", "\\prec", true);
4281
+ defineSymbol(math, main, rel, "\u227b", "\\succ", true);
4282
+ defineSymbol(math, main, rel, "\u223c", "\\sim", true);
4283
+ defineSymbol(math, main, rel, "\u22a5", "\\perp");
4284
+ defineSymbol(math, main, rel, "\u2aaf", "\\preceq", true);
4285
+ defineSymbol(math, main, rel, "\u2ab0", "\\succeq", true);
4286
+ defineSymbol(math, main, rel, "\u2243", "\\simeq", true);
4287
+ defineSymbol(math, main, rel, "\u2223", "\\mid", true);
4288
+ defineSymbol(math, main, rel, "\u226a", "\\ll", true);
4289
+ defineSymbol(math, main, rel, "\u226b", "\\gg", true);
4290
+ defineSymbol(math, main, rel, "\u224d", "\\asymp", true);
4291
+ defineSymbol(math, main, rel, "\u2225", "\\parallel");
4292
+ defineSymbol(math, main, rel, "\u22c8", "\\bowtie", true);
4293
+ defineSymbol(math, main, rel, "\u2323", "\\smile", true);
4294
+ defineSymbol(math, main, rel, "\u2291", "\\sqsubseteq", true);
4295
+ defineSymbol(math, main, rel, "\u2292", "\\sqsupseteq", true);
4296
+ defineSymbol(math, main, rel, "\u2250", "\\doteq", true);
4297
+ defineSymbol(math, main, rel, "\u2322", "\\frown", true);
4298
+ defineSymbol(math, main, rel, "\u220b", "\\ni", true);
4299
+ defineSymbol(math, main, rel, "\u221d", "\\propto", true);
4300
+ defineSymbol(math, main, rel, "\u22a2", "\\vdash", true);
4301
+ defineSymbol(math, main, rel, "\u22a3", "\\dashv", true);
4302
+ defineSymbol(math, main, rel, "\u220b", "\\owns"); // Punctuation
4569
4303
 
4570
- defineSymbol(math, main, mathord, _ch3, wideChar);
4571
- defineSymbol(text, main, textord, _ch3, wideChar);
4572
- wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic
4304
+ defineSymbol(math, main, punct, "\u002e", "\\ldotp");
4305
+ defineSymbol(math, main, punct, "\u22c5", "\\cdotp"); // Misc Symbols
4573
4306
 
4574
- defineSymbol(math, main, mathord, _ch3, wideChar);
4575
- defineSymbol(text, main, textord, _ch3, wideChar);
4576
- wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur
4307
+ defineSymbol(math, main, textord, "\u0023", "\\#");
4308
+ defineSymbol(text, main, textord, "\u0023", "\\#");
4309
+ defineSymbol(math, main, textord, "\u0026", "\\&");
4310
+ defineSymbol(text, main, textord, "\u0026", "\\&");
4311
+ defineSymbol(math, main, textord, "\u2135", "\\aleph", true);
4312
+ defineSymbol(math, main, textord, "\u2200", "\\forall", true);
4313
+ defineSymbol(math, main, textord, "\u210f", "\\hbar", true);
4314
+ defineSymbol(math, main, textord, "\u2203", "\\exists", true);
4315
+ defineSymbol(math, main, textord, "\u2207", "\\nabla", true);
4316
+ defineSymbol(math, main, textord, "\u266d", "\\flat", true);
4317
+ defineSymbol(math, main, textord, "\u2113", "\\ell", true);
4318
+ defineSymbol(math, main, textord, "\u266e", "\\natural", true);
4319
+ defineSymbol(math, main, textord, "\u2663", "\\clubsuit", true);
4320
+ defineSymbol(math, main, textord, "\u2118", "\\wp", true);
4321
+ defineSymbol(math, main, textord, "\u266f", "\\sharp", true);
4322
+ defineSymbol(math, main, textord, "\u2662", "\\diamondsuit", true);
4323
+ defineSymbol(math, main, textord, "\u211c", "\\Re", true);
4324
+ defineSymbol(math, main, textord, "\u2661", "\\heartsuit", true);
4325
+ defineSymbol(math, main, textord, "\u2111", "\\Im", true);
4326
+ defineSymbol(math, main, textord, "\u2660", "\\spadesuit", true);
4327
+ defineSymbol(math, main, textord, "\u00a7", "\\S", true);
4328
+ defineSymbol(text, main, textord, "\u00a7", "\\S");
4329
+ defineSymbol(math, main, textord, "\u00b6", "\\P", true);
4330
+ defineSymbol(text, main, textord, "\u00b6", "\\P"); // Math and Text
4577
4331
 
4578
- defineSymbol(math, main, mathord, _ch3, wideChar);
4579
- defineSymbol(text, main, textord, _ch3, wideChar);
4580
- wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif
4332
+ defineSymbol(math, main, textord, "\u2020", "\\dag");
4333
+ defineSymbol(text, main, textord, "\u2020", "\\dag");
4334
+ defineSymbol(text, main, textord, "\u2020", "\\textdagger");
4335
+ defineSymbol(math, main, textord, "\u2021", "\\ddag");
4336
+ defineSymbol(text, main, textord, "\u2021", "\\ddag");
4337
+ defineSymbol(text, main, textord, "\u2021", "\\textdaggerdbl"); // Large Delimiters
4581
4338
 
4582
- defineSymbol(math, main, mathord, _ch3, wideChar);
4583
- defineSymbol(text, main, textord, _ch3, wideChar);
4584
- wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold
4339
+ defineSymbol(math, main, close, "\u23b1", "\\rmoustache", true);
4340
+ defineSymbol(math, main, open, "\u23b0", "\\lmoustache", true);
4341
+ defineSymbol(math, main, close, "\u27ef", "\\rgroup", true);
4342
+ defineSymbol(math, main, open, "\u27ee", "\\lgroup", true); // Binary Operators
4585
4343
 
4586
- defineSymbol(math, main, mathord, _ch3, wideChar);
4587
- defineSymbol(text, main, textord, _ch3, wideChar);
4588
- wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic
4344
+ defineSymbol(math, main, bin, "\u2213", "\\mp", true);
4345
+ defineSymbol(math, main, bin, "\u2296", "\\ominus", true);
4346
+ defineSymbol(math, main, bin, "\u228e", "\\uplus", true);
4347
+ defineSymbol(math, main, bin, "\u2293", "\\sqcap", true);
4348
+ defineSymbol(math, main, bin, "\u2217", "\\ast");
4349
+ defineSymbol(math, main, bin, "\u2294", "\\sqcup", true);
4350
+ defineSymbol(math, main, bin, "\u25ef", "\\bigcirc", true);
4351
+ defineSymbol(math, main, bin, "\u2219", "\\bullet");
4352
+ defineSymbol(math, main, bin, "\u2021", "\\ddagger");
4353
+ defineSymbol(math, main, bin, "\u2240", "\\wr", true);
4354
+ defineSymbol(math, main, bin, "\u2a3f", "\\amalg");
4355
+ defineSymbol(math, main, bin, "\u0026", "\\And"); // from amsmath
4356
+ // Arrow Symbols
4589
4357
 
4590
- defineSymbol(math, main, mathord, _ch3, wideChar);
4591
- defineSymbol(text, main, textord, _ch3, wideChar);
4592
- wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace
4358
+ defineSymbol(math, main, rel, "\u27f5", "\\longleftarrow", true);
4359
+ defineSymbol(math, main, rel, "\u21d0", "\\Leftarrow", true);
4360
+ defineSymbol(math, main, rel, "\u27f8", "\\Longleftarrow", true);
4361
+ defineSymbol(math, main, rel, "\u27f6", "\\longrightarrow", true);
4362
+ defineSymbol(math, main, rel, "\u21d2", "\\Rightarrow", true);
4363
+ defineSymbol(math, main, rel, "\u27f9", "\\Longrightarrow", true);
4364
+ defineSymbol(math, main, rel, "\u2194", "\\leftrightarrow", true);
4365
+ defineSymbol(math, main, rel, "\u27f7", "\\longleftrightarrow", true);
4366
+ defineSymbol(math, main, rel, "\u21d4", "\\Leftrightarrow", true);
4367
+ defineSymbol(math, main, rel, "\u27fa", "\\Longleftrightarrow", true);
4368
+ defineSymbol(math, main, rel, "\u21a6", "\\mapsto", true);
4369
+ defineSymbol(math, main, rel, "\u27fc", "\\longmapsto", true);
4370
+ defineSymbol(math, main, rel, "\u2197", "\\nearrow", true);
4371
+ defineSymbol(math, main, rel, "\u21a9", "\\hookleftarrow", true);
4372
+ defineSymbol(math, main, rel, "\u21aa", "\\hookrightarrow", true);
4373
+ defineSymbol(math, main, rel, "\u2198", "\\searrow", true);
4374
+ defineSymbol(math, main, rel, "\u21bc", "\\leftharpoonup", true);
4375
+ defineSymbol(math, main, rel, "\u21c0", "\\rightharpoonup", true);
4376
+ defineSymbol(math, main, rel, "\u2199", "\\swarrow", true);
4377
+ defineSymbol(math, main, rel, "\u21bd", "\\leftharpoondown", true);
4378
+ defineSymbol(math, main, rel, "\u21c1", "\\rightharpoondown", true);
4379
+ defineSymbol(math, main, rel, "\u2196", "\\nwarrow", true);
4380
+ defineSymbol(math, main, rel, "\u21cc", "\\rightleftharpoons", true); // AMS Negated Binary Relations
4593
4381
 
4594
- defineSymbol(math, main, mathord, _ch3, wideChar);
4595
- defineSymbol(text, main, textord, _ch3, wideChar);
4382
+ defineSymbol(math, ams, rel, "\u226e", "\\nless", true); // Symbol names preceeded by "@" each have a corresponding macro.
4596
4383
 
4597
- if (_i3 < 26) {
4598
- // KaTeX fonts have only capital letters for blackboard bold and script.
4599
- // See exception for k below.
4600
- wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck
4384
+ defineSymbol(math, ams, rel, "\ue010", "\\@nleqslant");
4385
+ defineSymbol(math, ams, rel, "\ue011", "\\@nleqq");
4386
+ defineSymbol(math, ams, rel, "\u2a87", "\\lneq", true);
4387
+ defineSymbol(math, ams, rel, "\u2268", "\\lneqq", true);
4388
+ defineSymbol(math, ams, rel, "\ue00c", "\\@lvertneqq");
4389
+ defineSymbol(math, ams, rel, "\u22e6", "\\lnsim", true);
4390
+ defineSymbol(math, ams, rel, "\u2a89", "\\lnapprox", true);
4391
+ defineSymbol(math, ams, rel, "\u2280", "\\nprec", true); // unicode-math maps \u22e0 to \npreccurlyeq. We'll use the AMS synonym.
4601
4392
 
4602
- defineSymbol(math, main, mathord, _ch3, wideChar);
4603
- defineSymbol(text, main, textord, _ch3, wideChar);
4604
- wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script
4393
+ defineSymbol(math, ams, rel, "\u22e0", "\\npreceq", true);
4394
+ defineSymbol(math, ams, rel, "\u22e8", "\\precnsim", true);
4395
+ defineSymbol(math, ams, rel, "\u2ab9", "\\precnapprox", true);
4396
+ defineSymbol(math, ams, rel, "\u2241", "\\nsim", true);
4397
+ defineSymbol(math, ams, rel, "\ue006", "\\@nshortmid");
4398
+ defineSymbol(math, ams, rel, "\u2224", "\\nmid", true);
4399
+ defineSymbol(math, ams, rel, "\u22ac", "\\nvdash", true);
4400
+ defineSymbol(math, ams, rel, "\u22ad", "\\nvDash", true);
4401
+ defineSymbol(math, ams, rel, "\u22ea", "\\ntriangleleft");
4402
+ defineSymbol(math, ams, rel, "\u22ec", "\\ntrianglelefteq", true);
4403
+ defineSymbol(math, ams, rel, "\u228a", "\\subsetneq", true);
4404
+ defineSymbol(math, ams, rel, "\ue01a", "\\@varsubsetneq");
4405
+ defineSymbol(math, ams, rel, "\u2acb", "\\subsetneqq", true);
4406
+ defineSymbol(math, ams, rel, "\ue017", "\\@varsubsetneqq");
4407
+ defineSymbol(math, ams, rel, "\u226f", "\\ngtr", true);
4408
+ defineSymbol(math, ams, rel, "\ue00f", "\\@ngeqslant");
4409
+ defineSymbol(math, ams, rel, "\ue00e", "\\@ngeqq");
4410
+ defineSymbol(math, ams, rel, "\u2a88", "\\gneq", true);
4411
+ defineSymbol(math, ams, rel, "\u2269", "\\gneqq", true);
4412
+ defineSymbol(math, ams, rel, "\ue00d", "\\@gvertneqq");
4413
+ defineSymbol(math, ams, rel, "\u22e7", "\\gnsim", true);
4414
+ defineSymbol(math, ams, rel, "\u2a8a", "\\gnapprox", true);
4415
+ defineSymbol(math, ams, rel, "\u2281", "\\nsucc", true); // unicode-math maps \u22e1 to \nsucccurlyeq. We'll use the AMS synonym.
4605
4416
 
4606
- defineSymbol(math, main, mathord, _ch3, wideChar);
4607
- defineSymbol(text, main, textord, _ch3, wideChar);
4608
- } // TODO: Add bold script when it is supported by a KaTeX font.
4417
+ defineSymbol(math, ams, rel, "\u22e1", "\\nsucceq", true);
4418
+ defineSymbol(math, ams, rel, "\u22e9", "\\succnsim", true);
4419
+ defineSymbol(math, ams, rel, "\u2aba", "\\succnapprox", true); // unicode-math maps \u2246 to \simneqq. We'll use the AMS synonym.
4609
4420
 
4610
- } // "k" is the only double struck lower case letter in the KaTeX fonts.
4421
+ defineSymbol(math, ams, rel, "\u2246", "\\ncong", true);
4422
+ defineSymbol(math, ams, rel, "\ue007", "\\@nshortparallel");
4423
+ defineSymbol(math, ams, rel, "\u2226", "\\nparallel", true);
4424
+ defineSymbol(math, ams, rel, "\u22af", "\\nVDash", true);
4425
+ defineSymbol(math, ams, rel, "\u22eb", "\\ntriangleright");
4426
+ defineSymbol(math, ams, rel, "\u22ed", "\\ntrianglerighteq", true);
4427
+ defineSymbol(math, ams, rel, "\ue018", "\\@nsupseteqq");
4428
+ defineSymbol(math, ams, rel, "\u228b", "\\supsetneq", true);
4429
+ defineSymbol(math, ams, rel, "\ue01b", "\\@varsupsetneq");
4430
+ defineSymbol(math, ams, rel, "\u2acc", "\\supsetneqq", true);
4431
+ defineSymbol(math, ams, rel, "\ue019", "\\@varsupsetneqq");
4432
+ defineSymbol(math, ams, rel, "\u22ae", "\\nVdash", true);
4433
+ defineSymbol(math, ams, rel, "\u2ab5", "\\precneqq", true);
4434
+ defineSymbol(math, ams, rel, "\u2ab6", "\\succneqq", true);
4435
+ defineSymbol(math, ams, rel, "\ue016", "\\@nsubseteqq");
4436
+ defineSymbol(math, ams, bin, "\u22b4", "\\unlhd");
4437
+ defineSymbol(math, ams, bin, "\u22b5", "\\unrhd"); // AMS Negated Arrows
4611
4438
 
4439
+ defineSymbol(math, ams, rel, "\u219a", "\\nleftarrow", true);
4440
+ defineSymbol(math, ams, rel, "\u219b", "\\nrightarrow", true);
4441
+ defineSymbol(math, ams, rel, "\u21cd", "\\nLeftarrow", true);
4442
+ defineSymbol(math, ams, rel, "\u21cf", "\\nRightarrow", true);
4443
+ defineSymbol(math, ams, rel, "\u21ae", "\\nleftrightarrow", true);
4444
+ defineSymbol(math, ams, rel, "\u21ce", "\\nLeftrightarrow", true); // AMS Misc
4612
4445
 
4613
- wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
4446
+ defineSymbol(math, ams, rel, "\u25b3", "\\vartriangle");
4447
+ defineSymbol(math, ams, textord, "\u210f", "\\hslash");
4448
+ defineSymbol(math, ams, textord, "\u25bd", "\\triangledown");
4449
+ defineSymbol(math, ams, textord, "\u25ca", "\\lozenge");
4450
+ defineSymbol(math, ams, textord, "\u24c8", "\\circledS");
4451
+ defineSymbol(math, ams, textord, "\u00ae", "\\circledR");
4452
+ defineSymbol(text, ams, textord, "\u00ae", "\\circledR");
4453
+ defineSymbol(math, ams, textord, "\u2221", "\\measuredangle", true);
4454
+ defineSymbol(math, ams, textord, "\u2204", "\\nexists");
4455
+ defineSymbol(math, ams, textord, "\u2127", "\\mho");
4456
+ defineSymbol(math, ams, textord, "\u2132", "\\Finv", true);
4457
+ defineSymbol(math, ams, textord, "\u2141", "\\Game", true);
4458
+ defineSymbol(math, ams, textord, "\u2035", "\\backprime");
4459
+ defineSymbol(math, ams, textord, "\u25b2", "\\blacktriangle");
4460
+ defineSymbol(math, ams, textord, "\u25bc", "\\blacktriangledown");
4461
+ defineSymbol(math, ams, textord, "\u25a0", "\\blacksquare");
4462
+ defineSymbol(math, ams, textord, "\u29eb", "\\blacklozenge");
4463
+ defineSymbol(math, ams, textord, "\u2605", "\\bigstar");
4464
+ defineSymbol(math, ams, textord, "\u2222", "\\sphericalangle", true);
4465
+ defineSymbol(math, ams, textord, "\u2201", "\\complement", true); // unicode-math maps U+F0 to \matheth. We map to AMS function \eth
4614
4466
 
4615
- defineSymbol(math, main, mathord, "k", wideChar);
4616
- defineSymbol(text, main, textord, "k", wideChar); // Next, some wide character numerals
4467
+ defineSymbol(math, ams, textord, "\u00f0", "\\eth", true);
4468
+ defineSymbol(text, main, textord, "\u00f0", "\u00f0");
4469
+ defineSymbol(math, ams, textord, "\u2571", "\\diagup");
4470
+ defineSymbol(math, ams, textord, "\u2572", "\\diagdown");
4471
+ defineSymbol(math, ams, textord, "\u25a1", "\\square");
4472
+ defineSymbol(math, ams, textord, "\u25a1", "\\Box");
4473
+ defineSymbol(math, ams, textord, "\u25ca", "\\Diamond"); // unicode-math maps U+A5 to \mathyen. We map to AMS function \yen
4617
4474
 
4618
- for (var _i4 = 0; _i4 < 10; _i4++) {
4619
- var _ch4 = _i4.toString();
4475
+ defineSymbol(math, ams, textord, "\u00a5", "\\yen", true);
4476
+ defineSymbol(text, ams, textord, "\u00a5", "\\yen", true);
4477
+ defineSymbol(math, ams, textord, "\u2713", "\\checkmark", true);
4478
+ defineSymbol(text, ams, textord, "\u2713", "\\checkmark"); // AMS Hebrew
4620
4479
 
4621
- wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold
4480
+ defineSymbol(math, ams, textord, "\u2136", "\\beth", true);
4481
+ defineSymbol(math, ams, textord, "\u2138", "\\daleth", true);
4482
+ defineSymbol(math, ams, textord, "\u2137", "\\gimel", true); // AMS Greek
4622
4483
 
4623
- defineSymbol(math, main, mathord, _ch4, wideChar);
4624
- defineSymbol(text, main, textord, _ch4, wideChar);
4625
- wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif
4484
+ defineSymbol(math, ams, textord, "\u03dd", "\\digamma", true);
4485
+ defineSymbol(math, ams, textord, "\u03f0", "\\varkappa"); // AMS Delimiters
4626
4486
 
4627
- defineSymbol(math, main, mathord, _ch4, wideChar);
4628
- defineSymbol(text, main, textord, _ch4, wideChar);
4629
- wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans
4487
+ defineSymbol(math, ams, open, "\u250c", "\\@ulcorner", true);
4488
+ defineSymbol(math, ams, close, "\u2510", "\\@urcorner", true);
4489
+ defineSymbol(math, ams, open, "\u2514", "\\@llcorner", true);
4490
+ defineSymbol(math, ams, close, "\u2518", "\\@lrcorner", true); // AMS Binary Relations
4630
4491
 
4631
- defineSymbol(math, main, mathord, _ch4, wideChar);
4632
- defineSymbol(text, main, textord, _ch4, wideChar);
4633
- wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace
4492
+ defineSymbol(math, ams, rel, "\u2266", "\\leqq", true);
4493
+ defineSymbol(math, ams, rel, "\u2a7d", "\\leqslant", true);
4494
+ defineSymbol(math, ams, rel, "\u2a95", "\\eqslantless", true);
4495
+ defineSymbol(math, ams, rel, "\u2272", "\\lesssim", true);
4496
+ defineSymbol(math, ams, rel, "\u2a85", "\\lessapprox", true);
4497
+ defineSymbol(math, ams, rel, "\u224a", "\\approxeq", true);
4498
+ defineSymbol(math, ams, bin, "\u22d6", "\\lessdot");
4499
+ defineSymbol(math, ams, rel, "\u22d8", "\\lll", true);
4500
+ defineSymbol(math, ams, rel, "\u2276", "\\lessgtr", true);
4501
+ defineSymbol(math, ams, rel, "\u22da", "\\lesseqgtr", true);
4502
+ defineSymbol(math, ams, rel, "\u2a8b", "\\lesseqqgtr", true);
4503
+ defineSymbol(math, ams, rel, "\u2251", "\\doteqdot");
4504
+ defineSymbol(math, ams, rel, "\u2253", "\\risingdotseq", true);
4505
+ defineSymbol(math, ams, rel, "\u2252", "\\fallingdotseq", true);
4506
+ defineSymbol(math, ams, rel, "\u223d", "\\backsim", true);
4507
+ defineSymbol(math, ams, rel, "\u22cd", "\\backsimeq", true);
4508
+ defineSymbol(math, ams, rel, "\u2ac5", "\\subseteqq", true);
4509
+ defineSymbol(math, ams, rel, "\u22d0", "\\Subset", true);
4510
+ defineSymbol(math, ams, rel, "\u228f", "\\sqsubset", true);
4511
+ defineSymbol(math, ams, rel, "\u227c", "\\preccurlyeq", true);
4512
+ defineSymbol(math, ams, rel, "\u22de", "\\curlyeqprec", true);
4513
+ defineSymbol(math, ams, rel, "\u227e", "\\precsim", true);
4514
+ defineSymbol(math, ams, rel, "\u2ab7", "\\precapprox", true);
4515
+ defineSymbol(math, ams, rel, "\u22b2", "\\vartriangleleft");
4516
+ defineSymbol(math, ams, rel, "\u22b4", "\\trianglelefteq");
4517
+ defineSymbol(math, ams, rel, "\u22a8", "\\vDash", true);
4518
+ defineSymbol(math, ams, rel, "\u22aa", "\\Vvdash", true);
4519
+ defineSymbol(math, ams, rel, "\u2323", "\\smallsmile");
4520
+ defineSymbol(math, ams, rel, "\u2322", "\\smallfrown");
4521
+ defineSymbol(math, ams, rel, "\u224f", "\\bumpeq", true);
4522
+ defineSymbol(math, ams, rel, "\u224e", "\\Bumpeq", true);
4523
+ defineSymbol(math, ams, rel, "\u2267", "\\geqq", true);
4524
+ defineSymbol(math, ams, rel, "\u2a7e", "\\geqslant", true);
4525
+ defineSymbol(math, ams, rel, "\u2a96", "\\eqslantgtr", true);
4526
+ defineSymbol(math, ams, rel, "\u2273", "\\gtrsim", true);
4527
+ defineSymbol(math, ams, rel, "\u2a86", "\\gtrapprox", true);
4528
+ defineSymbol(math, ams, bin, "\u22d7", "\\gtrdot");
4529
+ defineSymbol(math, ams, rel, "\u22d9", "\\ggg", true);
4530
+ defineSymbol(math, ams, rel, "\u2277", "\\gtrless", true);
4531
+ defineSymbol(math, ams, rel, "\u22db", "\\gtreqless", true);
4532
+ defineSymbol(math, ams, rel, "\u2a8c", "\\gtreqqless", true);
4533
+ defineSymbol(math, ams, rel, "\u2256", "\\eqcirc", true);
4534
+ defineSymbol(math, ams, rel, "\u2257", "\\circeq", true);
4535
+ defineSymbol(math, ams, rel, "\u225c", "\\triangleq", true);
4536
+ defineSymbol(math, ams, rel, "\u223c", "\\thicksim");
4537
+ defineSymbol(math, ams, rel, "\u2248", "\\thickapprox");
4538
+ defineSymbol(math, ams, rel, "\u2ac6", "\\supseteqq", true);
4539
+ defineSymbol(math, ams, rel, "\u22d1", "\\Supset", true);
4540
+ defineSymbol(math, ams, rel, "\u2290", "\\sqsupset", true);
4541
+ defineSymbol(math, ams, rel, "\u227d", "\\succcurlyeq", true);
4542
+ defineSymbol(math, ams, rel, "\u22df", "\\curlyeqsucc", true);
4543
+ defineSymbol(math, ams, rel, "\u227f", "\\succsim", true);
4544
+ defineSymbol(math, ams, rel, "\u2ab8", "\\succapprox", true);
4545
+ defineSymbol(math, ams, rel, "\u22b3", "\\vartriangleright");
4546
+ defineSymbol(math, ams, rel, "\u22b5", "\\trianglerighteq");
4547
+ defineSymbol(math, ams, rel, "\u22a9", "\\Vdash", true);
4548
+ defineSymbol(math, ams, rel, "\u2223", "\\shortmid");
4549
+ defineSymbol(math, ams, rel, "\u2225", "\\shortparallel");
4550
+ defineSymbol(math, ams, rel, "\u226c", "\\between", true);
4551
+ defineSymbol(math, ams, rel, "\u22d4", "\\pitchfork", true);
4552
+ defineSymbol(math, ams, rel, "\u221d", "\\varpropto");
4553
+ defineSymbol(math, ams, rel, "\u25c0", "\\blacktriangleleft"); // unicode-math says that \therefore is a mathord atom.
4554
+ // We kept the amssymb atom type, which is rel.
4634
4555
 
4635
- defineSymbol(math, main, mathord, _ch4, wideChar);
4636
- defineSymbol(text, main, textord, _ch4, wideChar);
4637
- } // We add these Latin-1 letters as symbols for backwards-compatibility,
4638
- // but they are not actually in the font, nor are they supported by the
4639
- // Unicode accent mechanism, so they fall back to Times font and look ugly.
4640
- // TODO(edemaine): Fix this.
4556
+ defineSymbol(math, ams, rel, "\u2234", "\\therefore", true);
4557
+ defineSymbol(math, ams, rel, "\u220d", "\\backepsilon");
4558
+ defineSymbol(math, ams, rel, "\u25b6", "\\blacktriangleright"); // unicode-math says that \because is a mathord atom.
4559
+ // We kept the amssymb atom type, which is rel.
4641
4560
 
4561
+ defineSymbol(math, ams, rel, "\u2235", "\\because", true);
4562
+ defineSymbol(math, ams, rel, "\u22d8", "\\llless");
4563
+ defineSymbol(math, ams, rel, "\u22d9", "\\gggtr");
4564
+ defineSymbol(math, ams, bin, "\u22b2", "\\lhd");
4565
+ defineSymbol(math, ams, bin, "\u22b3", "\\rhd");
4566
+ defineSymbol(math, ams, rel, "\u2242", "\\eqsim", true);
4567
+ defineSymbol(math, main, rel, "\u22c8", "\\Join");
4568
+ defineSymbol(math, ams, rel, "\u2251", "\\Doteq", true); // AMS Binary Operators
4642
4569
 
4643
- var extraLatin = "\u00d0\u00de\u00fe";
4570
+ defineSymbol(math, ams, bin, "\u2214", "\\dotplus", true);
4571
+ defineSymbol(math, ams, bin, "\u2216", "\\smallsetminus");
4572
+ defineSymbol(math, ams, bin, "\u22d2", "\\Cap", true);
4573
+ defineSymbol(math, ams, bin, "\u22d3", "\\Cup", true);
4574
+ defineSymbol(math, ams, bin, "\u2a5e", "\\doublebarwedge", true);
4575
+ defineSymbol(math, ams, bin, "\u229f", "\\boxminus", true);
4576
+ defineSymbol(math, ams, bin, "\u229e", "\\boxplus", true);
4577
+ defineSymbol(math, ams, bin, "\u22c7", "\\divideontimes", true);
4578
+ defineSymbol(math, ams, bin, "\u22c9", "\\ltimes", true);
4579
+ defineSymbol(math, ams, bin, "\u22ca", "\\rtimes", true);
4580
+ defineSymbol(math, ams, bin, "\u22cb", "\\leftthreetimes", true);
4581
+ defineSymbol(math, ams, bin, "\u22cc", "\\rightthreetimes", true);
4582
+ defineSymbol(math, ams, bin, "\u22cf", "\\curlywedge", true);
4583
+ defineSymbol(math, ams, bin, "\u22ce", "\\curlyvee", true);
4584
+ defineSymbol(math, ams, bin, "\u229d", "\\circleddash", true);
4585
+ defineSymbol(math, ams, bin, "\u229b", "\\circledast", true);
4586
+ defineSymbol(math, ams, bin, "\u22c5", "\\centerdot");
4587
+ defineSymbol(math, ams, bin, "\u22ba", "\\intercal", true);
4588
+ defineSymbol(math, ams, bin, "\u22d2", "\\doublecap");
4589
+ defineSymbol(math, ams, bin, "\u22d3", "\\doublecup");
4590
+ defineSymbol(math, ams, bin, "\u22a0", "\\boxtimes", true); // AMS Arrows
4591
+ // Note: unicode-math maps \u21e2 to their own function \rightdasharrow.
4592
+ // We'll map it to AMS function \dashrightarrow. It produces the same atom.
4644
4593
 
4645
- for (var _i5 = 0; _i5 < extraLatin.length; _i5++) {
4646
- var _ch5 = extraLatin.charAt(_i5);
4594
+ defineSymbol(math, ams, rel, "\u21e2", "\\dashrightarrow", true); // unicode-math maps \u21e0 to \leftdasharrow. We'll use the AMS synonym.
4647
4595
 
4648
- defineSymbol(math, main, mathord, _ch5, _ch5);
4649
- defineSymbol(text, main, textord, _ch5, _ch5);
4650
- }
4596
+ defineSymbol(math, ams, rel, "\u21e0", "\\dashleftarrow", true);
4597
+ defineSymbol(math, ams, rel, "\u21c7", "\\leftleftarrows", true);
4598
+ defineSymbol(math, ams, rel, "\u21c6", "\\leftrightarrows", true);
4599
+ defineSymbol(math, ams, rel, "\u21da", "\\Lleftarrow", true);
4600
+ defineSymbol(math, ams, rel, "\u219e", "\\twoheadleftarrow", true);
4601
+ defineSymbol(math, ams, rel, "\u21a2", "\\leftarrowtail", true);
4602
+ defineSymbol(math, ams, rel, "\u21ab", "\\looparrowleft", true);
4603
+ defineSymbol(math, ams, rel, "\u21cb", "\\leftrightharpoons", true);
4604
+ defineSymbol(math, ams, rel, "\u21b6", "\\curvearrowleft", true); // unicode-math maps \u21ba to \acwopencirclearrow. We'll use the AMS synonym.
4651
4605
 
4652
- /**
4653
- * This file provides support for Unicode range U+1D400 to U+1D7FF,
4654
- * Mathematical Alphanumeric Symbols.
4655
- *
4656
- * Function wideCharacterFont takes a wide character as input and returns
4657
- * the font information necessary to render it properly.
4658
- */
4659
- /**
4660
- * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf
4661
- * That document sorts characters into groups by font type, say bold or italic.
4662
- *
4663
- * In the arrays below, each subarray consists three elements:
4664
- * * The CSS class of that group when in math mode.
4665
- * * The CSS class of that group when in text mode.
4666
- * * The font name, so that KaTeX can get font metrics.
4667
- */
4606
+ defineSymbol(math, ams, rel, "\u21ba", "\\circlearrowleft", true);
4607
+ defineSymbol(math, ams, rel, "\u21b0", "\\Lsh", true);
4608
+ defineSymbol(math, ams, rel, "\u21c8", "\\upuparrows", true);
4609
+ defineSymbol(math, ams, rel, "\u21bf", "\\upharpoonleft", true);
4610
+ defineSymbol(math, ams, rel, "\u21c3", "\\downharpoonleft", true);
4611
+ defineSymbol(math, main, rel, "\u22b6", "\\origof", true); // not in font
4668
4612
 
4669
- var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright
4670
- ["mathbf", "textbf", "Main-Bold"], // a-z bold upright
4671
- ["mathnormal", "textit", "Math-Italic"], // A-Z italic
4672
- ["mathnormal", "textit", "Math-Italic"], // a-z italic
4673
- ["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic
4674
- ["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic
4675
- // Map fancy A-Z letters to script, not calligraphic.
4676
- // This aligns with unicode-math and math fonts (except Cambria Math).
4677
- ["mathscr", "textscr", "Script-Regular"], // A-Z script
4678
- ["", "", ""], // a-z script. No font
4679
- ["", "", ""], // A-Z bold script. No font
4680
- ["", "", ""], // a-z bold script. No font
4681
- ["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur
4682
- ["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur
4683
- ["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
4684
- ["mathbb", "textbb", "AMS-Regular"], // k double-struck
4685
- ["", "", ""], // A-Z bold Fraktur No font metrics
4686
- ["", "", ""], // a-z bold Fraktur. No font.
4687
- ["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
4688
- ["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
4689
- ["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif
4690
- ["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif
4691
- ["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif
4692
- ["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif
4693
- ["", "", ""], // A-Z bold italic sans. No font
4694
- ["", "", ""], // a-z bold italic sans. No font
4695
- ["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace
4696
- ["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace
4697
- ];
4698
- var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold
4699
- ["", "", ""], // 0-9 double-struck. No KaTeX font.
4700
- ["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif
4701
- ["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif
4702
- ["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace
4703
- ];
4704
- var wideCharacterFont = function wideCharacterFont(wideChar, mode) {
4705
- // IE doesn't support codePointAt(). So work with the surrogate pair.
4706
- var H = wideChar.charCodeAt(0); // high surrogate
4613
+ defineSymbol(math, main, rel, "\u22b7", "\\imageof", true); // not in font
4707
4614
 
4708
- var L = wideChar.charCodeAt(1); // low surrogate
4615
+ defineSymbol(math, ams, rel, "\u22b8", "\\multimap", true);
4616
+ defineSymbol(math, ams, rel, "\u21ad", "\\leftrightsquigarrow", true);
4617
+ defineSymbol(math, ams, rel, "\u21c9", "\\rightrightarrows", true);
4618
+ defineSymbol(math, ams, rel, "\u21c4", "\\rightleftarrows", true);
4619
+ defineSymbol(math, ams, rel, "\u21a0", "\\twoheadrightarrow", true);
4620
+ defineSymbol(math, ams, rel, "\u21a3", "\\rightarrowtail", true);
4621
+ defineSymbol(math, ams, rel, "\u21ac", "\\looparrowright", true);
4622
+ defineSymbol(math, ams, rel, "\u21b7", "\\curvearrowright", true); // unicode-math maps \u21bb to \cwopencirclearrow. We'll use the AMS synonym.
4709
4623
 
4710
- var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000;
4711
- var j = mode === "math" ? 0 : 1; // column index for CSS class.
4624
+ defineSymbol(math, ams, rel, "\u21bb", "\\circlearrowright", true);
4625
+ defineSymbol(math, ams, rel, "\u21b1", "\\Rsh", true);
4626
+ defineSymbol(math, ams, rel, "\u21ca", "\\downdownarrows", true);
4627
+ defineSymbol(math, ams, rel, "\u21be", "\\upharpoonright", true);
4628
+ defineSymbol(math, ams, rel, "\u21c2", "\\downharpoonright", true);
4629
+ defineSymbol(math, ams, rel, "\u21dd", "\\rightsquigarrow", true);
4630
+ defineSymbol(math, ams, rel, "\u21dd", "\\leadsto");
4631
+ defineSymbol(math, ams, rel, "\u21db", "\\Rrightarrow", true);
4632
+ defineSymbol(math, ams, rel, "\u21be", "\\restriction");
4633
+ defineSymbol(math, main, textord, "\u2018", "`");
4634
+ defineSymbol(math, main, textord, "$", "\\$");
4635
+ defineSymbol(text, main, textord, "$", "\\$");
4636
+ defineSymbol(text, main, textord, "$", "\\textdollar");
4637
+ defineSymbol(math, main, textord, "%", "\\%");
4638
+ defineSymbol(text, main, textord, "%", "\\%");
4639
+ defineSymbol(math, main, textord, "_", "\\_");
4640
+ defineSymbol(text, main, textord, "_", "\\_");
4641
+ defineSymbol(text, main, textord, "_", "\\textunderscore");
4642
+ defineSymbol(math, main, textord, "\u2220", "\\angle", true);
4643
+ defineSymbol(math, main, textord, "\u221e", "\\infty", true);
4644
+ defineSymbol(math, main, textord, "\u2032", "\\prime");
4645
+ defineSymbol(math, main, textord, "\u25b3", "\\triangle");
4646
+ defineSymbol(math, main, textord, "\u0393", "\\Gamma", true);
4647
+ defineSymbol(math, main, textord, "\u0394", "\\Delta", true);
4648
+ defineSymbol(math, main, textord, "\u0398", "\\Theta", true);
4649
+ defineSymbol(math, main, textord, "\u039b", "\\Lambda", true);
4650
+ defineSymbol(math, main, textord, "\u039e", "\\Xi", true);
4651
+ defineSymbol(math, main, textord, "\u03a0", "\\Pi", true);
4652
+ defineSymbol(math, main, textord, "\u03a3", "\\Sigma", true);
4653
+ defineSymbol(math, main, textord, "\u03a5", "\\Upsilon", true);
4654
+ defineSymbol(math, main, textord, "\u03a6", "\\Phi", true);
4655
+ defineSymbol(math, main, textord, "\u03a8", "\\Psi", true);
4656
+ defineSymbol(math, main, textord, "\u03a9", "\\Omega", true);
4657
+ defineSymbol(math, main, textord, "A", "\u0391");
4658
+ defineSymbol(math, main, textord, "B", "\u0392");
4659
+ defineSymbol(math, main, textord, "E", "\u0395");
4660
+ defineSymbol(math, main, textord, "Z", "\u0396");
4661
+ defineSymbol(math, main, textord, "H", "\u0397");
4662
+ defineSymbol(math, main, textord, "I", "\u0399");
4663
+ defineSymbol(math, main, textord, "K", "\u039A");
4664
+ defineSymbol(math, main, textord, "M", "\u039C");
4665
+ defineSymbol(math, main, textord, "N", "\u039D");
4666
+ defineSymbol(math, main, textord, "O", "\u039F");
4667
+ defineSymbol(math, main, textord, "P", "\u03A1");
4668
+ defineSymbol(math, main, textord, "T", "\u03A4");
4669
+ defineSymbol(math, main, textord, "X", "\u03A7");
4670
+ defineSymbol(math, main, textord, "\u00ac", "\\neg", true);
4671
+ defineSymbol(math, main, textord, "\u00ac", "\\lnot");
4672
+ defineSymbol(math, main, textord, "\u22a4", "\\top");
4673
+ defineSymbol(math, main, textord, "\u22a5", "\\bot");
4674
+ defineSymbol(math, main, textord, "\u2205", "\\emptyset");
4675
+ defineSymbol(math, ams, textord, "\u2205", "\\varnothing");
4676
+ defineSymbol(math, main, mathord, "\u03b1", "\\alpha", true);
4677
+ defineSymbol(math, main, mathord, "\u03b2", "\\beta", true);
4678
+ defineSymbol(math, main, mathord, "\u03b3", "\\gamma", true);
4679
+ defineSymbol(math, main, mathord, "\u03b4", "\\delta", true);
4680
+ defineSymbol(math, main, mathord, "\u03f5", "\\epsilon", true);
4681
+ defineSymbol(math, main, mathord, "\u03b6", "\\zeta", true);
4682
+ defineSymbol(math, main, mathord, "\u03b7", "\\eta", true);
4683
+ defineSymbol(math, main, mathord, "\u03b8", "\\theta", true);
4684
+ defineSymbol(math, main, mathord, "\u03b9", "\\iota", true);
4685
+ defineSymbol(math, main, mathord, "\u03ba", "\\kappa", true);
4686
+ defineSymbol(math, main, mathord, "\u03bb", "\\lambda", true);
4687
+ defineSymbol(math, main, mathord, "\u03bc", "\\mu", true);
4688
+ defineSymbol(math, main, mathord, "\u03bd", "\\nu", true);
4689
+ defineSymbol(math, main, mathord, "\u03be", "\\xi", true);
4690
+ defineSymbol(math, main, mathord, "\u03bf", "\\omicron", true);
4691
+ defineSymbol(math, main, mathord, "\u03c0", "\\pi", true);
4692
+ defineSymbol(math, main, mathord, "\u03c1", "\\rho", true);
4693
+ defineSymbol(math, main, mathord, "\u03c3", "\\sigma", true);
4694
+ defineSymbol(math, main, mathord, "\u03c4", "\\tau", true);
4695
+ defineSymbol(math, main, mathord, "\u03c5", "\\upsilon", true);
4696
+ defineSymbol(math, main, mathord, "\u03d5", "\\phi", true);
4697
+ defineSymbol(math, main, mathord, "\u03c7", "\\chi", true);
4698
+ defineSymbol(math, main, mathord, "\u03c8", "\\psi", true);
4699
+ defineSymbol(math, main, mathord, "\u03c9", "\\omega", true);
4700
+ defineSymbol(math, main, mathord, "\u03b5", "\\varepsilon", true);
4701
+ defineSymbol(math, main, mathord, "\u03d1", "\\vartheta", true);
4702
+ defineSymbol(math, main, mathord, "\u03d6", "\\varpi", true);
4703
+ defineSymbol(math, main, mathord, "\u03f1", "\\varrho", true);
4704
+ defineSymbol(math, main, mathord, "\u03c2", "\\varsigma", true);
4705
+ defineSymbol(math, main, mathord, "\u03c6", "\\varphi", true);
4706
+ defineSymbol(math, main, bin, "\u2217", "*", true);
4707
+ defineSymbol(math, main, bin, "+", "+");
4708
+ defineSymbol(math, main, bin, "\u2212", "-", true);
4709
+ defineSymbol(math, main, bin, "\u22c5", "\\cdot", true);
4710
+ defineSymbol(math, main, bin, "\u2218", "\\circ");
4711
+ defineSymbol(math, main, bin, "\u00f7", "\\div", true);
4712
+ defineSymbol(math, main, bin, "\u00b1", "\\pm", true);
4713
+ defineSymbol(math, main, bin, "\u00d7", "\\times", true);
4714
+ defineSymbol(math, main, bin, "\u2229", "\\cap", true);
4715
+ defineSymbol(math, main, bin, "\u222a", "\\cup", true);
4716
+ defineSymbol(math, main, bin, "\u2216", "\\setminus");
4717
+ defineSymbol(math, main, bin, "\u2227", "\\land");
4718
+ defineSymbol(math, main, bin, "\u2228", "\\lor");
4719
+ defineSymbol(math, main, bin, "\u2227", "\\wedge", true);
4720
+ defineSymbol(math, main, bin, "\u2228", "\\vee", true);
4721
+ defineSymbol(math, main, textord, "\u221a", "\\surd");
4722
+ defineSymbol(math, main, open, "\u27e8", "\\langle", true);
4723
+ defineSymbol(math, main, open, "\u2223", "\\lvert");
4724
+ defineSymbol(math, main, open, "\u2225", "\\lVert");
4725
+ defineSymbol(math, main, close, "?", "?");
4726
+ defineSymbol(math, main, close, "!", "!");
4727
+ defineSymbol(math, main, close, "\u27e9", "\\rangle", true);
4728
+ defineSymbol(math, main, close, "\u2223", "\\rvert");
4729
+ defineSymbol(math, main, close, "\u2225", "\\rVert");
4730
+ defineSymbol(math, main, rel, "=", "=");
4731
+ defineSymbol(math, main, rel, ":", ":");
4732
+ defineSymbol(math, main, rel, "\u2248", "\\approx", true);
4733
+ defineSymbol(math, main, rel, "\u2245", "\\cong", true);
4734
+ defineSymbol(math, main, rel, "\u2265", "\\ge");
4735
+ defineSymbol(math, main, rel, "\u2265", "\\geq", true);
4736
+ defineSymbol(math, main, rel, "\u2190", "\\gets");
4737
+ defineSymbol(math, main, rel, ">", "\\gt", true);
4738
+ defineSymbol(math, main, rel, "\u2208", "\\in", true);
4739
+ defineSymbol(math, main, rel, "\ue020", "\\@not");
4740
+ defineSymbol(math, main, rel, "\u2282", "\\subset", true);
4741
+ defineSymbol(math, main, rel, "\u2283", "\\supset", true);
4742
+ defineSymbol(math, main, rel, "\u2286", "\\subseteq", true);
4743
+ defineSymbol(math, main, rel, "\u2287", "\\supseteq", true);
4744
+ defineSymbol(math, ams, rel, "\u2288", "\\nsubseteq", true);
4745
+ defineSymbol(math, ams, rel, "\u2289", "\\nsupseteq", true);
4746
+ defineSymbol(math, main, rel, "\u22a8", "\\models");
4747
+ defineSymbol(math, main, rel, "\u2190", "\\leftarrow", true);
4748
+ defineSymbol(math, main, rel, "\u2264", "\\le");
4749
+ defineSymbol(math, main, rel, "\u2264", "\\leq", true);
4750
+ defineSymbol(math, main, rel, "<", "\\lt", true);
4751
+ defineSymbol(math, main, rel, "\u2192", "\\rightarrow", true);
4752
+ defineSymbol(math, main, rel, "\u2192", "\\to");
4753
+ defineSymbol(math, ams, rel, "\u2271", "\\ngeq", true);
4754
+ defineSymbol(math, ams, rel, "\u2270", "\\nleq", true);
4755
+ defineSymbol(math, main, spacing, "\u00a0", "\\ ");
4756
+ defineSymbol(math, main, spacing, "\u00a0", "\\space"); // Ref: LaTeX Source 2e: \DeclareRobustCommand{\nobreakspace}{%
4712
4757
 
4713
- if (0x1D400 <= codePoint && codePoint < 0x1D6A4) {
4714
- // wideLatinLetterData contains exactly 26 chars on each row.
4715
- // So we can calculate the relevant row. No traverse necessary.
4716
- var i = Math.floor((codePoint - 0x1D400) / 26);
4717
- return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]];
4718
- } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) {
4719
- // Numerals, ten per row.
4720
- var _i = Math.floor((codePoint - 0x1D7CE) / 10);
4758
+ defineSymbol(math, main, spacing, "\u00a0", "\\nobreakspace");
4759
+ defineSymbol(text, main, spacing, "\u00a0", "\\ ");
4760
+ defineSymbol(text, main, spacing, "\u00a0", " ");
4761
+ defineSymbol(text, main, spacing, "\u00a0", "\\space");
4762
+ defineSymbol(text, main, spacing, "\u00a0", "\\nobreakspace");
4763
+ defineSymbol(math, main, spacing, null, "\\nobreak");
4764
+ defineSymbol(math, main, spacing, null, "\\allowbreak");
4765
+ defineSymbol(math, main, punct, ",", ",");
4766
+ defineSymbol(math, main, punct, ";", ";");
4767
+ defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true);
4768
+ defineSymbol(math, ams, bin, "\u22bb", "\\veebar", true);
4769
+ defineSymbol(math, main, bin, "\u2299", "\\odot", true);
4770
+ defineSymbol(math, main, bin, "\u2295", "\\oplus", true);
4771
+ defineSymbol(math, main, bin, "\u2297", "\\otimes", true);
4772
+ defineSymbol(math, main, textord, "\u2202", "\\partial", true);
4773
+ defineSymbol(math, main, bin, "\u2298", "\\oslash", true);
4774
+ defineSymbol(math, ams, bin, "\u229a", "\\circledcirc", true);
4775
+ defineSymbol(math, ams, bin, "\u22a1", "\\boxdot", true);
4776
+ defineSymbol(math, main, bin, "\u25b3", "\\bigtriangleup");
4777
+ defineSymbol(math, main, bin, "\u25bd", "\\bigtriangledown");
4778
+ defineSymbol(math, main, bin, "\u2020", "\\dagger");
4779
+ defineSymbol(math, main, bin, "\u22c4", "\\diamond");
4780
+ defineSymbol(math, main, bin, "\u22c6", "\\star");
4781
+ defineSymbol(math, main, bin, "\u25c3", "\\triangleleft");
4782
+ defineSymbol(math, main, bin, "\u25b9", "\\triangleright");
4783
+ defineSymbol(math, main, open, "{", "\\{");
4784
+ defineSymbol(text, main, textord, "{", "\\{");
4785
+ defineSymbol(text, main, textord, "{", "\\textbraceleft");
4786
+ defineSymbol(math, main, close, "}", "\\}");
4787
+ defineSymbol(text, main, textord, "}", "\\}");
4788
+ defineSymbol(text, main, textord, "}", "\\textbraceright");
4789
+ defineSymbol(math, main, open, "{", "\\lbrace");
4790
+ defineSymbol(math, main, close, "}", "\\rbrace");
4791
+ defineSymbol(math, main, open, "[", "\\lbrack", true);
4792
+ defineSymbol(text, main, textord, "[", "\\lbrack", true);
4793
+ defineSymbol(math, main, close, "]", "\\rbrack", true);
4794
+ defineSymbol(text, main, textord, "]", "\\rbrack", true);
4795
+ defineSymbol(math, main, open, "(", "\\lparen", true);
4796
+ defineSymbol(math, main, close, ")", "\\rparen", true);
4797
+ defineSymbol(text, main, textord, "<", "\\textless", true); // in T1 fontenc
4721
4798
 
4722
- return [wideNumeralData[_i][2], wideNumeralData[_i][j]];
4723
- } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) {
4724
- // dotless i or j
4725
- return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]];
4726
- } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) {
4727
- // Greek letters. Not supported, yet.
4728
- return ["", ""];
4729
- } else {
4730
- // We don't support any wide characters outside 1D400–1D7FF.
4731
- throw new ParseError("Unsupported character: " + wideChar);
4732
- }
4733
- };
4799
+ defineSymbol(text, main, textord, ">", "\\textgreater", true); // in T1 fontenc
4734
4800
 
4735
- /**
4736
- * This file contains information about the options that the Parser carries
4737
- * around with it while parsing. Data is held in an `Options` object, and when
4738
- * recursing, a new `Options` object can be created with the `.with*` and
4739
- * `.reset` functions.
4740
- */
4741
- var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize].
4742
- // The size mappings are taken from TeX with \normalsize=10pt.
4743
- [1, 1, 1], // size1: [5, 5, 5] \tiny
4744
- [2, 1, 1], // size2: [6, 5, 5]
4745
- [3, 1, 1], // size3: [7, 5, 5] \scriptsize
4746
- [4, 2, 1], // size4: [8, 6, 5] \footnotesize
4747
- [5, 2, 1], // size5: [9, 6, 5] \small
4748
- [6, 3, 1], // size6: [10, 7, 5] \normalsize
4749
- [7, 4, 2], // size7: [12, 8, 6] \large
4750
- [8, 6, 3], // size8: [14.4, 10, 7] \Large
4751
- [9, 7, 6], // size9: [17.28, 12, 10] \LARGE
4752
- [10, 8, 7], // size10: [20.74, 14.4, 12] \huge
4753
- [11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE
4754
- ];
4755
- var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if
4756
- // you change size indexes, change that function.
4757
- 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
4801
+ defineSymbol(math, main, open, "\u230a", "\\lfloor", true);
4802
+ defineSymbol(math, main, close, "\u230b", "\\rfloor", true);
4803
+ defineSymbol(math, main, open, "\u2308", "\\lceil", true);
4804
+ defineSymbol(math, main, close, "\u2309", "\\rceil", true);
4805
+ defineSymbol(math, main, textord, "\\", "\\backslash");
4806
+ defineSymbol(math, main, textord, "\u2223", "|");
4807
+ defineSymbol(math, main, textord, "\u2223", "\\vert");
4808
+ defineSymbol(text, main, textord, "|", "\\textbar", true); // in T1 fontenc
4758
4809
 
4759
- var sizeAtStyle = function sizeAtStyle(size, style) {
4760
- return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
4761
- }; // In these types, "" (empty string) means "no change".
4810
+ defineSymbol(math, main, textord, "\u2225", "\\|");
4811
+ defineSymbol(math, main, textord, "\u2225", "\\Vert");
4812
+ defineSymbol(text, main, textord, "\u2225", "\\textbardbl");
4813
+ defineSymbol(text, main, textord, "~", "\\textasciitilde");
4814
+ defineSymbol(text, main, textord, "\\", "\\textbackslash");
4815
+ defineSymbol(text, main, textord, "^", "\\textasciicircum");
4816
+ defineSymbol(math, main, rel, "\u2191", "\\uparrow", true);
4817
+ defineSymbol(math, main, rel, "\u21d1", "\\Uparrow", true);
4818
+ defineSymbol(math, main, rel, "\u2193", "\\downarrow", true);
4819
+ defineSymbol(math, main, rel, "\u21d3", "\\Downarrow", true);
4820
+ defineSymbol(math, main, rel, "\u2195", "\\updownarrow", true);
4821
+ defineSymbol(math, main, rel, "\u21d5", "\\Updownarrow", true);
4822
+ defineSymbol(math, main, op, "\u2210", "\\coprod");
4823
+ defineSymbol(math, main, op, "\u22c1", "\\bigvee");
4824
+ defineSymbol(math, main, op, "\u22c0", "\\bigwedge");
4825
+ defineSymbol(math, main, op, "\u2a04", "\\biguplus");
4826
+ defineSymbol(math, main, op, "\u22c2", "\\bigcap");
4827
+ defineSymbol(math, main, op, "\u22c3", "\\bigcup");
4828
+ defineSymbol(math, main, op, "\u222b", "\\int");
4829
+ defineSymbol(math, main, op, "\u222b", "\\intop");
4830
+ defineSymbol(math, main, op, "\u222c", "\\iint");
4831
+ defineSymbol(math, main, op, "\u222d", "\\iiint");
4832
+ defineSymbol(math, main, op, "\u220f", "\\prod");
4833
+ defineSymbol(math, main, op, "\u2211", "\\sum");
4834
+ defineSymbol(math, main, op, "\u2a02", "\\bigotimes");
4835
+ defineSymbol(math, main, op, "\u2a01", "\\bigoplus");
4836
+ defineSymbol(math, main, op, "\u2a00", "\\bigodot");
4837
+ defineSymbol(math, main, op, "\u222e", "\\oint");
4838
+ defineSymbol(math, main, op, "\u222f", "\\oiint");
4839
+ defineSymbol(math, main, op, "\u2230", "\\oiiint");
4840
+ defineSymbol(math, main, op, "\u2a06", "\\bigsqcup");
4841
+ defineSymbol(math, main, op, "\u222b", "\\smallint");
4842
+ defineSymbol(text, main, inner, "\u2026", "\\textellipsis");
4843
+ defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
4844
+ defineSymbol(text, main, inner, "\u2026", "\\ldots", true);
4845
+ defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
4846
+ defineSymbol(math, main, inner, "\u22ef", "\\@cdots", true);
4847
+ defineSymbol(math, main, inner, "\u22f1", "\\ddots", true);
4848
+ defineSymbol(math, main, textord, "\u22ee", "\\varvdots"); // \vdots is a macro
4762
4849
 
4850
+ defineSymbol(math, main, accent, "\u02ca", "\\acute");
4851
+ defineSymbol(math, main, accent, "\u02cb", "\\grave");
4852
+ defineSymbol(math, main, accent, "\u00a8", "\\ddot");
4853
+ defineSymbol(math, main, accent, "\u007e", "\\tilde");
4854
+ defineSymbol(math, main, accent, "\u02c9", "\\bar");
4855
+ defineSymbol(math, main, accent, "\u02d8", "\\breve");
4856
+ defineSymbol(math, main, accent, "\u02c7", "\\check");
4857
+ defineSymbol(math, main, accent, "\u005e", "\\hat");
4858
+ defineSymbol(math, main, accent, "\u20d7", "\\vec");
4859
+ defineSymbol(math, main, accent, "\u02d9", "\\dot");
4860
+ defineSymbol(math, main, accent, "\u02da", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA
4763
4861
 
4764
- /**
4765
- * This is the main options class. It contains the current style, size, color,
4766
- * and font.
4767
- *
4768
- * Options objects should not be modified. To create a new Options with
4769
- * different properties, call a `.having*` method.
4770
- */
4771
- class Options {
4772
- // A font family applies to a group of fonts (i.e. SansSerif), while a font
4773
- // represents a specific font (i.e. SansSerif Bold).
4774
- // See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm
4862
+ defineSymbol(math, main, mathord, "\ue131", "\\@imath");
4863
+ defineSymbol(math, main, mathord, "\ue237", "\\@jmath");
4864
+ defineSymbol(math, main, textord, "\u0131", "\u0131");
4865
+ defineSymbol(math, main, textord, "\u0237", "\u0237");
4866
+ defineSymbol(text, main, textord, "\u0131", "\\i", true);
4867
+ defineSymbol(text, main, textord, "\u0237", "\\j", true);
4868
+ defineSymbol(text, main, textord, "\u00df", "\\ss", true);
4869
+ defineSymbol(text, main, textord, "\u00e6", "\\ae", true);
4870
+ defineSymbol(text, main, textord, "\u0153", "\\oe", true);
4871
+ defineSymbol(text, main, textord, "\u00f8", "\\o", true);
4872
+ defineSymbol(text, main, textord, "\u00c6", "\\AE", true);
4873
+ defineSymbol(text, main, textord, "\u0152", "\\OE", true);
4874
+ defineSymbol(text, main, textord, "\u00d8", "\\O", true);
4875
+ defineSymbol(text, main, accent, "\u02ca", "\\'"); // acute
4775
4876
 
4776
- /**
4777
- * The base size index.
4778
- */
4779
- constructor(data) {
4780
- this.style = void 0;
4781
- this.color = void 0;
4782
- this.size = void 0;
4783
- this.textSize = void 0;
4784
- this.phantom = void 0;
4785
- this.font = void 0;
4786
- this.fontFamily = void 0;
4787
- this.fontWeight = void 0;
4788
- this.fontShape = void 0;
4789
- this.sizeMultiplier = void 0;
4790
- this.maxSize = void 0;
4791
- this.minRuleThickness = void 0;
4792
- this._fontMetrics = void 0;
4793
- this.style = data.style;
4794
- this.color = data.color;
4795
- this.size = data.size || Options.BASESIZE;
4796
- this.textSize = data.textSize || this.size;
4797
- this.phantom = !!data.phantom;
4798
- this.font = data.font || "";
4799
- this.fontFamily = data.fontFamily || "";
4800
- this.fontWeight = data.fontWeight || '';
4801
- this.fontShape = data.fontShape || '';
4802
- this.sizeMultiplier = sizeMultipliers[this.size - 1];
4803
- this.maxSize = data.maxSize;
4804
- this.minRuleThickness = data.minRuleThickness;
4805
- this._fontMetrics = undefined;
4806
- }
4807
- /**
4808
- * Returns a new options object with the same properties as "this". Properties
4809
- * from "extension" will be copied to the new options object.
4810
- */
4877
+ defineSymbol(text, main, accent, "\u02cb", "\\`"); // grave
4811
4878
 
4879
+ defineSymbol(text, main, accent, "\u02c6", "\\^"); // circumflex
4812
4880
 
4813
- extend(extension) {
4814
- var data = {
4815
- style: this.style,
4816
- size: this.size,
4817
- textSize: this.textSize,
4818
- color: this.color,
4819
- phantom: this.phantom,
4820
- font: this.font,
4821
- fontFamily: this.fontFamily,
4822
- fontWeight: this.fontWeight,
4823
- fontShape: this.fontShape,
4824
- maxSize: this.maxSize,
4825
- minRuleThickness: this.minRuleThickness
4826
- };
4881
+ defineSymbol(text, main, accent, "\u02dc", "\\~"); // tilde
4827
4882
 
4828
- for (var key in extension) {
4829
- if (extension.hasOwnProperty(key)) {
4830
- data[key] = extension[key];
4831
- }
4832
- }
4883
+ defineSymbol(text, main, accent, "\u02c9", "\\="); // macron
4833
4884
 
4834
- return new Options(data);
4835
- }
4836
- /**
4837
- * Return an options object with the given style. If `this.style === style`,
4838
- * returns `this`.
4839
- */
4885
+ defineSymbol(text, main, accent, "\u02d8", "\\u"); // breve
4840
4886
 
4887
+ defineSymbol(text, main, accent, "\u02d9", "\\."); // dot above
4841
4888
 
4842
- havingStyle(style) {
4843
- if (this.style === style) {
4844
- return this;
4845
- } else {
4846
- return this.extend({
4847
- style: style,
4848
- size: sizeAtStyle(this.textSize, style)
4849
- });
4850
- }
4851
- }
4852
- /**
4853
- * Return an options object with a cramped version of the current style. If
4854
- * the current style is cramped, returns `this`.
4855
- */
4889
+ defineSymbol(text, main, accent, "\u00b8", "\\c"); // cedilla
4856
4890
 
4891
+ defineSymbol(text, main, accent, "\u02da", "\\r"); // ring above
4857
4892
 
4858
- havingCrampedStyle() {
4859
- return this.havingStyle(this.style.cramp());
4860
- }
4861
- /**
4862
- * Return an options object with the given size and in at least `\textstyle`.
4863
- * Returns `this` if appropriate.
4864
- */
4893
+ defineSymbol(text, main, accent, "\u02c7", "\\v"); // caron
4865
4894
 
4895
+ defineSymbol(text, main, accent, "\u00a8", '\\"'); // diaresis
4866
4896
 
4867
- havingSize(size) {
4868
- if (this.size === size && this.textSize === size) {
4869
- return this;
4870
- } else {
4871
- return this.extend({
4872
- style: this.style.text(),
4873
- size: size,
4874
- textSize: size,
4875
- sizeMultiplier: sizeMultipliers[size - 1]
4876
- });
4877
- }
4878
- }
4879
- /**
4880
- * Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
4881
- * changes to at least `\textstyle`.
4882
- */
4897
+ defineSymbol(text, main, accent, "\u02dd", "\\H"); // double acute
4883
4898
 
4899
+ defineSymbol(text, main, accent, "\u25ef", "\\textcircled"); // \bigcirc glyph
4900
+ // These ligatures are detected and created in Parser.js's `formLigatures`.
4884
4901
 
4885
- havingBaseStyle(style) {
4886
- style = style || this.style.text();
4887
- var wantSize = sizeAtStyle(Options.BASESIZE, style);
4902
+ var ligatures = {
4903
+ "--": true,
4904
+ "---": true,
4905
+ "``": true,
4906
+ "''": true
4907
+ };
4908
+ defineSymbol(text, main, textord, "\u2013", "--", true);
4909
+ defineSymbol(text, main, textord, "\u2013", "\\textendash");
4910
+ defineSymbol(text, main, textord, "\u2014", "---", true);
4911
+ defineSymbol(text, main, textord, "\u2014", "\\textemdash");
4912
+ defineSymbol(text, main, textord, "\u2018", "`", true);
4913
+ defineSymbol(text, main, textord, "\u2018", "\\textquoteleft");
4914
+ defineSymbol(text, main, textord, "\u2019", "'", true);
4915
+ defineSymbol(text, main, textord, "\u2019", "\\textquoteright");
4916
+ defineSymbol(text, main, textord, "\u201c", "``", true);
4917
+ defineSymbol(text, main, textord, "\u201c", "\\textquotedblleft");
4918
+ defineSymbol(text, main, textord, "\u201d", "''", true);
4919
+ defineSymbol(text, main, textord, "\u201d", "\\textquotedblright"); // \degree from gensymb package
4888
4920
 
4889
- if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) {
4890
- return this;
4891
- } else {
4892
- return this.extend({
4893
- style: style,
4894
- size: wantSize
4895
- });
4896
- }
4897
- }
4898
- /**
4899
- * Remove the effect of sizing changes such as \Huge.
4900
- * Keep the effect of the current style, such as \scriptstyle.
4901
- */
4921
+ defineSymbol(math, main, textord, "\u00b0", "\\degree", true);
4922
+ defineSymbol(text, main, textord, "\u00b0", "\\degree"); // \textdegree from inputenc package
4902
4923
 
4924
+ defineSymbol(text, main, textord, "\u00b0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math
4925
+ // mode, but among our fonts, only Main-Regular defines this character "163".
4903
4926
 
4904
- havingBaseSizing() {
4905
- var size;
4927
+ defineSymbol(math, main, textord, "\u00a3", "\\pounds");
4928
+ defineSymbol(math, main, textord, "\u00a3", "\\mathsterling", true);
4929
+ defineSymbol(text, main, textord, "\u00a3", "\\pounds");
4930
+ defineSymbol(text, main, textord, "\u00a3", "\\textsterling", true);
4931
+ defineSymbol(math, ams, textord, "\u2720", "\\maltese");
4932
+ defineSymbol(text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards.
4933
+ // All of these are textords in math mode
4906
4934
 
4907
- switch (this.style.id) {
4908
- case 4:
4909
- case 5:
4910
- size = 3; // normalsize in scriptstyle
4935
+ var mathTextSymbols = "0123456789/@.\"";
4911
4936
 
4912
- break;
4937
+ for (var i = 0; i < mathTextSymbols.length; i++) {
4938
+ var ch = mathTextSymbols.charAt(i);
4939
+ defineSymbol(math, main, textord, ch, ch);
4940
+ } // All of these are textords in text mode
4913
4941
 
4914
- case 6:
4915
- case 7:
4916
- size = 1; // normalsize in scriptscriptstyle
4917
4942
 
4918
- break;
4943
+ var textSymbols = "0123456789!@*()-=+\";:?/.,";
4919
4944
 
4920
- default:
4921
- size = 6;
4922
- // normalsize in textstyle or displaystyle
4923
- }
4945
+ for (var _i = 0; _i < textSymbols.length; _i++) {
4946
+ var _ch = textSymbols.charAt(_i);
4924
4947
 
4925
- return this.extend({
4926
- style: this.style.text(),
4927
- size: size
4928
- });
4929
- }
4930
- /**
4931
- * Create a new options object with the given color.
4932
- */
4948
+ defineSymbol(text, main, textord, _ch, _ch);
4949
+ } // All of these are textords in text mode, and mathords in math mode
4933
4950
 
4934
4951
 
4935
- withColor(color) {
4936
- return this.extend({
4937
- color: color
4938
- });
4939
- }
4940
- /**
4941
- * Create a new options object with "phantom" set to true.
4942
- */
4952
+ var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
4943
4953
 
4954
+ for (var _i2 = 0; _i2 < letters.length; _i2++) {
4955
+ var _ch2 = letters.charAt(_i2);
4944
4956
 
4945
- withPhantom() {
4946
- return this.extend({
4947
- phantom: true
4948
- });
4949
- }
4950
- /**
4951
- * Creates a new options object with the given math font or old text font.
4952
- * @type {[type]}
4953
- */
4957
+ defineSymbol(math, main, mathord, _ch2, _ch2);
4958
+ defineSymbol(text, main, textord, _ch2, _ch2);
4959
+ } // Blackboard bold and script letters in Unicode range
4954
4960
 
4955
4961
 
4956
- withFont(font) {
4957
- return this.extend({
4958
- font
4959
- });
4960
- }
4961
- /**
4962
- * Create a new options objects with the given fontFamily.
4963
- */
4962
+ defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
4963
+
4964
+ defineSymbol(text, ams, textord, "C", "\u2102");
4965
+ defineSymbol(math, ams, textord, "H", "\u210D");
4966
+ defineSymbol(text, ams, textord, "H", "\u210D");
4967
+ defineSymbol(math, ams, textord, "N", "\u2115");
4968
+ defineSymbol(text, ams, textord, "N", "\u2115");
4969
+ defineSymbol(math, ams, textord, "P", "\u2119");
4970
+ defineSymbol(text, ams, textord, "P", "\u2119");
4971
+ defineSymbol(math, ams, textord, "Q", "\u211A");
4972
+ defineSymbol(text, ams, textord, "Q", "\u211A");
4973
+ defineSymbol(math, ams, textord, "R", "\u211D");
4974
+ defineSymbol(text, ams, textord, "R", "\u211D");
4975
+ defineSymbol(math, ams, textord, "Z", "\u2124");
4976
+ defineSymbol(text, ams, textord, "Z", "\u2124");
4977
+ defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant
4964
4978
 
4979
+ defineSymbol(text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters.
4980
+ // We support some letters in the Unicode range U+1D400 to U+1D7FF,
4981
+ // Mathematical Alphanumeric Symbols.
4982
+ // Some editors do not deal well with wide characters. So don't write the
4983
+ // string into this file. Instead, create the string from the surrogate pair.
4965
4984
 
4966
- withTextFontFamily(fontFamily) {
4967
- return this.extend({
4968
- fontFamily,
4969
- font: ""
4970
- });
4971
- }
4972
- /**
4973
- * Creates a new options object with the given font weight
4974
- */
4985
+ var wideChar = "";
4975
4986
 
4987
+ for (var _i3 = 0; _i3 < letters.length; _i3++) {
4988
+ var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair.
4989
+ // 0xD835 is the high surrogate for all letters in the range we support.
4990
+ // 0xDC00 is the low surrogate for bold A.
4976
4991
 
4977
- withTextFontWeight(fontWeight) {
4978
- return this.extend({
4979
- fontWeight,
4980
- font: ""
4981
- });
4982
- }
4983
- /**
4984
- * Creates a new options object with the given font weight
4985
- */
4986
4992
 
4993
+ wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
4994
+
4995
+ defineSymbol(math, main, mathord, _ch3, wideChar);
4996
+ defineSymbol(text, main, textord, _ch3, wideChar);
4997
+ wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic
4998
+
4999
+ defineSymbol(math, main, mathord, _ch3, wideChar);
5000
+ defineSymbol(text, main, textord, _ch3, wideChar);
5001
+ wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic
5002
+
5003
+ defineSymbol(math, main, mathord, _ch3, wideChar);
5004
+ defineSymbol(text, main, textord, _ch3, wideChar);
5005
+ wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur
5006
+
5007
+ defineSymbol(math, main, mathord, _ch3, wideChar);
5008
+ defineSymbol(text, main, textord, _ch3, wideChar);
5009
+ wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif
5010
+
5011
+ defineSymbol(math, main, mathord, _ch3, wideChar);
5012
+ defineSymbol(text, main, textord, _ch3, wideChar);
5013
+ wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold
5014
+
5015
+ defineSymbol(math, main, mathord, _ch3, wideChar);
5016
+ defineSymbol(text, main, textord, _ch3, wideChar);
5017
+ wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic
5018
+
5019
+ defineSymbol(math, main, mathord, _ch3, wideChar);
5020
+ defineSymbol(text, main, textord, _ch3, wideChar);
5021
+ wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace
5022
+
5023
+ defineSymbol(math, main, mathord, _ch3, wideChar);
5024
+ defineSymbol(text, main, textord, _ch3, wideChar);
4987
5025
 
4988
- withTextFontShape(fontShape) {
4989
- return this.extend({
4990
- fontShape,
4991
- font: ""
4992
- });
4993
- }
4994
- /**
4995
- * Return the CSS sizing classes required to switch from enclosing options
4996
- * `oldOptions` to `this`. Returns an array of classes.
4997
- */
5026
+ if (_i3 < 26) {
5027
+ // KaTeX fonts have only capital letters for blackboard bold and script.
5028
+ // See exception for k below.
5029
+ wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck
4998
5030
 
5031
+ defineSymbol(math, main, mathord, _ch3, wideChar);
5032
+ defineSymbol(text, main, textord, _ch3, wideChar);
5033
+ wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script
4999
5034
 
5000
- sizingClasses(oldOptions) {
5001
- if (oldOptions.size !== this.size) {
5002
- return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
5003
- } else {
5004
- return [];
5005
- }
5006
- }
5007
- /**
5008
- * Return the CSS sizing classes required to switch to the base size. Like
5009
- * `this.havingSize(BASESIZE).sizingClasses(this)`.
5010
- */
5035
+ defineSymbol(math, main, mathord, _ch3, wideChar);
5036
+ defineSymbol(text, main, textord, _ch3, wideChar);
5037
+ } // TODO: Add bold script when it is supported by a KaTeX font.
5011
5038
 
5039
+ } // "k" is the only double struck lower case letter in the KaTeX fonts.
5012
5040
 
5013
- baseSizingClasses() {
5014
- if (this.size !== Options.BASESIZE) {
5015
- return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
5016
- } else {
5017
- return [];
5018
- }
5019
- }
5020
- /**
5021
- * Return the font metrics for this size.
5022
- */
5023
5041
 
5042
+ wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
5024
5043
 
5025
- fontMetrics() {
5026
- if (!this._fontMetrics) {
5027
- this._fontMetrics = getGlobalMetrics(this.size);
5028
- }
5044
+ defineSymbol(math, main, mathord, "k", wideChar);
5045
+ defineSymbol(text, main, textord, "k", wideChar); // Next, some wide character numerals
5029
5046
 
5030
- return this._fontMetrics;
5031
- }
5032
- /**
5033
- * Gets the CSS color of the current options object
5034
- */
5047
+ for (var _i4 = 0; _i4 < 10; _i4++) {
5048
+ var _ch4 = _i4.toString();
5035
5049
 
5050
+ wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold
5036
5051
 
5037
- getColor() {
5038
- if (this.phantom) {
5039
- return "transparent";
5040
- } else {
5041
- return this.color;
5042
- }
5043
- }
5052
+ defineSymbol(math, main, mathord, _ch4, wideChar);
5053
+ defineSymbol(text, main, textord, _ch4, wideChar);
5054
+ wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif
5044
5055
 
5045
- }
5056
+ defineSymbol(math, main, mathord, _ch4, wideChar);
5057
+ defineSymbol(text, main, textord, _ch4, wideChar);
5058
+ wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans
5046
5059
 
5047
- Options.BASESIZE = 6;
5060
+ defineSymbol(math, main, mathord, _ch4, wideChar);
5061
+ defineSymbol(text, main, textord, _ch4, wideChar);
5062
+ wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace
5048
5063
 
5049
- /**
5050
- * This file does conversion between units. In particular, it provides
5051
- * calculateSize to convert other units into ems.
5052
- */
5053
- // Thus, multiplying a length by this number converts the length from units
5054
- // into pts. Dividing the result by ptPerEm gives the number of ems
5055
- // *assuming* a font size of ptPerEm (normal size, normal style).
5064
+ defineSymbol(math, main, mathord, _ch4, wideChar);
5065
+ defineSymbol(text, main, textord, _ch4, wideChar);
5066
+ } // We add these Latin-1 letters as symbols for backwards-compatibility,
5067
+ // but they are not actually in the font, nor are they supported by the
5068
+ // Unicode accent mechanism, so they fall back to Times font and look ugly.
5069
+ // TODO(edemaine): Fix this.
5056
5070
 
5057
- var ptPerUnit = {
5058
- // https://en.wikibooks.org/wiki/LaTeX/Lengths and
5059
- // https://tex.stackexchange.com/a/8263
5060
- "pt": 1,
5061
- // TeX point
5062
- "mm": 7227 / 2540,
5063
- // millimeter
5064
- "cm": 7227 / 254,
5065
- // centimeter
5066
- "in": 72.27,
5067
- // inch
5068
- "bp": 803 / 800,
5069
- // big (PostScript) points
5070
- "pc": 12,
5071
- // pica
5072
- "dd": 1238 / 1157,
5073
- // didot
5074
- "cc": 14856 / 1157,
5075
- // cicero (12 didot)
5076
- "nd": 685 / 642,
5077
- // new didot
5078
- "nc": 1370 / 107,
5079
- // new cicero (12 new didot)
5080
- "sp": 1 / 65536,
5081
- // scaled point (TeX's internal smallest unit)
5082
- // https://tex.stackexchange.com/a/41371
5083
- "px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX
5084
5071
 
5085
- }; // Dictionary of relative units, for fast validity testing.
5072
+ var extraLatin = "\u00d0\u00de\u00fe";
5086
5073
 
5087
- var relativeUnit = {
5088
- "ex": true,
5089
- "em": true,
5090
- "mu": true
5091
- };
5074
+ for (var _i5 = 0; _i5 < extraLatin.length; _i5++) {
5075
+ var _ch5 = extraLatin.charAt(_i5);
5076
+
5077
+ defineSymbol(math, main, mathord, _ch5, _ch5);
5078
+ defineSymbol(text, main, textord, _ch5, _ch5);
5079
+ }
5092
5080
 
5093
5081
  /**
5094
- * Determine whether the specified unit (either a string defining the unit
5095
- * or a "size" parse node containing a unit field) is valid.
5082
+ * This file provides support for Unicode range U+1D400 to U+1D7FF,
5083
+ * Mathematical Alphanumeric Symbols.
5084
+ *
5085
+ * Function wideCharacterFont takes a wide character as input and returns
5086
+ * the font information necessary to render it properly.
5096
5087
  */
5097
- var validUnit = function validUnit(unit) {
5098
- if (typeof unit !== "string") {
5099
- unit = unit.unit;
5100
- }
5101
-
5102
- return unit in ptPerUnit || unit in relativeUnit || unit === "ex";
5103
- };
5104
- /*
5105
- * Convert a "size" parse node (with numeric "number" and string "unit" fields,
5106
- * as parsed by functions.js argType "size") into a CSS em value for the
5107
- * current style/scale. `options` gives the current options.
5088
+ /**
5089
+ * Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf
5090
+ * That document sorts characters into groups by font type, say bold or italic.
5091
+ *
5092
+ * In the arrays below, each subarray consists three elements:
5093
+ * * The CSS class of that group when in math mode.
5094
+ * * The CSS class of that group when in text mode.
5095
+ * * The font name, so that KaTeX can get font metrics.
5108
5096
  */
5109
5097
 
5110
- var calculateSize = function calculateSize(sizeValue, options) {
5111
- var scale;
5112
-
5113
- if (sizeValue.unit in ptPerUnit) {
5114
- // Absolute units
5115
- scale = ptPerUnit[sizeValue.unit] // Convert unit to pt
5116
- / options.fontMetrics().ptPerEm // Convert pt to CSS em
5117
- / options.sizeMultiplier; // Unscale to make absolute units
5118
- } else if (sizeValue.unit === "mu") {
5119
- // `mu` units scale with scriptstyle/scriptscriptstyle.
5120
- scale = options.fontMetrics().cssEmPerMu;
5121
- } else {
5122
- // Other relative units always refer to the *textstyle* font
5123
- // in the current size.
5124
- var unitOptions;
5098
+ var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright
5099
+ ["mathbf", "textbf", "Main-Bold"], // a-z bold upright
5100
+ ["mathnormal", "textit", "Math-Italic"], // A-Z italic
5101
+ ["mathnormal", "textit", "Math-Italic"], // a-z italic
5102
+ ["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic
5103
+ ["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic
5104
+ // Map fancy A-Z letters to script, not calligraphic.
5105
+ // This aligns with unicode-math and math fonts (except Cambria Math).
5106
+ ["mathscr", "textscr", "Script-Regular"], // A-Z script
5107
+ ["", "", ""], // a-z script. No font
5108
+ ["", "", ""], // A-Z bold script. No font
5109
+ ["", "", ""], // a-z bold script. No font
5110
+ ["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur
5111
+ ["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur
5112
+ ["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
5113
+ ["mathbb", "textbb", "AMS-Regular"], // k double-struck
5114
+ ["", "", ""], // A-Z bold Fraktur No font metrics
5115
+ ["", "", ""], // a-z bold Fraktur. No font.
5116
+ ["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
5117
+ ["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
5118
+ ["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif
5119
+ ["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif
5120
+ ["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif
5121
+ ["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif
5122
+ ["", "", ""], // A-Z bold italic sans. No font
5123
+ ["", "", ""], // a-z bold italic sans. No font
5124
+ ["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace
5125
+ ["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace
5126
+ ];
5127
+ var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold
5128
+ ["", "", ""], // 0-9 double-struck. No KaTeX font.
5129
+ ["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif
5130
+ ["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif
5131
+ ["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace
5132
+ ];
5133
+ var wideCharacterFont = function wideCharacterFont(wideChar, mode) {
5134
+ // IE doesn't support codePointAt(). So work with the surrogate pair.
5135
+ var H = wideChar.charCodeAt(0); // high surrogate
5125
5136
 
5126
- if (options.style.isTight()) {
5127
- // isTight() means current style is script/scriptscript.
5128
- unitOptions = options.havingStyle(options.style.text());
5129
- } else {
5130
- unitOptions = options;
5131
- } // TODO: In TeX these units are relative to the quad of the current
5132
- // *text* font, e.g. cmr10. KaTeX instead uses values from the
5133
- // comparably-sized *Computer Modern symbol* font. At 10pt, these
5134
- // match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
5135
- // cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
5136
- // TeX \showlists shows a kern of 1.13889 * fontsize;
5137
- // KaTeX shows a kern of 1.171 * fontsize.
5137
+ var L = wideChar.charCodeAt(1); // low surrogate
5138
5138
 
5139
+ var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000;
5140
+ var j = mode === "math" ? 0 : 1; // column index for CSS class.
5139
5141
 
5140
- if (sizeValue.unit === "ex") {
5141
- scale = unitOptions.fontMetrics().xHeight;
5142
- } else if (sizeValue.unit === "em") {
5143
- scale = unitOptions.fontMetrics().quad;
5144
- } else {
5145
- throw new ParseError("Invalid unit: '" + sizeValue.unit + "'");
5146
- }
5142
+ if (0x1D400 <= codePoint && codePoint < 0x1D6A4) {
5143
+ // wideLatinLetterData contains exactly 26 chars on each row.
5144
+ // So we can calculate the relevant row. No traverse necessary.
5145
+ var i = Math.floor((codePoint - 0x1D400) / 26);
5146
+ return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]];
5147
+ } else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) {
5148
+ // Numerals, ten per row.
5149
+ var _i = Math.floor((codePoint - 0x1D7CE) / 10);
5147
5150
 
5148
- if (unitOptions !== options) {
5149
- scale *= unitOptions.sizeMultiplier / options.sizeMultiplier;
5150
- }
5151
+ return [wideNumeralData[_i][2], wideNumeralData[_i][j]];
5152
+ } else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) {
5153
+ // dotless i or j
5154
+ return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]];
5155
+ } else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) {
5156
+ // Greek letters. Not supported, yet.
5157
+ return ["", ""];
5158
+ } else {
5159
+ // We don't support any wide characters outside 1D400–1D7FF.
5160
+ throw new ParseError("Unsupported character: " + wideChar);
5151
5161
  }
5152
-
5153
- return Math.min(sizeValue.number * scale, options.maxSize);
5154
5162
  };
5155
5163
 
5156
5164
  /* eslint no-console:0 */
@@ -5455,7 +5463,7 @@ var makeSvgSpan = (classes, children, options, style) => new Span(classes, child
5455
5463
  var makeLineSpan = function makeLineSpan(className, options, thickness) {
5456
5464
  var line = makeSpan$2([className], [], options);
5457
5465
  line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness);
5458
- line.style.borderBottomWidth = line.height + "em";
5466
+ line.style.borderBottomWidth = makeEm(line.height);
5459
5467
  line.maxFontSize = 1.0;
5460
5468
  return line;
5461
5469
  };
@@ -5595,7 +5603,7 @@ var makeVList = function makeVList(params, options) {
5595
5603
 
5596
5604
  pstrutSize += 2;
5597
5605
  var pstrut = makeSpan$2(["pstrut"], []);
5598
- pstrut.style.height = pstrutSize + "em"; // Create a new list of actual children at the correct offsets
5606
+ pstrut.style.height = makeEm(pstrutSize); // Create a new list of actual children at the correct offsets
5599
5607
 
5600
5608
  var realChildren = [];
5601
5609
  var minPos = depth;
@@ -5612,7 +5620,7 @@ var makeVList = function makeVList(params, options) {
5612
5620
  var classes = _child.wrapperClasses || [];
5613
5621
  var style = _child.wrapperStyle || {};
5614
5622
  var childWrap = makeSpan$2(classes, [pstrut, _elem], undefined, style);
5615
- childWrap.style.top = -pstrutSize - currPos - _elem.depth + "em";
5623
+ childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth);
5616
5624
 
5617
5625
  if (_child.marginLeft) {
5618
5626
  childWrap.style.marginLeft = _child.marginLeft;
@@ -5634,7 +5642,7 @@ var makeVList = function makeVList(params, options) {
5634
5642
 
5635
5643
 
5636
5644
  var vlist = makeSpan$2(["vlist"], realChildren);
5637
- vlist.style.height = maxPos + "em"; // A second row is used if necessary to represent the vlist's depth.
5645
+ vlist.style.height = makeEm(maxPos); // A second row is used if necessary to represent the vlist's depth.
5638
5646
 
5639
5647
  var rows;
5640
5648
 
@@ -5646,7 +5654,7 @@ var makeVList = function makeVList(params, options) {
5646
5654
  // So we put another empty span inside the depth strut span.
5647
5655
  var emptySpan = makeSpan$2([], []);
5648
5656
  var depthStrut = makeSpan$2(["vlist"], [emptySpan]);
5649
- depthStrut.style.height = -minPos + "em"; // Safari wants the first row to have inline content; otherwise it
5657
+ depthStrut.style.height = makeEm(-minPos); // Safari wants the first row to have inline content; otherwise it
5650
5658
  // puts the bottom of the *second* row on the baseline.
5651
5659
 
5652
5660
  var topStrut = makeSpan$2(["vlist-s"], [new SymbolNode("\u200b")]);
@@ -5673,7 +5681,7 @@ var makeGlue = (measurement, options) => {
5673
5681
  // Make an empty span for the space
5674
5682
  var rule = makeSpan$2(["mspace"], [], options);
5675
5683
  var size = calculateSize(measurement, options);
5676
- rule.style.marginRight = size + "em";
5684
+ rule.style.marginRight = makeEm(size);
5677
5685
  return rule;
5678
5686
  }; // Takes font options, and returns the appropriate fontLookup name
5679
5687
 
@@ -5792,17 +5800,17 @@ var staticSvg = function staticSvg(value, options) {
5792
5800
  var [pathName, width, height] = svgData[value];
5793
5801
  var path = new PathNode(pathName);
5794
5802
  var svgNode = new SvgNode([path], {
5795
- "width": width + "em",
5796
- "height": height + "em",
5803
+ "width": makeEm(width),
5804
+ "height": makeEm(height),
5797
5805
  // Override CSS rule `.katex svg { width: 100% }`
5798
- "style": "width:" + width + "em",
5806
+ "style": "width:" + makeEm(width),
5799
5807
  "viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
5800
5808
  "preserveAspectRatio": "xMinYMin"
5801
5809
  });
5802
5810
  var span = makeSvgSpan(["overlay"], [svgNode], options);
5803
5811
  span.height = height;
5804
- span.style.height = height + "em";
5805
- span.style.width = width + "em";
5812
+ span.style.height = makeEm(height);
5813
+ span.style.width = makeEm(width);
5806
5814
  return span;
5807
5815
  };
5808
5816
 
@@ -6286,10 +6294,10 @@ function buildHTMLUnbreakable(children, options) {
6286
6294
  // falls at the depth of the expression.
6287
6295
 
6288
6296
  var strut = makeSpan$1(["strut"]);
6289
- strut.style.height = body.height + body.depth + "em";
6297
+ strut.style.height = makeEm(body.height + body.depth);
6290
6298
 
6291
6299
  if (body.depth) {
6292
- strut.style.verticalAlign = -body.depth + "em";
6300
+ strut.style.verticalAlign = makeEm(-body.depth);
6293
6301
  }
6294
6302
 
6295
6303
  body.children.unshift(strut);
@@ -6385,10 +6393,10 @@ function buildHTML(tree, options) {
6385
6393
 
6386
6394
  if (tagChild) {
6387
6395
  var strut = tagChild.children[0];
6388
- strut.style.height = htmlNode.height + htmlNode.depth + "em";
6396
+ strut.style.height = makeEm(htmlNode.height + htmlNode.depth);
6389
6397
 
6390
6398
  if (htmlNode.depth) {
6391
- strut.style.verticalAlign = -htmlNode.depth + "em";
6399
+ strut.style.verticalAlign = makeEm(-htmlNode.depth);
6392
6400
  }
6393
6401
  }
6394
6402
 
@@ -6588,7 +6596,7 @@ class SpaceNode {
6588
6596
  return document.createTextNode(this.character);
6589
6597
  } else {
6590
6598
  var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace");
6591
- node.setAttribute("width", this.width + "em");
6599
+ node.setAttribute("width", makeEm(this.width));
6592
6600
  return node;
6593
6601
  }
6594
6602
  }
@@ -6601,7 +6609,7 @@ class SpaceNode {
6601
6609
  if (this.character) {
6602
6610
  return "<mtext>" + this.character + "</mtext>";
6603
6611
  } else {
6604
- return "<mspace width=\"" + this.width + "em\"/>";
6612
+ return "<mspace width=\"" + makeEm(this.width) + "\"/>";
6605
6613
  }
6606
6614
  }
6607
6615
  /**
@@ -7117,7 +7125,7 @@ var svgSpan = function svgSpan(group, options) {
7117
7125
  var path = new PathNode(pathName);
7118
7126
  var svgNode = new SvgNode([path], {
7119
7127
  "width": "100%",
7120
- "height": _height + "em",
7128
+ "height": makeEm(_height),
7121
7129
  "viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight,
7122
7130
  "preserveAspectRatio": "none"
7123
7131
  });
@@ -7157,7 +7165,7 @@ var svgSpan = function svgSpan(group, options) {
7157
7165
 
7158
7166
  var _svgNode = new SvgNode([_path], {
7159
7167
  "width": "400em",
7160
- "height": _height2 + "em",
7168
+ "height": makeEm(_height2),
7161
7169
  "viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight,
7162
7170
  "preserveAspectRatio": aligns[i] + " slice"
7163
7171
  });
@@ -7171,7 +7179,7 @@ var svgSpan = function svgSpan(group, options) {
7171
7179
  height: _height2
7172
7180
  };
7173
7181
  } else {
7174
- _span.style.height = _height2 + "em";
7182
+ _span.style.height = makeEm(_height2);
7175
7183
  spans.push(_span);
7176
7184
  }
7177
7185
  }
@@ -7193,10 +7201,10 @@ var svgSpan = function svgSpan(group, options) {
7193
7201
  // Any adjustments relative to the baseline must be done in buildHTML.
7194
7202
 
7195
7203
  span.height = height;
7196
- span.style.height = height + "em";
7204
+ span.style.height = makeEm(height);
7197
7205
 
7198
7206
  if (minWidth > 0) {
7199
- span.style.minWidth = minWidth + "em";
7207
+ span.style.minWidth = makeEm(minWidth);
7200
7208
  }
7201
7209
 
7202
7210
  return span;
@@ -7245,13 +7253,13 @@ var encloseSpan = function encloseSpan(inner, label, topPad, bottomPad, options)
7245
7253
 
7246
7254
  var svgNode = new SvgNode(lines, {
7247
7255
  "width": "100%",
7248
- "height": totalHeight + "em"
7256
+ "height": makeEm(totalHeight)
7249
7257
  });
7250
7258
  img = buildCommon.makeSvgSpan([], [svgNode], options);
7251
7259
  }
7252
7260
 
7253
7261
  img.height = totalHeight;
7254
- img.style.height = totalHeight + "em";
7262
+ img.style.height = makeEm(totalHeight);
7255
7263
  return img;
7256
7264
  };
7257
7265
 
@@ -7412,7 +7420,7 @@ var htmlBuilder$a = (grp, options) => {
7412
7420
  left -= width / 2;
7413
7421
  }
7414
7422
 
7415
- accentBody.style.left = left + "em"; // \textcircled uses the \bigcirc glyph, so it needs some
7423
+ accentBody.style.left = makeEm(left); // \textcircled uses the \bigcirc glyph, so it needs some
7416
7424
  // vertical adjustment to match LaTeX.
7417
7425
 
7418
7426
  if (group.label === "\\textcircled") {
@@ -7444,8 +7452,8 @@ var htmlBuilder$a = (grp, options) => {
7444
7452
  elem: accentBody,
7445
7453
  wrapperClasses: ["svg-align"],
7446
7454
  wrapperStyle: skew > 0 ? {
7447
- width: "calc(100% - " + 2 * skew + "em)",
7448
- marginLeft: 2 * skew + "em"
7455
+ width: "calc(100% - " + makeEm(2 * skew) + ")",
7456
+ marginLeft: makeEm(2 * skew)
7449
7457
  } : undefined
7450
7458
  }]
7451
7459
  }, options);
@@ -7984,7 +7992,7 @@ defineFunction({
7984
7992
  var newOptions = options.havingStyle(options.style.sup());
7985
7993
  var label = buildCommon.wrapFragment(buildGroup$1(group.label, newOptions, options), options);
7986
7994
  label.classes.push("cd-label-" + group.side);
7987
- label.style.bottom = 0.8 - label.depth + "em"; // Zero out label height & depth, so vertical align of arrow is set
7995
+ label.style.bottom = makeEm(0.8 - label.depth); // Zero out label height & depth, so vertical align of arrow is set
7988
7996
  // by the arrow height, not by the label.
7989
7997
 
7990
7998
  label.height = 0;
@@ -8204,7 +8212,7 @@ defineFunction({
8204
8212
  span.classes.push("newline");
8205
8213
 
8206
8214
  if (group.size) {
8207
- span.style.marginTop = calculateSize(group.size, options) + "em";
8215
+ span.style.marginTop = makeEm(calculateSize(group.size, options));
8208
8216
  }
8209
8217
  }
8210
8218
 
@@ -8218,7 +8226,7 @@ defineFunction({
8218
8226
  node.setAttribute("linebreak", "newline");
8219
8227
 
8220
8228
  if (group.size) {
8221
- node.setAttribute("height", calculateSize(group.size, options) + "em");
8229
+ node.setAttribute("height", makeEm(calculateSize(group.size, options)));
8222
8230
  }
8223
8231
  }
8224
8232
 
@@ -8524,7 +8532,7 @@ var centerSpan = function centerSpan(span, options, style) {
8524
8532
  var newOptions = options.havingBaseStyle(style);
8525
8533
  var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight;
8526
8534
  span.classes.push("delimcenter");
8527
- span.style.top = shift + "em";
8535
+ span.style.top = makeEm(shift);
8528
8536
  span.height -= shift;
8529
8537
  span.depth += shift;
8530
8538
  };
@@ -8597,20 +8605,20 @@ var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) {
8597
8605
 
8598
8606
  var makeInner = function makeInner(ch, height, options) {
8599
8607
  // Create a span with inline SVG for the inner part of a tall stacked delimiter.
8600
- 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);
8608
+ var width = fontMetricsData['Size4-Regular'][ch.charCodeAt(0)] ? fontMetricsData['Size4-Regular'][ch.charCodeAt(0)][4] : fontMetricsData['Size1-Regular'][ch.charCodeAt(0)][4];
8601
8609
  var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height)));
8602
8610
  var svgNode = new SvgNode([path], {
8603
- "width": width + "em",
8604
- "height": height + "em",
8611
+ "width": makeEm(width),
8612
+ "height": makeEm(height),
8605
8613
  // Override CSS rule `.katex svg { width: 100% }`
8606
- "style": "width:" + width + "em",
8614
+ "style": "width:" + makeEm(width),
8607
8615
  "viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height),
8608
8616
  "preserveAspectRatio": "xMinYMin"
8609
8617
  });
8610
8618
  var span = buildCommon.makeSvgSpan([], [svgNode], options);
8611
8619
  span.height = height;
8612
- span.style.height = height + "em";
8613
- span.style.width = width + "em";
8620
+ span.style.height = makeEm(height);
8621
+ span.style.width = makeEm(width);
8614
8622
  return {
8615
8623
  type: "elem",
8616
8624
  elem: span
@@ -8819,7 +8827,7 @@ var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum,
8819
8827
  var svg = new SvgNode([pathNode], {
8820
8828
  // Note: 1000:1 ratio of viewBox to document em width.
8821
8829
  "width": "400em",
8822
- "height": height + "em",
8830
+ "height": makeEm(height),
8823
8831
  "viewBox": "0 0 400000 " + viewBoxHeight,
8824
8832
  "preserveAspectRatio": "xMinYMin slice"
8825
8833
  });
@@ -8888,7 +8896,7 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
8888
8896
  }
8889
8897
 
8890
8898
  span.height = texHeight;
8891
- span.style.height = spanHeight + "em";
8899
+ span.style.height = makeEm(spanHeight);
8892
8900
  return {
8893
8901
  span,
8894
8902
  advanceWidth,
@@ -9264,8 +9272,9 @@ defineFunction({
9264
9272
  }
9265
9273
 
9266
9274
  node.setAttribute("stretchy", "true");
9267
- node.setAttribute("minsize", delimiter.sizeToMaxHeight[group.size] + "em");
9268
- node.setAttribute("maxsize", delimiter.sizeToMaxHeight[group.size] + "em");
9275
+ var size = makeEm(delimiter.sizeToMaxHeight[group.size]);
9276
+ node.setAttribute("minsize", size);
9277
+ node.setAttribute("maxsize", size);
9269
9278
  return node;
9270
9279
  }
9271
9280
  });
@@ -9512,19 +9521,19 @@ var htmlBuilder$8 = (group, options) => {
9512
9521
  scale = scale / newOptions.sizeMultiplier;
9513
9522
  var angleHeight = inner.height + inner.depth + lineWeight + clearance; // Reserve a left pad for the angle.
9514
9523
 
9515
- inner.style.paddingLeft = angleHeight / 2 + lineWeight + "em"; // Create an SVG
9524
+ inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); // Create an SVG
9516
9525
 
9517
9526
  var viewBoxHeight = Math.floor(1000 * angleHeight * scale);
9518
9527
  var path = phasePath(viewBoxHeight);
9519
9528
  var svgNode = new SvgNode([new PathNode("phase", path)], {
9520
9529
  "width": "400em",
9521
- "height": viewBoxHeight / 1000 + "em",
9530
+ "height": makeEm(viewBoxHeight / 1000),
9522
9531
  "viewBox": "0 0 400000 " + viewBoxHeight,
9523
9532
  "preserveAspectRatio": "xMinYMin slice"
9524
9533
  }); // Wrap it in a span with overflow: hidden.
9525
9534
 
9526
9535
  img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options);
9527
- img.style.height = angleHeight + "em";
9536
+ img.style.height = makeEm(angleHeight);
9528
9537
  imgShift = inner.depth + lineWeight + clearance;
9529
9538
  } else {
9530
9539
  // Add horizontal padding
@@ -9563,10 +9572,10 @@ var htmlBuilder$8 = (group, options) => {
9563
9572
 
9564
9573
  if (/fbox|boxed|fcolorbox/.test(label)) {
9565
9574
  img.style.borderStyle = "solid";
9566
- img.style.borderWidth = ruleThickness + "em";
9575
+ img.style.borderWidth = makeEm(ruleThickness);
9567
9576
  } else if (label === "angl" && ruleThickness !== 0.049) {
9568
- img.style.borderTopWidth = ruleThickness + "em";
9569
- img.style.borderRightWidth = ruleThickness + "em";
9577
+ img.style.borderTopWidth = makeEm(ruleThickness);
9578
+ img.style.borderRightWidth = makeEm(ruleThickness);
9570
9579
  }
9571
9580
 
9572
9581
  imgShift = inner.depth + bottomPad;
@@ -10191,22 +10200,22 @@ var htmlBuilder$7 = function htmlBuilder(group, options) {
10191
10200
  // between them.
10192
10201
  if (!firstSeparator) {
10193
10202
  colSep = buildCommon.makeSpan(["arraycolsep"], []);
10194
- colSep.style.width = options.fontMetrics().doubleRuleSep + "em";
10203
+ colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep);
10195
10204
  cols.push(colSep);
10196
10205
  }
10197
10206
 
10198
10207
  if (colDescr.separator === "|" || colDescr.separator === ":") {
10199
10208
  var lineType = colDescr.separator === "|" ? "solid" : "dashed";
10200
10209
  var separator = buildCommon.makeSpan(["vertical-separator"], [], options);
10201
- separator.style.height = totalHeight + "em";
10202
- separator.style.borderRightWidth = ruleThickness + "em";
10210
+ separator.style.height = makeEm(totalHeight);
10211
+ separator.style.borderRightWidth = makeEm(ruleThickness);
10203
10212
  separator.style.borderRightStyle = lineType;
10204
- separator.style.margin = "0 -" + ruleThickness / 2 + "em";
10213
+ separator.style.margin = "0 " + makeEm(-ruleThickness / 2);
10205
10214
 
10206
10215
  var _shift = totalHeight - offset;
10207
10216
 
10208
10217
  if (_shift) {
10209
- separator.style.verticalAlign = -_shift + "em";
10218
+ separator.style.verticalAlign = makeEm(-_shift);
10210
10219
  }
10211
10220
 
10212
10221
  cols.push(separator);
@@ -10230,7 +10239,7 @@ var htmlBuilder$7 = function htmlBuilder(group, options) {
10230
10239
 
10231
10240
  if (sepwidth !== 0) {
10232
10241
  colSep = buildCommon.makeSpan(["arraycolsep"], []);
10233
- colSep.style.width = sepwidth + "em";
10242
+ colSep.style.width = makeEm(sepwidth);
10234
10243
  cols.push(colSep);
10235
10244
  }
10236
10245
  }
@@ -10268,7 +10277,7 @@ var htmlBuilder$7 = function htmlBuilder(group, options) {
10268
10277
 
10269
10278
  if (sepwidth !== 0) {
10270
10279
  colSep = buildCommon.makeSpan(["arraycolsep"], []);
10271
- colSep.style.width = sepwidth + "em";
10280
+ colSep.style.width = makeEm(sepwidth);
10272
10281
  cols.push(colSep);
10273
10282
  }
10274
10283
  }
@@ -10368,7 +10377,7 @@ var mathmlBuilder$6 = function mathmlBuilder(group, options) {
10368
10377
 
10369
10378
  var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray}
10370
10379
  : 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
10371
- table.setAttribute("rowspacing", gap.toFixed(4) + "em"); // MathML table lines go only between cells.
10380
+ table.setAttribute("rowspacing", makeEm(gap)); // MathML table lines go only between cells.
10372
10381
  // To place a line on an edge we'll use <menclose>, if necessary.
10373
10382
 
10374
10383
  var menclose = "";
@@ -11454,7 +11463,7 @@ var mathmlBuilder$3 = (group, options) => {
11454
11463
  node.setAttribute("linethickness", "0px");
11455
11464
  } else if (group.barSize) {
11456
11465
  var ruleWidth = calculateSize(group.barSize, options);
11457
- node.setAttribute("linethickness", ruleWidth + "em");
11466
+ node.setAttribute("linethickness", makeEm(ruleWidth));
11458
11467
  }
11459
11468
 
11460
11469
  var style = adjustStyle(group.size, options.style);
@@ -12317,7 +12326,6 @@ defineFunction({
12317
12326
 
12318
12327
  if (group.totalheight.number > 0) {
12319
12328
  depth = calculateSize(group.totalheight, options) - height;
12320
- depth = Number(depth.toFixed(2));
12321
12329
  }
12322
12330
 
12323
12331
  var width = 0;
@@ -12327,15 +12335,15 @@ defineFunction({
12327
12335
  }
12328
12336
 
12329
12337
  var style = {
12330
- height: height + depth + "em"
12338
+ height: makeEm(height + depth)
12331
12339
  };
12332
12340
 
12333
12341
  if (width > 0) {
12334
- style.width = width + "em";
12342
+ style.width = makeEm(width);
12335
12343
  }
12336
12344
 
12337
12345
  if (depth > 0) {
12338
- style.verticalAlign = -depth + "em";
12346
+ style.verticalAlign = makeEm(-depth);
12339
12347
  }
12340
12348
 
12341
12349
  var node = new Img(group.src, group.alt, style);
@@ -12351,15 +12359,14 @@ defineFunction({
12351
12359
 
12352
12360
  if (group.totalheight.number > 0) {
12353
12361
  depth = calculateSize(group.totalheight, options) - height;
12354
- depth = depth.toFixed(2);
12355
- node.setAttribute("valign", "-" + depth + "em");
12362
+ node.setAttribute("valign", makeEm(-depth));
12356
12363
  }
12357
12364
 
12358
- node.setAttribute("height", height + depth + "em");
12365
+ node.setAttribute("height", makeEm(height + depth));
12359
12366
 
12360
12367
  if (group.width.number > 0) {
12361
12368
  var width = calculateSize(group.width, options);
12362
- node.setAttribute("width", width + "em");
12369
+ node.setAttribute("width", makeEm(width));
12363
12370
  }
12364
12371
 
12365
12372
  node.setAttribute("src", group.src);
@@ -12467,10 +12474,10 @@ defineFunction({
12467
12474
  // This code resolved issue #1153
12468
12475
 
12469
12476
  var strut = buildCommon.makeSpan(["strut"]);
12470
- strut.style.height = node.height + node.depth + "em";
12477
+ strut.style.height = makeEm(node.height + node.depth);
12471
12478
 
12472
12479
  if (node.depth) {
12473
- strut.style.verticalAlign = -node.depth + "em";
12480
+ strut.style.verticalAlign = makeEm(-node.depth);
12474
12481
  }
12475
12482
 
12476
12483
  node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall.
@@ -12589,7 +12596,6 @@ defineFunction({
12589
12596
  }
12590
12597
  });
12591
12598
 
12592
- // For an operator with limits, assemble the base, sup, and sub into a span.
12593
12599
  var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift) => {
12594
12600
  base = buildCommon.makeSpan([], [base]);
12595
12601
  var subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup);
@@ -12629,7 +12635,7 @@ var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift
12629
12635
  }, {
12630
12636
  type: "elem",
12631
12637
  elem: sub.elem,
12632
- marginLeft: -slant + "em"
12638
+ marginLeft: makeEm(-slant)
12633
12639
  }, {
12634
12640
  type: "kern",
12635
12641
  size: sub.kern
@@ -12642,7 +12648,7 @@ var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift
12642
12648
  }, {
12643
12649
  type: "elem",
12644
12650
  elem: sup.elem,
12645
- marginLeft: slant + "em"
12651
+ marginLeft: makeEm(slant)
12646
12652
  }, {
12647
12653
  type: "kern",
12648
12654
  size: options.fontMetrics().bigOpSpacing5
@@ -12663,7 +12669,7 @@ var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift
12663
12669
  }, {
12664
12670
  type: "elem",
12665
12671
  elem: sub.elem,
12666
- marginLeft: -slant + "em"
12672
+ marginLeft: makeEm(-slant)
12667
12673
  }, {
12668
12674
  type: "kern",
12669
12675
  size: sub.kern
@@ -12687,7 +12693,7 @@ var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift
12687
12693
  }, {
12688
12694
  type: "elem",
12689
12695
  elem: sup.elem,
12690
- marginLeft: slant + "em"
12696
+ marginLeft: makeEm(slant)
12691
12697
  }, {
12692
12698
  type: "kern",
12693
12699
  size: options.fontMetrics().bigOpSpacing5
@@ -12706,7 +12712,7 @@ var assembleSupSub = (base, supGroup, subGroup, options, style, slant, baseShift
12706
12712
  // A negative margin-left was applied to the lower limit.
12707
12713
  // Avoid an overlap by placing a spacer on the left on the group.
12708
12714
  var spacer = buildCommon.makeSpan(["mspace"], [], options);
12709
- spacer.style.marginRight = slant + "em";
12715
+ spacer.style.marginRight = makeEm(slant);
12710
12716
  parts.unshift(spacer);
12711
12717
  }
12712
12718
 
@@ -12827,7 +12833,7 @@ var htmlBuilder$2 = (grp, options) => {
12827
12833
  } else {
12828
12834
  if (baseShift) {
12829
12835
  base.style.position = "relative";
12830
- base.style.top = baseShift + "em";
12836
+ base.style.top = makeEm(baseShift);
12831
12837
  }
12832
12838
 
12833
12839
  return base;
@@ -13454,9 +13460,9 @@ defineFunction({
13454
13460
  var height = calculateSize(group.height, options);
13455
13461
  var shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size
13456
13462
 
13457
- rule.style.borderRightWidth = width + "em";
13458
- rule.style.borderTopWidth = height + "em";
13459
- rule.style.bottom = shift + "em"; // Record the height and width
13463
+ rule.style.borderRightWidth = makeEm(width);
13464
+ rule.style.borderTopWidth = makeEm(height);
13465
+ rule.style.bottom = makeEm(shift); // Record the height and width
13460
13466
 
13461
13467
  rule.width = width;
13462
13468
  rule.height = height + shift;
@@ -13475,18 +13481,18 @@ defineFunction({
13475
13481
  var color = options.color && options.getColor() || "black";
13476
13482
  var rule = new mathMLTree.MathNode("mspace");
13477
13483
  rule.setAttribute("mathbackground", color);
13478
- rule.setAttribute("width", width + "em");
13479
- rule.setAttribute("height", height + "em");
13484
+ rule.setAttribute("width", makeEm(width));
13485
+ rule.setAttribute("height", makeEm(height));
13480
13486
  var wrapper = new mathMLTree.MathNode("mpadded", [rule]);
13481
13487
 
13482
13488
  if (shift >= 0) {
13483
- wrapper.setAttribute("height", "+" + shift + "em");
13489
+ wrapper.setAttribute("height", makeEm(shift));
13484
13490
  } else {
13485
- wrapper.setAttribute("height", shift + "em");
13486
- wrapper.setAttribute("depth", "+" + -shift + "em");
13491
+ wrapper.setAttribute("height", makeEm(shift));
13492
+ wrapper.setAttribute("depth", makeEm(-shift));
13487
13493
  }
13488
13494
 
13489
- wrapper.setAttribute("voffset", shift + "em");
13495
+ wrapper.setAttribute("voffset", makeEm(shift));
13490
13496
  return wrapper;
13491
13497
  }
13492
13498
 
@@ -13555,7 +13561,7 @@ defineFunction({
13555
13561
  // that we're passing an options parameter we should be able to fix
13556
13562
  // this.
13557
13563
 
13558
- node.setAttribute("mathsize", newOptions.sizeMultiplier + "em");
13564
+ node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier));
13559
13565
  return node;
13560
13566
  }
13561
13567
  });
@@ -13730,7 +13736,7 @@ defineFunction({
13730
13736
 
13731
13737
 
13732
13738
  var imgShift = img.height - inner.height - lineClearance - ruleWidth;
13733
- inner.style.paddingLeft = advanceWidth + "em"; // Overlay the image and the argument.
13739
+ inner.style.paddingLeft = makeEm(advanceWidth); // Overlay the image and the argument.
13734
13740
 
13735
13741
  var body = buildCommon.makeVList({
13736
13742
  positionType: "firstBaseline",
@@ -13944,7 +13950,7 @@ defineFunctionBuilders({
13944
13950
 
13945
13951
 
13946
13952
  var multiplier = options.sizeMultiplier;
13947
- var marginRight = 0.5 / metrics.ptPerEm / multiplier + "em";
13953
+ var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier);
13948
13954
  var marginLeft = null;
13949
13955
 
13950
13956
  if (subm) {
@@ -13955,7 +13961,7 @@ defineFunctionBuilders({
13955
13961
 
13956
13962
  if (base instanceof SymbolNode || isOiint) {
13957
13963
  // $FlowFixMe
13958
- marginLeft = -base.italic + "em";
13964
+ marginLeft = makeEm(-base.italic);
13959
13965
  }
13960
13966
  }
13961
13967
 
@@ -15370,7 +15376,7 @@ defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5e
15370
15376
  // We compute the corresponding \raisebox when A is rendered in \normalsize
15371
15377
  // \scriptstyle, which has a scale factor of 0.7 (see Options.js).
15372
15378
 
15373
- var latexRaiseA = fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1] + "em";
15379
+ var latexRaiseA = makeEm(fontMetricsData['Main-Regular']["T".charCodeAt(0)][1] - 0.7 * fontMetricsData['Main-Regular']["A".charCodeAt(0)][1]);
15374
15380
  defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo
15375
15381
 
15376
15382
  defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
@@ -17740,7 +17746,7 @@ var katex = {
17740
17746
  /**
17741
17747
  * Current KaTeX version
17742
17748
  */
17743
- version: "0.13.23",
17749
+ version: "0.13.24",
17744
17750
 
17745
17751
  /**
17746
17752
  * Renders the given LaTeX into an HTML+MathML combination, and adds