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/README.md +5 -5
- package/contrib/copy-tex/README.md +3 -3
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +5 -5
- package/dist/katex.css +1 -1
- package/dist/katex.js +1623 -1601
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +2085 -2079
- package/package.json +7 -1
- package/src/buildCommon.js +12 -12
- package/src/buildHTML.js +5 -4
- package/src/delimiter.js +11 -10
- package/src/domTree.js +2 -1
- package/src/environments/array.js +9 -9
- package/src/environments/cd.js +2 -1
- package/src/functions/accent.js +4 -3
- package/src/functions/cr.js +3 -3
- package/src/functions/delimsizing.js +4 -2
- package/src/functions/enclose.js +7 -7
- package/src/functions/genfrac.js +2 -2
- package/src/functions/includegraphics.js +7 -9
- package/src/functions/lap.js +3 -2
- package/src/functions/op.js +2 -1
- package/src/functions/rule.js +10 -10
- package/src/functions/sizing.js +2 -1
- package/src/functions/sqrt.js +2 -1
- package/src/functions/supsub.js +3 -2
- package/src/functions/utils/assembleSupSub.js +6 -5
- package/src/macros.js +3 -2
- package/src/mathMLTree.js +3 -2
- package/src/stretchy.js +8 -7
- package/src/units.js +8 -0
package/dist/katex.js
CHANGED
|
@@ -879,559 +879,6 @@ var DocumentFragment = /*#__PURE__*/function () {
|
|
|
879
879
|
|
|
880
880
|
return DocumentFragment;
|
|
881
881
|
}();
|
|
882
|
-
;// CONCATENATED MODULE: ./src/domTree.js
|
|
883
|
-
/**
|
|
884
|
-
* These objects store the data about the DOM nodes we create, as well as some
|
|
885
|
-
* extra data. They can then be transformed into real DOM nodes with the
|
|
886
|
-
* `toNode` function or HTML markup using `toMarkup`. They are useful for both
|
|
887
|
-
* storing extra properties on the nodes, as well as providing a way to easily
|
|
888
|
-
* work with the DOM.
|
|
889
|
-
*
|
|
890
|
-
* Similar functions for working with MathML nodes exist in mathMLTree.js.
|
|
891
|
-
*
|
|
892
|
-
* TODO: refactor `span` and `anchor` into common superclass when
|
|
893
|
-
* target environments support class inheritance
|
|
894
|
-
*/
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* Create an HTML className based on a list of classes. In addition to joining
|
|
902
|
-
* with spaces, we also remove empty classes.
|
|
903
|
-
*/
|
|
904
|
-
var createClass = function createClass(classes) {
|
|
905
|
-
return classes.filter(function (cls) {
|
|
906
|
-
return cls;
|
|
907
|
-
}).join(" ");
|
|
908
|
-
};
|
|
909
|
-
|
|
910
|
-
var initNode = function initNode(classes, options, style) {
|
|
911
|
-
this.classes = classes || [];
|
|
912
|
-
this.attributes = {};
|
|
913
|
-
this.height = 0;
|
|
914
|
-
this.depth = 0;
|
|
915
|
-
this.maxFontSize = 0;
|
|
916
|
-
this.style = style || {};
|
|
917
|
-
|
|
918
|
-
if (options) {
|
|
919
|
-
if (options.style.isTight()) {
|
|
920
|
-
this.classes.push("mtight");
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
var color = options.getColor();
|
|
924
|
-
|
|
925
|
-
if (color) {
|
|
926
|
-
this.style.color = color;
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
|
-
/**
|
|
931
|
-
* Convert into an HTML node
|
|
932
|
-
*/
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
var _toNode = function toNode(tagName) {
|
|
936
|
-
var node = document.createElement(tagName); // Apply the class
|
|
937
|
-
|
|
938
|
-
node.className = createClass(this.classes); // Apply inline styles
|
|
939
|
-
|
|
940
|
-
for (var style in this.style) {
|
|
941
|
-
if (this.style.hasOwnProperty(style)) {
|
|
942
|
-
// $FlowFixMe Flow doesn't seem to understand span.style's type.
|
|
943
|
-
node.style[style] = this.style[style];
|
|
944
|
-
}
|
|
945
|
-
} // Apply attributes
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
for (var attr in this.attributes) {
|
|
949
|
-
if (this.attributes.hasOwnProperty(attr)) {
|
|
950
|
-
node.setAttribute(attr, this.attributes[attr]);
|
|
951
|
-
}
|
|
952
|
-
} // Append the children, also as HTML nodes
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
for (var i = 0; i < this.children.length; i++) {
|
|
956
|
-
node.appendChild(this.children[i].toNode());
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
return node;
|
|
960
|
-
};
|
|
961
|
-
/**
|
|
962
|
-
* Convert into an HTML markup string
|
|
963
|
-
*/
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
var _toMarkup = function toMarkup(tagName) {
|
|
967
|
-
var markup = "<" + tagName; // Add the class
|
|
968
|
-
|
|
969
|
-
if (this.classes.length) {
|
|
970
|
-
markup += " class=\"" + utils.escape(createClass(this.classes)) + "\"";
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
var styles = ""; // Add the styles, after hyphenation
|
|
974
|
-
|
|
975
|
-
for (var style in this.style) {
|
|
976
|
-
if (this.style.hasOwnProperty(style)) {
|
|
977
|
-
styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
if (styles) {
|
|
982
|
-
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
983
|
-
} // Add the attributes
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
for (var attr in this.attributes) {
|
|
987
|
-
if (this.attributes.hasOwnProperty(attr)) {
|
|
988
|
-
markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\"";
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
markup += ">"; // Add the markup of the children, also as markup
|
|
993
|
-
|
|
994
|
-
for (var i = 0; i < this.children.length; i++) {
|
|
995
|
-
markup += this.children[i].toMarkup();
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
markup += "</" + tagName + ">";
|
|
999
|
-
return markup;
|
|
1000
|
-
}; // Making the type below exact with all optional fields doesn't work due to
|
|
1001
|
-
// - https://github.com/facebook/flow/issues/4582
|
|
1002
|
-
// - https://github.com/facebook/flow/issues/5688
|
|
1003
|
-
// However, since *all* fields are optional, $Shape<> works as suggested in 5688
|
|
1004
|
-
// above.
|
|
1005
|
-
// This type does not include all CSS properties. Additional properties should
|
|
1006
|
-
// be added as needed.
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
/**
|
|
1010
|
-
* This node represents a span node, with a className, a list of children, and
|
|
1011
|
-
* an inline style. It also contains information about its height, depth, and
|
|
1012
|
-
* maxFontSize.
|
|
1013
|
-
*
|
|
1014
|
-
* Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan
|
|
1015
|
-
* otherwise. This typesafety is important when HTML builders access a span's
|
|
1016
|
-
* children.
|
|
1017
|
-
*/
|
|
1018
|
-
var Span = /*#__PURE__*/function () {
|
|
1019
|
-
function Span(classes, children, options, style) {
|
|
1020
|
-
this.children = void 0;
|
|
1021
|
-
this.attributes = void 0;
|
|
1022
|
-
this.classes = void 0;
|
|
1023
|
-
this.height = void 0;
|
|
1024
|
-
this.depth = void 0;
|
|
1025
|
-
this.width = void 0;
|
|
1026
|
-
this.maxFontSize = void 0;
|
|
1027
|
-
this.style = void 0;
|
|
1028
|
-
initNode.call(this, classes, options, style);
|
|
1029
|
-
this.children = children || [];
|
|
1030
|
-
}
|
|
1031
|
-
/**
|
|
1032
|
-
* Sets an arbitrary attribute on the span. Warning: use this wisely. Not
|
|
1033
|
-
* all browsers support attributes the same, and having too many custom
|
|
1034
|
-
* attributes is probably bad.
|
|
1035
|
-
*/
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
var _proto = Span.prototype;
|
|
1039
|
-
|
|
1040
|
-
_proto.setAttribute = function setAttribute(attribute, value) {
|
|
1041
|
-
this.attributes[attribute] = value;
|
|
1042
|
-
};
|
|
1043
|
-
|
|
1044
|
-
_proto.hasClass = function hasClass(className) {
|
|
1045
|
-
return utils.contains(this.classes, className);
|
|
1046
|
-
};
|
|
1047
|
-
|
|
1048
|
-
_proto.toNode = function toNode() {
|
|
1049
|
-
return _toNode.call(this, "span");
|
|
1050
|
-
};
|
|
1051
|
-
|
|
1052
|
-
_proto.toMarkup = function toMarkup() {
|
|
1053
|
-
return _toMarkup.call(this, "span");
|
|
1054
|
-
};
|
|
1055
|
-
|
|
1056
|
-
return Span;
|
|
1057
|
-
}();
|
|
1058
|
-
/**
|
|
1059
|
-
* This node represents an anchor (<a>) element with a hyperlink. See `span`
|
|
1060
|
-
* for further details.
|
|
1061
|
-
*/
|
|
1062
|
-
|
|
1063
|
-
var Anchor = /*#__PURE__*/function () {
|
|
1064
|
-
function Anchor(href, classes, children, options) {
|
|
1065
|
-
this.children = void 0;
|
|
1066
|
-
this.attributes = void 0;
|
|
1067
|
-
this.classes = void 0;
|
|
1068
|
-
this.height = void 0;
|
|
1069
|
-
this.depth = void 0;
|
|
1070
|
-
this.maxFontSize = void 0;
|
|
1071
|
-
this.style = void 0;
|
|
1072
|
-
initNode.call(this, classes, options);
|
|
1073
|
-
this.children = children || [];
|
|
1074
|
-
this.setAttribute('href', href);
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
var _proto2 = Anchor.prototype;
|
|
1078
|
-
|
|
1079
|
-
_proto2.setAttribute = function setAttribute(attribute, value) {
|
|
1080
|
-
this.attributes[attribute] = value;
|
|
1081
|
-
};
|
|
1082
|
-
|
|
1083
|
-
_proto2.hasClass = function hasClass(className) {
|
|
1084
|
-
return utils.contains(this.classes, className);
|
|
1085
|
-
};
|
|
1086
|
-
|
|
1087
|
-
_proto2.toNode = function toNode() {
|
|
1088
|
-
return _toNode.call(this, "a");
|
|
1089
|
-
};
|
|
1090
|
-
|
|
1091
|
-
_proto2.toMarkup = function toMarkup() {
|
|
1092
|
-
return _toMarkup.call(this, "a");
|
|
1093
|
-
};
|
|
1094
|
-
|
|
1095
|
-
return Anchor;
|
|
1096
|
-
}();
|
|
1097
|
-
/**
|
|
1098
|
-
* This node represents an image embed (<img>) element.
|
|
1099
|
-
*/
|
|
1100
|
-
|
|
1101
|
-
var Img = /*#__PURE__*/function () {
|
|
1102
|
-
function Img(src, alt, style) {
|
|
1103
|
-
this.src = void 0;
|
|
1104
|
-
this.alt = void 0;
|
|
1105
|
-
this.classes = void 0;
|
|
1106
|
-
this.height = void 0;
|
|
1107
|
-
this.depth = void 0;
|
|
1108
|
-
this.maxFontSize = void 0;
|
|
1109
|
-
this.style = void 0;
|
|
1110
|
-
this.alt = alt;
|
|
1111
|
-
this.src = src;
|
|
1112
|
-
this.classes = ["mord"];
|
|
1113
|
-
this.style = style;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
var _proto3 = Img.prototype;
|
|
1117
|
-
|
|
1118
|
-
_proto3.hasClass = function hasClass(className) {
|
|
1119
|
-
return utils.contains(this.classes, className);
|
|
1120
|
-
};
|
|
1121
|
-
|
|
1122
|
-
_proto3.toNode = function toNode() {
|
|
1123
|
-
var node = document.createElement("img");
|
|
1124
|
-
node.src = this.src;
|
|
1125
|
-
node.alt = this.alt;
|
|
1126
|
-
node.className = "mord"; // Apply inline styles
|
|
1127
|
-
|
|
1128
|
-
for (var style in this.style) {
|
|
1129
|
-
if (this.style.hasOwnProperty(style)) {
|
|
1130
|
-
// $FlowFixMe
|
|
1131
|
-
node.style[style] = this.style[style];
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
return node;
|
|
1136
|
-
};
|
|
1137
|
-
|
|
1138
|
-
_proto3.toMarkup = function toMarkup() {
|
|
1139
|
-
var markup = "<img src='" + this.src + " 'alt='" + this.alt + "' "; // Add the styles, after hyphenation
|
|
1140
|
-
|
|
1141
|
-
var styles = "";
|
|
1142
|
-
|
|
1143
|
-
for (var style in this.style) {
|
|
1144
|
-
if (this.style.hasOwnProperty(style)) {
|
|
1145
|
-
styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
if (styles) {
|
|
1150
|
-
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
markup += "'/>";
|
|
1154
|
-
return markup;
|
|
1155
|
-
};
|
|
1156
|
-
|
|
1157
|
-
return Img;
|
|
1158
|
-
}();
|
|
1159
|
-
var iCombinations = {
|
|
1160
|
-
'î': "\u0131\u0302",
|
|
1161
|
-
'ï': "\u0131\u0308",
|
|
1162
|
-
'í': "\u0131\u0301",
|
|
1163
|
-
// 'ī': '\u0131\u0304', // enable when we add Extended Latin
|
|
1164
|
-
'ì': "\u0131\u0300"
|
|
1165
|
-
};
|
|
1166
|
-
/**
|
|
1167
|
-
* A symbol node contains information about a single symbol. It either renders
|
|
1168
|
-
* to a single text node, or a span with a single text node in it, depending on
|
|
1169
|
-
* whether it has CSS classes, styles, or needs italic correction.
|
|
1170
|
-
*/
|
|
1171
|
-
|
|
1172
|
-
var SymbolNode = /*#__PURE__*/function () {
|
|
1173
|
-
function SymbolNode(text, height, depth, italic, skew, width, classes, style) {
|
|
1174
|
-
this.text = void 0;
|
|
1175
|
-
this.height = void 0;
|
|
1176
|
-
this.depth = void 0;
|
|
1177
|
-
this.italic = void 0;
|
|
1178
|
-
this.skew = void 0;
|
|
1179
|
-
this.width = void 0;
|
|
1180
|
-
this.maxFontSize = void 0;
|
|
1181
|
-
this.classes = void 0;
|
|
1182
|
-
this.style = void 0;
|
|
1183
|
-
this.text = text;
|
|
1184
|
-
this.height = height || 0;
|
|
1185
|
-
this.depth = depth || 0;
|
|
1186
|
-
this.italic = italic || 0;
|
|
1187
|
-
this.skew = skew || 0;
|
|
1188
|
-
this.width = width || 0;
|
|
1189
|
-
this.classes = classes || [];
|
|
1190
|
-
this.style = style || {};
|
|
1191
|
-
this.maxFontSize = 0; // Mark text from non-Latin scripts with specific classes so that we
|
|
1192
|
-
// can specify which fonts to use. This allows us to render these
|
|
1193
|
-
// characters with a serif font in situations where the browser would
|
|
1194
|
-
// either default to a sans serif or render a placeholder character.
|
|
1195
|
-
// We use CSS class names like cjk_fallback, hangul_fallback and
|
|
1196
|
-
// brahmic_fallback. See ./unicodeScripts.js for the set of possible
|
|
1197
|
-
// script names
|
|
1198
|
-
|
|
1199
|
-
var script = scriptFromCodepoint(this.text.charCodeAt(0));
|
|
1200
|
-
|
|
1201
|
-
if (script) {
|
|
1202
|
-
this.classes.push(script + "_fallback");
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
if (/[îïíì]/.test(this.text)) {
|
|
1206
|
-
// add ī when we add Extended Latin
|
|
1207
|
-
this.text = iCombinations[this.text];
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
var _proto4 = SymbolNode.prototype;
|
|
1212
|
-
|
|
1213
|
-
_proto4.hasClass = function hasClass(className) {
|
|
1214
|
-
return utils.contains(this.classes, className);
|
|
1215
|
-
}
|
|
1216
|
-
/**
|
|
1217
|
-
* Creates a text node or span from a symbol node. Note that a span is only
|
|
1218
|
-
* created if it is needed.
|
|
1219
|
-
*/
|
|
1220
|
-
;
|
|
1221
|
-
|
|
1222
|
-
_proto4.toNode = function toNode() {
|
|
1223
|
-
var node = document.createTextNode(this.text);
|
|
1224
|
-
var span = null;
|
|
1225
|
-
|
|
1226
|
-
if (this.italic > 0) {
|
|
1227
|
-
span = document.createElement("span");
|
|
1228
|
-
span.style.marginRight = this.italic + "em";
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
if (this.classes.length > 0) {
|
|
1232
|
-
span = span || document.createElement("span");
|
|
1233
|
-
span.className = createClass(this.classes);
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
for (var style in this.style) {
|
|
1237
|
-
if (this.style.hasOwnProperty(style)) {
|
|
1238
|
-
span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type.
|
|
1239
|
-
|
|
1240
|
-
span.style[style] = this.style[style];
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
if (span) {
|
|
1245
|
-
span.appendChild(node);
|
|
1246
|
-
return span;
|
|
1247
|
-
} else {
|
|
1248
|
-
return node;
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
/**
|
|
1252
|
-
* Creates markup for a symbol node.
|
|
1253
|
-
*/
|
|
1254
|
-
;
|
|
1255
|
-
|
|
1256
|
-
_proto4.toMarkup = function toMarkup() {
|
|
1257
|
-
// TODO(alpert): More duplication than I'd like from
|
|
1258
|
-
// span.prototype.toMarkup and symbolNode.prototype.toNode...
|
|
1259
|
-
var needsSpan = false;
|
|
1260
|
-
var markup = "<span";
|
|
1261
|
-
|
|
1262
|
-
if (this.classes.length) {
|
|
1263
|
-
needsSpan = true;
|
|
1264
|
-
markup += " class=\"";
|
|
1265
|
-
markup += utils.escape(createClass(this.classes));
|
|
1266
|
-
markup += "\"";
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
var styles = "";
|
|
1270
|
-
|
|
1271
|
-
if (this.italic > 0) {
|
|
1272
|
-
styles += "margin-right:" + this.italic + "em;";
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
for (var style in this.style) {
|
|
1276
|
-
if (this.style.hasOwnProperty(style)) {
|
|
1277
|
-
styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
if (styles) {
|
|
1282
|
-
needsSpan = true;
|
|
1283
|
-
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
var escaped = utils.escape(this.text);
|
|
1287
|
-
|
|
1288
|
-
if (needsSpan) {
|
|
1289
|
-
markup += ">";
|
|
1290
|
-
markup += escaped;
|
|
1291
|
-
markup += "</span>";
|
|
1292
|
-
return markup;
|
|
1293
|
-
} else {
|
|
1294
|
-
return escaped;
|
|
1295
|
-
}
|
|
1296
|
-
};
|
|
1297
|
-
|
|
1298
|
-
return SymbolNode;
|
|
1299
|
-
}();
|
|
1300
|
-
/**
|
|
1301
|
-
* SVG nodes are used to render stretchy wide elements.
|
|
1302
|
-
*/
|
|
1303
|
-
|
|
1304
|
-
var SvgNode = /*#__PURE__*/function () {
|
|
1305
|
-
function SvgNode(children, attributes) {
|
|
1306
|
-
this.children = void 0;
|
|
1307
|
-
this.attributes = void 0;
|
|
1308
|
-
this.children = children || [];
|
|
1309
|
-
this.attributes = attributes || {};
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
var _proto5 = SvgNode.prototype;
|
|
1313
|
-
|
|
1314
|
-
_proto5.toNode = function toNode() {
|
|
1315
|
-
var svgNS = "http://www.w3.org/2000/svg";
|
|
1316
|
-
var node = document.createElementNS(svgNS, "svg"); // Apply attributes
|
|
1317
|
-
|
|
1318
|
-
for (var attr in this.attributes) {
|
|
1319
|
-
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
1320
|
-
node.setAttribute(attr, this.attributes[attr]);
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
for (var i = 0; i < this.children.length; i++) {
|
|
1325
|
-
node.appendChild(this.children[i].toNode());
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
return node;
|
|
1329
|
-
};
|
|
1330
|
-
|
|
1331
|
-
_proto5.toMarkup = function toMarkup() {
|
|
1332
|
-
var markup = "<svg xmlns=\"http://www.w3.org/2000/svg\""; // Apply attributes
|
|
1333
|
-
|
|
1334
|
-
for (var attr in this.attributes) {
|
|
1335
|
-
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
1336
|
-
markup += " " + attr + "='" + this.attributes[attr] + "'";
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
markup += ">";
|
|
1341
|
-
|
|
1342
|
-
for (var i = 0; i < this.children.length; i++) {
|
|
1343
|
-
markup += this.children[i].toMarkup();
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
markup += "</svg>";
|
|
1347
|
-
return markup;
|
|
1348
|
-
};
|
|
1349
|
-
|
|
1350
|
-
return SvgNode;
|
|
1351
|
-
}();
|
|
1352
|
-
var PathNode = /*#__PURE__*/function () {
|
|
1353
|
-
function PathNode(pathName, alternate) {
|
|
1354
|
-
this.pathName = void 0;
|
|
1355
|
-
this.alternate = void 0;
|
|
1356
|
-
this.pathName = pathName;
|
|
1357
|
-
this.alternate = alternate; // Used only for \sqrt, \phase, & tall delims
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
var _proto6 = PathNode.prototype;
|
|
1361
|
-
|
|
1362
|
-
_proto6.toNode = function toNode() {
|
|
1363
|
-
var svgNS = "http://www.w3.org/2000/svg";
|
|
1364
|
-
var node = document.createElementNS(svgNS, "path");
|
|
1365
|
-
|
|
1366
|
-
if (this.alternate) {
|
|
1367
|
-
node.setAttribute("d", this.alternate);
|
|
1368
|
-
} else {
|
|
1369
|
-
node.setAttribute("d", path[this.pathName]);
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
return node;
|
|
1373
|
-
};
|
|
1374
|
-
|
|
1375
|
-
_proto6.toMarkup = function toMarkup() {
|
|
1376
|
-
if (this.alternate) {
|
|
1377
|
-
return "<path d='" + this.alternate + "'/>";
|
|
1378
|
-
} else {
|
|
1379
|
-
return "<path d='" + path[this.pathName] + "'/>";
|
|
1380
|
-
}
|
|
1381
|
-
};
|
|
1382
|
-
|
|
1383
|
-
return PathNode;
|
|
1384
|
-
}();
|
|
1385
|
-
var LineNode = /*#__PURE__*/function () {
|
|
1386
|
-
function LineNode(attributes) {
|
|
1387
|
-
this.attributes = void 0;
|
|
1388
|
-
this.attributes = attributes || {};
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
var _proto7 = LineNode.prototype;
|
|
1392
|
-
|
|
1393
|
-
_proto7.toNode = function toNode() {
|
|
1394
|
-
var svgNS = "http://www.w3.org/2000/svg";
|
|
1395
|
-
var node = document.createElementNS(svgNS, "line"); // Apply attributes
|
|
1396
|
-
|
|
1397
|
-
for (var attr in this.attributes) {
|
|
1398
|
-
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
1399
|
-
node.setAttribute(attr, this.attributes[attr]);
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
return node;
|
|
1404
|
-
};
|
|
1405
|
-
|
|
1406
|
-
_proto7.toMarkup = function toMarkup() {
|
|
1407
|
-
var markup = "<line";
|
|
1408
|
-
|
|
1409
|
-
for (var attr in this.attributes) {
|
|
1410
|
-
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
1411
|
-
markup += " " + attr + "='" + this.attributes[attr] + "'";
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
markup += "/>";
|
|
1416
|
-
return markup;
|
|
1417
|
-
};
|
|
1418
|
-
|
|
1419
|
-
return LineNode;
|
|
1420
|
-
}();
|
|
1421
|
-
function assertSymbolDomNode(group) {
|
|
1422
|
-
if (group instanceof SymbolNode) {
|
|
1423
|
-
return group;
|
|
1424
|
-
} else {
|
|
1425
|
-
throw new Error("Expected symbolNode but got " + String(group) + ".");
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
function assertSpan(group) {
|
|
1429
|
-
if (group instanceof Span) {
|
|
1430
|
-
return group;
|
|
1431
|
-
} else {
|
|
1432
|
-
throw new Error("Expected span<HtmlDomNode> but got " + String(group) + ".");
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
882
|
;// CONCATENATED MODULE: ./src/fontMetricsData.js
|
|
1436
883
|
// This file is GENERATED by buildMetrics.sh. DO NOT MODIFY.
|
|
1437
884
|
/* harmony default export */ var fontMetricsData = ({
|
|
@@ -3509,289 +2956,1279 @@ function assertSpan(group) {
|
|
|
3509
2956
|
"8242": [0, 0.61111, 0, 0, 0.525],
|
|
3510
2957
|
"9251": [0.11111, 0.21944, 0, 0, 0.525]
|
|
3511
2958
|
}
|
|
3512
|
-
});
|
|
3513
|
-
;// CONCATENATED MODULE: ./src/fontMetrics.js
|
|
2959
|
+
});
|
|
2960
|
+
;// CONCATENATED MODULE: ./src/fontMetrics.js
|
|
2961
|
+
|
|
2962
|
+
|
|
2963
|
+
/**
|
|
2964
|
+
* This file contains metrics regarding fonts and individual symbols. The sigma
|
|
2965
|
+
* and xi variables, as well as the metricMap map contain data extracted from
|
|
2966
|
+
* TeX, TeX font metrics, and the TTF files. These data are then exposed via the
|
|
2967
|
+
* `metrics` variable and the getCharacterMetrics function.
|
|
2968
|
+
*/
|
|
2969
|
+
// In TeX, there are actually three sets of dimensions, one for each of
|
|
2970
|
+
// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
|
|
2971
|
+
// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
|
|
2972
|
+
// provided in the the arrays below, in that order.
|
|
2973
|
+
//
|
|
2974
|
+
// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
|
|
2975
|
+
// This was determined by running the following script:
|
|
2976
|
+
//
|
|
2977
|
+
// latex -interaction=nonstopmode \
|
|
2978
|
+
// '\documentclass{article}\usepackage{amsmath}\begin{document}' \
|
|
2979
|
+
// '$a$ \expandafter\show\the\textfont2' \
|
|
2980
|
+
// '\expandafter\show\the\scriptfont2' \
|
|
2981
|
+
// '\expandafter\show\the\scriptscriptfont2' \
|
|
2982
|
+
// '\stop'
|
|
2983
|
+
//
|
|
2984
|
+
// The metrics themselves were retreived using the following commands:
|
|
2985
|
+
//
|
|
2986
|
+
// tftopl cmsy10
|
|
2987
|
+
// tftopl cmsy7
|
|
2988
|
+
// tftopl cmsy5
|
|
2989
|
+
//
|
|
2990
|
+
// The output of each of these commands is quite lengthy. The only part we
|
|
2991
|
+
// care about is the FONTDIMEN section. Each value is measured in EMs.
|
|
2992
|
+
var sigmasAndXis = {
|
|
2993
|
+
slant: [0.250, 0.250, 0.250],
|
|
2994
|
+
// sigma1
|
|
2995
|
+
space: [0.000, 0.000, 0.000],
|
|
2996
|
+
// sigma2
|
|
2997
|
+
stretch: [0.000, 0.000, 0.000],
|
|
2998
|
+
// sigma3
|
|
2999
|
+
shrink: [0.000, 0.000, 0.000],
|
|
3000
|
+
// sigma4
|
|
3001
|
+
xHeight: [0.431, 0.431, 0.431],
|
|
3002
|
+
// sigma5
|
|
3003
|
+
quad: [1.000, 1.171, 1.472],
|
|
3004
|
+
// sigma6
|
|
3005
|
+
extraSpace: [0.000, 0.000, 0.000],
|
|
3006
|
+
// sigma7
|
|
3007
|
+
num1: [0.677, 0.732, 0.925],
|
|
3008
|
+
// sigma8
|
|
3009
|
+
num2: [0.394, 0.384, 0.387],
|
|
3010
|
+
// sigma9
|
|
3011
|
+
num3: [0.444, 0.471, 0.504],
|
|
3012
|
+
// sigma10
|
|
3013
|
+
denom1: [0.686, 0.752, 1.025],
|
|
3014
|
+
// sigma11
|
|
3015
|
+
denom2: [0.345, 0.344, 0.532],
|
|
3016
|
+
// sigma12
|
|
3017
|
+
sup1: [0.413, 0.503, 0.504],
|
|
3018
|
+
// sigma13
|
|
3019
|
+
sup2: [0.363, 0.431, 0.404],
|
|
3020
|
+
// sigma14
|
|
3021
|
+
sup3: [0.289, 0.286, 0.294],
|
|
3022
|
+
// sigma15
|
|
3023
|
+
sub1: [0.150, 0.143, 0.200],
|
|
3024
|
+
// sigma16
|
|
3025
|
+
sub2: [0.247, 0.286, 0.400],
|
|
3026
|
+
// sigma17
|
|
3027
|
+
supDrop: [0.386, 0.353, 0.494],
|
|
3028
|
+
// sigma18
|
|
3029
|
+
subDrop: [0.050, 0.071, 0.100],
|
|
3030
|
+
// sigma19
|
|
3031
|
+
delim1: [2.390, 1.700, 1.980],
|
|
3032
|
+
// sigma20
|
|
3033
|
+
delim2: [1.010, 1.157, 1.420],
|
|
3034
|
+
// sigma21
|
|
3035
|
+
axisHeight: [0.250, 0.250, 0.250],
|
|
3036
|
+
// sigma22
|
|
3037
|
+
// These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
|
|
3038
|
+
// they correspond to the font parameters of the extension fonts (family 3).
|
|
3039
|
+
// See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
|
|
3040
|
+
// match cmex7, we'd use cmex7.tfm values for script and scriptscript
|
|
3041
|
+
// values.
|
|
3042
|
+
defaultRuleThickness: [0.04, 0.049, 0.049],
|
|
3043
|
+
// xi8; cmex7: 0.049
|
|
3044
|
+
bigOpSpacing1: [0.111, 0.111, 0.111],
|
|
3045
|
+
// xi9
|
|
3046
|
+
bigOpSpacing2: [0.166, 0.166, 0.166],
|
|
3047
|
+
// xi10
|
|
3048
|
+
bigOpSpacing3: [0.2, 0.2, 0.2],
|
|
3049
|
+
// xi11
|
|
3050
|
+
bigOpSpacing4: [0.6, 0.611, 0.611],
|
|
3051
|
+
// xi12; cmex7: 0.611
|
|
3052
|
+
bigOpSpacing5: [0.1, 0.143, 0.143],
|
|
3053
|
+
// xi13; cmex7: 0.143
|
|
3054
|
+
// The \sqrt rule width is taken from the height of the surd character.
|
|
3055
|
+
// Since we use the same font at all sizes, this thickness doesn't scale.
|
|
3056
|
+
sqrtRuleThickness: [0.04, 0.04, 0.04],
|
|
3057
|
+
// This value determines how large a pt is, for metrics which are defined
|
|
3058
|
+
// in terms of pts.
|
|
3059
|
+
// This value is also used in katex.less; if you change it make sure the
|
|
3060
|
+
// values match.
|
|
3061
|
+
ptPerEm: [10.0, 10.0, 10.0],
|
|
3062
|
+
// The space between adjacent `|` columns in an array definition. From
|
|
3063
|
+
// `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
|
|
3064
|
+
doubleRuleSep: [0.2, 0.2, 0.2],
|
|
3065
|
+
// The width of separator lines in {array} environments. From
|
|
3066
|
+
// `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
|
|
3067
|
+
arrayRuleWidth: [0.04, 0.04, 0.04],
|
|
3068
|
+
// Two values from LaTeX source2e:
|
|
3069
|
+
fboxsep: [0.3, 0.3, 0.3],
|
|
3070
|
+
// 3 pt / ptPerEm
|
|
3071
|
+
fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm
|
|
3072
|
+
|
|
3073
|
+
}; // This map contains a mapping from font name and character code to character
|
|
3074
|
+
// metrics, including height, depth, italic correction, and skew (kern from the
|
|
3075
|
+
// character to the corresponding \skewchar)
|
|
3076
|
+
// This map is generated via `make metrics`. It should not be changed manually.
|
|
3077
|
+
|
|
3078
|
+
// These are very rough approximations. We default to Times New Roman which
|
|
3079
|
+
// should have Latin-1 and Cyrillic characters, but may not depending on the
|
|
3080
|
+
// operating system. The metrics do not account for extra height from the
|
|
3081
|
+
// accents. In the case of Cyrillic characters which have both ascenders and
|
|
3082
|
+
// descenders we prefer approximations with ascenders, primarily to prevent
|
|
3083
|
+
// the fraction bar or root line from intersecting the glyph.
|
|
3084
|
+
// TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
|
|
3085
|
+
|
|
3086
|
+
var extraCharacterMap = {
|
|
3087
|
+
// Latin-1
|
|
3088
|
+
'Å': 'A',
|
|
3089
|
+
'Ð': 'D',
|
|
3090
|
+
'Þ': 'o',
|
|
3091
|
+
'å': 'a',
|
|
3092
|
+
'ð': 'd',
|
|
3093
|
+
'þ': 'o',
|
|
3094
|
+
// Cyrillic
|
|
3095
|
+
'А': 'A',
|
|
3096
|
+
'Б': 'B',
|
|
3097
|
+
'В': 'B',
|
|
3098
|
+
'Г': 'F',
|
|
3099
|
+
'Д': 'A',
|
|
3100
|
+
'Е': 'E',
|
|
3101
|
+
'Ж': 'K',
|
|
3102
|
+
'З': '3',
|
|
3103
|
+
'И': 'N',
|
|
3104
|
+
'Й': 'N',
|
|
3105
|
+
'К': 'K',
|
|
3106
|
+
'Л': 'N',
|
|
3107
|
+
'М': 'M',
|
|
3108
|
+
'Н': 'H',
|
|
3109
|
+
'О': 'O',
|
|
3110
|
+
'П': 'N',
|
|
3111
|
+
'Р': 'P',
|
|
3112
|
+
'С': 'C',
|
|
3113
|
+
'Т': 'T',
|
|
3114
|
+
'У': 'y',
|
|
3115
|
+
'Ф': 'O',
|
|
3116
|
+
'Х': 'X',
|
|
3117
|
+
'Ц': 'U',
|
|
3118
|
+
'Ч': 'h',
|
|
3119
|
+
'Ш': 'W',
|
|
3120
|
+
'Щ': 'W',
|
|
3121
|
+
'Ъ': 'B',
|
|
3122
|
+
'Ы': 'X',
|
|
3123
|
+
'Ь': 'B',
|
|
3124
|
+
'Э': '3',
|
|
3125
|
+
'Ю': 'X',
|
|
3126
|
+
'Я': 'R',
|
|
3127
|
+
'а': 'a',
|
|
3128
|
+
'б': 'b',
|
|
3129
|
+
'в': 'a',
|
|
3130
|
+
'г': 'r',
|
|
3131
|
+
'д': 'y',
|
|
3132
|
+
'е': 'e',
|
|
3133
|
+
'ж': 'm',
|
|
3134
|
+
'з': 'e',
|
|
3135
|
+
'и': 'n',
|
|
3136
|
+
'й': 'n',
|
|
3137
|
+
'к': 'n',
|
|
3138
|
+
'л': 'n',
|
|
3139
|
+
'м': 'm',
|
|
3140
|
+
'н': 'n',
|
|
3141
|
+
'о': 'o',
|
|
3142
|
+
'п': 'n',
|
|
3143
|
+
'р': 'p',
|
|
3144
|
+
'с': 'c',
|
|
3145
|
+
'т': 'o',
|
|
3146
|
+
'у': 'y',
|
|
3147
|
+
'ф': 'b',
|
|
3148
|
+
'х': 'x',
|
|
3149
|
+
'ц': 'n',
|
|
3150
|
+
'ч': 'n',
|
|
3151
|
+
'ш': 'w',
|
|
3152
|
+
'щ': 'w',
|
|
3153
|
+
'ъ': 'a',
|
|
3154
|
+
'ы': 'm',
|
|
3155
|
+
'ь': 'a',
|
|
3156
|
+
'э': 'e',
|
|
3157
|
+
'ю': 'm',
|
|
3158
|
+
'я': 'r'
|
|
3159
|
+
};
|
|
3160
|
+
|
|
3161
|
+
/**
|
|
3162
|
+
* This function adds new font metrics to default metricMap
|
|
3163
|
+
* It can also override existing metrics
|
|
3164
|
+
*/
|
|
3165
|
+
function setFontMetrics(fontName, metrics) {
|
|
3166
|
+
fontMetricsData[fontName] = metrics;
|
|
3167
|
+
}
|
|
3168
|
+
/**
|
|
3169
|
+
* This function is a convenience function for looking up information in the
|
|
3170
|
+
* metricMap table. It takes a character as a string, and a font.
|
|
3171
|
+
*
|
|
3172
|
+
* Note: the `width` property may be undefined if fontMetricsData.js wasn't
|
|
3173
|
+
* built using `Make extended_metrics`.
|
|
3174
|
+
*/
|
|
3175
|
+
|
|
3176
|
+
function getCharacterMetrics(character, font, mode) {
|
|
3177
|
+
if (!fontMetricsData[font]) {
|
|
3178
|
+
throw new Error("Font metrics not found for font: " + font + ".");
|
|
3179
|
+
}
|
|
3180
|
+
|
|
3181
|
+
var ch = character.charCodeAt(0);
|
|
3182
|
+
var metrics = fontMetricsData[font][ch];
|
|
3183
|
+
|
|
3184
|
+
if (!metrics && character[0] in extraCharacterMap) {
|
|
3185
|
+
ch = extraCharacterMap[character[0]].charCodeAt(0);
|
|
3186
|
+
metrics = fontMetricsData[font][ch];
|
|
3187
|
+
}
|
|
3188
|
+
|
|
3189
|
+
if (!metrics && mode === 'text') {
|
|
3190
|
+
// We don't typically have font metrics for Asian scripts.
|
|
3191
|
+
// But since we support them in text mode, we need to return
|
|
3192
|
+
// some sort of metrics.
|
|
3193
|
+
// So if the character is in a script we support but we
|
|
3194
|
+
// don't have metrics for it, just use the metrics for
|
|
3195
|
+
// the Latin capital letter M. This is close enough because
|
|
3196
|
+
// we (currently) only care about the height of the glpyh
|
|
3197
|
+
// not its width.
|
|
3198
|
+
if (supportedCodepoint(ch)) {
|
|
3199
|
+
metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M'
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
|
|
3203
|
+
if (metrics) {
|
|
3204
|
+
return {
|
|
3205
|
+
depth: metrics[0],
|
|
3206
|
+
height: metrics[1],
|
|
3207
|
+
italic: metrics[2],
|
|
3208
|
+
skew: metrics[3],
|
|
3209
|
+
width: metrics[4]
|
|
3210
|
+
};
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
var fontMetricsBySizeIndex = {};
|
|
3214
|
+
/**
|
|
3215
|
+
* Get the font metrics for a given size.
|
|
3216
|
+
*/
|
|
3217
|
+
|
|
3218
|
+
function getGlobalMetrics(size) {
|
|
3219
|
+
var sizeIndex;
|
|
3220
|
+
|
|
3221
|
+
if (size >= 5) {
|
|
3222
|
+
sizeIndex = 0;
|
|
3223
|
+
} else if (size >= 3) {
|
|
3224
|
+
sizeIndex = 1;
|
|
3225
|
+
} else {
|
|
3226
|
+
sizeIndex = 2;
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
if (!fontMetricsBySizeIndex[sizeIndex]) {
|
|
3230
|
+
var metrics = fontMetricsBySizeIndex[sizeIndex] = {
|
|
3231
|
+
cssEmPerMu: sigmasAndXis.quad[sizeIndex] / 18
|
|
3232
|
+
};
|
|
3233
|
+
|
|
3234
|
+
for (var key in sigmasAndXis) {
|
|
3235
|
+
if (sigmasAndXis.hasOwnProperty(key)) {
|
|
3236
|
+
metrics[key] = sigmasAndXis[key][sizeIndex];
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
|
|
3241
|
+
return fontMetricsBySizeIndex[sizeIndex];
|
|
3242
|
+
}
|
|
3243
|
+
;// CONCATENATED MODULE: ./src/Options.js
|
|
3244
|
+
/**
|
|
3245
|
+
* This file contains information about the options that the Parser carries
|
|
3246
|
+
* around with it while parsing. Data is held in an `Options` object, and when
|
|
3247
|
+
* recursing, a new `Options` object can be created with the `.with*` and
|
|
3248
|
+
* `.reset` functions.
|
|
3249
|
+
*/
|
|
3250
|
+
|
|
3251
|
+
var sizeStyleMap = [// Each element contains [textsize, scriptsize, scriptscriptsize].
|
|
3252
|
+
// The size mappings are taken from TeX with \normalsize=10pt.
|
|
3253
|
+
[1, 1, 1], // size1: [5, 5, 5] \tiny
|
|
3254
|
+
[2, 1, 1], // size2: [6, 5, 5]
|
|
3255
|
+
[3, 1, 1], // size3: [7, 5, 5] \scriptsize
|
|
3256
|
+
[4, 2, 1], // size4: [8, 6, 5] \footnotesize
|
|
3257
|
+
[5, 2, 1], // size5: [9, 6, 5] \small
|
|
3258
|
+
[6, 3, 1], // size6: [10, 7, 5] \normalsize
|
|
3259
|
+
[7, 4, 2], // size7: [12, 8, 6] \large
|
|
3260
|
+
[8, 6, 3], // size8: [14.4, 10, 7] \Large
|
|
3261
|
+
[9, 7, 6], // size9: [17.28, 12, 10] \LARGE
|
|
3262
|
+
[10, 8, 7], // size10: [20.74, 14.4, 12] \huge
|
|
3263
|
+
[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE
|
|
3264
|
+
];
|
|
3265
|
+
var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if
|
|
3266
|
+
// you change size indexes, change that function.
|
|
3267
|
+
0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
|
|
3268
|
+
|
|
3269
|
+
var sizeAtStyle = function sizeAtStyle(size, style) {
|
|
3270
|
+
return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
|
|
3271
|
+
}; // In these types, "" (empty string) means "no change".
|
|
3272
|
+
|
|
3273
|
+
|
|
3274
|
+
/**
|
|
3275
|
+
* This is the main options class. It contains the current style, size, color,
|
|
3276
|
+
* and font.
|
|
3277
|
+
*
|
|
3278
|
+
* Options objects should not be modified. To create a new Options with
|
|
3279
|
+
* different properties, call a `.having*` method.
|
|
3280
|
+
*/
|
|
3281
|
+
var Options = /*#__PURE__*/function () {
|
|
3282
|
+
// A font family applies to a group of fonts (i.e. SansSerif), while a font
|
|
3283
|
+
// represents a specific font (i.e. SansSerif Bold).
|
|
3284
|
+
// See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm
|
|
3285
|
+
|
|
3286
|
+
/**
|
|
3287
|
+
* The base size index.
|
|
3288
|
+
*/
|
|
3289
|
+
function Options(data) {
|
|
3290
|
+
this.style = void 0;
|
|
3291
|
+
this.color = void 0;
|
|
3292
|
+
this.size = void 0;
|
|
3293
|
+
this.textSize = void 0;
|
|
3294
|
+
this.phantom = void 0;
|
|
3295
|
+
this.font = void 0;
|
|
3296
|
+
this.fontFamily = void 0;
|
|
3297
|
+
this.fontWeight = void 0;
|
|
3298
|
+
this.fontShape = void 0;
|
|
3299
|
+
this.sizeMultiplier = void 0;
|
|
3300
|
+
this.maxSize = void 0;
|
|
3301
|
+
this.minRuleThickness = void 0;
|
|
3302
|
+
this._fontMetrics = void 0;
|
|
3303
|
+
this.style = data.style;
|
|
3304
|
+
this.color = data.color;
|
|
3305
|
+
this.size = data.size || Options.BASESIZE;
|
|
3306
|
+
this.textSize = data.textSize || this.size;
|
|
3307
|
+
this.phantom = !!data.phantom;
|
|
3308
|
+
this.font = data.font || "";
|
|
3309
|
+
this.fontFamily = data.fontFamily || "";
|
|
3310
|
+
this.fontWeight = data.fontWeight || '';
|
|
3311
|
+
this.fontShape = data.fontShape || '';
|
|
3312
|
+
this.sizeMultiplier = sizeMultipliers[this.size - 1];
|
|
3313
|
+
this.maxSize = data.maxSize;
|
|
3314
|
+
this.minRuleThickness = data.minRuleThickness;
|
|
3315
|
+
this._fontMetrics = undefined;
|
|
3316
|
+
}
|
|
3317
|
+
/**
|
|
3318
|
+
* Returns a new options object with the same properties as "this". Properties
|
|
3319
|
+
* from "extension" will be copied to the new options object.
|
|
3320
|
+
*/
|
|
3321
|
+
|
|
3322
|
+
|
|
3323
|
+
var _proto = Options.prototype;
|
|
3324
|
+
|
|
3325
|
+
_proto.extend = function extend(extension) {
|
|
3326
|
+
var data = {
|
|
3327
|
+
style: this.style,
|
|
3328
|
+
size: this.size,
|
|
3329
|
+
textSize: this.textSize,
|
|
3330
|
+
color: this.color,
|
|
3331
|
+
phantom: this.phantom,
|
|
3332
|
+
font: this.font,
|
|
3333
|
+
fontFamily: this.fontFamily,
|
|
3334
|
+
fontWeight: this.fontWeight,
|
|
3335
|
+
fontShape: this.fontShape,
|
|
3336
|
+
maxSize: this.maxSize,
|
|
3337
|
+
minRuleThickness: this.minRuleThickness
|
|
3338
|
+
};
|
|
3339
|
+
|
|
3340
|
+
for (var key in extension) {
|
|
3341
|
+
if (extension.hasOwnProperty(key)) {
|
|
3342
|
+
data[key] = extension[key];
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
|
|
3346
|
+
return new Options(data);
|
|
3347
|
+
}
|
|
3348
|
+
/**
|
|
3349
|
+
* Return an options object with the given style. If `this.style === style`,
|
|
3350
|
+
* returns `this`.
|
|
3351
|
+
*/
|
|
3352
|
+
;
|
|
3353
|
+
|
|
3354
|
+
_proto.havingStyle = function havingStyle(style) {
|
|
3355
|
+
if (this.style === style) {
|
|
3356
|
+
return this;
|
|
3357
|
+
} else {
|
|
3358
|
+
return this.extend({
|
|
3359
|
+
style: style,
|
|
3360
|
+
size: sizeAtStyle(this.textSize, style)
|
|
3361
|
+
});
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
/**
|
|
3365
|
+
* Return an options object with a cramped version of the current style. If
|
|
3366
|
+
* the current style is cramped, returns `this`.
|
|
3367
|
+
*/
|
|
3368
|
+
;
|
|
3369
|
+
|
|
3370
|
+
_proto.havingCrampedStyle = function havingCrampedStyle() {
|
|
3371
|
+
return this.havingStyle(this.style.cramp());
|
|
3372
|
+
}
|
|
3373
|
+
/**
|
|
3374
|
+
* Return an options object with the given size and in at least `\textstyle`.
|
|
3375
|
+
* Returns `this` if appropriate.
|
|
3376
|
+
*/
|
|
3377
|
+
;
|
|
3378
|
+
|
|
3379
|
+
_proto.havingSize = function havingSize(size) {
|
|
3380
|
+
if (this.size === size && this.textSize === size) {
|
|
3381
|
+
return this;
|
|
3382
|
+
} else {
|
|
3383
|
+
return this.extend({
|
|
3384
|
+
style: this.style.text(),
|
|
3385
|
+
size: size,
|
|
3386
|
+
textSize: size,
|
|
3387
|
+
sizeMultiplier: sizeMultipliers[size - 1]
|
|
3388
|
+
});
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
/**
|
|
3392
|
+
* Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
|
|
3393
|
+
* changes to at least `\textstyle`.
|
|
3394
|
+
*/
|
|
3395
|
+
;
|
|
3396
|
+
|
|
3397
|
+
_proto.havingBaseStyle = function havingBaseStyle(style) {
|
|
3398
|
+
style = style || this.style.text();
|
|
3399
|
+
var wantSize = sizeAtStyle(Options.BASESIZE, style);
|
|
3400
|
+
|
|
3401
|
+
if (this.size === wantSize && this.textSize === Options.BASESIZE && this.style === style) {
|
|
3402
|
+
return this;
|
|
3403
|
+
} else {
|
|
3404
|
+
return this.extend({
|
|
3405
|
+
style: style,
|
|
3406
|
+
size: wantSize
|
|
3407
|
+
});
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
/**
|
|
3411
|
+
* Remove the effect of sizing changes such as \Huge.
|
|
3412
|
+
* Keep the effect of the current style, such as \scriptstyle.
|
|
3413
|
+
*/
|
|
3414
|
+
;
|
|
3415
|
+
|
|
3416
|
+
_proto.havingBaseSizing = function havingBaseSizing() {
|
|
3417
|
+
var size;
|
|
3418
|
+
|
|
3419
|
+
switch (this.style.id) {
|
|
3420
|
+
case 4:
|
|
3421
|
+
case 5:
|
|
3422
|
+
size = 3; // normalsize in scriptstyle
|
|
3423
|
+
|
|
3424
|
+
break;
|
|
3425
|
+
|
|
3426
|
+
case 6:
|
|
3427
|
+
case 7:
|
|
3428
|
+
size = 1; // normalsize in scriptscriptstyle
|
|
3429
|
+
|
|
3430
|
+
break;
|
|
3431
|
+
|
|
3432
|
+
default:
|
|
3433
|
+
size = 6;
|
|
3434
|
+
// normalsize in textstyle or displaystyle
|
|
3435
|
+
}
|
|
3436
|
+
|
|
3437
|
+
return this.extend({
|
|
3438
|
+
style: this.style.text(),
|
|
3439
|
+
size: size
|
|
3440
|
+
});
|
|
3441
|
+
}
|
|
3442
|
+
/**
|
|
3443
|
+
* Create a new options object with the given color.
|
|
3444
|
+
*/
|
|
3445
|
+
;
|
|
3446
|
+
|
|
3447
|
+
_proto.withColor = function withColor(color) {
|
|
3448
|
+
return this.extend({
|
|
3449
|
+
color: color
|
|
3450
|
+
});
|
|
3451
|
+
}
|
|
3452
|
+
/**
|
|
3453
|
+
* Create a new options object with "phantom" set to true.
|
|
3454
|
+
*/
|
|
3455
|
+
;
|
|
3456
|
+
|
|
3457
|
+
_proto.withPhantom = function withPhantom() {
|
|
3458
|
+
return this.extend({
|
|
3459
|
+
phantom: true
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
3462
|
+
/**
|
|
3463
|
+
* Creates a new options object with the given math font or old text font.
|
|
3464
|
+
* @type {[type]}
|
|
3465
|
+
*/
|
|
3466
|
+
;
|
|
3467
|
+
|
|
3468
|
+
_proto.withFont = function withFont(font) {
|
|
3469
|
+
return this.extend({
|
|
3470
|
+
font: font
|
|
3471
|
+
});
|
|
3472
|
+
}
|
|
3473
|
+
/**
|
|
3474
|
+
* Create a new options objects with the given fontFamily.
|
|
3475
|
+
*/
|
|
3476
|
+
;
|
|
3477
|
+
|
|
3478
|
+
_proto.withTextFontFamily = function withTextFontFamily(fontFamily) {
|
|
3479
|
+
return this.extend({
|
|
3480
|
+
fontFamily: fontFamily,
|
|
3481
|
+
font: ""
|
|
3482
|
+
});
|
|
3483
|
+
}
|
|
3484
|
+
/**
|
|
3485
|
+
* Creates a new options object with the given font weight
|
|
3486
|
+
*/
|
|
3487
|
+
;
|
|
3488
|
+
|
|
3489
|
+
_proto.withTextFontWeight = function withTextFontWeight(fontWeight) {
|
|
3490
|
+
return this.extend({
|
|
3491
|
+
fontWeight: fontWeight,
|
|
3492
|
+
font: ""
|
|
3493
|
+
});
|
|
3494
|
+
}
|
|
3495
|
+
/**
|
|
3496
|
+
* Creates a new options object with the given font weight
|
|
3497
|
+
*/
|
|
3498
|
+
;
|
|
3499
|
+
|
|
3500
|
+
_proto.withTextFontShape = function withTextFontShape(fontShape) {
|
|
3501
|
+
return this.extend({
|
|
3502
|
+
fontShape: fontShape,
|
|
3503
|
+
font: ""
|
|
3504
|
+
});
|
|
3505
|
+
}
|
|
3506
|
+
/**
|
|
3507
|
+
* Return the CSS sizing classes required to switch from enclosing options
|
|
3508
|
+
* `oldOptions` to `this`. Returns an array of classes.
|
|
3509
|
+
*/
|
|
3510
|
+
;
|
|
3511
|
+
|
|
3512
|
+
_proto.sizingClasses = function sizingClasses(oldOptions) {
|
|
3513
|
+
if (oldOptions.size !== this.size) {
|
|
3514
|
+
return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
|
|
3515
|
+
} else {
|
|
3516
|
+
return [];
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
/**
|
|
3520
|
+
* Return the CSS sizing classes required to switch to the base size. Like
|
|
3521
|
+
* `this.havingSize(BASESIZE).sizingClasses(this)`.
|
|
3522
|
+
*/
|
|
3523
|
+
;
|
|
3524
|
+
|
|
3525
|
+
_proto.baseSizingClasses = function baseSizingClasses() {
|
|
3526
|
+
if (this.size !== Options.BASESIZE) {
|
|
3527
|
+
return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
|
|
3528
|
+
} else {
|
|
3529
|
+
return [];
|
|
3530
|
+
}
|
|
3531
|
+
}
|
|
3532
|
+
/**
|
|
3533
|
+
* Return the font metrics for this size.
|
|
3534
|
+
*/
|
|
3535
|
+
;
|
|
3536
|
+
|
|
3537
|
+
_proto.fontMetrics = function fontMetrics() {
|
|
3538
|
+
if (!this._fontMetrics) {
|
|
3539
|
+
this._fontMetrics = getGlobalMetrics(this.size);
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
return this._fontMetrics;
|
|
3543
|
+
}
|
|
3544
|
+
/**
|
|
3545
|
+
* Gets the CSS color of the current options object
|
|
3546
|
+
*/
|
|
3547
|
+
;
|
|
3548
|
+
|
|
3549
|
+
_proto.getColor = function getColor() {
|
|
3550
|
+
if (this.phantom) {
|
|
3551
|
+
return "transparent";
|
|
3552
|
+
} else {
|
|
3553
|
+
return this.color;
|
|
3554
|
+
}
|
|
3555
|
+
};
|
|
3556
|
+
|
|
3557
|
+
return Options;
|
|
3558
|
+
}();
|
|
3559
|
+
|
|
3560
|
+
Options.BASESIZE = 6;
|
|
3561
|
+
/* harmony default export */ var src_Options = (Options);
|
|
3562
|
+
;// CONCATENATED MODULE: ./src/units.js
|
|
3563
|
+
/**
|
|
3564
|
+
* This file does conversion between units. In particular, it provides
|
|
3565
|
+
* calculateSize to convert other units into ems.
|
|
3566
|
+
*/
|
|
3567
|
+
|
|
3568
|
+
// This table gives the number of TeX pts in one of each *absolute* TeX unit.
|
|
3569
|
+
// Thus, multiplying a length by this number converts the length from units
|
|
3570
|
+
// into pts. Dividing the result by ptPerEm gives the number of ems
|
|
3571
|
+
// *assuming* a font size of ptPerEm (normal size, normal style).
|
|
3572
|
+
|
|
3573
|
+
var ptPerUnit = {
|
|
3574
|
+
// https://en.wikibooks.org/wiki/LaTeX/Lengths and
|
|
3575
|
+
// https://tex.stackexchange.com/a/8263
|
|
3576
|
+
"pt": 1,
|
|
3577
|
+
// TeX point
|
|
3578
|
+
"mm": 7227 / 2540,
|
|
3579
|
+
// millimeter
|
|
3580
|
+
"cm": 7227 / 254,
|
|
3581
|
+
// centimeter
|
|
3582
|
+
"in": 72.27,
|
|
3583
|
+
// inch
|
|
3584
|
+
"bp": 803 / 800,
|
|
3585
|
+
// big (PostScript) points
|
|
3586
|
+
"pc": 12,
|
|
3587
|
+
// pica
|
|
3588
|
+
"dd": 1238 / 1157,
|
|
3589
|
+
// didot
|
|
3590
|
+
"cc": 14856 / 1157,
|
|
3591
|
+
// cicero (12 didot)
|
|
3592
|
+
"nd": 685 / 642,
|
|
3593
|
+
// new didot
|
|
3594
|
+
"nc": 1370 / 107,
|
|
3595
|
+
// new cicero (12 new didot)
|
|
3596
|
+
"sp": 1 / 65536,
|
|
3597
|
+
// scaled point (TeX's internal smallest unit)
|
|
3598
|
+
// https://tex.stackexchange.com/a/41371
|
|
3599
|
+
"px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX
|
|
3600
|
+
|
|
3601
|
+
}; // Dictionary of relative units, for fast validity testing.
|
|
3602
|
+
|
|
3603
|
+
var relativeUnit = {
|
|
3604
|
+
"ex": true,
|
|
3605
|
+
"em": true,
|
|
3606
|
+
"mu": true
|
|
3607
|
+
};
|
|
3608
|
+
|
|
3609
|
+
/**
|
|
3610
|
+
* Determine whether the specified unit (either a string defining the unit
|
|
3611
|
+
* or a "size" parse node containing a unit field) is valid.
|
|
3612
|
+
*/
|
|
3613
|
+
var validUnit = function validUnit(unit) {
|
|
3614
|
+
if (typeof unit !== "string") {
|
|
3615
|
+
unit = unit.unit;
|
|
3616
|
+
}
|
|
3617
|
+
|
|
3618
|
+
return unit in ptPerUnit || unit in relativeUnit || unit === "ex";
|
|
3619
|
+
};
|
|
3620
|
+
/*
|
|
3621
|
+
* Convert a "size" parse node (with numeric "number" and string "unit" fields,
|
|
3622
|
+
* as parsed by functions.js argType "size") into a CSS em value for the
|
|
3623
|
+
* current style/scale. `options` gives the current options.
|
|
3624
|
+
*/
|
|
3625
|
+
|
|
3626
|
+
var calculateSize = function calculateSize(sizeValue, options) {
|
|
3627
|
+
var scale;
|
|
3628
|
+
|
|
3629
|
+
if (sizeValue.unit in ptPerUnit) {
|
|
3630
|
+
// Absolute units
|
|
3631
|
+
scale = ptPerUnit[sizeValue.unit] // Convert unit to pt
|
|
3632
|
+
/ options.fontMetrics().ptPerEm // Convert pt to CSS em
|
|
3633
|
+
/ options.sizeMultiplier; // Unscale to make absolute units
|
|
3634
|
+
} else if (sizeValue.unit === "mu") {
|
|
3635
|
+
// `mu` units scale with scriptstyle/scriptscriptstyle.
|
|
3636
|
+
scale = options.fontMetrics().cssEmPerMu;
|
|
3637
|
+
} else {
|
|
3638
|
+
// Other relative units always refer to the *textstyle* font
|
|
3639
|
+
// in the current size.
|
|
3640
|
+
var unitOptions;
|
|
3641
|
+
|
|
3642
|
+
if (options.style.isTight()) {
|
|
3643
|
+
// isTight() means current style is script/scriptscript.
|
|
3644
|
+
unitOptions = options.havingStyle(options.style.text());
|
|
3645
|
+
} else {
|
|
3646
|
+
unitOptions = options;
|
|
3647
|
+
} // TODO: In TeX these units are relative to the quad of the current
|
|
3648
|
+
// *text* font, e.g. cmr10. KaTeX instead uses values from the
|
|
3649
|
+
// comparably-sized *Computer Modern symbol* font. At 10pt, these
|
|
3650
|
+
// match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
|
|
3651
|
+
// cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
|
|
3652
|
+
// TeX \showlists shows a kern of 1.13889 * fontsize;
|
|
3653
|
+
// KaTeX shows a kern of 1.171 * fontsize.
|
|
3654
|
+
|
|
3655
|
+
|
|
3656
|
+
if (sizeValue.unit === "ex") {
|
|
3657
|
+
scale = unitOptions.fontMetrics().xHeight;
|
|
3658
|
+
} else if (sizeValue.unit === "em") {
|
|
3659
|
+
scale = unitOptions.fontMetrics().quad;
|
|
3660
|
+
} else {
|
|
3661
|
+
throw new src_ParseError("Invalid unit: '" + sizeValue.unit + "'");
|
|
3662
|
+
}
|
|
3663
|
+
|
|
3664
|
+
if (unitOptions !== options) {
|
|
3665
|
+
scale *= unitOptions.sizeMultiplier / options.sizeMultiplier;
|
|
3666
|
+
}
|
|
3667
|
+
}
|
|
3668
|
+
|
|
3669
|
+
return Math.min(sizeValue.number * scale, options.maxSize);
|
|
3670
|
+
};
|
|
3671
|
+
/**
|
|
3672
|
+
* Round `n` to 4 decimal places, or to the nearest 1/10,000th em. See
|
|
3673
|
+
* https://github.com/KaTeX/KaTeX/pull/2460.
|
|
3674
|
+
*/
|
|
3675
|
+
|
|
3676
|
+
var makeEm = function makeEm(n) {
|
|
3677
|
+
return +n.toFixed(4) + "em";
|
|
3678
|
+
};
|
|
3679
|
+
;// CONCATENATED MODULE: ./src/domTree.js
|
|
3680
|
+
/**
|
|
3681
|
+
* These objects store the data about the DOM nodes we create, as well as some
|
|
3682
|
+
* extra data. They can then be transformed into real DOM nodes with the
|
|
3683
|
+
* `toNode` function or HTML markup using `toMarkup`. They are useful for both
|
|
3684
|
+
* storing extra properties on the nodes, as well as providing a way to easily
|
|
3685
|
+
* work with the DOM.
|
|
3686
|
+
*
|
|
3687
|
+
* Similar functions for working with MathML nodes exist in mathMLTree.js.
|
|
3688
|
+
*
|
|
3689
|
+
* TODO: refactor `span` and `anchor` into common superclass when
|
|
3690
|
+
* target environments support class inheritance
|
|
3691
|
+
*/
|
|
3692
|
+
|
|
3693
|
+
|
|
3694
|
+
|
|
3695
|
+
|
|
3696
|
+
|
|
3697
|
+
|
|
3698
|
+
/**
|
|
3699
|
+
* Create an HTML className based on a list of classes. In addition to joining
|
|
3700
|
+
* with spaces, we also remove empty classes.
|
|
3701
|
+
*/
|
|
3702
|
+
var createClass = function createClass(classes) {
|
|
3703
|
+
return classes.filter(function (cls) {
|
|
3704
|
+
return cls;
|
|
3705
|
+
}).join(" ");
|
|
3706
|
+
};
|
|
3707
|
+
|
|
3708
|
+
var initNode = function initNode(classes, options, style) {
|
|
3709
|
+
this.classes = classes || [];
|
|
3710
|
+
this.attributes = {};
|
|
3711
|
+
this.height = 0;
|
|
3712
|
+
this.depth = 0;
|
|
3713
|
+
this.maxFontSize = 0;
|
|
3714
|
+
this.style = style || {};
|
|
3715
|
+
|
|
3716
|
+
if (options) {
|
|
3717
|
+
if (options.style.isTight()) {
|
|
3718
|
+
this.classes.push("mtight");
|
|
3719
|
+
}
|
|
3720
|
+
|
|
3721
|
+
var color = options.getColor();
|
|
3722
|
+
|
|
3723
|
+
if (color) {
|
|
3724
|
+
this.style.color = color;
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3727
|
+
};
|
|
3728
|
+
/**
|
|
3729
|
+
* Convert into an HTML node
|
|
3730
|
+
*/
|
|
3731
|
+
|
|
3732
|
+
|
|
3733
|
+
var _toNode = function toNode(tagName) {
|
|
3734
|
+
var node = document.createElement(tagName); // Apply the class
|
|
3735
|
+
|
|
3736
|
+
node.className = createClass(this.classes); // Apply inline styles
|
|
3737
|
+
|
|
3738
|
+
for (var style in this.style) {
|
|
3739
|
+
if (this.style.hasOwnProperty(style)) {
|
|
3740
|
+
// $FlowFixMe Flow doesn't seem to understand span.style's type.
|
|
3741
|
+
node.style[style] = this.style[style];
|
|
3742
|
+
}
|
|
3743
|
+
} // Apply attributes
|
|
3744
|
+
|
|
3745
|
+
|
|
3746
|
+
for (var attr in this.attributes) {
|
|
3747
|
+
if (this.attributes.hasOwnProperty(attr)) {
|
|
3748
|
+
node.setAttribute(attr, this.attributes[attr]);
|
|
3749
|
+
}
|
|
3750
|
+
} // Append the children, also as HTML nodes
|
|
3751
|
+
|
|
3752
|
+
|
|
3753
|
+
for (var i = 0; i < this.children.length; i++) {
|
|
3754
|
+
node.appendChild(this.children[i].toNode());
|
|
3755
|
+
}
|
|
3756
|
+
|
|
3757
|
+
return node;
|
|
3758
|
+
};
|
|
3759
|
+
/**
|
|
3760
|
+
* Convert into an HTML markup string
|
|
3761
|
+
*/
|
|
3762
|
+
|
|
3763
|
+
|
|
3764
|
+
var _toMarkup = function toMarkup(tagName) {
|
|
3765
|
+
var markup = "<" + tagName; // Add the class
|
|
3766
|
+
|
|
3767
|
+
if (this.classes.length) {
|
|
3768
|
+
markup += " class=\"" + utils.escape(createClass(this.classes)) + "\"";
|
|
3769
|
+
}
|
|
3770
|
+
|
|
3771
|
+
var styles = ""; // Add the styles, after hyphenation
|
|
3772
|
+
|
|
3773
|
+
for (var style in this.style) {
|
|
3774
|
+
if (this.style.hasOwnProperty(style)) {
|
|
3775
|
+
styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
|
|
3779
|
+
if (styles) {
|
|
3780
|
+
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
3781
|
+
} // Add the attributes
|
|
3782
|
+
|
|
3783
|
+
|
|
3784
|
+
for (var attr in this.attributes) {
|
|
3785
|
+
if (this.attributes.hasOwnProperty(attr)) {
|
|
3786
|
+
markup += " " + attr + "=\"" + utils.escape(this.attributes[attr]) + "\"";
|
|
3787
|
+
}
|
|
3788
|
+
}
|
|
3789
|
+
|
|
3790
|
+
markup += ">"; // Add the markup of the children, also as markup
|
|
3791
|
+
|
|
3792
|
+
for (var i = 0; i < this.children.length; i++) {
|
|
3793
|
+
markup += this.children[i].toMarkup();
|
|
3794
|
+
}
|
|
3795
|
+
|
|
3796
|
+
markup += "</" + tagName + ">";
|
|
3797
|
+
return markup;
|
|
3798
|
+
}; // Making the type below exact with all optional fields doesn't work due to
|
|
3799
|
+
// - https://github.com/facebook/flow/issues/4582
|
|
3800
|
+
// - https://github.com/facebook/flow/issues/5688
|
|
3801
|
+
// However, since *all* fields are optional, $Shape<> works as suggested in 5688
|
|
3802
|
+
// above.
|
|
3803
|
+
// This type does not include all CSS properties. Additional properties should
|
|
3804
|
+
// be added as needed.
|
|
3805
|
+
|
|
3806
|
+
|
|
3807
|
+
/**
|
|
3808
|
+
* This node represents a span node, with a className, a list of children, and
|
|
3809
|
+
* an inline style. It also contains information about its height, depth, and
|
|
3810
|
+
* maxFontSize.
|
|
3811
|
+
*
|
|
3812
|
+
* Represents two types with different uses: SvgSpan to wrap an SVG and DomSpan
|
|
3813
|
+
* otherwise. This typesafety is important when HTML builders access a span's
|
|
3814
|
+
* children.
|
|
3815
|
+
*/
|
|
3816
|
+
var Span = /*#__PURE__*/function () {
|
|
3817
|
+
function Span(classes, children, options, style) {
|
|
3818
|
+
this.children = void 0;
|
|
3819
|
+
this.attributes = void 0;
|
|
3820
|
+
this.classes = void 0;
|
|
3821
|
+
this.height = void 0;
|
|
3822
|
+
this.depth = void 0;
|
|
3823
|
+
this.width = void 0;
|
|
3824
|
+
this.maxFontSize = void 0;
|
|
3825
|
+
this.style = void 0;
|
|
3826
|
+
initNode.call(this, classes, options, style);
|
|
3827
|
+
this.children = children || [];
|
|
3828
|
+
}
|
|
3829
|
+
/**
|
|
3830
|
+
* Sets an arbitrary attribute on the span. Warning: use this wisely. Not
|
|
3831
|
+
* all browsers support attributes the same, and having too many custom
|
|
3832
|
+
* attributes is probably bad.
|
|
3833
|
+
*/
|
|
3834
|
+
|
|
3835
|
+
|
|
3836
|
+
var _proto = Span.prototype;
|
|
3837
|
+
|
|
3838
|
+
_proto.setAttribute = function setAttribute(attribute, value) {
|
|
3839
|
+
this.attributes[attribute] = value;
|
|
3840
|
+
};
|
|
3841
|
+
|
|
3842
|
+
_proto.hasClass = function hasClass(className) {
|
|
3843
|
+
return utils.contains(this.classes, className);
|
|
3844
|
+
};
|
|
3845
|
+
|
|
3846
|
+
_proto.toNode = function toNode() {
|
|
3847
|
+
return _toNode.call(this, "span");
|
|
3848
|
+
};
|
|
3849
|
+
|
|
3850
|
+
_proto.toMarkup = function toMarkup() {
|
|
3851
|
+
return _toMarkup.call(this, "span");
|
|
3852
|
+
};
|
|
3853
|
+
|
|
3854
|
+
return Span;
|
|
3855
|
+
}();
|
|
3856
|
+
/**
|
|
3857
|
+
* This node represents an anchor (<a>) element with a hyperlink. See `span`
|
|
3858
|
+
* for further details.
|
|
3859
|
+
*/
|
|
3860
|
+
|
|
3861
|
+
var Anchor = /*#__PURE__*/function () {
|
|
3862
|
+
function Anchor(href, classes, children, options) {
|
|
3863
|
+
this.children = void 0;
|
|
3864
|
+
this.attributes = void 0;
|
|
3865
|
+
this.classes = void 0;
|
|
3866
|
+
this.height = void 0;
|
|
3867
|
+
this.depth = void 0;
|
|
3868
|
+
this.maxFontSize = void 0;
|
|
3869
|
+
this.style = void 0;
|
|
3870
|
+
initNode.call(this, classes, options);
|
|
3871
|
+
this.children = children || [];
|
|
3872
|
+
this.setAttribute('href', href);
|
|
3873
|
+
}
|
|
3874
|
+
|
|
3875
|
+
var _proto2 = Anchor.prototype;
|
|
3876
|
+
|
|
3877
|
+
_proto2.setAttribute = function setAttribute(attribute, value) {
|
|
3878
|
+
this.attributes[attribute] = value;
|
|
3879
|
+
};
|
|
3880
|
+
|
|
3881
|
+
_proto2.hasClass = function hasClass(className) {
|
|
3882
|
+
return utils.contains(this.classes, className);
|
|
3883
|
+
};
|
|
3884
|
+
|
|
3885
|
+
_proto2.toNode = function toNode() {
|
|
3886
|
+
return _toNode.call(this, "a");
|
|
3887
|
+
};
|
|
3888
|
+
|
|
3889
|
+
_proto2.toMarkup = function toMarkup() {
|
|
3890
|
+
return _toMarkup.call(this, "a");
|
|
3891
|
+
};
|
|
3892
|
+
|
|
3893
|
+
return Anchor;
|
|
3894
|
+
}();
|
|
3895
|
+
/**
|
|
3896
|
+
* This node represents an image embed (<img>) element.
|
|
3897
|
+
*/
|
|
3898
|
+
|
|
3899
|
+
var Img = /*#__PURE__*/function () {
|
|
3900
|
+
function Img(src, alt, style) {
|
|
3901
|
+
this.src = void 0;
|
|
3902
|
+
this.alt = void 0;
|
|
3903
|
+
this.classes = void 0;
|
|
3904
|
+
this.height = void 0;
|
|
3905
|
+
this.depth = void 0;
|
|
3906
|
+
this.maxFontSize = void 0;
|
|
3907
|
+
this.style = void 0;
|
|
3908
|
+
this.alt = alt;
|
|
3909
|
+
this.src = src;
|
|
3910
|
+
this.classes = ["mord"];
|
|
3911
|
+
this.style = style;
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3914
|
+
var _proto3 = Img.prototype;
|
|
3915
|
+
|
|
3916
|
+
_proto3.hasClass = function hasClass(className) {
|
|
3917
|
+
return utils.contains(this.classes, className);
|
|
3918
|
+
};
|
|
3919
|
+
|
|
3920
|
+
_proto3.toNode = function toNode() {
|
|
3921
|
+
var node = document.createElement("img");
|
|
3922
|
+
node.src = this.src;
|
|
3923
|
+
node.alt = this.alt;
|
|
3924
|
+
node.className = "mord"; // Apply inline styles
|
|
3925
|
+
|
|
3926
|
+
for (var style in this.style) {
|
|
3927
|
+
if (this.style.hasOwnProperty(style)) {
|
|
3928
|
+
// $FlowFixMe
|
|
3929
|
+
node.style[style] = this.style[style];
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
|
|
3933
|
+
return node;
|
|
3934
|
+
};
|
|
3935
|
+
|
|
3936
|
+
_proto3.toMarkup = function toMarkup() {
|
|
3937
|
+
var markup = "<img src='" + this.src + " 'alt='" + this.alt + "' "; // Add the styles, after hyphenation
|
|
3938
|
+
|
|
3939
|
+
var styles = "";
|
|
3940
|
+
|
|
3941
|
+
for (var style in this.style) {
|
|
3942
|
+
if (this.style.hasOwnProperty(style)) {
|
|
3943
|
+
styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
|
|
3947
|
+
if (styles) {
|
|
3948
|
+
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
3949
|
+
}
|
|
3514
3950
|
|
|
3951
|
+
markup += "'/>";
|
|
3952
|
+
return markup;
|
|
3953
|
+
};
|
|
3515
3954
|
|
|
3955
|
+
return Img;
|
|
3956
|
+
}();
|
|
3957
|
+
var iCombinations = {
|
|
3958
|
+
'î': "\u0131\u0302",
|
|
3959
|
+
'ï': "\u0131\u0308",
|
|
3960
|
+
'í': "\u0131\u0301",
|
|
3961
|
+
// 'ī': '\u0131\u0304', // enable when we add Extended Latin
|
|
3962
|
+
'ì': "\u0131\u0300"
|
|
3963
|
+
};
|
|
3516
3964
|
/**
|
|
3517
|
-
*
|
|
3518
|
-
*
|
|
3519
|
-
*
|
|
3520
|
-
* `metrics` variable and the getCharacterMetrics function.
|
|
3965
|
+
* A symbol node contains information about a single symbol. It either renders
|
|
3966
|
+
* to a single text node, or a span with a single text node in it, depending on
|
|
3967
|
+
* whether it has CSS classes, styles, or needs italic correction.
|
|
3521
3968
|
*/
|
|
3522
|
-
// In TeX, there are actually three sets of dimensions, one for each of
|
|
3523
|
-
// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
|
|
3524
|
-
// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
|
|
3525
|
-
// provided in the the arrays below, in that order.
|
|
3526
|
-
//
|
|
3527
|
-
// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
|
|
3528
|
-
// This was determined by running the following script:
|
|
3529
|
-
//
|
|
3530
|
-
// latex -interaction=nonstopmode \
|
|
3531
|
-
// '\documentclass{article}\usepackage{amsmath}\begin{document}' \
|
|
3532
|
-
// '$a$ \expandafter\show\the\textfont2' \
|
|
3533
|
-
// '\expandafter\show\the\scriptfont2' \
|
|
3534
|
-
// '\expandafter\show\the\scriptscriptfont2' \
|
|
3535
|
-
// '\stop'
|
|
3536
|
-
//
|
|
3537
|
-
// The metrics themselves were retreived using the following commands:
|
|
3538
|
-
//
|
|
3539
|
-
// tftopl cmsy10
|
|
3540
|
-
// tftopl cmsy7
|
|
3541
|
-
// tftopl cmsy5
|
|
3542
|
-
//
|
|
3543
|
-
// The output of each of these commands is quite lengthy. The only part we
|
|
3544
|
-
// care about is the FONTDIMEN section. Each value is measured in EMs.
|
|
3545
|
-
var sigmasAndXis = {
|
|
3546
|
-
slant: [0.250, 0.250, 0.250],
|
|
3547
|
-
// sigma1
|
|
3548
|
-
space: [0.000, 0.000, 0.000],
|
|
3549
|
-
// sigma2
|
|
3550
|
-
stretch: [0.000, 0.000, 0.000],
|
|
3551
|
-
// sigma3
|
|
3552
|
-
shrink: [0.000, 0.000, 0.000],
|
|
3553
|
-
// sigma4
|
|
3554
|
-
xHeight: [0.431, 0.431, 0.431],
|
|
3555
|
-
// sigma5
|
|
3556
|
-
quad: [1.000, 1.171, 1.472],
|
|
3557
|
-
// sigma6
|
|
3558
|
-
extraSpace: [0.000, 0.000, 0.000],
|
|
3559
|
-
// sigma7
|
|
3560
|
-
num1: [0.677, 0.732, 0.925],
|
|
3561
|
-
// sigma8
|
|
3562
|
-
num2: [0.394, 0.384, 0.387],
|
|
3563
|
-
// sigma9
|
|
3564
|
-
num3: [0.444, 0.471, 0.504],
|
|
3565
|
-
// sigma10
|
|
3566
|
-
denom1: [0.686, 0.752, 1.025],
|
|
3567
|
-
// sigma11
|
|
3568
|
-
denom2: [0.345, 0.344, 0.532],
|
|
3569
|
-
// sigma12
|
|
3570
|
-
sup1: [0.413, 0.503, 0.504],
|
|
3571
|
-
// sigma13
|
|
3572
|
-
sup2: [0.363, 0.431, 0.404],
|
|
3573
|
-
// sigma14
|
|
3574
|
-
sup3: [0.289, 0.286, 0.294],
|
|
3575
|
-
// sigma15
|
|
3576
|
-
sub1: [0.150, 0.143, 0.200],
|
|
3577
|
-
// sigma16
|
|
3578
|
-
sub2: [0.247, 0.286, 0.400],
|
|
3579
|
-
// sigma17
|
|
3580
|
-
supDrop: [0.386, 0.353, 0.494],
|
|
3581
|
-
// sigma18
|
|
3582
|
-
subDrop: [0.050, 0.071, 0.100],
|
|
3583
|
-
// sigma19
|
|
3584
|
-
delim1: [2.390, 1.700, 1.980],
|
|
3585
|
-
// sigma20
|
|
3586
|
-
delim2: [1.010, 1.157, 1.420],
|
|
3587
|
-
// sigma21
|
|
3588
|
-
axisHeight: [0.250, 0.250, 0.250],
|
|
3589
|
-
// sigma22
|
|
3590
|
-
// These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
|
|
3591
|
-
// they correspond to the font parameters of the extension fonts (family 3).
|
|
3592
|
-
// See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
|
|
3593
|
-
// match cmex7, we'd use cmex7.tfm values for script and scriptscript
|
|
3594
|
-
// values.
|
|
3595
|
-
defaultRuleThickness: [0.04, 0.049, 0.049],
|
|
3596
|
-
// xi8; cmex7: 0.049
|
|
3597
|
-
bigOpSpacing1: [0.111, 0.111, 0.111],
|
|
3598
|
-
// xi9
|
|
3599
|
-
bigOpSpacing2: [0.166, 0.166, 0.166],
|
|
3600
|
-
// xi10
|
|
3601
|
-
bigOpSpacing3: [0.2, 0.2, 0.2],
|
|
3602
|
-
// xi11
|
|
3603
|
-
bigOpSpacing4: [0.6, 0.611, 0.611],
|
|
3604
|
-
// xi12; cmex7: 0.611
|
|
3605
|
-
bigOpSpacing5: [0.1, 0.143, 0.143],
|
|
3606
|
-
// xi13; cmex7: 0.143
|
|
3607
|
-
// The \sqrt rule width is taken from the height of the surd character.
|
|
3608
|
-
// Since we use the same font at all sizes, this thickness doesn't scale.
|
|
3609
|
-
sqrtRuleThickness: [0.04, 0.04, 0.04],
|
|
3610
|
-
// This value determines how large a pt is, for metrics which are defined
|
|
3611
|
-
// in terms of pts.
|
|
3612
|
-
// This value is also used in katex.less; if you change it make sure the
|
|
3613
|
-
// values match.
|
|
3614
|
-
ptPerEm: [10.0, 10.0, 10.0],
|
|
3615
|
-
// The space between adjacent `|` columns in an array definition. From
|
|
3616
|
-
// `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
|
|
3617
|
-
doubleRuleSep: [0.2, 0.2, 0.2],
|
|
3618
|
-
// The width of separator lines in {array} environments. From
|
|
3619
|
-
// `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
|
|
3620
|
-
arrayRuleWidth: [0.04, 0.04, 0.04],
|
|
3621
|
-
// Two values from LaTeX source2e:
|
|
3622
|
-
fboxsep: [0.3, 0.3, 0.3],
|
|
3623
|
-
// 3 pt / ptPerEm
|
|
3624
|
-
fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm
|
|
3625
3969
|
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3970
|
+
var SymbolNode = /*#__PURE__*/function () {
|
|
3971
|
+
function SymbolNode(text, height, depth, italic, skew, width, classes, style) {
|
|
3972
|
+
this.text = void 0;
|
|
3973
|
+
this.height = void 0;
|
|
3974
|
+
this.depth = void 0;
|
|
3975
|
+
this.italic = void 0;
|
|
3976
|
+
this.skew = void 0;
|
|
3977
|
+
this.width = void 0;
|
|
3978
|
+
this.maxFontSize = void 0;
|
|
3979
|
+
this.classes = void 0;
|
|
3980
|
+
this.style = void 0;
|
|
3981
|
+
this.text = text;
|
|
3982
|
+
this.height = height || 0;
|
|
3983
|
+
this.depth = depth || 0;
|
|
3984
|
+
this.italic = italic || 0;
|
|
3985
|
+
this.skew = skew || 0;
|
|
3986
|
+
this.width = width || 0;
|
|
3987
|
+
this.classes = classes || [];
|
|
3988
|
+
this.style = style || {};
|
|
3989
|
+
this.maxFontSize = 0; // Mark text from non-Latin scripts with specific classes so that we
|
|
3990
|
+
// can specify which fonts to use. This allows us to render these
|
|
3991
|
+
// characters with a serif font in situations where the browser would
|
|
3992
|
+
// either default to a sans serif or render a placeholder character.
|
|
3993
|
+
// We use CSS class names like cjk_fallback, hangul_fallback and
|
|
3994
|
+
// brahmic_fallback. See ./unicodeScripts.js for the set of possible
|
|
3995
|
+
// script names
|
|
3996
|
+
|
|
3997
|
+
var script = scriptFromCodepoint(this.text.charCodeAt(0));
|
|
3998
|
+
|
|
3999
|
+
if (script) {
|
|
4000
|
+
this.classes.push(script + "_fallback");
|
|
4001
|
+
}
|
|
4002
|
+
|
|
4003
|
+
if (/[îïíì]/.test(this.text)) {
|
|
4004
|
+
// add ī when we add Extended Latin
|
|
4005
|
+
this.text = iCombinations[this.text];
|
|
4006
|
+
}
|
|
4007
|
+
}
|
|
4008
|
+
|
|
4009
|
+
var _proto4 = SymbolNode.prototype;
|
|
4010
|
+
|
|
4011
|
+
_proto4.hasClass = function hasClass(className) {
|
|
4012
|
+
return utils.contains(this.classes, className);
|
|
4013
|
+
}
|
|
4014
|
+
/**
|
|
4015
|
+
* Creates a text node or span from a symbol node. Note that a span is only
|
|
4016
|
+
* created if it is needed.
|
|
4017
|
+
*/
|
|
4018
|
+
;
|
|
4019
|
+
|
|
4020
|
+
_proto4.toNode = function toNode() {
|
|
4021
|
+
var node = document.createTextNode(this.text);
|
|
4022
|
+
var span = null;
|
|
4023
|
+
|
|
4024
|
+
if (this.italic > 0) {
|
|
4025
|
+
span = document.createElement("span");
|
|
4026
|
+
span.style.marginRight = makeEm(this.italic);
|
|
4027
|
+
}
|
|
4028
|
+
|
|
4029
|
+
if (this.classes.length > 0) {
|
|
4030
|
+
span = span || document.createElement("span");
|
|
4031
|
+
span.className = createClass(this.classes);
|
|
4032
|
+
}
|
|
4033
|
+
|
|
4034
|
+
for (var style in this.style) {
|
|
4035
|
+
if (this.style.hasOwnProperty(style)) {
|
|
4036
|
+
span = span || document.createElement("span"); // $FlowFixMe Flow doesn't seem to understand span.style's type.
|
|
4037
|
+
|
|
4038
|
+
span.style[style] = this.style[style];
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
|
|
4042
|
+
if (span) {
|
|
4043
|
+
span.appendChild(node);
|
|
4044
|
+
return span;
|
|
4045
|
+
} else {
|
|
4046
|
+
return node;
|
|
4047
|
+
}
|
|
4048
|
+
}
|
|
4049
|
+
/**
|
|
4050
|
+
* Creates markup for a symbol node.
|
|
4051
|
+
*/
|
|
4052
|
+
;
|
|
4053
|
+
|
|
4054
|
+
_proto4.toMarkup = function toMarkup() {
|
|
4055
|
+
// TODO(alpert): More duplication than I'd like from
|
|
4056
|
+
// span.prototype.toMarkup and symbolNode.prototype.toNode...
|
|
4057
|
+
var needsSpan = false;
|
|
4058
|
+
var markup = "<span";
|
|
4059
|
+
|
|
4060
|
+
if (this.classes.length) {
|
|
4061
|
+
needsSpan = true;
|
|
4062
|
+
markup += " class=\"";
|
|
4063
|
+
markup += utils.escape(createClass(this.classes));
|
|
4064
|
+
markup += "\"";
|
|
4065
|
+
}
|
|
4066
|
+
|
|
4067
|
+
var styles = "";
|
|
4068
|
+
|
|
4069
|
+
if (this.italic > 0) {
|
|
4070
|
+
styles += "margin-right:" + this.italic + "em;";
|
|
4071
|
+
}
|
|
4072
|
+
|
|
4073
|
+
for (var style in this.style) {
|
|
4074
|
+
if (this.style.hasOwnProperty(style)) {
|
|
4075
|
+
styles += utils.hyphenate(style) + ":" + this.style[style] + ";";
|
|
4076
|
+
}
|
|
4077
|
+
}
|
|
3630
4078
|
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
// descenders we prefer approximations with ascenders, primarily to prevent
|
|
3636
|
-
// the fraction bar or root line from intersecting the glyph.
|
|
3637
|
-
// TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
|
|
4079
|
+
if (styles) {
|
|
4080
|
+
needsSpan = true;
|
|
4081
|
+
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
4082
|
+
}
|
|
3638
4083
|
|
|
3639
|
-
var
|
|
3640
|
-
// Latin-1
|
|
3641
|
-
'Å': 'A',
|
|
3642
|
-
'Ð': 'D',
|
|
3643
|
-
'Þ': 'o',
|
|
3644
|
-
'å': 'a',
|
|
3645
|
-
'ð': 'd',
|
|
3646
|
-
'þ': 'o',
|
|
3647
|
-
// Cyrillic
|
|
3648
|
-
'А': 'A',
|
|
3649
|
-
'Б': 'B',
|
|
3650
|
-
'В': 'B',
|
|
3651
|
-
'Г': 'F',
|
|
3652
|
-
'Д': 'A',
|
|
3653
|
-
'Е': 'E',
|
|
3654
|
-
'Ж': 'K',
|
|
3655
|
-
'З': '3',
|
|
3656
|
-
'И': 'N',
|
|
3657
|
-
'Й': 'N',
|
|
3658
|
-
'К': 'K',
|
|
3659
|
-
'Л': 'N',
|
|
3660
|
-
'М': 'M',
|
|
3661
|
-
'Н': 'H',
|
|
3662
|
-
'О': 'O',
|
|
3663
|
-
'П': 'N',
|
|
3664
|
-
'Р': 'P',
|
|
3665
|
-
'С': 'C',
|
|
3666
|
-
'Т': 'T',
|
|
3667
|
-
'У': 'y',
|
|
3668
|
-
'Ф': 'O',
|
|
3669
|
-
'Х': 'X',
|
|
3670
|
-
'Ц': 'U',
|
|
3671
|
-
'Ч': 'h',
|
|
3672
|
-
'Ш': 'W',
|
|
3673
|
-
'Щ': 'W',
|
|
3674
|
-
'Ъ': 'B',
|
|
3675
|
-
'Ы': 'X',
|
|
3676
|
-
'Ь': 'B',
|
|
3677
|
-
'Э': '3',
|
|
3678
|
-
'Ю': 'X',
|
|
3679
|
-
'Я': 'R',
|
|
3680
|
-
'а': 'a',
|
|
3681
|
-
'б': 'b',
|
|
3682
|
-
'в': 'a',
|
|
3683
|
-
'г': 'r',
|
|
3684
|
-
'д': 'y',
|
|
3685
|
-
'е': 'e',
|
|
3686
|
-
'ж': 'm',
|
|
3687
|
-
'з': 'e',
|
|
3688
|
-
'и': 'n',
|
|
3689
|
-
'й': 'n',
|
|
3690
|
-
'к': 'n',
|
|
3691
|
-
'л': 'n',
|
|
3692
|
-
'м': 'm',
|
|
3693
|
-
'н': 'n',
|
|
3694
|
-
'о': 'o',
|
|
3695
|
-
'п': 'n',
|
|
3696
|
-
'р': 'p',
|
|
3697
|
-
'с': 'c',
|
|
3698
|
-
'т': 'o',
|
|
3699
|
-
'у': 'y',
|
|
3700
|
-
'ф': 'b',
|
|
3701
|
-
'х': 'x',
|
|
3702
|
-
'ц': 'n',
|
|
3703
|
-
'ч': 'n',
|
|
3704
|
-
'ш': 'w',
|
|
3705
|
-
'щ': 'w',
|
|
3706
|
-
'ъ': 'a',
|
|
3707
|
-
'ы': 'm',
|
|
3708
|
-
'ь': 'a',
|
|
3709
|
-
'э': 'e',
|
|
3710
|
-
'ю': 'm',
|
|
3711
|
-
'я': 'r'
|
|
3712
|
-
};
|
|
4084
|
+
var escaped = utils.escape(this.text);
|
|
3713
4085
|
|
|
4086
|
+
if (needsSpan) {
|
|
4087
|
+
markup += ">";
|
|
4088
|
+
markup += escaped;
|
|
4089
|
+
markup += "</span>";
|
|
4090
|
+
return markup;
|
|
4091
|
+
} else {
|
|
4092
|
+
return escaped;
|
|
4093
|
+
}
|
|
4094
|
+
};
|
|
4095
|
+
|
|
4096
|
+
return SymbolNode;
|
|
4097
|
+
}();
|
|
3714
4098
|
/**
|
|
3715
|
-
*
|
|
3716
|
-
* It can also override existing metrics
|
|
3717
|
-
*/
|
|
3718
|
-
function setFontMetrics(fontName, metrics) {
|
|
3719
|
-
fontMetricsData[fontName] = metrics;
|
|
3720
|
-
}
|
|
3721
|
-
/**
|
|
3722
|
-
* This function is a convenience function for looking up information in the
|
|
3723
|
-
* metricMap table. It takes a character as a string, and a font.
|
|
3724
|
-
*
|
|
3725
|
-
* Note: the `width` property may be undefined if fontMetricsData.js wasn't
|
|
3726
|
-
* built using `Make extended_metrics`.
|
|
4099
|
+
* SVG nodes are used to render stretchy wide elements.
|
|
3727
4100
|
*/
|
|
3728
4101
|
|
|
3729
|
-
function
|
|
3730
|
-
|
|
3731
|
-
|
|
4102
|
+
var SvgNode = /*#__PURE__*/function () {
|
|
4103
|
+
function SvgNode(children, attributes) {
|
|
4104
|
+
this.children = void 0;
|
|
4105
|
+
this.attributes = void 0;
|
|
4106
|
+
this.children = children || [];
|
|
4107
|
+
this.attributes = attributes || {};
|
|
3732
4108
|
}
|
|
3733
4109
|
|
|
3734
|
-
var
|
|
3735
|
-
var metrics = fontMetricsData[font][ch];
|
|
4110
|
+
var _proto5 = SvgNode.prototype;
|
|
3736
4111
|
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
}
|
|
4112
|
+
_proto5.toNode = function toNode() {
|
|
4113
|
+
var svgNS = "http://www.w3.org/2000/svg";
|
|
4114
|
+
var node = document.createElementNS(svgNS, "svg"); // Apply attributes
|
|
3741
4115
|
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
// So if the character is in a script we support but we
|
|
3747
|
-
// don't have metrics for it, just use the metrics for
|
|
3748
|
-
// the Latin capital letter M. This is close enough because
|
|
3749
|
-
// we (currently) only care about the height of the glpyh
|
|
3750
|
-
// not its width.
|
|
3751
|
-
if (supportedCodepoint(ch)) {
|
|
3752
|
-
metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M'
|
|
4116
|
+
for (var attr in this.attributes) {
|
|
4117
|
+
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
4118
|
+
node.setAttribute(attr, this.attributes[attr]);
|
|
4119
|
+
}
|
|
3753
4120
|
}
|
|
3754
|
-
}
|
|
3755
4121
|
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
4122
|
+
for (var i = 0; i < this.children.length; i++) {
|
|
4123
|
+
node.appendChild(this.children[i].toNode());
|
|
4124
|
+
}
|
|
4125
|
+
|
|
4126
|
+
return node;
|
|
4127
|
+
};
|
|
4128
|
+
|
|
4129
|
+
_proto5.toMarkup = function toMarkup() {
|
|
4130
|
+
var markup = "<svg xmlns=\"http://www.w3.org/2000/svg\""; // Apply attributes
|
|
4131
|
+
|
|
4132
|
+
for (var attr in this.attributes) {
|
|
4133
|
+
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
4134
|
+
markup += " " + attr + "='" + this.attributes[attr] + "'";
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4138
|
+
markup += ">";
|
|
4139
|
+
|
|
4140
|
+
for (var i = 0; i < this.children.length; i++) {
|
|
4141
|
+
markup += this.children[i].toMarkup();
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
markup += "</svg>";
|
|
4145
|
+
return markup;
|
|
4146
|
+
};
|
|
4147
|
+
|
|
4148
|
+
return SvgNode;
|
|
4149
|
+
}();
|
|
4150
|
+
var PathNode = /*#__PURE__*/function () {
|
|
4151
|
+
function PathNode(pathName, alternate) {
|
|
4152
|
+
this.pathName = void 0;
|
|
4153
|
+
this.alternate = void 0;
|
|
4154
|
+
this.pathName = pathName;
|
|
4155
|
+
this.alternate = alternate; // Used only for \sqrt, \phase, & tall delims
|
|
3764
4156
|
}
|
|
3765
|
-
}
|
|
3766
|
-
var fontMetricsBySizeIndex = {};
|
|
3767
|
-
/**
|
|
3768
|
-
* Get the font metrics for a given size.
|
|
3769
|
-
*/
|
|
3770
4157
|
|
|
3771
|
-
|
|
3772
|
-
var sizeIndex;
|
|
4158
|
+
var _proto6 = PathNode.prototype;
|
|
3773
4159
|
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
4160
|
+
_proto6.toNode = function toNode() {
|
|
4161
|
+
var svgNS = "http://www.w3.org/2000/svg";
|
|
4162
|
+
var node = document.createElementNS(svgNS, "path");
|
|
4163
|
+
|
|
4164
|
+
if (this.alternate) {
|
|
4165
|
+
node.setAttribute("d", this.alternate);
|
|
4166
|
+
} else {
|
|
4167
|
+
node.setAttribute("d", path[this.pathName]);
|
|
4168
|
+
}
|
|
4169
|
+
|
|
4170
|
+
return node;
|
|
4171
|
+
};
|
|
4172
|
+
|
|
4173
|
+
_proto6.toMarkup = function toMarkup() {
|
|
4174
|
+
if (this.alternate) {
|
|
4175
|
+
return "<path d='" + this.alternate + "'/>";
|
|
4176
|
+
} else {
|
|
4177
|
+
return "<path d='" + path[this.pathName] + "'/>";
|
|
4178
|
+
}
|
|
4179
|
+
};
|
|
4180
|
+
|
|
4181
|
+
return PathNode;
|
|
4182
|
+
}();
|
|
4183
|
+
var LineNode = /*#__PURE__*/function () {
|
|
4184
|
+
function LineNode(attributes) {
|
|
4185
|
+
this.attributes = void 0;
|
|
4186
|
+
this.attributes = attributes || {};
|
|
3780
4187
|
}
|
|
3781
4188
|
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
4189
|
+
var _proto7 = LineNode.prototype;
|
|
4190
|
+
|
|
4191
|
+
_proto7.toNode = function toNode() {
|
|
4192
|
+
var svgNS = "http://www.w3.org/2000/svg";
|
|
4193
|
+
var node = document.createElementNS(svgNS, "line"); // Apply attributes
|
|
4194
|
+
|
|
4195
|
+
for (var attr in this.attributes) {
|
|
4196
|
+
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
4197
|
+
node.setAttribute(attr, this.attributes[attr]);
|
|
4198
|
+
}
|
|
4199
|
+
}
|
|
4200
|
+
|
|
4201
|
+
return node;
|
|
4202
|
+
};
|
|
3786
4203
|
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
4204
|
+
_proto7.toMarkup = function toMarkup() {
|
|
4205
|
+
var markup = "<line";
|
|
4206
|
+
|
|
4207
|
+
for (var attr in this.attributes) {
|
|
4208
|
+
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
4209
|
+
markup += " " + attr + "='" + this.attributes[attr] + "'";
|
|
3790
4210
|
}
|
|
3791
4211
|
}
|
|
3792
|
-
}
|
|
3793
4212
|
|
|
3794
|
-
|
|
4213
|
+
markup += "/>";
|
|
4214
|
+
return markup;
|
|
4215
|
+
};
|
|
4216
|
+
|
|
4217
|
+
return LineNode;
|
|
4218
|
+
}();
|
|
4219
|
+
function assertSymbolDomNode(group) {
|
|
4220
|
+
if (group instanceof SymbolNode) {
|
|
4221
|
+
return group;
|
|
4222
|
+
} else {
|
|
4223
|
+
throw new Error("Expected symbolNode but got " + String(group) + ".");
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
function assertSpan(group) {
|
|
4227
|
+
if (group instanceof Span) {
|
|
4228
|
+
return group;
|
|
4229
|
+
} else {
|
|
4230
|
+
throw new Error("Expected span<HtmlDomNode> but got " + String(group) + ".");
|
|
4231
|
+
}
|
|
3795
4232
|
}
|
|
3796
4233
|
;// CONCATENATED MODULE: ./src/symbols.js
|
|
3797
4234
|
/**
|
|
@@ -4416,772 +4853,344 @@ defineSymbol(math, main, rel, "\u21D5", "\\Updownarrow", true);
|
|
|
4416
4853
|
defineSymbol(math, main, op, "\u2210", "\\coprod");
|
|
4417
4854
|
defineSymbol(math, main, op, "\u22C1", "\\bigvee");
|
|
4418
4855
|
defineSymbol(math, main, op, "\u22C0", "\\bigwedge");
|
|
4419
|
-
defineSymbol(math, main, op, "\u2A04", "\\biguplus");
|
|
4420
|
-
defineSymbol(math, main, op, "\u22C2", "\\bigcap");
|
|
4421
|
-
defineSymbol(math, main, op, "\u22C3", "\\bigcup");
|
|
4422
|
-
defineSymbol(math, main, op, "\u222B", "\\int");
|
|
4423
|
-
defineSymbol(math, main, op, "\u222B", "\\intop");
|
|
4424
|
-
defineSymbol(math, main, op, "\u222C", "\\iint");
|
|
4425
|
-
defineSymbol(math, main, op, "\u222D", "\\iiint");
|
|
4426
|
-
defineSymbol(math, main, op, "\u220F", "\\prod");
|
|
4427
|
-
defineSymbol(math, main, op, "\u2211", "\\sum");
|
|
4428
|
-
defineSymbol(math, main, op, "\u2A02", "\\bigotimes");
|
|
4429
|
-
defineSymbol(math, main, op, "\u2A01", "\\bigoplus");
|
|
4430
|
-
defineSymbol(math, main, op, "\u2A00", "\\bigodot");
|
|
4431
|
-
defineSymbol(math, main, op, "\u222E", "\\oint");
|
|
4432
|
-
defineSymbol(math, main, op, "\u222F", "\\oiint");
|
|
4433
|
-
defineSymbol(math, main, op, "\u2230", "\\oiiint");
|
|
4434
|
-
defineSymbol(math, main, op, "\u2A06", "\\bigsqcup");
|
|
4435
|
-
defineSymbol(math, main, op, "\u222B", "\\smallint");
|
|
4436
|
-
defineSymbol(symbols_text, main, inner, "\u2026", "\\textellipsis");
|
|
4437
|
-
defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
|
|
4438
|
-
defineSymbol(symbols_text, main, inner, "\u2026", "\\ldots", true);
|
|
4439
|
-
defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
|
|
4440
|
-
defineSymbol(math, main, inner, "\u22EF", "\\@cdots", true);
|
|
4441
|
-
defineSymbol(math, main, inner, "\u22F1", "\\ddots", true);
|
|
4442
|
-
defineSymbol(math, main, textord, "\u22EE", "\\varvdots"); // \vdots is a macro
|
|
4443
|
-
|
|
4444
|
-
defineSymbol(math, main, accent, "\u02CA", "\\acute");
|
|
4445
|
-
defineSymbol(math, main, accent, "\u02CB", "\\grave");
|
|
4446
|
-
defineSymbol(math, main, accent, "\xA8", "\\ddot");
|
|
4447
|
-
defineSymbol(math, main, accent, "~", "\\tilde");
|
|
4448
|
-
defineSymbol(math, main, accent, "\u02C9", "\\bar");
|
|
4449
|
-
defineSymbol(math, main, accent, "\u02D8", "\\breve");
|
|
4450
|
-
defineSymbol(math, main, accent, "\u02C7", "\\check");
|
|
4451
|
-
defineSymbol(math, main, accent, "^", "\\hat");
|
|
4452
|
-
defineSymbol(math, main, accent, "\u20D7", "\\vec");
|
|
4453
|
-
defineSymbol(math, main, accent, "\u02D9", "\\dot");
|
|
4454
|
-
defineSymbol(math, main, accent, "\u02DA", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA
|
|
4455
|
-
|
|
4456
|
-
defineSymbol(math, main, mathord, "\uE131", "\\@imath");
|
|
4457
|
-
defineSymbol(math, main, mathord, "\uE237", "\\@jmath");
|
|
4458
|
-
defineSymbol(math, main, textord, "\u0131", "\u0131");
|
|
4459
|
-
defineSymbol(math, main, textord, "\u0237", "\u0237");
|
|
4460
|
-
defineSymbol(symbols_text, main, textord, "\u0131", "\\i", true);
|
|
4461
|
-
defineSymbol(symbols_text, main, textord, "\u0237", "\\j", true);
|
|
4462
|
-
defineSymbol(symbols_text, main, textord, "\xDF", "\\ss", true);
|
|
4463
|
-
defineSymbol(symbols_text, main, textord, "\xE6", "\\ae", true);
|
|
4464
|
-
defineSymbol(symbols_text, main, textord, "\u0153", "\\oe", true);
|
|
4465
|
-
defineSymbol(symbols_text, main, textord, "\xF8", "\\o", true);
|
|
4466
|
-
defineSymbol(symbols_text, main, textord, "\xC6", "\\AE", true);
|
|
4467
|
-
defineSymbol(symbols_text, main, textord, "\u0152", "\\OE", true);
|
|
4468
|
-
defineSymbol(symbols_text, main, textord, "\xD8", "\\O", true);
|
|
4469
|
-
defineSymbol(symbols_text, main, accent, "\u02CA", "\\'"); // acute
|
|
4470
|
-
|
|
4471
|
-
defineSymbol(symbols_text, main, accent, "\u02CB", "\\`"); // grave
|
|
4472
|
-
|
|
4473
|
-
defineSymbol(symbols_text, main, accent, "\u02C6", "\\^"); // circumflex
|
|
4474
|
-
|
|
4475
|
-
defineSymbol(symbols_text, main, accent, "\u02DC", "\\~"); // tilde
|
|
4476
|
-
|
|
4477
|
-
defineSymbol(symbols_text, main, accent, "\u02C9", "\\="); // macron
|
|
4478
|
-
|
|
4479
|
-
defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve
|
|
4480
|
-
|
|
4481
|
-
defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above
|
|
4482
|
-
|
|
4483
|
-
defineSymbol(symbols_text, main, accent, "\xB8", "\\c"); // cedilla
|
|
4484
|
-
|
|
4485
|
-
defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above
|
|
4486
|
-
|
|
4487
|
-
defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron
|
|
4488
|
-
|
|
4489
|
-
defineSymbol(symbols_text, main, accent, "\xA8", '\\"'); // diaresis
|
|
4490
|
-
|
|
4491
|
-
defineSymbol(symbols_text, main, accent, "\u02DD", "\\H"); // double acute
|
|
4492
|
-
|
|
4493
|
-
defineSymbol(symbols_text, main, accent, "\u25EF", "\\textcircled"); // \bigcirc glyph
|
|
4494
|
-
// These ligatures are detected and created in Parser.js's `formLigatures`.
|
|
4495
|
-
|
|
4496
|
-
var ligatures = {
|
|
4497
|
-
"--": true,
|
|
4498
|
-
"---": true,
|
|
4499
|
-
"``": true,
|
|
4500
|
-
"''": true
|
|
4501
|
-
};
|
|
4502
|
-
defineSymbol(symbols_text, main, textord, "\u2013", "--", true);
|
|
4503
|
-
defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash");
|
|
4504
|
-
defineSymbol(symbols_text, main, textord, "\u2014", "---", true);
|
|
4505
|
-
defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash");
|
|
4506
|
-
defineSymbol(symbols_text, main, textord, "\u2018", "`", true);
|
|
4507
|
-
defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft");
|
|
4508
|
-
defineSymbol(symbols_text, main, textord, "\u2019", "'", true);
|
|
4509
|
-
defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright");
|
|
4510
|
-
defineSymbol(symbols_text, main, textord, "\u201C", "``", true);
|
|
4511
|
-
defineSymbol(symbols_text, main, textord, "\u201C", "\\textquotedblleft");
|
|
4512
|
-
defineSymbol(symbols_text, main, textord, "\u201D", "''", true);
|
|
4513
|
-
defineSymbol(symbols_text, main, textord, "\u201D", "\\textquotedblright"); // \degree from gensymb package
|
|
4514
|
-
|
|
4515
|
-
defineSymbol(math, main, textord, "\xB0", "\\degree", true);
|
|
4516
|
-
defineSymbol(symbols_text, main, textord, "\xB0", "\\degree"); // \textdegree from inputenc package
|
|
4517
|
-
|
|
4518
|
-
defineSymbol(symbols_text, main, textord, "\xB0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math
|
|
4519
|
-
// mode, but among our fonts, only Main-Regular defines this character "163".
|
|
4520
|
-
|
|
4521
|
-
defineSymbol(math, main, textord, "\xA3", "\\pounds");
|
|
4522
|
-
defineSymbol(math, main, textord, "\xA3", "\\mathsterling", true);
|
|
4523
|
-
defineSymbol(symbols_text, main, textord, "\xA3", "\\pounds");
|
|
4524
|
-
defineSymbol(symbols_text, main, textord, "\xA3", "\\textsterling", true);
|
|
4525
|
-
defineSymbol(math, ams, textord, "\u2720", "\\maltese");
|
|
4526
|
-
defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards.
|
|
4527
|
-
// All of these are textords in math mode
|
|
4528
|
-
|
|
4529
|
-
var mathTextSymbols = "0123456789/@.\"";
|
|
4530
|
-
|
|
4531
|
-
for (var i = 0; i < mathTextSymbols.length; i++) {
|
|
4532
|
-
var ch = mathTextSymbols.charAt(i);
|
|
4533
|
-
defineSymbol(math, main, textord, ch, ch);
|
|
4534
|
-
} // All of these are textords in text mode
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
var textSymbols = "0123456789!@*()-=+\";:?/.,";
|
|
4538
|
-
|
|
4539
|
-
for (var _i = 0; _i < textSymbols.length; _i++) {
|
|
4540
|
-
var _ch = textSymbols.charAt(_i);
|
|
4541
|
-
|
|
4542
|
-
defineSymbol(symbols_text, main, textord, _ch, _ch);
|
|
4543
|
-
} // All of these are textords in text mode, and mathords in math mode
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
4547
|
-
|
|
4548
|
-
for (var _i2 = 0; _i2 < letters.length; _i2++) {
|
|
4549
|
-
var _ch2 = letters.charAt(_i2);
|
|
4550
|
-
|
|
4551
|
-
defineSymbol(math, main, mathord, _ch2, _ch2);
|
|
4552
|
-
defineSymbol(symbols_text, main, textord, _ch2, _ch2);
|
|
4553
|
-
} // Blackboard bold and script letters in Unicode range
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
|
|
4557
|
-
|
|
4558
|
-
defineSymbol(symbols_text, ams, textord, "C", "\u2102");
|
|
4559
|
-
defineSymbol(math, ams, textord, "H", "\u210D");
|
|
4560
|
-
defineSymbol(symbols_text, ams, textord, "H", "\u210D");
|
|
4561
|
-
defineSymbol(math, ams, textord, "N", "\u2115");
|
|
4562
|
-
defineSymbol(symbols_text, ams, textord, "N", "\u2115");
|
|
4563
|
-
defineSymbol(math, ams, textord, "P", "\u2119");
|
|
4564
|
-
defineSymbol(symbols_text, ams, textord, "P", "\u2119");
|
|
4565
|
-
defineSymbol(math, ams, textord, "Q", "\u211A");
|
|
4566
|
-
defineSymbol(symbols_text, ams, textord, "Q", "\u211A");
|
|
4567
|
-
defineSymbol(math, ams, textord, "R", "\u211D");
|
|
4568
|
-
defineSymbol(symbols_text, ams, textord, "R", "\u211D");
|
|
4569
|
-
defineSymbol(math, ams, textord, "Z", "\u2124");
|
|
4570
|
-
defineSymbol(symbols_text, ams, textord, "Z", "\u2124");
|
|
4571
|
-
defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant
|
|
4572
|
-
|
|
4573
|
-
defineSymbol(symbols_text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters.
|
|
4574
|
-
// We support some letters in the Unicode range U+1D400 to U+1D7FF,
|
|
4575
|
-
// Mathematical Alphanumeric Symbols.
|
|
4576
|
-
// Some editors do not deal well with wide characters. So don't write the
|
|
4577
|
-
// string into this file. Instead, create the string from the surrogate pair.
|
|
4578
|
-
|
|
4579
|
-
var wideChar = "";
|
|
4580
|
-
|
|
4581
|
-
for (var _i3 = 0; _i3 < letters.length; _i3++) {
|
|
4582
|
-
var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair.
|
|
4583
|
-
// 0xD835 is the high surrogate for all letters in the range we support.
|
|
4584
|
-
// 0xDC00 is the low surrogate for bold A.
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
|
|
4588
|
-
|
|
4589
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4590
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4591
|
-
wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic
|
|
4592
|
-
|
|
4593
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4594
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4595
|
-
wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic
|
|
4596
|
-
|
|
4597
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4598
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4599
|
-
wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur
|
|
4600
|
-
|
|
4601
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4602
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4603
|
-
wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif
|
|
4604
|
-
|
|
4605
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4606
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4607
|
-
wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold
|
|
4608
|
-
|
|
4609
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4610
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4611
|
-
wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic
|
|
4612
|
-
|
|
4613
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4614
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4615
|
-
wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace
|
|
4616
|
-
|
|
4617
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4618
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4619
|
-
|
|
4620
|
-
if (_i3 < 26) {
|
|
4621
|
-
// KaTeX fonts have only capital letters for blackboard bold and script.
|
|
4622
|
-
// See exception for k below.
|
|
4623
|
-
wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck
|
|
4624
|
-
|
|
4625
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4626
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4627
|
-
wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script
|
|
4628
|
-
|
|
4629
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4630
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4631
|
-
} // TODO: Add bold script when it is supported by a KaTeX font.
|
|
4632
|
-
|
|
4633
|
-
} // "k" is the only double struck lower case letter in the KaTeX fonts.
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
|
|
4637
|
-
|
|
4638
|
-
defineSymbol(math, main, mathord, "k", wideChar);
|
|
4639
|
-
defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals
|
|
4640
|
-
|
|
4641
|
-
for (var _i4 = 0; _i4 < 10; _i4++) {
|
|
4642
|
-
var _ch4 = _i4.toString();
|
|
4856
|
+
defineSymbol(math, main, op, "\u2A04", "\\biguplus");
|
|
4857
|
+
defineSymbol(math, main, op, "\u22C2", "\\bigcap");
|
|
4858
|
+
defineSymbol(math, main, op, "\u22C3", "\\bigcup");
|
|
4859
|
+
defineSymbol(math, main, op, "\u222B", "\\int");
|
|
4860
|
+
defineSymbol(math, main, op, "\u222B", "\\intop");
|
|
4861
|
+
defineSymbol(math, main, op, "\u222C", "\\iint");
|
|
4862
|
+
defineSymbol(math, main, op, "\u222D", "\\iiint");
|
|
4863
|
+
defineSymbol(math, main, op, "\u220F", "\\prod");
|
|
4864
|
+
defineSymbol(math, main, op, "\u2211", "\\sum");
|
|
4865
|
+
defineSymbol(math, main, op, "\u2A02", "\\bigotimes");
|
|
4866
|
+
defineSymbol(math, main, op, "\u2A01", "\\bigoplus");
|
|
4867
|
+
defineSymbol(math, main, op, "\u2A00", "\\bigodot");
|
|
4868
|
+
defineSymbol(math, main, op, "\u222E", "\\oint");
|
|
4869
|
+
defineSymbol(math, main, op, "\u222F", "\\oiint");
|
|
4870
|
+
defineSymbol(math, main, op, "\u2230", "\\oiiint");
|
|
4871
|
+
defineSymbol(math, main, op, "\u2A06", "\\bigsqcup");
|
|
4872
|
+
defineSymbol(math, main, op, "\u222B", "\\smallint");
|
|
4873
|
+
defineSymbol(symbols_text, main, inner, "\u2026", "\\textellipsis");
|
|
4874
|
+
defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
|
|
4875
|
+
defineSymbol(symbols_text, main, inner, "\u2026", "\\ldots", true);
|
|
4876
|
+
defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
|
|
4877
|
+
defineSymbol(math, main, inner, "\u22EF", "\\@cdots", true);
|
|
4878
|
+
defineSymbol(math, main, inner, "\u22F1", "\\ddots", true);
|
|
4879
|
+
defineSymbol(math, main, textord, "\u22EE", "\\varvdots"); // \vdots is a macro
|
|
4643
4880
|
|
|
4644
|
-
|
|
4881
|
+
defineSymbol(math, main, accent, "\u02CA", "\\acute");
|
|
4882
|
+
defineSymbol(math, main, accent, "\u02CB", "\\grave");
|
|
4883
|
+
defineSymbol(math, main, accent, "\xA8", "\\ddot");
|
|
4884
|
+
defineSymbol(math, main, accent, "~", "\\tilde");
|
|
4885
|
+
defineSymbol(math, main, accent, "\u02C9", "\\bar");
|
|
4886
|
+
defineSymbol(math, main, accent, "\u02D8", "\\breve");
|
|
4887
|
+
defineSymbol(math, main, accent, "\u02C7", "\\check");
|
|
4888
|
+
defineSymbol(math, main, accent, "^", "\\hat");
|
|
4889
|
+
defineSymbol(math, main, accent, "\u20D7", "\\vec");
|
|
4890
|
+
defineSymbol(math, main, accent, "\u02D9", "\\dot");
|
|
4891
|
+
defineSymbol(math, main, accent, "\u02DA", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA
|
|
4645
4892
|
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4893
|
+
defineSymbol(math, main, mathord, "\uE131", "\\@imath");
|
|
4894
|
+
defineSymbol(math, main, mathord, "\uE237", "\\@jmath");
|
|
4895
|
+
defineSymbol(math, main, textord, "\u0131", "\u0131");
|
|
4896
|
+
defineSymbol(math, main, textord, "\u0237", "\u0237");
|
|
4897
|
+
defineSymbol(symbols_text, main, textord, "\u0131", "\\i", true);
|
|
4898
|
+
defineSymbol(symbols_text, main, textord, "\u0237", "\\j", true);
|
|
4899
|
+
defineSymbol(symbols_text, main, textord, "\xDF", "\\ss", true);
|
|
4900
|
+
defineSymbol(symbols_text, main, textord, "\xE6", "\\ae", true);
|
|
4901
|
+
defineSymbol(symbols_text, main, textord, "\u0153", "\\oe", true);
|
|
4902
|
+
defineSymbol(symbols_text, main, textord, "\xF8", "\\o", true);
|
|
4903
|
+
defineSymbol(symbols_text, main, textord, "\xC6", "\\AE", true);
|
|
4904
|
+
defineSymbol(symbols_text, main, textord, "\u0152", "\\OE", true);
|
|
4905
|
+
defineSymbol(symbols_text, main, textord, "\xD8", "\\O", true);
|
|
4906
|
+
defineSymbol(symbols_text, main, accent, "\u02CA", "\\'"); // acute
|
|
4649
4907
|
|
|
4650
|
-
|
|
4651
|
-
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
4652
|
-
wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans
|
|
4908
|
+
defineSymbol(symbols_text, main, accent, "\u02CB", "\\`"); // grave
|
|
4653
4909
|
|
|
4654
|
-
|
|
4655
|
-
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
4656
|
-
wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace
|
|
4910
|
+
defineSymbol(symbols_text, main, accent, "\u02C6", "\\^"); // circumflex
|
|
4657
4911
|
|
|
4658
|
-
|
|
4659
|
-
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
4660
|
-
} // We add these Latin-1 letters as symbols for backwards-compatibility,
|
|
4661
|
-
// but they are not actually in the font, nor are they supported by the
|
|
4662
|
-
// Unicode accent mechanism, so they fall back to Times font and look ugly.
|
|
4663
|
-
// TODO(edemaine): Fix this.
|
|
4912
|
+
defineSymbol(symbols_text, main, accent, "\u02DC", "\\~"); // tilde
|
|
4664
4913
|
|
|
4914
|
+
defineSymbol(symbols_text, main, accent, "\u02C9", "\\="); // macron
|
|
4665
4915
|
|
|
4666
|
-
|
|
4916
|
+
defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve
|
|
4667
4917
|
|
|
4668
|
-
|
|
4669
|
-
var _ch5 = extraLatin.charAt(_i5);
|
|
4918
|
+
defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above
|
|
4670
4919
|
|
|
4671
|
-
|
|
4672
|
-
defineSymbol(symbols_text, main, textord, _ch5, _ch5);
|
|
4673
|
-
}
|
|
4674
|
-
;// CONCATENATED MODULE: ./src/wide-character.js
|
|
4675
|
-
/**
|
|
4676
|
-
* This file provides support for Unicode range U+1D400 to U+1D7FF,
|
|
4677
|
-
* Mathematical Alphanumeric Symbols.
|
|
4678
|
-
*
|
|
4679
|
-
* Function wideCharacterFont takes a wide character as input and returns
|
|
4680
|
-
* the font information necessary to render it properly.
|
|
4681
|
-
*/
|
|
4920
|
+
defineSymbol(symbols_text, main, accent, "\xB8", "\\c"); // cedilla
|
|
4682
4921
|
|
|
4683
|
-
|
|
4684
|
-
* Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
4685
|
-
* That document sorts characters into groups by font type, say bold or italic.
|
|
4686
|
-
*
|
|
4687
|
-
* In the arrays below, each subarray consists three elements:
|
|
4688
|
-
* * The CSS class of that group when in math mode.
|
|
4689
|
-
* * The CSS class of that group when in text mode.
|
|
4690
|
-
* * The font name, so that KaTeX can get font metrics.
|
|
4691
|
-
*/
|
|
4922
|
+
defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above
|
|
4692
4923
|
|
|
4693
|
-
|
|
4694
|
-
["mathbf", "textbf", "Main-Bold"], // a-z bold upright
|
|
4695
|
-
["mathnormal", "textit", "Math-Italic"], // A-Z italic
|
|
4696
|
-
["mathnormal", "textit", "Math-Italic"], // a-z italic
|
|
4697
|
-
["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic
|
|
4698
|
-
["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic
|
|
4699
|
-
// Map fancy A-Z letters to script, not calligraphic.
|
|
4700
|
-
// This aligns with unicode-math and math fonts (except Cambria Math).
|
|
4701
|
-
["mathscr", "textscr", "Script-Regular"], // A-Z script
|
|
4702
|
-
["", "", ""], // a-z script. No font
|
|
4703
|
-
["", "", ""], // A-Z bold script. No font
|
|
4704
|
-
["", "", ""], // a-z bold script. No font
|
|
4705
|
-
["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur
|
|
4706
|
-
["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur
|
|
4707
|
-
["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
|
|
4708
|
-
["mathbb", "textbb", "AMS-Regular"], // k double-struck
|
|
4709
|
-
["", "", ""], // A-Z bold Fraktur No font metrics
|
|
4710
|
-
["", "", ""], // a-z bold Fraktur. No font.
|
|
4711
|
-
["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
|
|
4712
|
-
["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
|
|
4713
|
-
["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif
|
|
4714
|
-
["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif
|
|
4715
|
-
["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif
|
|
4716
|
-
["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif
|
|
4717
|
-
["", "", ""], // A-Z bold italic sans. No font
|
|
4718
|
-
["", "", ""], // a-z bold italic sans. No font
|
|
4719
|
-
["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace
|
|
4720
|
-
["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace
|
|
4721
|
-
];
|
|
4722
|
-
var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold
|
|
4723
|
-
["", "", ""], // 0-9 double-struck. No KaTeX font.
|
|
4724
|
-
["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif
|
|
4725
|
-
["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif
|
|
4726
|
-
["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace
|
|
4727
|
-
];
|
|
4728
|
-
var wideCharacterFont = function wideCharacterFont(wideChar, mode) {
|
|
4729
|
-
// IE doesn't support codePointAt(). So work with the surrogate pair.
|
|
4730
|
-
var H = wideChar.charCodeAt(0); // high surrogate
|
|
4924
|
+
defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron
|
|
4731
4925
|
|
|
4732
|
-
|
|
4926
|
+
defineSymbol(symbols_text, main, accent, "\xA8", '\\"'); // diaresis
|
|
4733
4927
|
|
|
4734
|
-
|
|
4735
|
-
var j = mode === "math" ? 0 : 1; // column index for CSS class.
|
|
4928
|
+
defineSymbol(symbols_text, main, accent, "\u02DD", "\\H"); // double acute
|
|
4736
4929
|
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
// So we can calculate the relevant row. No traverse necessary.
|
|
4740
|
-
var i = Math.floor((codePoint - 0x1D400) / 26);
|
|
4741
|
-
return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]];
|
|
4742
|
-
} else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) {
|
|
4743
|
-
// Numerals, ten per row.
|
|
4744
|
-
var _i = Math.floor((codePoint - 0x1D7CE) / 10);
|
|
4930
|
+
defineSymbol(symbols_text, main, accent, "\u25EF", "\\textcircled"); // \bigcirc glyph
|
|
4931
|
+
// These ligatures are detected and created in Parser.js's `formLigatures`.
|
|
4745
4932
|
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
// Greek letters. Not supported, yet.
|
|
4752
|
-
return ["", ""];
|
|
4753
|
-
} else {
|
|
4754
|
-
// We don't support any wide characters outside 1D400–1D7FF.
|
|
4755
|
-
throw new src_ParseError("Unsupported character: " + wideChar);
|
|
4756
|
-
}
|
|
4933
|
+
var ligatures = {
|
|
4934
|
+
"--": true,
|
|
4935
|
+
"---": true,
|
|
4936
|
+
"``": true,
|
|
4937
|
+
"''": true
|
|
4757
4938
|
};
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
[3, 1, 1], // size3: [7, 5, 5] \scriptsize
|
|
4771
|
-
[4, 2, 1], // size4: [8, 6, 5] \footnotesize
|
|
4772
|
-
[5, 2, 1], // size5: [9, 6, 5] \small
|
|
4773
|
-
[6, 3, 1], // size6: [10, 7, 5] \normalsize
|
|
4774
|
-
[7, 4, 2], // size7: [12, 8, 6] \large
|
|
4775
|
-
[8, 6, 3], // size8: [14.4, 10, 7] \Large
|
|
4776
|
-
[9, 7, 6], // size9: [17.28, 12, 10] \LARGE
|
|
4777
|
-
[10, 8, 7], // size10: [20.74, 14.4, 12] \huge
|
|
4778
|
-
[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE
|
|
4779
|
-
];
|
|
4780
|
-
var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if
|
|
4781
|
-
// you change size indexes, change that function.
|
|
4782
|
-
0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
|
|
4783
|
-
|
|
4784
|
-
var sizeAtStyle = function sizeAtStyle(size, style) {
|
|
4785
|
-
return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
|
|
4786
|
-
}; // In these types, "" (empty string) means "no change".
|
|
4787
|
-
|
|
4939
|
+
defineSymbol(symbols_text, main, textord, "\u2013", "--", true);
|
|
4940
|
+
defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash");
|
|
4941
|
+
defineSymbol(symbols_text, main, textord, "\u2014", "---", true);
|
|
4942
|
+
defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash");
|
|
4943
|
+
defineSymbol(symbols_text, main, textord, "\u2018", "`", true);
|
|
4944
|
+
defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft");
|
|
4945
|
+
defineSymbol(symbols_text, main, textord, "\u2019", "'", true);
|
|
4946
|
+
defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright");
|
|
4947
|
+
defineSymbol(symbols_text, main, textord, "\u201C", "``", true);
|
|
4948
|
+
defineSymbol(symbols_text, main, textord, "\u201C", "\\textquotedblleft");
|
|
4949
|
+
defineSymbol(symbols_text, main, textord, "\u201D", "''", true);
|
|
4950
|
+
defineSymbol(symbols_text, main, textord, "\u201D", "\\textquotedblright"); // \degree from gensymb package
|
|
4788
4951
|
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
* and font.
|
|
4792
|
-
*
|
|
4793
|
-
* Options objects should not be modified. To create a new Options with
|
|
4794
|
-
* different properties, call a `.having*` method.
|
|
4795
|
-
*/
|
|
4796
|
-
var Options = /*#__PURE__*/function () {
|
|
4797
|
-
// A font family applies to a group of fonts (i.e. SansSerif), while a font
|
|
4798
|
-
// represents a specific font (i.e. SansSerif Bold).
|
|
4799
|
-
// See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm
|
|
4952
|
+
defineSymbol(math, main, textord, "\xB0", "\\degree", true);
|
|
4953
|
+
defineSymbol(symbols_text, main, textord, "\xB0", "\\degree"); // \textdegree from inputenc package
|
|
4800
4954
|
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
*/
|
|
4804
|
-
function Options(data) {
|
|
4805
|
-
this.style = void 0;
|
|
4806
|
-
this.color = void 0;
|
|
4807
|
-
this.size = void 0;
|
|
4808
|
-
this.textSize = void 0;
|
|
4809
|
-
this.phantom = void 0;
|
|
4810
|
-
this.font = void 0;
|
|
4811
|
-
this.fontFamily = void 0;
|
|
4812
|
-
this.fontWeight = void 0;
|
|
4813
|
-
this.fontShape = void 0;
|
|
4814
|
-
this.sizeMultiplier = void 0;
|
|
4815
|
-
this.maxSize = void 0;
|
|
4816
|
-
this.minRuleThickness = void 0;
|
|
4817
|
-
this._fontMetrics = void 0;
|
|
4818
|
-
this.style = data.style;
|
|
4819
|
-
this.color = data.color;
|
|
4820
|
-
this.size = data.size || Options.BASESIZE;
|
|
4821
|
-
this.textSize = data.textSize || this.size;
|
|
4822
|
-
this.phantom = !!data.phantom;
|
|
4823
|
-
this.font = data.font || "";
|
|
4824
|
-
this.fontFamily = data.fontFamily || "";
|
|
4825
|
-
this.fontWeight = data.fontWeight || '';
|
|
4826
|
-
this.fontShape = data.fontShape || '';
|
|
4827
|
-
this.sizeMultiplier = sizeMultipliers[this.size - 1];
|
|
4828
|
-
this.maxSize = data.maxSize;
|
|
4829
|
-
this.minRuleThickness = data.minRuleThickness;
|
|
4830
|
-
this._fontMetrics = undefined;
|
|
4831
|
-
}
|
|
4832
|
-
/**
|
|
4833
|
-
* Returns a new options object with the same properties as "this". Properties
|
|
4834
|
-
* from "extension" will be copied to the new options object.
|
|
4835
|
-
*/
|
|
4955
|
+
defineSymbol(symbols_text, main, textord, "\xB0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math
|
|
4956
|
+
// mode, but among our fonts, only Main-Regular defines this character "163".
|
|
4836
4957
|
|
|
4958
|
+
defineSymbol(math, main, textord, "\xA3", "\\pounds");
|
|
4959
|
+
defineSymbol(math, main, textord, "\xA3", "\\mathsterling", true);
|
|
4960
|
+
defineSymbol(symbols_text, main, textord, "\xA3", "\\pounds");
|
|
4961
|
+
defineSymbol(symbols_text, main, textord, "\xA3", "\\textsterling", true);
|
|
4962
|
+
defineSymbol(math, ams, textord, "\u2720", "\\maltese");
|
|
4963
|
+
defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards.
|
|
4964
|
+
// All of these are textords in math mode
|
|
4837
4965
|
|
|
4838
|
-
|
|
4966
|
+
var mathTextSymbols = "0123456789/@.\"";
|
|
4839
4967
|
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
textSize: this.textSize,
|
|
4845
|
-
color: this.color,
|
|
4846
|
-
phantom: this.phantom,
|
|
4847
|
-
font: this.font,
|
|
4848
|
-
fontFamily: this.fontFamily,
|
|
4849
|
-
fontWeight: this.fontWeight,
|
|
4850
|
-
fontShape: this.fontShape,
|
|
4851
|
-
maxSize: this.maxSize,
|
|
4852
|
-
minRuleThickness: this.minRuleThickness
|
|
4853
|
-
};
|
|
4968
|
+
for (var i = 0; i < mathTextSymbols.length; i++) {
|
|
4969
|
+
var ch = mathTextSymbols.charAt(i);
|
|
4970
|
+
defineSymbol(math, main, textord, ch, ch);
|
|
4971
|
+
} // All of these are textords in text mode
|
|
4854
4972
|
|
|
4855
|
-
for (var key in extension) {
|
|
4856
|
-
if (extension.hasOwnProperty(key)) {
|
|
4857
|
-
data[key] = extension[key];
|
|
4858
|
-
}
|
|
4859
|
-
}
|
|
4860
4973
|
|
|
4861
|
-
|
|
4862
|
-
}
|
|
4863
|
-
/**
|
|
4864
|
-
* Return an options object with the given style. If `this.style === style`,
|
|
4865
|
-
* returns `this`.
|
|
4866
|
-
*/
|
|
4867
|
-
;
|
|
4974
|
+
var textSymbols = "0123456789!@*()-=+\";:?/.,";
|
|
4868
4975
|
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
return this;
|
|
4872
|
-
} else {
|
|
4873
|
-
return this.extend({
|
|
4874
|
-
style: style,
|
|
4875
|
-
size: sizeAtStyle(this.textSize, style)
|
|
4876
|
-
});
|
|
4877
|
-
}
|
|
4878
|
-
}
|
|
4879
|
-
/**
|
|
4880
|
-
* Return an options object with a cramped version of the current style. If
|
|
4881
|
-
* the current style is cramped, returns `this`.
|
|
4882
|
-
*/
|
|
4883
|
-
;
|
|
4976
|
+
for (var _i = 0; _i < textSymbols.length; _i++) {
|
|
4977
|
+
var _ch = textSymbols.charAt(_i);
|
|
4884
4978
|
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
}
|
|
4888
|
-
/**
|
|
4889
|
-
* Return an options object with the given size and in at least `\textstyle`.
|
|
4890
|
-
* Returns `this` if appropriate.
|
|
4891
|
-
*/
|
|
4892
|
-
;
|
|
4979
|
+
defineSymbol(symbols_text, main, textord, _ch, _ch);
|
|
4980
|
+
} // All of these are textords in text mode, and mathords in math mode
|
|
4893
4981
|
|
|
4894
|
-
_proto.havingSize = function havingSize(size) {
|
|
4895
|
-
if (this.size === size && this.textSize === size) {
|
|
4896
|
-
return this;
|
|
4897
|
-
} else {
|
|
4898
|
-
return this.extend({
|
|
4899
|
-
style: this.style.text(),
|
|
4900
|
-
size: size,
|
|
4901
|
-
textSize: size,
|
|
4902
|
-
sizeMultiplier: sizeMultipliers[size - 1]
|
|
4903
|
-
});
|
|
4904
|
-
}
|
|
4905
|
-
}
|
|
4906
|
-
/**
|
|
4907
|
-
* Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
|
|
4908
|
-
* changes to at least `\textstyle`.
|
|
4909
|
-
*/
|
|
4910
|
-
;
|
|
4911
4982
|
|
|
4912
|
-
|
|
4913
|
-
style = style || this.style.text();
|
|
4914
|
-
var wantSize = sizeAtStyle(Options.BASESIZE, style);
|
|
4983
|
+
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
4915
4984
|
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
} else {
|
|
4919
|
-
return this.extend({
|
|
4920
|
-
style: style,
|
|
4921
|
-
size: wantSize
|
|
4922
|
-
});
|
|
4923
|
-
}
|
|
4924
|
-
}
|
|
4925
|
-
/**
|
|
4926
|
-
* Remove the effect of sizing changes such as \Huge.
|
|
4927
|
-
* Keep the effect of the current style, such as \scriptstyle.
|
|
4928
|
-
*/
|
|
4929
|
-
;
|
|
4985
|
+
for (var _i2 = 0; _i2 < letters.length; _i2++) {
|
|
4986
|
+
var _ch2 = letters.charAt(_i2);
|
|
4930
4987
|
|
|
4931
|
-
|
|
4932
|
-
|
|
4988
|
+
defineSymbol(math, main, mathord, _ch2, _ch2);
|
|
4989
|
+
defineSymbol(symbols_text, main, textord, _ch2, _ch2);
|
|
4990
|
+
} // Blackboard bold and script letters in Unicode range
|
|
4933
4991
|
|
|
4934
|
-
switch (this.style.id) {
|
|
4935
|
-
case 4:
|
|
4936
|
-
case 5:
|
|
4937
|
-
size = 3; // normalsize in scriptstyle
|
|
4938
4992
|
|
|
4939
|
-
|
|
4993
|
+
defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
|
|
4940
4994
|
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4995
|
+
defineSymbol(symbols_text, ams, textord, "C", "\u2102");
|
|
4996
|
+
defineSymbol(math, ams, textord, "H", "\u210D");
|
|
4997
|
+
defineSymbol(symbols_text, ams, textord, "H", "\u210D");
|
|
4998
|
+
defineSymbol(math, ams, textord, "N", "\u2115");
|
|
4999
|
+
defineSymbol(symbols_text, ams, textord, "N", "\u2115");
|
|
5000
|
+
defineSymbol(math, ams, textord, "P", "\u2119");
|
|
5001
|
+
defineSymbol(symbols_text, ams, textord, "P", "\u2119");
|
|
5002
|
+
defineSymbol(math, ams, textord, "Q", "\u211A");
|
|
5003
|
+
defineSymbol(symbols_text, ams, textord, "Q", "\u211A");
|
|
5004
|
+
defineSymbol(math, ams, textord, "R", "\u211D");
|
|
5005
|
+
defineSymbol(symbols_text, ams, textord, "R", "\u211D");
|
|
5006
|
+
defineSymbol(math, ams, textord, "Z", "\u2124");
|
|
5007
|
+
defineSymbol(symbols_text, ams, textord, "Z", "\u2124");
|
|
5008
|
+
defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant
|
|
4944
5009
|
|
|
4945
|
-
|
|
5010
|
+
defineSymbol(symbols_text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters.
|
|
5011
|
+
// We support some letters in the Unicode range U+1D400 to U+1D7FF,
|
|
5012
|
+
// Mathematical Alphanumeric Symbols.
|
|
5013
|
+
// Some editors do not deal well with wide characters. So don't write the
|
|
5014
|
+
// string into this file. Instead, create the string from the surrogate pair.
|
|
4946
5015
|
|
|
4947
|
-
|
|
4948
|
-
size = 6;
|
|
4949
|
-
// normalsize in textstyle or displaystyle
|
|
4950
|
-
}
|
|
5016
|
+
var wideChar = "";
|
|
4951
5017
|
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
}
|
|
4957
|
-
/**
|
|
4958
|
-
* Create a new options object with the given color.
|
|
4959
|
-
*/
|
|
4960
|
-
;
|
|
5018
|
+
for (var _i3 = 0; _i3 < letters.length; _i3++) {
|
|
5019
|
+
var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair.
|
|
5020
|
+
// 0xD835 is the high surrogate for all letters in the range we support.
|
|
5021
|
+
// 0xDC00 is the low surrogate for bold A.
|
|
4961
5022
|
|
|
4962
|
-
_proto.withColor = function withColor(color) {
|
|
4963
|
-
return this.extend({
|
|
4964
|
-
color: color
|
|
4965
|
-
});
|
|
4966
|
-
}
|
|
4967
|
-
/**
|
|
4968
|
-
* Create a new options object with "phantom" set to true.
|
|
4969
|
-
*/
|
|
4970
|
-
;
|
|
4971
5023
|
|
|
4972
|
-
|
|
4973
|
-
return this.extend({
|
|
4974
|
-
phantom: true
|
|
4975
|
-
});
|
|
4976
|
-
}
|
|
4977
|
-
/**
|
|
4978
|
-
* Creates a new options object with the given math font or old text font.
|
|
4979
|
-
* @type {[type]}
|
|
4980
|
-
*/
|
|
4981
|
-
;
|
|
5024
|
+
wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
|
|
4982
5025
|
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
});
|
|
4987
|
-
}
|
|
4988
|
-
/**
|
|
4989
|
-
* Create a new options objects with the given fontFamily.
|
|
4990
|
-
*/
|
|
4991
|
-
;
|
|
5026
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5027
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5028
|
+
wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic
|
|
4992
5029
|
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
font: ""
|
|
4997
|
-
});
|
|
4998
|
-
}
|
|
4999
|
-
/**
|
|
5000
|
-
* Creates a new options object with the given font weight
|
|
5001
|
-
*/
|
|
5002
|
-
;
|
|
5030
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5031
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5032
|
+
wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic
|
|
5003
5033
|
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
font: ""
|
|
5008
|
-
});
|
|
5009
|
-
}
|
|
5010
|
-
/**
|
|
5011
|
-
* Creates a new options object with the given font weight
|
|
5012
|
-
*/
|
|
5013
|
-
;
|
|
5034
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5035
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5036
|
+
wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur
|
|
5014
5037
|
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
;
|
|
5038
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5039
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5040
|
+
wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif
|
|
5041
|
+
|
|
5042
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5043
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5044
|
+
wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold
|
|
5045
|
+
|
|
5046
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5047
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5048
|
+
wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic
|
|
5049
|
+
|
|
5050
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5051
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5052
|
+
wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace
|
|
5053
|
+
|
|
5054
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5055
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5056
|
+
|
|
5057
|
+
if (_i3 < 26) {
|
|
5058
|
+
// KaTeX fonts have only capital letters for blackboard bold and script.
|
|
5059
|
+
// See exception for k below.
|
|
5060
|
+
wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck
|
|
5061
|
+
|
|
5062
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5063
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5064
|
+
wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script
|
|
5065
|
+
|
|
5066
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5067
|
+
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
5068
|
+
} // TODO: Add bold script when it is supported by a KaTeX font.
|
|
5026
5069
|
|
|
5027
|
-
|
|
5028
|
-
if (oldOptions.size !== this.size) {
|
|
5029
|
-
return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
|
|
5030
|
-
} else {
|
|
5031
|
-
return [];
|
|
5032
|
-
}
|
|
5033
|
-
}
|
|
5034
|
-
/**
|
|
5035
|
-
* Return the CSS sizing classes required to switch to the base size. Like
|
|
5036
|
-
* `this.havingSize(BASESIZE).sizingClasses(this)`.
|
|
5037
|
-
*/
|
|
5038
|
-
;
|
|
5070
|
+
} // "k" is the only double struck lower case letter in the KaTeX fonts.
|
|
5039
5071
|
|
|
5040
|
-
_proto.baseSizingClasses = function baseSizingClasses() {
|
|
5041
|
-
if (this.size !== Options.BASESIZE) {
|
|
5042
|
-
return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
|
|
5043
|
-
} else {
|
|
5044
|
-
return [];
|
|
5045
|
-
}
|
|
5046
|
-
}
|
|
5047
|
-
/**
|
|
5048
|
-
* Return the font metrics for this size.
|
|
5049
|
-
*/
|
|
5050
|
-
;
|
|
5051
5072
|
|
|
5052
|
-
|
|
5053
|
-
if (!this._fontMetrics) {
|
|
5054
|
-
this._fontMetrics = getGlobalMetrics(this.size);
|
|
5055
|
-
}
|
|
5073
|
+
wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
|
|
5056
5074
|
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
/**
|
|
5060
|
-
* Gets the CSS color of the current options object
|
|
5061
|
-
*/
|
|
5062
|
-
;
|
|
5075
|
+
defineSymbol(math, main, mathord, "k", wideChar);
|
|
5076
|
+
defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals
|
|
5063
5077
|
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
return "transparent";
|
|
5067
|
-
} else {
|
|
5068
|
-
return this.color;
|
|
5069
|
-
}
|
|
5070
|
-
};
|
|
5078
|
+
for (var _i4 = 0; _i4 < 10; _i4++) {
|
|
5079
|
+
var _ch4 = _i4.toString();
|
|
5071
5080
|
|
|
5072
|
-
|
|
5073
|
-
}();
|
|
5081
|
+
wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold
|
|
5074
5082
|
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
/**
|
|
5079
|
-
* This file does conversion between units. In particular, it provides
|
|
5080
|
-
* calculateSize to convert other units into ems.
|
|
5081
|
-
*/
|
|
5083
|
+
defineSymbol(math, main, mathord, _ch4, wideChar);
|
|
5084
|
+
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
5085
|
+
wideChar = String.fromCharCode(0xD835, 0xDFE2 + _i4); // 0-9 sans serif
|
|
5082
5086
|
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
// *assuming* a font size of ptPerEm (normal size, normal style).
|
|
5087
|
+
defineSymbol(math, main, mathord, _ch4, wideChar);
|
|
5088
|
+
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
5089
|
+
wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans
|
|
5087
5090
|
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
//
|
|
5091
|
-
"pt": 1,
|
|
5092
|
-
// TeX point
|
|
5093
|
-
"mm": 7227 / 2540,
|
|
5094
|
-
// millimeter
|
|
5095
|
-
"cm": 7227 / 254,
|
|
5096
|
-
// centimeter
|
|
5097
|
-
"in": 72.27,
|
|
5098
|
-
// inch
|
|
5099
|
-
"bp": 803 / 800,
|
|
5100
|
-
// big (PostScript) points
|
|
5101
|
-
"pc": 12,
|
|
5102
|
-
// pica
|
|
5103
|
-
"dd": 1238 / 1157,
|
|
5104
|
-
// didot
|
|
5105
|
-
"cc": 14856 / 1157,
|
|
5106
|
-
// cicero (12 didot)
|
|
5107
|
-
"nd": 685 / 642,
|
|
5108
|
-
// new didot
|
|
5109
|
-
"nc": 1370 / 107,
|
|
5110
|
-
// new cicero (12 new didot)
|
|
5111
|
-
"sp": 1 / 65536,
|
|
5112
|
-
// scaled point (TeX's internal smallest unit)
|
|
5113
|
-
// https://tex.stackexchange.com/a/41371
|
|
5114
|
-
"px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX
|
|
5091
|
+
defineSymbol(math, main, mathord, _ch4, wideChar);
|
|
5092
|
+
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
5093
|
+
wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace
|
|
5115
5094
|
|
|
5116
|
-
|
|
5095
|
+
defineSymbol(math, main, mathord, _ch4, wideChar);
|
|
5096
|
+
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
5097
|
+
} // We add these Latin-1 letters as symbols for backwards-compatibility,
|
|
5098
|
+
// but they are not actually in the font, nor are they supported by the
|
|
5099
|
+
// Unicode accent mechanism, so they fall back to Times font and look ugly.
|
|
5100
|
+
// TODO(edemaine): Fix this.
|
|
5117
5101
|
|
|
5118
|
-
var relativeUnit = {
|
|
5119
|
-
"ex": true,
|
|
5120
|
-
"em": true,
|
|
5121
|
-
"mu": true
|
|
5122
|
-
};
|
|
5123
5102
|
|
|
5103
|
+
var extraLatin = "\xD0\xDE\xFE";
|
|
5104
|
+
|
|
5105
|
+
for (var _i5 = 0; _i5 < extraLatin.length; _i5++) {
|
|
5106
|
+
var _ch5 = extraLatin.charAt(_i5);
|
|
5107
|
+
|
|
5108
|
+
defineSymbol(math, main, mathord, _ch5, _ch5);
|
|
5109
|
+
defineSymbol(symbols_text, main, textord, _ch5, _ch5);
|
|
5110
|
+
}
|
|
5111
|
+
;// CONCATENATED MODULE: ./src/wide-character.js
|
|
5124
5112
|
/**
|
|
5125
|
-
*
|
|
5126
|
-
*
|
|
5113
|
+
* This file provides support for Unicode range U+1D400 to U+1D7FF,
|
|
5114
|
+
* Mathematical Alphanumeric Symbols.
|
|
5115
|
+
*
|
|
5116
|
+
* Function wideCharacterFont takes a wide character as input and returns
|
|
5117
|
+
* the font information necessary to render it properly.
|
|
5127
5118
|
*/
|
|
5128
|
-
var validUnit = function validUnit(unit) {
|
|
5129
|
-
if (typeof unit !== "string") {
|
|
5130
|
-
unit = unit.unit;
|
|
5131
|
-
}
|
|
5132
5119
|
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
*
|
|
5137
|
-
*
|
|
5138
|
-
*
|
|
5120
|
+
/**
|
|
5121
|
+
* Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
5122
|
+
* That document sorts characters into groups by font type, say bold or italic.
|
|
5123
|
+
*
|
|
5124
|
+
* In the arrays below, each subarray consists three elements:
|
|
5125
|
+
* * The CSS class of that group when in math mode.
|
|
5126
|
+
* * The CSS class of that group when in text mode.
|
|
5127
|
+
* * The font name, so that KaTeX can get font metrics.
|
|
5139
5128
|
*/
|
|
5140
5129
|
|
|
5141
|
-
var
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5130
|
+
var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold upright
|
|
5131
|
+
["mathbf", "textbf", "Main-Bold"], // a-z bold upright
|
|
5132
|
+
["mathnormal", "textit", "Math-Italic"], // A-Z italic
|
|
5133
|
+
["mathnormal", "textit", "Math-Italic"], // a-z italic
|
|
5134
|
+
["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic
|
|
5135
|
+
["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic
|
|
5136
|
+
// Map fancy A-Z letters to script, not calligraphic.
|
|
5137
|
+
// This aligns with unicode-math and math fonts (except Cambria Math).
|
|
5138
|
+
["mathscr", "textscr", "Script-Regular"], // A-Z script
|
|
5139
|
+
["", "", ""], // a-z script. No font
|
|
5140
|
+
["", "", ""], // A-Z bold script. No font
|
|
5141
|
+
["", "", ""], // a-z bold script. No font
|
|
5142
|
+
["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur
|
|
5143
|
+
["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur
|
|
5144
|
+
["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
|
|
5145
|
+
["mathbb", "textbb", "AMS-Regular"], // k double-struck
|
|
5146
|
+
["", "", ""], // A-Z bold Fraktur No font metrics
|
|
5147
|
+
["", "", ""], // a-z bold Fraktur. No font.
|
|
5148
|
+
["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
|
|
5149
|
+
["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
|
|
5150
|
+
["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif
|
|
5151
|
+
["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif
|
|
5152
|
+
["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif
|
|
5153
|
+
["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif
|
|
5154
|
+
["", "", ""], // A-Z bold italic sans. No font
|
|
5155
|
+
["", "", ""], // a-z bold italic sans. No font
|
|
5156
|
+
["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace
|
|
5157
|
+
["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace
|
|
5158
|
+
];
|
|
5159
|
+
var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold
|
|
5160
|
+
["", "", ""], // 0-9 double-struck. No KaTeX font.
|
|
5161
|
+
["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif
|
|
5162
|
+
["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif
|
|
5163
|
+
["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace
|
|
5164
|
+
];
|
|
5165
|
+
var wideCharacterFont = function wideCharacterFont(wideChar, mode) {
|
|
5166
|
+
// IE doesn't support codePointAt(). So work with the surrogate pair.
|
|
5167
|
+
var H = wideChar.charCodeAt(0); // high surrogate
|
|
5156
5168
|
|
|
5157
|
-
|
|
5158
|
-
// isTight() means current style is script/scriptscript.
|
|
5159
|
-
unitOptions = options.havingStyle(options.style.text());
|
|
5160
|
-
} else {
|
|
5161
|
-
unitOptions = options;
|
|
5162
|
-
} // TODO: In TeX these units are relative to the quad of the current
|
|
5163
|
-
// *text* font, e.g. cmr10. KaTeX instead uses values from the
|
|
5164
|
-
// comparably-sized *Computer Modern symbol* font. At 10pt, these
|
|
5165
|
-
// match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
|
|
5166
|
-
// cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
|
|
5167
|
-
// TeX \showlists shows a kern of 1.13889 * fontsize;
|
|
5168
|
-
// KaTeX shows a kern of 1.171 * fontsize.
|
|
5169
|
+
var L = wideChar.charCodeAt(1); // low surrogate
|
|
5169
5170
|
|
|
5171
|
+
var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000;
|
|
5172
|
+
var j = mode === "math" ? 0 : 1; // column index for CSS class.
|
|
5170
5173
|
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5174
|
+
if (0x1D400 <= codePoint && codePoint < 0x1D6A4) {
|
|
5175
|
+
// wideLatinLetterData contains exactly 26 chars on each row.
|
|
5176
|
+
// So we can calculate the relevant row. No traverse necessary.
|
|
5177
|
+
var i = Math.floor((codePoint - 0x1D400) / 26);
|
|
5178
|
+
return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]];
|
|
5179
|
+
} else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) {
|
|
5180
|
+
// Numerals, ten per row.
|
|
5181
|
+
var _i = Math.floor((codePoint - 0x1D7CE) / 10);
|
|
5178
5182
|
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5183
|
+
return [wideNumeralData[_i][2], wideNumeralData[_i][j]];
|
|
5184
|
+
} else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) {
|
|
5185
|
+
// dotless i or j
|
|
5186
|
+
return [wideLatinLetterData[0][2], wideLatinLetterData[0][j]];
|
|
5187
|
+
} else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) {
|
|
5188
|
+
// Greek letters. Not supported, yet.
|
|
5189
|
+
return ["", ""];
|
|
5190
|
+
} else {
|
|
5191
|
+
// We don't support any wide characters outside 1D400–1D7FF.
|
|
5192
|
+
throw new src_ParseError("Unsupported character: " + wideChar);
|
|
5182
5193
|
}
|
|
5183
|
-
|
|
5184
|
-
return Math.min(sizeValue.number * scale, options.maxSize);
|
|
5185
5194
|
};
|
|
5186
5195
|
;// CONCATENATED MODULE: ./src/buildCommon.js
|
|
5187
5196
|
/* eslint no-console:0 */
|
|
@@ -5502,7 +5511,7 @@ var makeSvgSpan = function makeSvgSpan(classes, children, options, style) {
|
|
|
5502
5511
|
var makeLineSpan = function makeLineSpan(className, options, thickness) {
|
|
5503
5512
|
var line = makeSpan([className], [], options);
|
|
5504
5513
|
line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness);
|
|
5505
|
-
line.style.borderBottomWidth = line.height
|
|
5514
|
+
line.style.borderBottomWidth = makeEm(line.height);
|
|
5506
5515
|
line.maxFontSize = 1.0;
|
|
5507
5516
|
return line;
|
|
5508
5517
|
};
|
|
@@ -5642,7 +5651,7 @@ var makeVList = function makeVList(params, options) {
|
|
|
5642
5651
|
|
|
5643
5652
|
pstrutSize += 2;
|
|
5644
5653
|
var pstrut = makeSpan(["pstrut"], []);
|
|
5645
|
-
pstrut.style.height = pstrutSize
|
|
5654
|
+
pstrut.style.height = makeEm(pstrutSize); // Create a new list of actual children at the correct offsets
|
|
5646
5655
|
|
|
5647
5656
|
var realChildren = [];
|
|
5648
5657
|
var minPos = depth;
|
|
@@ -5659,7 +5668,7 @@ var makeVList = function makeVList(params, options) {
|
|
|
5659
5668
|
var classes = _child.wrapperClasses || [];
|
|
5660
5669
|
var style = _child.wrapperStyle || {};
|
|
5661
5670
|
var childWrap = makeSpan(classes, [pstrut, _elem], undefined, style);
|
|
5662
|
-
childWrap.style.top = -pstrutSize - currPos - _elem.depth
|
|
5671
|
+
childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth);
|
|
5663
5672
|
|
|
5664
5673
|
if (_child.marginLeft) {
|
|
5665
5674
|
childWrap.style.marginLeft = _child.marginLeft;
|
|
@@ -5681,7 +5690,7 @@ var makeVList = function makeVList(params, options) {
|
|
|
5681
5690
|
|
|
5682
5691
|
|
|
5683
5692
|
var vlist = makeSpan(["vlist"], realChildren);
|
|
5684
|
-
vlist.style.height = maxPos
|
|
5693
|
+
vlist.style.height = makeEm(maxPos); // A second row is used if necessary to represent the vlist's depth.
|
|
5685
5694
|
|
|
5686
5695
|
var rows;
|
|
5687
5696
|
|
|
@@ -5693,7 +5702,7 @@ var makeVList = function makeVList(params, options) {
|
|
|
5693
5702
|
// So we put another empty span inside the depth strut span.
|
|
5694
5703
|
var emptySpan = makeSpan([], []);
|
|
5695
5704
|
var depthStrut = makeSpan(["vlist"], [emptySpan]);
|
|
5696
|
-
depthStrut.style.height = -minPos
|
|
5705
|
+
depthStrut.style.height = makeEm(-minPos); // Safari wants the first row to have inline content; otherwise it
|
|
5697
5706
|
// puts the bottom of the *second* row on the baseline.
|
|
5698
5707
|
|
|
5699
5708
|
var topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200B")]);
|
|
@@ -5720,7 +5729,7 @@ var makeGlue = function makeGlue(measurement, options) {
|
|
|
5720
5729
|
// Make an empty span for the space
|
|
5721
5730
|
var rule = makeSpan(["mspace"], [], options);
|
|
5722
5731
|
var size = calculateSize(measurement, options);
|
|
5723
|
-
rule.style.marginRight = size
|
|
5732
|
+
rule.style.marginRight = makeEm(size);
|
|
5724
5733
|
return rule;
|
|
5725
5734
|
}; // Takes font options, and returns the appropriate fontLookup name
|
|
5726
5735
|
|
|
@@ -5842,17 +5851,17 @@ var staticSvg = function staticSvg(value, options) {
|
|
|
5842
5851
|
height = _svgData$value[2];
|
|
5843
5852
|
var path = new PathNode(pathName);
|
|
5844
5853
|
var svgNode = new SvgNode([path], {
|
|
5845
|
-
"width": width
|
|
5846
|
-
"height": height
|
|
5854
|
+
"width": makeEm(width),
|
|
5855
|
+
"height": makeEm(height),
|
|
5847
5856
|
// Override CSS rule `.katex svg { width: 100% }`
|
|
5848
|
-
"style": "width:" + width
|
|
5857
|
+
"style": "width:" + makeEm(width),
|
|
5849
5858
|
"viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
|
|
5850
5859
|
"preserveAspectRatio": "xMinYMin"
|
|
5851
5860
|
});
|
|
5852
5861
|
var span = makeSvgSpan(["overlay"], [svgNode], options);
|
|
5853
5862
|
span.height = height;
|
|
5854
|
-
span.style.height = height
|
|
5855
|
-
span.style.width = width
|
|
5863
|
+
span.style.height = makeEm(height);
|
|
5864
|
+
span.style.width = makeEm(width);
|
|
5856
5865
|
return span;
|
|
5857
5866
|
};
|
|
5858
5867
|
|
|
@@ -6081,6 +6090,7 @@ var ordargument = function ordargument(arg) {
|
|
|
6081
6090
|
|
|
6082
6091
|
|
|
6083
6092
|
|
|
6093
|
+
|
|
6084
6094
|
var buildHTML_makeSpan = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`)
|
|
6085
6095
|
// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6,
|
|
6086
6096
|
// and the text before Rule 19.
|
|
@@ -6340,10 +6350,10 @@ function buildHTMLUnbreakable(children, options) {
|
|
|
6340
6350
|
// falls at the depth of the expression.
|
|
6341
6351
|
|
|
6342
6352
|
var strut = buildHTML_makeSpan(["strut"]);
|
|
6343
|
-
strut.style.height = body.height + body.depth
|
|
6353
|
+
strut.style.height = makeEm(body.height + body.depth);
|
|
6344
6354
|
|
|
6345
6355
|
if (body.depth) {
|
|
6346
|
-
strut.style.verticalAlign = -body.depth
|
|
6356
|
+
strut.style.verticalAlign = makeEm(-body.depth);
|
|
6347
6357
|
}
|
|
6348
6358
|
|
|
6349
6359
|
body.children.unshift(strut);
|
|
@@ -6439,10 +6449,10 @@ function buildHTML(tree, options) {
|
|
|
6439
6449
|
|
|
6440
6450
|
if (tagChild) {
|
|
6441
6451
|
var strut = tagChild.children[0];
|
|
6442
|
-
strut.style.height = htmlNode.height + htmlNode.depth
|
|
6452
|
+
strut.style.height = makeEm(htmlNode.height + htmlNode.depth);
|
|
6443
6453
|
|
|
6444
6454
|
if (htmlNode.depth) {
|
|
6445
|
-
strut.style.verticalAlign = -htmlNode.depth
|
|
6455
|
+
strut.style.verticalAlign = makeEm(-htmlNode.depth);
|
|
6446
6456
|
}
|
|
6447
6457
|
}
|
|
6448
6458
|
|
|
@@ -6461,6 +6471,7 @@ function buildHTML(tree, options) {
|
|
|
6461
6471
|
|
|
6462
6472
|
|
|
6463
6473
|
|
|
6474
|
+
|
|
6464
6475
|
function newDocumentFragment(children) {
|
|
6465
6476
|
return new DocumentFragment(children);
|
|
6466
6477
|
}
|
|
@@ -6655,7 +6666,7 @@ var SpaceNode = /*#__PURE__*/function () {
|
|
|
6655
6666
|
return document.createTextNode(this.character);
|
|
6656
6667
|
} else {
|
|
6657
6668
|
var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace");
|
|
6658
|
-
node.setAttribute("width", this.width
|
|
6669
|
+
node.setAttribute("width", makeEm(this.width));
|
|
6659
6670
|
return node;
|
|
6660
6671
|
}
|
|
6661
6672
|
}
|
|
@@ -6668,7 +6679,7 @@ var SpaceNode = /*#__PURE__*/function () {
|
|
|
6668
6679
|
if (this.character) {
|
|
6669
6680
|
return "<mtext>" + this.character + "</mtext>";
|
|
6670
6681
|
} else {
|
|
6671
|
-
return "<mspace width=\"" + this.width + "
|
|
6682
|
+
return "<mspace width=\"" + makeEm(this.width) + "\"/>";
|
|
6672
6683
|
}
|
|
6673
6684
|
}
|
|
6674
6685
|
/**
|
|
@@ -7017,6 +7028,7 @@ var buildHTMLTree = function buildHTMLTree(tree, expression, settings) {
|
|
|
7017
7028
|
|
|
7018
7029
|
|
|
7019
7030
|
|
|
7031
|
+
|
|
7020
7032
|
var stretchyCodePoint = {
|
|
7021
7033
|
widehat: "^",
|
|
7022
7034
|
widecheck: "ˇ",
|
|
@@ -7214,7 +7226,7 @@ var svgSpan = function svgSpan(group, options) {
|
|
|
7214
7226
|
var path = new PathNode(pathName);
|
|
7215
7227
|
var svgNode = new SvgNode([path], {
|
|
7216
7228
|
"width": "100%",
|
|
7217
|
-
"height": _height
|
|
7229
|
+
"height": makeEm(_height),
|
|
7218
7230
|
"viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight,
|
|
7219
7231
|
"preserveAspectRatio": "none"
|
|
7220
7232
|
});
|
|
@@ -7256,7 +7268,7 @@ var svgSpan = function svgSpan(group, options) {
|
|
|
7256
7268
|
|
|
7257
7269
|
var _svgNode = new SvgNode([_path], {
|
|
7258
7270
|
"width": "400em",
|
|
7259
|
-
"height": _height2
|
|
7271
|
+
"height": makeEm(_height2),
|
|
7260
7272
|
"viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight,
|
|
7261
7273
|
"preserveAspectRatio": aligns[i] + " slice"
|
|
7262
7274
|
});
|
|
@@ -7270,7 +7282,7 @@ var svgSpan = function svgSpan(group, options) {
|
|
|
7270
7282
|
height: _height2
|
|
7271
7283
|
};
|
|
7272
7284
|
} else {
|
|
7273
|
-
_span.style.height = _height2
|
|
7285
|
+
_span.style.height = makeEm(_height2);
|
|
7274
7286
|
spans.push(_span);
|
|
7275
7287
|
}
|
|
7276
7288
|
}
|
|
@@ -7292,10 +7304,10 @@ var svgSpan = function svgSpan(group, options) {
|
|
|
7292
7304
|
|
|
7293
7305
|
|
|
7294
7306
|
span.height = height;
|
|
7295
|
-
span.style.height = height
|
|
7307
|
+
span.style.height = makeEm(height);
|
|
7296
7308
|
|
|
7297
7309
|
if (minWidth > 0) {
|
|
7298
|
-
span.style.minWidth = minWidth
|
|
7310
|
+
span.style.minWidth = makeEm(minWidth);
|
|
7299
7311
|
}
|
|
7300
7312
|
|
|
7301
7313
|
return span;
|
|
@@ -7344,13 +7356,13 @@ var encloseSpan = function encloseSpan(inner, label, topPad, bottomPad, options)
|
|
|
7344
7356
|
|
|
7345
7357
|
var svgNode = new SvgNode(lines, {
|
|
7346
7358
|
"width": "100%",
|
|
7347
|
-
"height": totalHeight
|
|
7359
|
+
"height": makeEm(totalHeight)
|
|
7348
7360
|
});
|
|
7349
7361
|
img = buildCommon.makeSvgSpan([], [svgNode], options);
|
|
7350
7362
|
}
|
|
7351
7363
|
|
|
7352
7364
|
img.height = totalHeight;
|
|
7353
|
-
img.style.height = totalHeight
|
|
7365
|
+
img.style.height = makeEm(totalHeight);
|
|
7354
7366
|
return img;
|
|
7355
7367
|
};
|
|
7356
7368
|
|
|
@@ -7411,6 +7423,7 @@ function checkSymbolNodeType(node) {
|
|
|
7411
7423
|
|
|
7412
7424
|
|
|
7413
7425
|
|
|
7426
|
+
|
|
7414
7427
|
// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but
|
|
7415
7428
|
// also "supsub" since an accent can affect super/subscripting.
|
|
7416
7429
|
var htmlBuilder = function htmlBuilder(grp, options) {
|
|
@@ -7522,7 +7535,7 @@ var htmlBuilder = function htmlBuilder(grp, options) {
|
|
|
7522
7535
|
left -= width / 2;
|
|
7523
7536
|
}
|
|
7524
7537
|
|
|
7525
|
-
accentBody.style.left = left
|
|
7538
|
+
accentBody.style.left = makeEm(left); // \textcircled uses the \bigcirc glyph, so it needs some
|
|
7526
7539
|
// vertical adjustment to match LaTeX.
|
|
7527
7540
|
|
|
7528
7541
|
if (group.label === "\\textcircled") {
|
|
@@ -7554,8 +7567,8 @@ var htmlBuilder = function htmlBuilder(grp, options) {
|
|
|
7554
7567
|
elem: accentBody,
|
|
7555
7568
|
wrapperClasses: ["svg-align"],
|
|
7556
7569
|
wrapperStyle: skew > 0 ? {
|
|
7557
|
-
width: "calc(100% - " + 2 * skew + "
|
|
7558
|
-
marginLeft: 2 * skew
|
|
7570
|
+
width: "calc(100% - " + makeEm(2 * skew) + ")",
|
|
7571
|
+
marginLeft: makeEm(2 * skew)
|
|
7559
7572
|
} : undefined
|
|
7560
7573
|
}]
|
|
7561
7574
|
}, options);
|
|
@@ -7844,6 +7857,7 @@ defineFunction({
|
|
|
7844
7857
|
|
|
7845
7858
|
|
|
7846
7859
|
|
|
7860
|
+
|
|
7847
7861
|
var cdArrowFunctionName = {
|
|
7848
7862
|
">": "\\\\cdrightarrow",
|
|
7849
7863
|
"<": "\\\\cdleftarrow",
|
|
@@ -8106,7 +8120,7 @@ defineFunction({
|
|
|
8106
8120
|
var newOptions = options.havingStyle(options.style.sup());
|
|
8107
8121
|
var label = buildCommon.wrapFragment(buildGroup(group.label, newOptions, options), options);
|
|
8108
8122
|
label.classes.push("cd-label-" + group.side);
|
|
8109
|
-
label.style.bottom = 0.8 - label.depth
|
|
8123
|
+
label.style.bottom = makeEm(0.8 - label.depth); // Zero out label height & depth, so vertical align of arrow is set
|
|
8110
8124
|
// by the arrow height, not by the label.
|
|
8111
8125
|
|
|
8112
8126
|
label.height = 0;
|
|
@@ -8317,7 +8331,7 @@ defineFunction({
|
|
|
8317
8331
|
span.classes.push("newline");
|
|
8318
8332
|
|
|
8319
8333
|
if (group.size) {
|
|
8320
|
-
span.style.marginTop = calculateSize(group.size, options)
|
|
8334
|
+
span.style.marginTop = makeEm(calculateSize(group.size, options));
|
|
8321
8335
|
}
|
|
8322
8336
|
}
|
|
8323
8337
|
|
|
@@ -8330,7 +8344,7 @@ defineFunction({
|
|
|
8330
8344
|
node.setAttribute("linebreak", "newline");
|
|
8331
8345
|
|
|
8332
8346
|
if (group.size) {
|
|
8333
|
-
node.setAttribute("height", calculateSize(group.size, options)
|
|
8347
|
+
node.setAttribute("height", makeEm(calculateSize(group.size, options)));
|
|
8334
8348
|
}
|
|
8335
8349
|
}
|
|
8336
8350
|
|
|
@@ -8596,6 +8610,7 @@ defineFunction({
|
|
|
8596
8610
|
|
|
8597
8611
|
|
|
8598
8612
|
|
|
8613
|
+
|
|
8599
8614
|
/**
|
|
8600
8615
|
* Get the metrics for a given symbol and font, after transformation (i.e.
|
|
8601
8616
|
* after following replacement from symbols.js)
|
|
@@ -8630,7 +8645,7 @@ var centerSpan = function centerSpan(span, options, style) {
|
|
|
8630
8645
|
var newOptions = options.havingBaseStyle(style);
|
|
8631
8646
|
var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight;
|
|
8632
8647
|
span.classes.push("delimcenter");
|
|
8633
|
-
span.style.top = shift
|
|
8648
|
+
span.style.top = makeEm(shift);
|
|
8634
8649
|
span.height -= shift;
|
|
8635
8650
|
span.depth += shift;
|
|
8636
8651
|
};
|
|
@@ -8703,20 +8718,20 @@ var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) {
|
|
|
8703
8718
|
|
|
8704
8719
|
var makeInner = function makeInner(ch, height, options) {
|
|
8705
8720
|
// Create a span with inline SVG for the inner part of a tall stacked delimiter.
|
|
8706
|
-
var width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4]
|
|
8721
|
+
var width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4] : fontMetricsData["Size1-Regular"][ch.charCodeAt(0)][4];
|
|
8707
8722
|
var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height)));
|
|
8708
8723
|
var svgNode = new SvgNode([path], {
|
|
8709
|
-
"width": width
|
|
8710
|
-
"height": height
|
|
8724
|
+
"width": makeEm(width),
|
|
8725
|
+
"height": makeEm(height),
|
|
8711
8726
|
// Override CSS rule `.katex svg { width: 100% }`
|
|
8712
|
-
"style": "width:" + width
|
|
8727
|
+
"style": "width:" + makeEm(width),
|
|
8713
8728
|
"viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height),
|
|
8714
8729
|
"preserveAspectRatio": "xMinYMin"
|
|
8715
8730
|
});
|
|
8716
8731
|
var span = buildCommon.makeSvgSpan([], [svgNode], options);
|
|
8717
8732
|
span.height = height;
|
|
8718
|
-
span.style.height = height
|
|
8719
|
-
span.style.width = width
|
|
8733
|
+
span.style.height = makeEm(height);
|
|
8734
|
+
span.style.width = makeEm(width);
|
|
8720
8735
|
return {
|
|
8721
8736
|
type: "elem",
|
|
8722
8737
|
elem: span
|
|
@@ -8925,7 +8940,7 @@ var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum,
|
|
|
8925
8940
|
var svg = new SvgNode([pathNode], {
|
|
8926
8941
|
// Note: 1000:1 ratio of viewBox to document em width.
|
|
8927
8942
|
"width": "400em",
|
|
8928
|
-
"height": height
|
|
8943
|
+
"height": makeEm(height),
|
|
8929
8944
|
"viewBox": "0 0 400000 " + viewBoxHeight,
|
|
8930
8945
|
"preserveAspectRatio": "xMinYMin slice"
|
|
8931
8946
|
});
|
|
@@ -8994,7 +9009,7 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
|
|
|
8994
9009
|
}
|
|
8995
9010
|
|
|
8996
9011
|
span.height = texHeight;
|
|
8997
|
-
span.style.height = spanHeight
|
|
9012
|
+
span.style.height = makeEm(spanHeight);
|
|
8998
9013
|
return {
|
|
8999
9014
|
span: span,
|
|
9000
9015
|
advanceWidth: advanceWidth,
|
|
@@ -9250,6 +9265,7 @@ var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, optio
|
|
|
9250
9265
|
|
|
9251
9266
|
|
|
9252
9267
|
|
|
9268
|
+
|
|
9253
9269
|
// Extra data needed for the delimiter handler down below
|
|
9254
9270
|
var delimiterSizes = {
|
|
9255
9271
|
"\\bigl": {
|
|
@@ -9379,8 +9395,9 @@ defineFunction({
|
|
|
9379
9395
|
}
|
|
9380
9396
|
|
|
9381
9397
|
node.setAttribute("stretchy", "true");
|
|
9382
|
-
|
|
9383
|
-
node.setAttribute("
|
|
9398
|
+
var size = makeEm(delimiter.sizeToMaxHeight[group.size]);
|
|
9399
|
+
node.setAttribute("minsize", size);
|
|
9400
|
+
node.setAttribute("maxsize", size);
|
|
9384
9401
|
return node;
|
|
9385
9402
|
}
|
|
9386
9403
|
});
|
|
@@ -9639,19 +9656,19 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
9639
9656
|
scale = scale / newOptions.sizeMultiplier;
|
|
9640
9657
|
var angleHeight = inner.height + inner.depth + lineWeight + clearance; // Reserve a left pad for the angle.
|
|
9641
9658
|
|
|
9642
|
-
inner.style.paddingLeft = angleHeight / 2 + lineWeight
|
|
9659
|
+
inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); // Create an SVG
|
|
9643
9660
|
|
|
9644
9661
|
var viewBoxHeight = Math.floor(1000 * angleHeight * scale);
|
|
9645
9662
|
var path = phasePath(viewBoxHeight);
|
|
9646
9663
|
var svgNode = new SvgNode([new PathNode("phase", path)], {
|
|
9647
9664
|
"width": "400em",
|
|
9648
|
-
"height": viewBoxHeight / 1000
|
|
9665
|
+
"height": makeEm(viewBoxHeight / 1000),
|
|
9649
9666
|
"viewBox": "0 0 400000 " + viewBoxHeight,
|
|
9650
9667
|
"preserveAspectRatio": "xMinYMin slice"
|
|
9651
9668
|
}); // Wrap it in a span with overflow: hidden.
|
|
9652
9669
|
|
|
9653
9670
|
img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options);
|
|
9654
|
-
img.style.height = angleHeight
|
|
9671
|
+
img.style.height = makeEm(angleHeight);
|
|
9655
9672
|
imgShift = inner.depth + lineWeight + clearance;
|
|
9656
9673
|
} else {
|
|
9657
9674
|
// Add horizontal padding
|
|
@@ -9690,10 +9707,10 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
9690
9707
|
|
|
9691
9708
|
if (/fbox|boxed|fcolorbox/.test(label)) {
|
|
9692
9709
|
img.style.borderStyle = "solid";
|
|
9693
|
-
img.style.borderWidth = ruleThickness
|
|
9710
|
+
img.style.borderWidth = makeEm(ruleThickness);
|
|
9694
9711
|
} else if (label === "angl" && ruleThickness !== 0.049) {
|
|
9695
|
-
img.style.borderTopWidth = ruleThickness
|
|
9696
|
-
img.style.borderRightWidth = ruleThickness
|
|
9712
|
+
img.style.borderTopWidth = makeEm(ruleThickness);
|
|
9713
|
+
img.style.borderRightWidth = makeEm(ruleThickness);
|
|
9697
9714
|
}
|
|
9698
9715
|
|
|
9699
9716
|
imgShift = inner.depth + bottomPad;
|
|
@@ -10310,22 +10327,22 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
10310
10327
|
// between them.
|
|
10311
10328
|
if (!firstSeparator) {
|
|
10312
10329
|
colSep = buildCommon.makeSpan(["arraycolsep"], []);
|
|
10313
|
-
colSep.style.width = options.fontMetrics().doubleRuleSep
|
|
10330
|
+
colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep);
|
|
10314
10331
|
cols.push(colSep);
|
|
10315
10332
|
}
|
|
10316
10333
|
|
|
10317
10334
|
if (colDescr.separator === "|" || colDescr.separator === ":") {
|
|
10318
10335
|
var lineType = colDescr.separator === "|" ? "solid" : "dashed";
|
|
10319
10336
|
var separator = buildCommon.makeSpan(["vertical-separator"], [], options);
|
|
10320
|
-
separator.style.height = totalHeight
|
|
10321
|
-
separator.style.borderRightWidth = ruleThickness
|
|
10337
|
+
separator.style.height = makeEm(totalHeight);
|
|
10338
|
+
separator.style.borderRightWidth = makeEm(ruleThickness);
|
|
10322
10339
|
separator.style.borderRightStyle = lineType;
|
|
10323
|
-
separator.style.margin = "0
|
|
10340
|
+
separator.style.margin = "0 " + makeEm(-ruleThickness / 2);
|
|
10324
10341
|
|
|
10325
10342
|
var _shift = totalHeight - offset;
|
|
10326
10343
|
|
|
10327
10344
|
if (_shift) {
|
|
10328
|
-
separator.style.verticalAlign = -_shift
|
|
10345
|
+
separator.style.verticalAlign = makeEm(-_shift);
|
|
10329
10346
|
}
|
|
10330
10347
|
|
|
10331
10348
|
cols.push(separator);
|
|
@@ -10349,7 +10366,7 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
10349
10366
|
|
|
10350
10367
|
if (sepwidth !== 0) {
|
|
10351
10368
|
colSep = buildCommon.makeSpan(["arraycolsep"], []);
|
|
10352
|
-
colSep.style.width = sepwidth
|
|
10369
|
+
colSep.style.width = makeEm(sepwidth);
|
|
10353
10370
|
cols.push(colSep);
|
|
10354
10371
|
}
|
|
10355
10372
|
}
|
|
@@ -10387,7 +10404,7 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
10387
10404
|
|
|
10388
10405
|
if (sepwidth !== 0) {
|
|
10389
10406
|
colSep = buildCommon.makeSpan(["arraycolsep"], []);
|
|
10390
|
-
colSep.style.width = sepwidth
|
|
10407
|
+
colSep.style.width = makeEm(sepwidth);
|
|
10391
10408
|
cols.push(colSep);
|
|
10392
10409
|
}
|
|
10393
10410
|
}
|
|
@@ -10487,7 +10504,7 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) {
|
|
|
10487
10504
|
|
|
10488
10505
|
var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray}
|
|
10489
10506
|
: 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
|
|
10490
|
-
table.setAttribute("rowspacing", gap
|
|
10507
|
+
table.setAttribute("rowspacing", makeEm(gap)); // MathML table lines go only between cells.
|
|
10491
10508
|
// To place a line on an edge we'll use <menclose>, if necessary.
|
|
10492
10509
|
|
|
10493
10510
|
var menclose = "";
|
|
@@ -11564,7 +11581,7 @@ var genfrac_mathmlBuilder = function mathmlBuilder(group, options) {
|
|
|
11564
11581
|
node.setAttribute("linethickness", "0px");
|
|
11565
11582
|
} else if (group.barSize) {
|
|
11566
11583
|
var ruleWidth = calculateSize(group.barSize, options);
|
|
11567
|
-
node.setAttribute("linethickness", ruleWidth
|
|
11584
|
+
node.setAttribute("linethickness", makeEm(ruleWidth));
|
|
11568
11585
|
}
|
|
11569
11586
|
|
|
11570
11587
|
var style = adjustStyle(group.size, options.style);
|
|
@@ -12425,7 +12442,6 @@ defineFunction({
|
|
|
12425
12442
|
|
|
12426
12443
|
if (group.totalheight.number > 0) {
|
|
12427
12444
|
depth = calculateSize(group.totalheight, options) - height;
|
|
12428
|
-
depth = Number(depth.toFixed(2));
|
|
12429
12445
|
}
|
|
12430
12446
|
|
|
12431
12447
|
var width = 0;
|
|
@@ -12435,15 +12451,15 @@ defineFunction({
|
|
|
12435
12451
|
}
|
|
12436
12452
|
|
|
12437
12453
|
var style = {
|
|
12438
|
-
height: height + depth
|
|
12454
|
+
height: makeEm(height + depth)
|
|
12439
12455
|
};
|
|
12440
12456
|
|
|
12441
12457
|
if (width > 0) {
|
|
12442
|
-
style.width = width
|
|
12458
|
+
style.width = makeEm(width);
|
|
12443
12459
|
}
|
|
12444
12460
|
|
|
12445
12461
|
if (depth > 0) {
|
|
12446
|
-
style.verticalAlign = -depth
|
|
12462
|
+
style.verticalAlign = makeEm(-depth);
|
|
12447
12463
|
}
|
|
12448
12464
|
|
|
12449
12465
|
var node = new Img(group.src, group.alt, style);
|
|
@@ -12459,15 +12475,14 @@ defineFunction({
|
|
|
12459
12475
|
|
|
12460
12476
|
if (group.totalheight.number > 0) {
|
|
12461
12477
|
depth = calculateSize(group.totalheight, options) - height;
|
|
12462
|
-
|
|
12463
|
-
node.setAttribute("valign", "-" + depth + "em");
|
|
12478
|
+
node.setAttribute("valign", makeEm(-depth));
|
|
12464
12479
|
}
|
|
12465
12480
|
|
|
12466
|
-
node.setAttribute("height", height + depth
|
|
12481
|
+
node.setAttribute("height", makeEm(height + depth));
|
|
12467
12482
|
|
|
12468
12483
|
if (group.width.number > 0) {
|
|
12469
12484
|
var width = calculateSize(group.width, options);
|
|
12470
|
-
node.setAttribute("width", width
|
|
12485
|
+
node.setAttribute("width", makeEm(width));
|
|
12471
12486
|
}
|
|
12472
12487
|
|
|
12473
12488
|
node.setAttribute("src", group.src);
|
|
@@ -12538,6 +12553,7 @@ defineFunction({
|
|
|
12538
12553
|
|
|
12539
12554
|
|
|
12540
12555
|
|
|
12556
|
+
|
|
12541
12557
|
defineFunction({
|
|
12542
12558
|
type: "lap",
|
|
12543
12559
|
names: ["\\mathllap", "\\mathrlap", "\\mathclap"],
|
|
@@ -12577,10 +12593,10 @@ defineFunction({
|
|
|
12577
12593
|
// This code resolved issue #1153
|
|
12578
12594
|
|
|
12579
12595
|
var strut = buildCommon.makeSpan(["strut"]);
|
|
12580
|
-
strut.style.height = node.height + node.depth
|
|
12596
|
+
strut.style.height = makeEm(node.height + node.depth);
|
|
12581
12597
|
|
|
12582
12598
|
if (node.depth) {
|
|
12583
|
-
strut.style.verticalAlign = -node.depth
|
|
12599
|
+
strut.style.verticalAlign = makeEm(-node.depth);
|
|
12584
12600
|
}
|
|
12585
12601
|
|
|
12586
12602
|
node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall.
|
|
@@ -12703,7 +12719,8 @@ defineFunction({
|
|
|
12703
12719
|
|
|
12704
12720
|
|
|
12705
12721
|
|
|
12706
|
-
// For an operator with limits, assemble the base, sup, and sub into a span.
|
|
12722
|
+
// For an operator with limits, assemble the base, sup, and sub into a span.
|
|
12723
|
+
|
|
12707
12724
|
var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift) {
|
|
12708
12725
|
base = buildCommon.makeSpan([], [base]);
|
|
12709
12726
|
var subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup);
|
|
@@ -12743,7 +12760,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12743
12760
|
}, {
|
|
12744
12761
|
type: "elem",
|
|
12745
12762
|
elem: sub.elem,
|
|
12746
|
-
marginLeft: -slant
|
|
12763
|
+
marginLeft: makeEm(-slant)
|
|
12747
12764
|
}, {
|
|
12748
12765
|
type: "kern",
|
|
12749
12766
|
size: sub.kern
|
|
@@ -12756,7 +12773,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12756
12773
|
}, {
|
|
12757
12774
|
type: "elem",
|
|
12758
12775
|
elem: sup.elem,
|
|
12759
|
-
marginLeft: slant
|
|
12776
|
+
marginLeft: makeEm(slant)
|
|
12760
12777
|
}, {
|
|
12761
12778
|
type: "kern",
|
|
12762
12779
|
size: options.fontMetrics().bigOpSpacing5
|
|
@@ -12777,7 +12794,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12777
12794
|
}, {
|
|
12778
12795
|
type: "elem",
|
|
12779
12796
|
elem: sub.elem,
|
|
12780
|
-
marginLeft: -slant
|
|
12797
|
+
marginLeft: makeEm(-slant)
|
|
12781
12798
|
}, {
|
|
12782
12799
|
type: "kern",
|
|
12783
12800
|
size: sub.kern
|
|
@@ -12801,7 +12818,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12801
12818
|
}, {
|
|
12802
12819
|
type: "elem",
|
|
12803
12820
|
elem: sup.elem,
|
|
12804
|
-
marginLeft: slant
|
|
12821
|
+
marginLeft: makeEm(slant)
|
|
12805
12822
|
}, {
|
|
12806
12823
|
type: "kern",
|
|
12807
12824
|
size: options.fontMetrics().bigOpSpacing5
|
|
@@ -12820,7 +12837,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12820
12837
|
// A negative margin-left was applied to the lower limit.
|
|
12821
12838
|
// Avoid an overlap by placing a spacer on the left on the group.
|
|
12822
12839
|
var spacer = buildCommon.makeSpan(["mspace"], [], options);
|
|
12823
|
-
spacer.style.marginRight = slant
|
|
12840
|
+
spacer.style.marginRight = makeEm(slant);
|
|
12824
12841
|
parts.unshift(spacer);
|
|
12825
12842
|
}
|
|
12826
12843
|
|
|
@@ -12838,6 +12855,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12838
12855
|
|
|
12839
12856
|
|
|
12840
12857
|
|
|
12858
|
+
|
|
12841
12859
|
// Most operators have a large successor symbol, but these don't.
|
|
12842
12860
|
var noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also
|
|
12843
12861
|
// "supsub" since some of them (like \int) can affect super/subscripting.
|
|
@@ -12951,7 +12969,7 @@ var op_htmlBuilder = function htmlBuilder(grp, options) {
|
|
|
12951
12969
|
} else {
|
|
12952
12970
|
if (baseShift) {
|
|
12953
12971
|
base.style.position = "relative";
|
|
12954
|
-
base.style.top = baseShift
|
|
12972
|
+
base.style.top = makeEm(baseShift);
|
|
12955
12973
|
}
|
|
12956
12974
|
|
|
12957
12975
|
return base;
|
|
@@ -13576,9 +13594,9 @@ defineFunction({
|
|
|
13576
13594
|
var height = calculateSize(group.height, options);
|
|
13577
13595
|
var shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size
|
|
13578
13596
|
|
|
13579
|
-
rule.style.borderRightWidth = width
|
|
13580
|
-
rule.style.borderTopWidth = height
|
|
13581
|
-
rule.style.bottom = shift
|
|
13597
|
+
rule.style.borderRightWidth = makeEm(width);
|
|
13598
|
+
rule.style.borderTopWidth = makeEm(height);
|
|
13599
|
+
rule.style.bottom = makeEm(shift); // Record the height and width
|
|
13582
13600
|
|
|
13583
13601
|
rule.width = width;
|
|
13584
13602
|
rule.height = height + shift;
|
|
@@ -13596,18 +13614,18 @@ defineFunction({
|
|
|
13596
13614
|
var color = options.color && options.getColor() || "black";
|
|
13597
13615
|
var rule = new mathMLTree.MathNode("mspace");
|
|
13598
13616
|
rule.setAttribute("mathbackground", color);
|
|
13599
|
-
rule.setAttribute("width", width
|
|
13600
|
-
rule.setAttribute("height", height
|
|
13617
|
+
rule.setAttribute("width", makeEm(width));
|
|
13618
|
+
rule.setAttribute("height", makeEm(height));
|
|
13601
13619
|
var wrapper = new mathMLTree.MathNode("mpadded", [rule]);
|
|
13602
13620
|
|
|
13603
13621
|
if (shift >= 0) {
|
|
13604
|
-
wrapper.setAttribute("height",
|
|
13622
|
+
wrapper.setAttribute("height", makeEm(shift));
|
|
13605
13623
|
} else {
|
|
13606
|
-
wrapper.setAttribute("height", shift
|
|
13607
|
-
wrapper.setAttribute("depth",
|
|
13624
|
+
wrapper.setAttribute("height", makeEm(shift));
|
|
13625
|
+
wrapper.setAttribute("depth", makeEm(-shift));
|
|
13608
13626
|
}
|
|
13609
13627
|
|
|
13610
|
-
wrapper.setAttribute("voffset", shift
|
|
13628
|
+
wrapper.setAttribute("voffset", makeEm(shift));
|
|
13611
13629
|
return wrapper;
|
|
13612
13630
|
}
|
|
13613
13631
|
});
|
|
@@ -13617,6 +13635,7 @@ defineFunction({
|
|
|
13617
13635
|
|
|
13618
13636
|
|
|
13619
13637
|
|
|
13638
|
+
|
|
13620
13639
|
function sizingGroup(value, options, baseOptions) {
|
|
13621
13640
|
var inner = buildExpression(value, options, false);
|
|
13622
13641
|
var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize
|
|
@@ -13678,7 +13697,7 @@ defineFunction({
|
|
|
13678
13697
|
// that we're passing an options parameter we should be able to fix
|
|
13679
13698
|
// this.
|
|
13680
13699
|
|
|
13681
|
-
node.setAttribute("mathsize", newOptions.sizeMultiplier
|
|
13700
|
+
node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier));
|
|
13682
13701
|
return node;
|
|
13683
13702
|
}
|
|
13684
13703
|
});
|
|
@@ -13802,6 +13821,7 @@ defineFunction({
|
|
|
13802
13821
|
|
|
13803
13822
|
|
|
13804
13823
|
|
|
13824
|
+
|
|
13805
13825
|
defineFunction({
|
|
13806
13826
|
type: "sqrt",
|
|
13807
13827
|
names: ["\\sqrt"],
|
|
@@ -13860,7 +13880,7 @@ defineFunction({
|
|
|
13860
13880
|
|
|
13861
13881
|
|
|
13862
13882
|
var imgShift = img.height - inner.height - lineClearance - ruleWidth;
|
|
13863
|
-
inner.style.paddingLeft = advanceWidth
|
|
13883
|
+
inner.style.paddingLeft = makeEm(advanceWidth); // Overlay the image and the argument.
|
|
13864
13884
|
|
|
13865
13885
|
var body = buildCommon.makeVList({
|
|
13866
13886
|
positionType: "firstBaseline",
|
|
@@ -13988,6 +14008,7 @@ defineFunction({
|
|
|
13988
14008
|
|
|
13989
14009
|
|
|
13990
14010
|
|
|
14011
|
+
|
|
13991
14012
|
/**
|
|
13992
14013
|
* Sometimes, groups perform special rules when they have superscripts or
|
|
13993
14014
|
* subscripts attached to them. This function lets the `supsub` group know that
|
|
@@ -14079,7 +14100,7 @@ defineFunctionBuilders({
|
|
|
14079
14100
|
|
|
14080
14101
|
|
|
14081
14102
|
var multiplier = options.sizeMultiplier;
|
|
14082
|
-
var marginRight = 0.5 / metrics.ptPerEm / multiplier
|
|
14103
|
+
var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier);
|
|
14083
14104
|
var marginLeft = null;
|
|
14084
14105
|
|
|
14085
14106
|
if (subm) {
|
|
@@ -14090,7 +14111,7 @@ defineFunctionBuilders({
|
|
|
14090
14111
|
|
|
14091
14112
|
if (base instanceof SymbolNode || isOiint) {
|
|
14092
14113
|
// $FlowFixMe
|
|
14093
|
-
marginLeft = -base.italic
|
|
14114
|
+
marginLeft = makeEm(-base.italic);
|
|
14094
14115
|
}
|
|
14095
14116
|
}
|
|
14096
14117
|
|
|
@@ -15057,6 +15078,7 @@ var macros = _macros;
|
|
|
15057
15078
|
|
|
15058
15079
|
|
|
15059
15080
|
|
|
15081
|
+
|
|
15060
15082
|
//////////////////////////////////////////////////////////////////////
|
|
15061
15083
|
// macro tools
|
|
15062
15084
|
|
|
@@ -15678,7 +15700,7 @@ defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5e
|
|
|
15678
15700
|
// We compute the corresponding \raisebox when A is rendered in \normalsize
|
|
15679
15701
|
// \scriptstyle, which has a scale factor of 0.7 (see Options.js).
|
|
15680
15702
|
|
|
15681
|
-
var latexRaiseA = fontMetricsData["Main-Regular"]["T".charCodeAt(0)][1] - 0.7 * fontMetricsData["Main-Regular"]["A".charCodeAt(0)][1]
|
|
15703
|
+
var latexRaiseA = makeEm(fontMetricsData["Main-Regular"]["T".charCodeAt(0)][1] - 0.7 * fontMetricsData["Main-Regular"]["A".charCodeAt(0)][1]);
|
|
15682
15704
|
defineMacro("\\LaTeX", "\\textrm{\\html@mathml{" + ("L\\kern-.36em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{LaTeX}}"); // New KaTeX logo based on tweaking LaTeX logo
|
|
15683
15705
|
|
|
15684
15706
|
defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
|
|
@@ -18103,7 +18125,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
|
|
|
18103
18125
|
/**
|
|
18104
18126
|
* Current KaTeX version
|
|
18105
18127
|
*/
|
|
18106
|
-
version: "0.13.
|
|
18128
|
+
version: "0.13.24",
|
|
18107
18129
|
|
|
18108
18130
|
/**
|
|
18109
18131
|
* Renders the given LaTeX into an HTML+MathML combination, and adds
|