katex 0.13.20 → 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/cli.js +1 -1
- package/contrib/copy-tex/README.md +3 -3
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +5 -5
- package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/katex.css +4 -4
- package/dist/katex.js +1625 -1602
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +2087 -2080
- package/package.json +16 -7
- package/src/buildCommon.js +12 -12
- package/src/buildHTML.js +5 -4
- package/src/delimiter.js +11 -10
- package/src/domTree.js +2 -1
- package/src/environments/array.js +9 -9
- package/src/environments/cd.js +2 -1
- package/src/fontMetricsData.js +2 -1
- package/src/fonts/generate_fonts.py +3 -6
- package/src/fonts/makeFF +2 -0
- package/src/functions/accent.js +4 -3
- package/src/functions/cr.js +3 -3
- package/src/functions/delimsizing.js +4 -2
- package/src/functions/enclose.js +7 -7
- package/src/functions/genfrac.js +2 -2
- package/src/functions/includegraphics.js +7 -9
- package/src/functions/lap.js +3 -2
- package/src/functions/op.js +2 -1
- package/src/functions/rule.js +10 -10
- package/src/functions/sizing.js +2 -1
- package/src/functions/sqrt.js +2 -1
- package/src/functions/supsub.js +3 -2
- package/src/functions/utils/assembleSupSub.js +6 -5
- package/src/katex.less +3 -3
- package/src/macros.js +3 -2
- package/src/mathMLTree.js +3 -2
- package/src/metrics/extract_ttfs.py +3 -0
- package/src/stretchy.js +8 -7
- package/src/units.js +8 -0
package/dist/katex.js
CHANGED
|
@@ -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 = ({
|
|
@@ -2017,6 +1464,7 @@ function assertSpan(group) {
|
|
|
2017
1464
|
"8764": [-0.10889, 0.39111, 0, 0, 0.89444],
|
|
2018
1465
|
"8768": [0.19444, 0.69444, 0, 0, 0.31944],
|
|
2019
1466
|
"8771": [0.00222, 0.50222, 0, 0, 0.89444],
|
|
1467
|
+
"8773": [0.027, 0.638, 0, 0, 0.894],
|
|
2020
1468
|
"8776": [0.02444, 0.52444, 0, 0, 0.89444],
|
|
2021
1469
|
"8781": [0.00222, 0.50222, 0, 0, 0.89444],
|
|
2022
1470
|
"8801": [0.00222, 0.50222, 0, 0, 0.89444],
|
|
@@ -2534,7 +1982,7 @@ function assertSpan(group) {
|
|
|
2534
1982
|
"8764": [-0.13313, 0.36687, 0, 0, 0.77778],
|
|
2535
1983
|
"8768": [0.19444, 0.69444, 0, 0, 0.27778],
|
|
2536
1984
|
"8771": [-0.03625, 0.46375, 0, 0, 0.77778],
|
|
2537
|
-
"8773": [-0.022, 0.589, 0, 0,
|
|
1985
|
+
"8773": [-0.022, 0.589, 0, 0, 0.778],
|
|
2538
1986
|
"8776": [-0.01688, 0.48312, 0, 0, 0.77778],
|
|
2539
1987
|
"8781": [-0.03625, 0.46375, 0, 0, 0.77778],
|
|
2540
1988
|
"8784": [-0.133, 0.673, 0, 0, 0.778],
|
|
@@ -3508,289 +2956,1279 @@ function assertSpan(group) {
|
|
|
3508
2956
|
"8242": [0, 0.61111, 0, 0, 0.525],
|
|
3509
2957
|
"9251": [0.11111, 0.21944, 0, 0, 0.525]
|
|
3510
2958
|
}
|
|
3511
|
-
});
|
|
3512
|
-
;// 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
|
+
}
|
|
3513
3950
|
|
|
3951
|
+
markup += "'/>";
|
|
3952
|
+
return markup;
|
|
3953
|
+
};
|
|
3514
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
|
+
};
|
|
3515
3964
|
/**
|
|
3516
|
-
*
|
|
3517
|
-
*
|
|
3518
|
-
*
|
|
3519
|
-
* `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.
|
|
3520
3968
|
*/
|
|
3521
|
-
// In TeX, there are actually three sets of dimensions, one for each of
|
|
3522
|
-
// textstyle (size index 5 and higher: >=9pt), scriptstyle (size index 3 and 4:
|
|
3523
|
-
// 7-8pt), and scriptscriptstyle (size index 1 and 2: 5-6pt). These are
|
|
3524
|
-
// provided in the the arrays below, in that order.
|
|
3525
|
-
//
|
|
3526
|
-
// The font metrics are stored in fonts cmsy10, cmsy7, and cmsy5 respsectively.
|
|
3527
|
-
// This was determined by running the following script:
|
|
3528
|
-
//
|
|
3529
|
-
// latex -interaction=nonstopmode \
|
|
3530
|
-
// '\documentclass{article}\usepackage{amsmath}\begin{document}' \
|
|
3531
|
-
// '$a$ \expandafter\show\the\textfont2' \
|
|
3532
|
-
// '\expandafter\show\the\scriptfont2' \
|
|
3533
|
-
// '\expandafter\show\the\scriptscriptfont2' \
|
|
3534
|
-
// '\stop'
|
|
3535
|
-
//
|
|
3536
|
-
// The metrics themselves were retreived using the following commands:
|
|
3537
|
-
//
|
|
3538
|
-
// tftopl cmsy10
|
|
3539
|
-
// tftopl cmsy7
|
|
3540
|
-
// tftopl cmsy5
|
|
3541
|
-
//
|
|
3542
|
-
// The output of each of these commands is quite lengthy. The only part we
|
|
3543
|
-
// care about is the FONTDIMEN section. Each value is measured in EMs.
|
|
3544
|
-
var sigmasAndXis = {
|
|
3545
|
-
slant: [0.250, 0.250, 0.250],
|
|
3546
|
-
// sigma1
|
|
3547
|
-
space: [0.000, 0.000, 0.000],
|
|
3548
|
-
// sigma2
|
|
3549
|
-
stretch: [0.000, 0.000, 0.000],
|
|
3550
|
-
// sigma3
|
|
3551
|
-
shrink: [0.000, 0.000, 0.000],
|
|
3552
|
-
// sigma4
|
|
3553
|
-
xHeight: [0.431, 0.431, 0.431],
|
|
3554
|
-
// sigma5
|
|
3555
|
-
quad: [1.000, 1.171, 1.472],
|
|
3556
|
-
// sigma6
|
|
3557
|
-
extraSpace: [0.000, 0.000, 0.000],
|
|
3558
|
-
// sigma7
|
|
3559
|
-
num1: [0.677, 0.732, 0.925],
|
|
3560
|
-
// sigma8
|
|
3561
|
-
num2: [0.394, 0.384, 0.387],
|
|
3562
|
-
// sigma9
|
|
3563
|
-
num3: [0.444, 0.471, 0.504],
|
|
3564
|
-
// sigma10
|
|
3565
|
-
denom1: [0.686, 0.752, 1.025],
|
|
3566
|
-
// sigma11
|
|
3567
|
-
denom2: [0.345, 0.344, 0.532],
|
|
3568
|
-
// sigma12
|
|
3569
|
-
sup1: [0.413, 0.503, 0.504],
|
|
3570
|
-
// sigma13
|
|
3571
|
-
sup2: [0.363, 0.431, 0.404],
|
|
3572
|
-
// sigma14
|
|
3573
|
-
sup3: [0.289, 0.286, 0.294],
|
|
3574
|
-
// sigma15
|
|
3575
|
-
sub1: [0.150, 0.143, 0.200],
|
|
3576
|
-
// sigma16
|
|
3577
|
-
sub2: [0.247, 0.286, 0.400],
|
|
3578
|
-
// sigma17
|
|
3579
|
-
supDrop: [0.386, 0.353, 0.494],
|
|
3580
|
-
// sigma18
|
|
3581
|
-
subDrop: [0.050, 0.071, 0.100],
|
|
3582
|
-
// sigma19
|
|
3583
|
-
delim1: [2.390, 1.700, 1.980],
|
|
3584
|
-
// sigma20
|
|
3585
|
-
delim2: [1.010, 1.157, 1.420],
|
|
3586
|
-
// sigma21
|
|
3587
|
-
axisHeight: [0.250, 0.250, 0.250],
|
|
3588
|
-
// sigma22
|
|
3589
|
-
// These font metrics are extracted from TeX by using tftopl on cmex10.tfm;
|
|
3590
|
-
// they correspond to the font parameters of the extension fonts (family 3).
|
|
3591
|
-
// See the TeXbook, page 441. In AMSTeX, the extension fonts scale; to
|
|
3592
|
-
// match cmex7, we'd use cmex7.tfm values for script and scriptscript
|
|
3593
|
-
// values.
|
|
3594
|
-
defaultRuleThickness: [0.04, 0.049, 0.049],
|
|
3595
|
-
// xi8; cmex7: 0.049
|
|
3596
|
-
bigOpSpacing1: [0.111, 0.111, 0.111],
|
|
3597
|
-
// xi9
|
|
3598
|
-
bigOpSpacing2: [0.166, 0.166, 0.166],
|
|
3599
|
-
// xi10
|
|
3600
|
-
bigOpSpacing3: [0.2, 0.2, 0.2],
|
|
3601
|
-
// xi11
|
|
3602
|
-
bigOpSpacing4: [0.6, 0.611, 0.611],
|
|
3603
|
-
// xi12; cmex7: 0.611
|
|
3604
|
-
bigOpSpacing5: [0.1, 0.143, 0.143],
|
|
3605
|
-
// xi13; cmex7: 0.143
|
|
3606
|
-
// The \sqrt rule width is taken from the height of the surd character.
|
|
3607
|
-
// Since we use the same font at all sizes, this thickness doesn't scale.
|
|
3608
|
-
sqrtRuleThickness: [0.04, 0.04, 0.04],
|
|
3609
|
-
// This value determines how large a pt is, for metrics which are defined
|
|
3610
|
-
// in terms of pts.
|
|
3611
|
-
// This value is also used in katex.less; if you change it make sure the
|
|
3612
|
-
// values match.
|
|
3613
|
-
ptPerEm: [10.0, 10.0, 10.0],
|
|
3614
|
-
// The space between adjacent `|` columns in an array definition. From
|
|
3615
|
-
// `\showthe\doublerulesep` in LaTeX. Equals 2.0 / ptPerEm.
|
|
3616
|
-
doubleRuleSep: [0.2, 0.2, 0.2],
|
|
3617
|
-
// The width of separator lines in {array} environments. From
|
|
3618
|
-
// `\showthe\arrayrulewidth` in LaTeX. Equals 0.4 / ptPerEm.
|
|
3619
|
-
arrayRuleWidth: [0.04, 0.04, 0.04],
|
|
3620
|
-
// Two values from LaTeX source2e:
|
|
3621
|
-
fboxsep: [0.3, 0.3, 0.3],
|
|
3622
|
-
// 3 pt / ptPerEm
|
|
3623
|
-
fboxrule: [0.04, 0.04, 0.04] // 0.4 pt / ptPerEm
|
|
3624
3969
|
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
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
|
+
}
|
|
3629
4078
|
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
// descenders we prefer approximations with ascenders, primarily to prevent
|
|
3635
|
-
// the fraction bar or root line from intersecting the glyph.
|
|
3636
|
-
// TODO(kevinb) allow union of multiple glyph metrics for better accuracy.
|
|
4079
|
+
if (styles) {
|
|
4080
|
+
needsSpan = true;
|
|
4081
|
+
markup += " style=\"" + utils.escape(styles) + "\"";
|
|
4082
|
+
}
|
|
3637
4083
|
|
|
3638
|
-
var
|
|
3639
|
-
// Latin-1
|
|
3640
|
-
'Å': 'A',
|
|
3641
|
-
'Ð': 'D',
|
|
3642
|
-
'Þ': 'o',
|
|
3643
|
-
'å': 'a',
|
|
3644
|
-
'ð': 'd',
|
|
3645
|
-
'þ': 'o',
|
|
3646
|
-
// Cyrillic
|
|
3647
|
-
'А': 'A',
|
|
3648
|
-
'Б': 'B',
|
|
3649
|
-
'В': 'B',
|
|
3650
|
-
'Г': 'F',
|
|
3651
|
-
'Д': 'A',
|
|
3652
|
-
'Е': 'E',
|
|
3653
|
-
'Ж': 'K',
|
|
3654
|
-
'З': '3',
|
|
3655
|
-
'И': 'N',
|
|
3656
|
-
'Й': 'N',
|
|
3657
|
-
'К': 'K',
|
|
3658
|
-
'Л': 'N',
|
|
3659
|
-
'М': 'M',
|
|
3660
|
-
'Н': 'H',
|
|
3661
|
-
'О': 'O',
|
|
3662
|
-
'П': 'N',
|
|
3663
|
-
'Р': 'P',
|
|
3664
|
-
'С': 'C',
|
|
3665
|
-
'Т': 'T',
|
|
3666
|
-
'У': 'y',
|
|
3667
|
-
'Ф': 'O',
|
|
3668
|
-
'Х': 'X',
|
|
3669
|
-
'Ц': 'U',
|
|
3670
|
-
'Ч': 'h',
|
|
3671
|
-
'Ш': 'W',
|
|
3672
|
-
'Щ': 'W',
|
|
3673
|
-
'Ъ': 'B',
|
|
3674
|
-
'Ы': 'X',
|
|
3675
|
-
'Ь': 'B',
|
|
3676
|
-
'Э': '3',
|
|
3677
|
-
'Ю': 'X',
|
|
3678
|
-
'Я': 'R',
|
|
3679
|
-
'а': 'a',
|
|
3680
|
-
'б': 'b',
|
|
3681
|
-
'в': 'a',
|
|
3682
|
-
'г': 'r',
|
|
3683
|
-
'д': 'y',
|
|
3684
|
-
'е': 'e',
|
|
3685
|
-
'ж': 'm',
|
|
3686
|
-
'з': 'e',
|
|
3687
|
-
'и': 'n',
|
|
3688
|
-
'й': 'n',
|
|
3689
|
-
'к': 'n',
|
|
3690
|
-
'л': 'n',
|
|
3691
|
-
'м': 'm',
|
|
3692
|
-
'н': 'n',
|
|
3693
|
-
'о': 'o',
|
|
3694
|
-
'п': 'n',
|
|
3695
|
-
'р': 'p',
|
|
3696
|
-
'с': 'c',
|
|
3697
|
-
'т': 'o',
|
|
3698
|
-
'у': 'y',
|
|
3699
|
-
'ф': 'b',
|
|
3700
|
-
'х': 'x',
|
|
3701
|
-
'ц': 'n',
|
|
3702
|
-
'ч': 'n',
|
|
3703
|
-
'ш': 'w',
|
|
3704
|
-
'щ': 'w',
|
|
3705
|
-
'ъ': 'a',
|
|
3706
|
-
'ы': 'm',
|
|
3707
|
-
'ь': 'a',
|
|
3708
|
-
'э': 'e',
|
|
3709
|
-
'ю': 'm',
|
|
3710
|
-
'я': 'r'
|
|
3711
|
-
};
|
|
4084
|
+
var escaped = utils.escape(this.text);
|
|
3712
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
|
+
}();
|
|
3713
4098
|
/**
|
|
3714
|
-
*
|
|
3715
|
-
* It can also override existing metrics
|
|
3716
|
-
*/
|
|
3717
|
-
function setFontMetrics(fontName, metrics) {
|
|
3718
|
-
fontMetricsData[fontName] = metrics;
|
|
3719
|
-
}
|
|
3720
|
-
/**
|
|
3721
|
-
* This function is a convenience function for looking up information in the
|
|
3722
|
-
* metricMap table. It takes a character as a string, and a font.
|
|
3723
|
-
*
|
|
3724
|
-
* Note: the `width` property may be undefined if fontMetricsData.js wasn't
|
|
3725
|
-
* built using `Make extended_metrics`.
|
|
4099
|
+
* SVG nodes are used to render stretchy wide elements.
|
|
3726
4100
|
*/
|
|
3727
4101
|
|
|
3728
|
-
function
|
|
3729
|
-
|
|
3730
|
-
|
|
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 || {};
|
|
3731
4108
|
}
|
|
3732
4109
|
|
|
3733
|
-
var
|
|
3734
|
-
var metrics = fontMetricsData[font][ch];
|
|
4110
|
+
var _proto5 = SvgNode.prototype;
|
|
3735
4111
|
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
}
|
|
4112
|
+
_proto5.toNode = function toNode() {
|
|
4113
|
+
var svgNS = "http://www.w3.org/2000/svg";
|
|
4114
|
+
var node = document.createElementNS(svgNS, "svg"); // Apply attributes
|
|
3740
4115
|
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
// So if the character is in a script we support but we
|
|
3746
|
-
// don't have metrics for it, just use the metrics for
|
|
3747
|
-
// the Latin capital letter M. This is close enough because
|
|
3748
|
-
// we (currently) only care about the height of the glpyh
|
|
3749
|
-
// not its width.
|
|
3750
|
-
if (supportedCodepoint(ch)) {
|
|
3751
|
-
metrics = fontMetricsData[font][77]; // 77 is the charcode for 'M'
|
|
4116
|
+
for (var attr in this.attributes) {
|
|
4117
|
+
if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) {
|
|
4118
|
+
node.setAttribute(attr, this.attributes[attr]);
|
|
4119
|
+
}
|
|
3752
4120
|
}
|
|
3753
|
-
}
|
|
3754
4121
|
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
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
|
|
3763
4156
|
}
|
|
3764
|
-
}
|
|
3765
|
-
var fontMetricsBySizeIndex = {};
|
|
3766
|
-
/**
|
|
3767
|
-
* Get the font metrics for a given size.
|
|
3768
|
-
*/
|
|
3769
4157
|
|
|
3770
|
-
|
|
3771
|
-
var sizeIndex;
|
|
4158
|
+
var _proto6 = PathNode.prototype;
|
|
3772
4159
|
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
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 || {};
|
|
3779
4187
|
}
|
|
3780
4188
|
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
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
|
+
};
|
|
3785
4203
|
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
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] + "'";
|
|
3789
4210
|
}
|
|
3790
4211
|
}
|
|
3791
|
-
}
|
|
3792
4212
|
|
|
3793
|
-
|
|
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
|
+
}
|
|
3794
4232
|
}
|
|
3795
4233
|
;// CONCATENATED MODULE: ./src/symbols.js
|
|
3796
4234
|
/**
|
|
@@ -4415,772 +4853,344 @@ defineSymbol(math, main, rel, "\u21D5", "\\Updownarrow", true);
|
|
|
4415
4853
|
defineSymbol(math, main, op, "\u2210", "\\coprod");
|
|
4416
4854
|
defineSymbol(math, main, op, "\u22C1", "\\bigvee");
|
|
4417
4855
|
defineSymbol(math, main, op, "\u22C0", "\\bigwedge");
|
|
4418
|
-
defineSymbol(math, main, op, "\u2A04", "\\biguplus");
|
|
4419
|
-
defineSymbol(math, main, op, "\u22C2", "\\bigcap");
|
|
4420
|
-
defineSymbol(math, main, op, "\u22C3", "\\bigcup");
|
|
4421
|
-
defineSymbol(math, main, op, "\u222B", "\\int");
|
|
4422
|
-
defineSymbol(math, main, op, "\u222B", "\\intop");
|
|
4423
|
-
defineSymbol(math, main, op, "\u222C", "\\iint");
|
|
4424
|
-
defineSymbol(math, main, op, "\u222D", "\\iiint");
|
|
4425
|
-
defineSymbol(math, main, op, "\u220F", "\\prod");
|
|
4426
|
-
defineSymbol(math, main, op, "\u2211", "\\sum");
|
|
4427
|
-
defineSymbol(math, main, op, "\u2A02", "\\bigotimes");
|
|
4428
|
-
defineSymbol(math, main, op, "\u2A01", "\\bigoplus");
|
|
4429
|
-
defineSymbol(math, main, op, "\u2A00", "\\bigodot");
|
|
4430
|
-
defineSymbol(math, main, op, "\u222E", "\\oint");
|
|
4431
|
-
defineSymbol(math, main, op, "\u222F", "\\oiint");
|
|
4432
|
-
defineSymbol(math, main, op, "\u2230", "\\oiiint");
|
|
4433
|
-
defineSymbol(math, main, op, "\u2A06", "\\bigsqcup");
|
|
4434
|
-
defineSymbol(math, main, op, "\u222B", "\\smallint");
|
|
4435
|
-
defineSymbol(symbols_text, main, inner, "\u2026", "\\textellipsis");
|
|
4436
|
-
defineSymbol(math, main, inner, "\u2026", "\\mathellipsis");
|
|
4437
|
-
defineSymbol(symbols_text, main, inner, "\u2026", "\\ldots", true);
|
|
4438
|
-
defineSymbol(math, main, inner, "\u2026", "\\ldots", true);
|
|
4439
|
-
defineSymbol(math, main, inner, "\u22EF", "\\@cdots", true);
|
|
4440
|
-
defineSymbol(math, main, inner, "\u22F1", "\\ddots", true);
|
|
4441
|
-
defineSymbol(math, main, textord, "\u22EE", "\\varvdots"); // \vdots is a macro
|
|
4442
|
-
|
|
4443
|
-
defineSymbol(math, main, accent, "\u02CA", "\\acute");
|
|
4444
|
-
defineSymbol(math, main, accent, "\u02CB", "\\grave");
|
|
4445
|
-
defineSymbol(math, main, accent, "\xA8", "\\ddot");
|
|
4446
|
-
defineSymbol(math, main, accent, "~", "\\tilde");
|
|
4447
|
-
defineSymbol(math, main, accent, "\u02C9", "\\bar");
|
|
4448
|
-
defineSymbol(math, main, accent, "\u02D8", "\\breve");
|
|
4449
|
-
defineSymbol(math, main, accent, "\u02C7", "\\check");
|
|
4450
|
-
defineSymbol(math, main, accent, "^", "\\hat");
|
|
4451
|
-
defineSymbol(math, main, accent, "\u20D7", "\\vec");
|
|
4452
|
-
defineSymbol(math, main, accent, "\u02D9", "\\dot");
|
|
4453
|
-
defineSymbol(math, main, accent, "\u02DA", "\\mathring"); // \imath and \jmath should be invariant to \mathrm, \mathbf, etc., so use PUA
|
|
4454
|
-
|
|
4455
|
-
defineSymbol(math, main, mathord, "\uE131", "\\@imath");
|
|
4456
|
-
defineSymbol(math, main, mathord, "\uE237", "\\@jmath");
|
|
4457
|
-
defineSymbol(math, main, textord, "\u0131", "\u0131");
|
|
4458
|
-
defineSymbol(math, main, textord, "\u0237", "\u0237");
|
|
4459
|
-
defineSymbol(symbols_text, main, textord, "\u0131", "\\i", true);
|
|
4460
|
-
defineSymbol(symbols_text, main, textord, "\u0237", "\\j", true);
|
|
4461
|
-
defineSymbol(symbols_text, main, textord, "\xDF", "\\ss", true);
|
|
4462
|
-
defineSymbol(symbols_text, main, textord, "\xE6", "\\ae", true);
|
|
4463
|
-
defineSymbol(symbols_text, main, textord, "\u0153", "\\oe", true);
|
|
4464
|
-
defineSymbol(symbols_text, main, textord, "\xF8", "\\o", true);
|
|
4465
|
-
defineSymbol(symbols_text, main, textord, "\xC6", "\\AE", true);
|
|
4466
|
-
defineSymbol(symbols_text, main, textord, "\u0152", "\\OE", true);
|
|
4467
|
-
defineSymbol(symbols_text, main, textord, "\xD8", "\\O", true);
|
|
4468
|
-
defineSymbol(symbols_text, main, accent, "\u02CA", "\\'"); // acute
|
|
4469
|
-
|
|
4470
|
-
defineSymbol(symbols_text, main, accent, "\u02CB", "\\`"); // grave
|
|
4471
|
-
|
|
4472
|
-
defineSymbol(symbols_text, main, accent, "\u02C6", "\\^"); // circumflex
|
|
4473
|
-
|
|
4474
|
-
defineSymbol(symbols_text, main, accent, "\u02DC", "\\~"); // tilde
|
|
4475
|
-
|
|
4476
|
-
defineSymbol(symbols_text, main, accent, "\u02C9", "\\="); // macron
|
|
4477
|
-
|
|
4478
|
-
defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve
|
|
4479
|
-
|
|
4480
|
-
defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above
|
|
4481
|
-
|
|
4482
|
-
defineSymbol(symbols_text, main, accent, "\xB8", "\\c"); // cedilla
|
|
4483
|
-
|
|
4484
|
-
defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above
|
|
4485
|
-
|
|
4486
|
-
defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron
|
|
4487
|
-
|
|
4488
|
-
defineSymbol(symbols_text, main, accent, "\xA8", '\\"'); // diaresis
|
|
4489
|
-
|
|
4490
|
-
defineSymbol(symbols_text, main, accent, "\u02DD", "\\H"); // double acute
|
|
4491
|
-
|
|
4492
|
-
defineSymbol(symbols_text, main, accent, "\u25EF", "\\textcircled"); // \bigcirc glyph
|
|
4493
|
-
// These ligatures are detected and created in Parser.js's `formLigatures`.
|
|
4494
|
-
|
|
4495
|
-
var ligatures = {
|
|
4496
|
-
"--": true,
|
|
4497
|
-
"---": true,
|
|
4498
|
-
"``": true,
|
|
4499
|
-
"''": true
|
|
4500
|
-
};
|
|
4501
|
-
defineSymbol(symbols_text, main, textord, "\u2013", "--", true);
|
|
4502
|
-
defineSymbol(symbols_text, main, textord, "\u2013", "\\textendash");
|
|
4503
|
-
defineSymbol(symbols_text, main, textord, "\u2014", "---", true);
|
|
4504
|
-
defineSymbol(symbols_text, main, textord, "\u2014", "\\textemdash");
|
|
4505
|
-
defineSymbol(symbols_text, main, textord, "\u2018", "`", true);
|
|
4506
|
-
defineSymbol(symbols_text, main, textord, "\u2018", "\\textquoteleft");
|
|
4507
|
-
defineSymbol(symbols_text, main, textord, "\u2019", "'", true);
|
|
4508
|
-
defineSymbol(symbols_text, main, textord, "\u2019", "\\textquoteright");
|
|
4509
|
-
defineSymbol(symbols_text, main, textord, "\u201C", "``", true);
|
|
4510
|
-
defineSymbol(symbols_text, main, textord, "\u201C", "\\textquotedblleft");
|
|
4511
|
-
defineSymbol(symbols_text, main, textord, "\u201D", "''", true);
|
|
4512
|
-
defineSymbol(symbols_text, main, textord, "\u201D", "\\textquotedblright"); // \degree from gensymb package
|
|
4513
|
-
|
|
4514
|
-
defineSymbol(math, main, textord, "\xB0", "\\degree", true);
|
|
4515
|
-
defineSymbol(symbols_text, main, textord, "\xB0", "\\degree"); // \textdegree from inputenc package
|
|
4516
|
-
|
|
4517
|
-
defineSymbol(symbols_text, main, textord, "\xB0", "\\textdegree", true); // TODO: In LaTeX, \pounds can generate a different character in text and math
|
|
4518
|
-
// mode, but among our fonts, only Main-Regular defines this character "163".
|
|
4519
|
-
|
|
4520
|
-
defineSymbol(math, main, textord, "\xA3", "\\pounds");
|
|
4521
|
-
defineSymbol(math, main, textord, "\xA3", "\\mathsterling", true);
|
|
4522
|
-
defineSymbol(symbols_text, main, textord, "\xA3", "\\pounds");
|
|
4523
|
-
defineSymbol(symbols_text, main, textord, "\xA3", "\\textsterling", true);
|
|
4524
|
-
defineSymbol(math, ams, textord, "\u2720", "\\maltese");
|
|
4525
|
-
defineSymbol(symbols_text, ams, textord, "\u2720", "\\maltese"); // There are lots of symbols which are the same, so we add them in afterwards.
|
|
4526
|
-
// All of these are textords in math mode
|
|
4527
|
-
|
|
4528
|
-
var mathTextSymbols = "0123456789/@.\"";
|
|
4529
|
-
|
|
4530
|
-
for (var i = 0; i < mathTextSymbols.length; i++) {
|
|
4531
|
-
var ch = mathTextSymbols.charAt(i);
|
|
4532
|
-
defineSymbol(math, main, textord, ch, ch);
|
|
4533
|
-
} // All of these are textords in text mode
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
var textSymbols = "0123456789!@*()-=+\";:?/.,";
|
|
4537
|
-
|
|
4538
|
-
for (var _i = 0; _i < textSymbols.length; _i++) {
|
|
4539
|
-
var _ch = textSymbols.charAt(_i);
|
|
4540
|
-
|
|
4541
|
-
defineSymbol(symbols_text, main, textord, _ch, _ch);
|
|
4542
|
-
} // All of these are textords in text mode, and mathords in math mode
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
4546
|
-
|
|
4547
|
-
for (var _i2 = 0; _i2 < letters.length; _i2++) {
|
|
4548
|
-
var _ch2 = letters.charAt(_i2);
|
|
4549
|
-
|
|
4550
|
-
defineSymbol(math, main, mathord, _ch2, _ch2);
|
|
4551
|
-
defineSymbol(symbols_text, main, textord, _ch2, _ch2);
|
|
4552
|
-
} // Blackboard bold and script letters in Unicode range
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
|
|
4556
|
-
|
|
4557
|
-
defineSymbol(symbols_text, ams, textord, "C", "\u2102");
|
|
4558
|
-
defineSymbol(math, ams, textord, "H", "\u210D");
|
|
4559
|
-
defineSymbol(symbols_text, ams, textord, "H", "\u210D");
|
|
4560
|
-
defineSymbol(math, ams, textord, "N", "\u2115");
|
|
4561
|
-
defineSymbol(symbols_text, ams, textord, "N", "\u2115");
|
|
4562
|
-
defineSymbol(math, ams, textord, "P", "\u2119");
|
|
4563
|
-
defineSymbol(symbols_text, ams, textord, "P", "\u2119");
|
|
4564
|
-
defineSymbol(math, ams, textord, "Q", "\u211A");
|
|
4565
|
-
defineSymbol(symbols_text, ams, textord, "Q", "\u211A");
|
|
4566
|
-
defineSymbol(math, ams, textord, "R", "\u211D");
|
|
4567
|
-
defineSymbol(symbols_text, ams, textord, "R", "\u211D");
|
|
4568
|
-
defineSymbol(math, ams, textord, "Z", "\u2124");
|
|
4569
|
-
defineSymbol(symbols_text, ams, textord, "Z", "\u2124");
|
|
4570
|
-
defineSymbol(math, main, mathord, "h", "\u210E"); // italic h, Planck constant
|
|
4571
|
-
|
|
4572
|
-
defineSymbol(symbols_text, main, mathord, "h", "\u210E"); // The next loop loads wide (surrogate pair) characters.
|
|
4573
|
-
// We support some letters in the Unicode range U+1D400 to U+1D7FF,
|
|
4574
|
-
// Mathematical Alphanumeric Symbols.
|
|
4575
|
-
// Some editors do not deal well with wide characters. So don't write the
|
|
4576
|
-
// string into this file. Instead, create the string from the surrogate pair.
|
|
4577
|
-
|
|
4578
|
-
var wideChar = "";
|
|
4579
|
-
|
|
4580
|
-
for (var _i3 = 0; _i3 < letters.length; _i3++) {
|
|
4581
|
-
var _ch3 = letters.charAt(_i3); // The hex numbers in the next line are a surrogate pair.
|
|
4582
|
-
// 0xD835 is the high surrogate for all letters in the range we support.
|
|
4583
|
-
// 0xDC00 is the low surrogate for bold A.
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
|
|
4587
|
-
|
|
4588
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4589
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4590
|
-
wideChar = String.fromCharCode(0xD835, 0xDC34 + _i3); // A-Z a-z italic
|
|
4591
|
-
|
|
4592
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4593
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4594
|
-
wideChar = String.fromCharCode(0xD835, 0xDC68 + _i3); // A-Z a-z bold italic
|
|
4595
|
-
|
|
4596
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4597
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4598
|
-
wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur
|
|
4599
|
-
|
|
4600
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4601
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4602
|
-
wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif
|
|
4603
|
-
|
|
4604
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4605
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4606
|
-
wideChar = String.fromCharCode(0xD835, 0xDDD4 + _i3); // A-Z a-z sans bold
|
|
4607
|
-
|
|
4608
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4609
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4610
|
-
wideChar = String.fromCharCode(0xD835, 0xDE08 + _i3); // A-Z a-z sans italic
|
|
4611
|
-
|
|
4612
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4613
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4614
|
-
wideChar = String.fromCharCode(0xD835, 0xDE70 + _i3); // A-Z a-z monospace
|
|
4615
|
-
|
|
4616
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4617
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4618
|
-
|
|
4619
|
-
if (_i3 < 26) {
|
|
4620
|
-
// KaTeX fonts have only capital letters for blackboard bold and script.
|
|
4621
|
-
// See exception for k below.
|
|
4622
|
-
wideChar = String.fromCharCode(0xD835, 0xDD38 + _i3); // A-Z double struck
|
|
4623
|
-
|
|
4624
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4625
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4626
|
-
wideChar = String.fromCharCode(0xD835, 0xDC9C + _i3); // A-Z script
|
|
4627
|
-
|
|
4628
|
-
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
4629
|
-
defineSymbol(symbols_text, main, textord, _ch3, wideChar);
|
|
4630
|
-
} // TODO: Add bold script when it is supported by a KaTeX font.
|
|
4631
|
-
|
|
4632
|
-
} // "k" is the only double struck lower case letter in the KaTeX fonts.
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
|
|
4636
|
-
|
|
4637
|
-
defineSymbol(math, main, mathord, "k", wideChar);
|
|
4638
|
-
defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals
|
|
4639
|
-
|
|
4640
|
-
for (var _i4 = 0; _i4 < 10; _i4++) {
|
|
4641
|
-
var _ch4 = _i4.toString();
|
|
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
|
|
4642
4880
|
|
|
4643
|
-
|
|
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
|
|
4644
4892
|
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
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
|
|
4648
4907
|
|
|
4649
|
-
|
|
4650
|
-
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
4651
|
-
wideChar = String.fromCharCode(0xD835, 0xDFEC + _i4); // 0-9 bold sans
|
|
4908
|
+
defineSymbol(symbols_text, main, accent, "\u02CB", "\\`"); // grave
|
|
4652
4909
|
|
|
4653
|
-
|
|
4654
|
-
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
4655
|
-
wideChar = String.fromCharCode(0xD835, 0xDFF6 + _i4); // 0-9 monospace
|
|
4910
|
+
defineSymbol(symbols_text, main, accent, "\u02C6", "\\^"); // circumflex
|
|
4656
4911
|
|
|
4657
|
-
|
|
4658
|
-
defineSymbol(symbols_text, main, textord, _ch4, wideChar);
|
|
4659
|
-
} // We add these Latin-1 letters as symbols for backwards-compatibility,
|
|
4660
|
-
// but they are not actually in the font, nor are they supported by the
|
|
4661
|
-
// Unicode accent mechanism, so they fall back to Times font and look ugly.
|
|
4662
|
-
// TODO(edemaine): Fix this.
|
|
4912
|
+
defineSymbol(symbols_text, main, accent, "\u02DC", "\\~"); // tilde
|
|
4663
4913
|
|
|
4914
|
+
defineSymbol(symbols_text, main, accent, "\u02C9", "\\="); // macron
|
|
4664
4915
|
|
|
4665
|
-
|
|
4916
|
+
defineSymbol(symbols_text, main, accent, "\u02D8", "\\u"); // breve
|
|
4666
4917
|
|
|
4667
|
-
|
|
4668
|
-
var _ch5 = extraLatin.charAt(_i5);
|
|
4918
|
+
defineSymbol(symbols_text, main, accent, "\u02D9", "\\."); // dot above
|
|
4669
4919
|
|
|
4670
|
-
|
|
4671
|
-
defineSymbol(symbols_text, main, textord, _ch5, _ch5);
|
|
4672
|
-
}
|
|
4673
|
-
;// CONCATENATED MODULE: ./src/wide-character.js
|
|
4674
|
-
/**
|
|
4675
|
-
* This file provides support for Unicode range U+1D400 to U+1D7FF,
|
|
4676
|
-
* Mathematical Alphanumeric Symbols.
|
|
4677
|
-
*
|
|
4678
|
-
* Function wideCharacterFont takes a wide character as input and returns
|
|
4679
|
-
* the font information necessary to render it properly.
|
|
4680
|
-
*/
|
|
4920
|
+
defineSymbol(symbols_text, main, accent, "\xB8", "\\c"); // cedilla
|
|
4681
4921
|
|
|
4682
|
-
|
|
4683
|
-
* Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
4684
|
-
* That document sorts characters into groups by font type, say bold or italic.
|
|
4685
|
-
*
|
|
4686
|
-
* In the arrays below, each subarray consists three elements:
|
|
4687
|
-
* * The CSS class of that group when in math mode.
|
|
4688
|
-
* * The CSS class of that group when in text mode.
|
|
4689
|
-
* * The font name, so that KaTeX can get font metrics.
|
|
4690
|
-
*/
|
|
4922
|
+
defineSymbol(symbols_text, main, accent, "\u02DA", "\\r"); // ring above
|
|
4691
4923
|
|
|
4692
|
-
|
|
4693
|
-
["mathbf", "textbf", "Main-Bold"], // a-z bold upright
|
|
4694
|
-
["mathnormal", "textit", "Math-Italic"], // A-Z italic
|
|
4695
|
-
["mathnormal", "textit", "Math-Italic"], // a-z italic
|
|
4696
|
-
["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic
|
|
4697
|
-
["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic
|
|
4698
|
-
// Map fancy A-Z letters to script, not calligraphic.
|
|
4699
|
-
// This aligns with unicode-math and math fonts (except Cambria Math).
|
|
4700
|
-
["mathscr", "textscr", "Script-Regular"], // A-Z script
|
|
4701
|
-
["", "", ""], // a-z script. No font
|
|
4702
|
-
["", "", ""], // A-Z bold script. No font
|
|
4703
|
-
["", "", ""], // a-z bold script. No font
|
|
4704
|
-
["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur
|
|
4705
|
-
["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur
|
|
4706
|
-
["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
|
|
4707
|
-
["mathbb", "textbb", "AMS-Regular"], // k double-struck
|
|
4708
|
-
["", "", ""], // A-Z bold Fraktur No font metrics
|
|
4709
|
-
["", "", ""], // a-z bold Fraktur. No font.
|
|
4710
|
-
["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
|
|
4711
|
-
["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
|
|
4712
|
-
["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif
|
|
4713
|
-
["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif
|
|
4714
|
-
["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif
|
|
4715
|
-
["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif
|
|
4716
|
-
["", "", ""], // A-Z bold italic sans. No font
|
|
4717
|
-
["", "", ""], // a-z bold italic sans. No font
|
|
4718
|
-
["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace
|
|
4719
|
-
["mathtt", "texttt", "Typewriter-Regular"] // a-z monospace
|
|
4720
|
-
];
|
|
4721
|
-
var wideNumeralData = [["mathbf", "textbf", "Main-Bold"], // 0-9 bold
|
|
4722
|
-
["", "", ""], // 0-9 double-struck. No KaTeX font.
|
|
4723
|
-
["mathsf", "textsf", "SansSerif-Regular"], // 0-9 sans-serif
|
|
4724
|
-
["mathboldsf", "textboldsf", "SansSerif-Bold"], // 0-9 bold sans-serif
|
|
4725
|
-
["mathtt", "texttt", "Typewriter-Regular"] // 0-9 monospace
|
|
4726
|
-
];
|
|
4727
|
-
var wideCharacterFont = function wideCharacterFont(wideChar, mode) {
|
|
4728
|
-
// IE doesn't support codePointAt(). So work with the surrogate pair.
|
|
4729
|
-
var H = wideChar.charCodeAt(0); // high surrogate
|
|
4924
|
+
defineSymbol(symbols_text, main, accent, "\u02C7", "\\v"); // caron
|
|
4730
4925
|
|
|
4731
|
-
|
|
4926
|
+
defineSymbol(symbols_text, main, accent, "\xA8", '\\"'); // diaresis
|
|
4732
4927
|
|
|
4733
|
-
|
|
4734
|
-
var j = mode === "math" ? 0 : 1; // column index for CSS class.
|
|
4928
|
+
defineSymbol(symbols_text, main, accent, "\u02DD", "\\H"); // double acute
|
|
4735
4929
|
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
// So we can calculate the relevant row. No traverse necessary.
|
|
4739
|
-
var i = Math.floor((codePoint - 0x1D400) / 26);
|
|
4740
|
-
return [wideLatinLetterData[i][2], wideLatinLetterData[i][j]];
|
|
4741
|
-
} else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) {
|
|
4742
|
-
// Numerals, ten per row.
|
|
4743
|
-
var _i = Math.floor((codePoint - 0x1D7CE) / 10);
|
|
4930
|
+
defineSymbol(symbols_text, main, accent, "\u25EF", "\\textcircled"); // \bigcirc glyph
|
|
4931
|
+
// These ligatures are detected and created in Parser.js's `formLigatures`.
|
|
4744
4932
|
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
// Greek letters. Not supported, yet.
|
|
4751
|
-
return ["", ""];
|
|
4752
|
-
} else {
|
|
4753
|
-
// We don't support any wide characters outside 1D400–1D7FF.
|
|
4754
|
-
throw new src_ParseError("Unsupported character: " + wideChar);
|
|
4755
|
-
}
|
|
4933
|
+
var ligatures = {
|
|
4934
|
+
"--": true,
|
|
4935
|
+
"---": true,
|
|
4936
|
+
"``": true,
|
|
4937
|
+
"''": true
|
|
4756
4938
|
};
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
[3, 1, 1], // size3: [7, 5, 5] \scriptsize
|
|
4770
|
-
[4, 2, 1], // size4: [8, 6, 5] \footnotesize
|
|
4771
|
-
[5, 2, 1], // size5: [9, 6, 5] \small
|
|
4772
|
-
[6, 3, 1], // size6: [10, 7, 5] \normalsize
|
|
4773
|
-
[7, 4, 2], // size7: [12, 8, 6] \large
|
|
4774
|
-
[8, 6, 3], // size8: [14.4, 10, 7] \Large
|
|
4775
|
-
[9, 7, 6], // size9: [17.28, 12, 10] \LARGE
|
|
4776
|
-
[10, 8, 7], // size10: [20.74, 14.4, 12] \huge
|
|
4777
|
-
[11, 10, 9] // size11: [24.88, 20.74, 17.28] \HUGE
|
|
4778
|
-
];
|
|
4779
|
-
var sizeMultipliers = [// fontMetrics.js:getGlobalMetrics also uses size indexes, so if
|
|
4780
|
-
// you change size indexes, change that function.
|
|
4781
|
-
0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
|
|
4782
|
-
|
|
4783
|
-
var sizeAtStyle = function sizeAtStyle(size, style) {
|
|
4784
|
-
return style.size < 2 ? size : sizeStyleMap[size - 1][style.size - 1];
|
|
4785
|
-
}; // In these types, "" (empty string) means "no change".
|
|
4786
|
-
|
|
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
|
|
4787
4951
|
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
* and font.
|
|
4791
|
-
*
|
|
4792
|
-
* Options objects should not be modified. To create a new Options with
|
|
4793
|
-
* different properties, call a `.having*` method.
|
|
4794
|
-
*/
|
|
4795
|
-
var Options = /*#__PURE__*/function () {
|
|
4796
|
-
// A font family applies to a group of fonts (i.e. SansSerif), while a font
|
|
4797
|
-
// represents a specific font (i.e. SansSerif Bold).
|
|
4798
|
-
// See: https://tex.stackexchange.com/questions/22350/difference-between-textrm-and-mathrm
|
|
4952
|
+
defineSymbol(math, main, textord, "\xB0", "\\degree", true);
|
|
4953
|
+
defineSymbol(symbols_text, main, textord, "\xB0", "\\degree"); // \textdegree from inputenc package
|
|
4799
4954
|
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
*/
|
|
4803
|
-
function Options(data) {
|
|
4804
|
-
this.style = void 0;
|
|
4805
|
-
this.color = void 0;
|
|
4806
|
-
this.size = void 0;
|
|
4807
|
-
this.textSize = void 0;
|
|
4808
|
-
this.phantom = void 0;
|
|
4809
|
-
this.font = void 0;
|
|
4810
|
-
this.fontFamily = void 0;
|
|
4811
|
-
this.fontWeight = void 0;
|
|
4812
|
-
this.fontShape = void 0;
|
|
4813
|
-
this.sizeMultiplier = void 0;
|
|
4814
|
-
this.maxSize = void 0;
|
|
4815
|
-
this.minRuleThickness = void 0;
|
|
4816
|
-
this._fontMetrics = void 0;
|
|
4817
|
-
this.style = data.style;
|
|
4818
|
-
this.color = data.color;
|
|
4819
|
-
this.size = data.size || Options.BASESIZE;
|
|
4820
|
-
this.textSize = data.textSize || this.size;
|
|
4821
|
-
this.phantom = !!data.phantom;
|
|
4822
|
-
this.font = data.font || "";
|
|
4823
|
-
this.fontFamily = data.fontFamily || "";
|
|
4824
|
-
this.fontWeight = data.fontWeight || '';
|
|
4825
|
-
this.fontShape = data.fontShape || '';
|
|
4826
|
-
this.sizeMultiplier = sizeMultipliers[this.size - 1];
|
|
4827
|
-
this.maxSize = data.maxSize;
|
|
4828
|
-
this.minRuleThickness = data.minRuleThickness;
|
|
4829
|
-
this._fontMetrics = undefined;
|
|
4830
|
-
}
|
|
4831
|
-
/**
|
|
4832
|
-
* Returns a new options object with the same properties as "this". Properties
|
|
4833
|
-
* from "extension" will be copied to the new options object.
|
|
4834
|
-
*/
|
|
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".
|
|
4835
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
|
|
4836
4965
|
|
|
4837
|
-
|
|
4966
|
+
var mathTextSymbols = "0123456789/@.\"";
|
|
4838
4967
|
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
textSize: this.textSize,
|
|
4844
|
-
color: this.color,
|
|
4845
|
-
phantom: this.phantom,
|
|
4846
|
-
font: this.font,
|
|
4847
|
-
fontFamily: this.fontFamily,
|
|
4848
|
-
fontWeight: this.fontWeight,
|
|
4849
|
-
fontShape: this.fontShape,
|
|
4850
|
-
maxSize: this.maxSize,
|
|
4851
|
-
minRuleThickness: this.minRuleThickness
|
|
4852
|
-
};
|
|
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
|
|
4853
4972
|
|
|
4854
|
-
for (var key in extension) {
|
|
4855
|
-
if (extension.hasOwnProperty(key)) {
|
|
4856
|
-
data[key] = extension[key];
|
|
4857
|
-
}
|
|
4858
|
-
}
|
|
4859
4973
|
|
|
4860
|
-
|
|
4861
|
-
}
|
|
4862
|
-
/**
|
|
4863
|
-
* Return an options object with the given style. If `this.style === style`,
|
|
4864
|
-
* returns `this`.
|
|
4865
|
-
*/
|
|
4866
|
-
;
|
|
4974
|
+
var textSymbols = "0123456789!@*()-=+\";:?/.,";
|
|
4867
4975
|
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
return this;
|
|
4871
|
-
} else {
|
|
4872
|
-
return this.extend({
|
|
4873
|
-
style: style,
|
|
4874
|
-
size: sizeAtStyle(this.textSize, style)
|
|
4875
|
-
});
|
|
4876
|
-
}
|
|
4877
|
-
}
|
|
4878
|
-
/**
|
|
4879
|
-
* Return an options object with a cramped version of the current style. If
|
|
4880
|
-
* the current style is cramped, returns `this`.
|
|
4881
|
-
*/
|
|
4882
|
-
;
|
|
4976
|
+
for (var _i = 0; _i < textSymbols.length; _i++) {
|
|
4977
|
+
var _ch = textSymbols.charAt(_i);
|
|
4883
4978
|
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
}
|
|
4887
|
-
/**
|
|
4888
|
-
* Return an options object with the given size and in at least `\textstyle`.
|
|
4889
|
-
* Returns `this` if appropriate.
|
|
4890
|
-
*/
|
|
4891
|
-
;
|
|
4979
|
+
defineSymbol(symbols_text, main, textord, _ch, _ch);
|
|
4980
|
+
} // All of these are textords in text mode, and mathords in math mode
|
|
4892
4981
|
|
|
4893
|
-
_proto.havingSize = function havingSize(size) {
|
|
4894
|
-
if (this.size === size && this.textSize === size) {
|
|
4895
|
-
return this;
|
|
4896
|
-
} else {
|
|
4897
|
-
return this.extend({
|
|
4898
|
-
style: this.style.text(),
|
|
4899
|
-
size: size,
|
|
4900
|
-
textSize: size,
|
|
4901
|
-
sizeMultiplier: sizeMultipliers[size - 1]
|
|
4902
|
-
});
|
|
4903
|
-
}
|
|
4904
|
-
}
|
|
4905
|
-
/**
|
|
4906
|
-
* Like `this.havingSize(BASESIZE).havingStyle(style)`. If `style` is omitted,
|
|
4907
|
-
* changes to at least `\textstyle`.
|
|
4908
|
-
*/
|
|
4909
|
-
;
|
|
4910
4982
|
|
|
4911
|
-
|
|
4912
|
-
style = style || this.style.text();
|
|
4913
|
-
var wantSize = sizeAtStyle(Options.BASESIZE, style);
|
|
4983
|
+
var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
4914
4984
|
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
} else {
|
|
4918
|
-
return this.extend({
|
|
4919
|
-
style: style,
|
|
4920
|
-
size: wantSize
|
|
4921
|
-
});
|
|
4922
|
-
}
|
|
4923
|
-
}
|
|
4924
|
-
/**
|
|
4925
|
-
* Remove the effect of sizing changes such as \Huge.
|
|
4926
|
-
* Keep the effect of the current style, such as \scriptstyle.
|
|
4927
|
-
*/
|
|
4928
|
-
;
|
|
4985
|
+
for (var _i2 = 0; _i2 < letters.length; _i2++) {
|
|
4986
|
+
var _ch2 = letters.charAt(_i2);
|
|
4929
4987
|
|
|
4930
|
-
|
|
4931
|
-
|
|
4988
|
+
defineSymbol(math, main, mathord, _ch2, _ch2);
|
|
4989
|
+
defineSymbol(symbols_text, main, textord, _ch2, _ch2);
|
|
4990
|
+
} // Blackboard bold and script letters in Unicode range
|
|
4932
4991
|
|
|
4933
|
-
switch (this.style.id) {
|
|
4934
|
-
case 4:
|
|
4935
|
-
case 5:
|
|
4936
|
-
size = 3; // normalsize in scriptstyle
|
|
4937
4992
|
|
|
4938
|
-
|
|
4993
|
+
defineSymbol(math, ams, textord, "C", "\u2102"); // blackboard bold
|
|
4939
4994
|
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
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
|
|
4943
5009
|
|
|
4944
|
-
|
|
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.
|
|
4945
5015
|
|
|
4946
|
-
|
|
4947
|
-
size = 6;
|
|
4948
|
-
// normalsize in textstyle or displaystyle
|
|
4949
|
-
}
|
|
5016
|
+
var wideChar = "";
|
|
4950
5017
|
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
}
|
|
4956
|
-
/**
|
|
4957
|
-
* Create a new options object with the given color.
|
|
4958
|
-
*/
|
|
4959
|
-
;
|
|
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.
|
|
4960
5022
|
|
|
4961
|
-
_proto.withColor = function withColor(color) {
|
|
4962
|
-
return this.extend({
|
|
4963
|
-
color: color
|
|
4964
|
-
});
|
|
4965
|
-
}
|
|
4966
|
-
/**
|
|
4967
|
-
* Create a new options object with "phantom" set to true.
|
|
4968
|
-
*/
|
|
4969
|
-
;
|
|
4970
5023
|
|
|
4971
|
-
|
|
4972
|
-
return this.extend({
|
|
4973
|
-
phantom: true
|
|
4974
|
-
});
|
|
4975
|
-
}
|
|
4976
|
-
/**
|
|
4977
|
-
* Creates a new options object with the given math font or old text font.
|
|
4978
|
-
* @type {[type]}
|
|
4979
|
-
*/
|
|
4980
|
-
;
|
|
5024
|
+
wideChar = String.fromCharCode(0xD835, 0xDC00 + _i3); // A-Z a-z bold
|
|
4981
5025
|
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
});
|
|
4986
|
-
}
|
|
4987
|
-
/**
|
|
4988
|
-
* Create a new options objects with the given fontFamily.
|
|
4989
|
-
*/
|
|
4990
|
-
;
|
|
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
|
|
4991
5029
|
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
font: ""
|
|
4996
|
-
});
|
|
4997
|
-
}
|
|
4998
|
-
/**
|
|
4999
|
-
* Creates a new options object with the given font weight
|
|
5000
|
-
*/
|
|
5001
|
-
;
|
|
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
|
|
5002
5033
|
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
font: ""
|
|
5007
|
-
});
|
|
5008
|
-
}
|
|
5009
|
-
/**
|
|
5010
|
-
* Creates a new options object with the given font weight
|
|
5011
|
-
*/
|
|
5012
|
-
;
|
|
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
|
|
5013
5037
|
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
;
|
|
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.
|
|
5025
5069
|
|
|
5026
|
-
|
|
5027
|
-
if (oldOptions.size !== this.size) {
|
|
5028
|
-
return ["sizing", "reset-size" + oldOptions.size, "size" + this.size];
|
|
5029
|
-
} else {
|
|
5030
|
-
return [];
|
|
5031
|
-
}
|
|
5032
|
-
}
|
|
5033
|
-
/**
|
|
5034
|
-
* Return the CSS sizing classes required to switch to the base size. Like
|
|
5035
|
-
* `this.havingSize(BASESIZE).sizingClasses(this)`.
|
|
5036
|
-
*/
|
|
5037
|
-
;
|
|
5070
|
+
} // "k" is the only double struck lower case letter in the KaTeX fonts.
|
|
5038
5071
|
|
|
5039
|
-
_proto.baseSizingClasses = function baseSizingClasses() {
|
|
5040
|
-
if (this.size !== Options.BASESIZE) {
|
|
5041
|
-
return ["sizing", "reset-size" + this.size, "size" + Options.BASESIZE];
|
|
5042
|
-
} else {
|
|
5043
|
-
return [];
|
|
5044
|
-
}
|
|
5045
|
-
}
|
|
5046
|
-
/**
|
|
5047
|
-
* Return the font metrics for this size.
|
|
5048
|
-
*/
|
|
5049
|
-
;
|
|
5050
5072
|
|
|
5051
|
-
|
|
5052
|
-
if (!this._fontMetrics) {
|
|
5053
|
-
this._fontMetrics = getGlobalMetrics(this.size);
|
|
5054
|
-
}
|
|
5073
|
+
wideChar = String.fromCharCode(0xD835, 0xDD5C); // k double struck
|
|
5055
5074
|
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
/**
|
|
5059
|
-
* Gets the CSS color of the current options object
|
|
5060
|
-
*/
|
|
5061
|
-
;
|
|
5075
|
+
defineSymbol(math, main, mathord, "k", wideChar);
|
|
5076
|
+
defineSymbol(symbols_text, main, textord, "k", wideChar); // Next, some wide character numerals
|
|
5062
5077
|
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
return "transparent";
|
|
5066
|
-
} else {
|
|
5067
|
-
return this.color;
|
|
5068
|
-
}
|
|
5069
|
-
};
|
|
5078
|
+
for (var _i4 = 0; _i4 < 10; _i4++) {
|
|
5079
|
+
var _ch4 = _i4.toString();
|
|
5070
5080
|
|
|
5071
|
-
|
|
5072
|
-
}();
|
|
5081
|
+
wideChar = String.fromCharCode(0xD835, 0xDFCE + _i4); // 0-9 bold
|
|
5073
5082
|
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
/**
|
|
5078
|
-
* This file does conversion between units. In particular, it provides
|
|
5079
|
-
* calculateSize to convert other units into ems.
|
|
5080
|
-
*/
|
|
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
|
|
5081
5086
|
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
// *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
|
|
5086
5090
|
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
//
|
|
5090
|
-
"pt": 1,
|
|
5091
|
-
// TeX point
|
|
5092
|
-
"mm": 7227 / 2540,
|
|
5093
|
-
// millimeter
|
|
5094
|
-
"cm": 7227 / 254,
|
|
5095
|
-
// centimeter
|
|
5096
|
-
"in": 72.27,
|
|
5097
|
-
// inch
|
|
5098
|
-
"bp": 803 / 800,
|
|
5099
|
-
// big (PostScript) points
|
|
5100
|
-
"pc": 12,
|
|
5101
|
-
// pica
|
|
5102
|
-
"dd": 1238 / 1157,
|
|
5103
|
-
// didot
|
|
5104
|
-
"cc": 14856 / 1157,
|
|
5105
|
-
// cicero (12 didot)
|
|
5106
|
-
"nd": 685 / 642,
|
|
5107
|
-
// new didot
|
|
5108
|
-
"nc": 1370 / 107,
|
|
5109
|
-
// new cicero (12 new didot)
|
|
5110
|
-
"sp": 1 / 65536,
|
|
5111
|
-
// scaled point (TeX's internal smallest unit)
|
|
5112
|
-
// https://tex.stackexchange.com/a/41371
|
|
5113
|
-
"px": 803 / 800 // \pdfpxdimen defaults to 1 bp in pdfTeX and LuaTeX
|
|
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
|
|
5114
5094
|
|
|
5115
|
-
|
|
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.
|
|
5116
5101
|
|
|
5117
|
-
var relativeUnit = {
|
|
5118
|
-
"ex": true,
|
|
5119
|
-
"em": true,
|
|
5120
|
-
"mu": true
|
|
5121
|
-
};
|
|
5122
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
|
|
5123
5112
|
/**
|
|
5124
|
-
*
|
|
5125
|
-
*
|
|
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.
|
|
5126
5118
|
*/
|
|
5127
|
-
var validUnit = function validUnit(unit) {
|
|
5128
|
-
if (typeof unit !== "string") {
|
|
5129
|
-
unit = unit.unit;
|
|
5130
|
-
}
|
|
5131
5119
|
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
*
|
|
5136
|
-
*
|
|
5137
|
-
*
|
|
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.
|
|
5138
5128
|
*/
|
|
5139
5129
|
|
|
5140
|
-
var
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
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
|
|
5155
5168
|
|
|
5156
|
-
|
|
5157
|
-
// isTight() means current style is script/scriptscript.
|
|
5158
|
-
unitOptions = options.havingStyle(options.style.text());
|
|
5159
|
-
} else {
|
|
5160
|
-
unitOptions = options;
|
|
5161
|
-
} // TODO: In TeX these units are relative to the quad of the current
|
|
5162
|
-
// *text* font, e.g. cmr10. KaTeX instead uses values from the
|
|
5163
|
-
// comparably-sized *Computer Modern symbol* font. At 10pt, these
|
|
5164
|
-
// match. At 7pt and 5pt, they differ: cmr7=1.138894, cmsy7=1.170641;
|
|
5165
|
-
// cmr5=1.361133, cmsy5=1.472241. Consider $\scriptsize a\kern1emb$.
|
|
5166
|
-
// TeX \showlists shows a kern of 1.13889 * fontsize;
|
|
5167
|
-
// KaTeX shows a kern of 1.171 * fontsize.
|
|
5169
|
+
var L = wideChar.charCodeAt(1); // low surrogate
|
|
5168
5170
|
|
|
5171
|
+
var codePoint = (H - 0xD800) * 0x400 + (L - 0xDC00) + 0x10000;
|
|
5172
|
+
var j = mode === "math" ? 0 : 1; // column index for CSS class.
|
|
5169
5173
|
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
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);
|
|
5177
5182
|
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
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);
|
|
5181
5193
|
}
|
|
5182
|
-
|
|
5183
|
-
return Math.min(sizeValue.number * scale, options.maxSize);
|
|
5184
5194
|
};
|
|
5185
5195
|
;// CONCATENATED MODULE: ./src/buildCommon.js
|
|
5186
5196
|
/* eslint no-console:0 */
|
|
@@ -5501,7 +5511,7 @@ var makeSvgSpan = function makeSvgSpan(classes, children, options, style) {
|
|
|
5501
5511
|
var makeLineSpan = function makeLineSpan(className, options, thickness) {
|
|
5502
5512
|
var line = makeSpan([className], [], options);
|
|
5503
5513
|
line.height = Math.max(thickness || options.fontMetrics().defaultRuleThickness, options.minRuleThickness);
|
|
5504
|
-
line.style.borderBottomWidth = line.height
|
|
5514
|
+
line.style.borderBottomWidth = makeEm(line.height);
|
|
5505
5515
|
line.maxFontSize = 1.0;
|
|
5506
5516
|
return line;
|
|
5507
5517
|
};
|
|
@@ -5641,7 +5651,7 @@ var makeVList = function makeVList(params, options) {
|
|
|
5641
5651
|
|
|
5642
5652
|
pstrutSize += 2;
|
|
5643
5653
|
var pstrut = makeSpan(["pstrut"], []);
|
|
5644
|
-
pstrut.style.height = pstrutSize
|
|
5654
|
+
pstrut.style.height = makeEm(pstrutSize); // Create a new list of actual children at the correct offsets
|
|
5645
5655
|
|
|
5646
5656
|
var realChildren = [];
|
|
5647
5657
|
var minPos = depth;
|
|
@@ -5658,7 +5668,7 @@ var makeVList = function makeVList(params, options) {
|
|
|
5658
5668
|
var classes = _child.wrapperClasses || [];
|
|
5659
5669
|
var style = _child.wrapperStyle || {};
|
|
5660
5670
|
var childWrap = makeSpan(classes, [pstrut, _elem], undefined, style);
|
|
5661
|
-
childWrap.style.top = -pstrutSize - currPos - _elem.depth
|
|
5671
|
+
childWrap.style.top = makeEm(-pstrutSize - currPos - _elem.depth);
|
|
5662
5672
|
|
|
5663
5673
|
if (_child.marginLeft) {
|
|
5664
5674
|
childWrap.style.marginLeft = _child.marginLeft;
|
|
@@ -5680,7 +5690,7 @@ var makeVList = function makeVList(params, options) {
|
|
|
5680
5690
|
|
|
5681
5691
|
|
|
5682
5692
|
var vlist = makeSpan(["vlist"], realChildren);
|
|
5683
|
-
vlist.style.height = maxPos
|
|
5693
|
+
vlist.style.height = makeEm(maxPos); // A second row is used if necessary to represent the vlist's depth.
|
|
5684
5694
|
|
|
5685
5695
|
var rows;
|
|
5686
5696
|
|
|
@@ -5692,7 +5702,7 @@ var makeVList = function makeVList(params, options) {
|
|
|
5692
5702
|
// So we put another empty span inside the depth strut span.
|
|
5693
5703
|
var emptySpan = makeSpan([], []);
|
|
5694
5704
|
var depthStrut = makeSpan(["vlist"], [emptySpan]);
|
|
5695
|
-
depthStrut.style.height = -minPos
|
|
5705
|
+
depthStrut.style.height = makeEm(-minPos); // Safari wants the first row to have inline content; otherwise it
|
|
5696
5706
|
// puts the bottom of the *second* row on the baseline.
|
|
5697
5707
|
|
|
5698
5708
|
var topStrut = makeSpan(["vlist-s"], [new SymbolNode("\u200B")]);
|
|
@@ -5719,7 +5729,7 @@ var makeGlue = function makeGlue(measurement, options) {
|
|
|
5719
5729
|
// Make an empty span for the space
|
|
5720
5730
|
var rule = makeSpan(["mspace"], [], options);
|
|
5721
5731
|
var size = calculateSize(measurement, options);
|
|
5722
|
-
rule.style.marginRight = size
|
|
5732
|
+
rule.style.marginRight = makeEm(size);
|
|
5723
5733
|
return rule;
|
|
5724
5734
|
}; // Takes font options, and returns the appropriate fontLookup name
|
|
5725
5735
|
|
|
@@ -5841,17 +5851,17 @@ var staticSvg = function staticSvg(value, options) {
|
|
|
5841
5851
|
height = _svgData$value[2];
|
|
5842
5852
|
var path = new PathNode(pathName);
|
|
5843
5853
|
var svgNode = new SvgNode([path], {
|
|
5844
|
-
"width": width
|
|
5845
|
-
"height": height
|
|
5854
|
+
"width": makeEm(width),
|
|
5855
|
+
"height": makeEm(height),
|
|
5846
5856
|
// Override CSS rule `.katex svg { width: 100% }`
|
|
5847
|
-
"style": "width:" + width
|
|
5857
|
+
"style": "width:" + makeEm(width),
|
|
5848
5858
|
"viewBox": "0 0 " + 1000 * width + " " + 1000 * height,
|
|
5849
5859
|
"preserveAspectRatio": "xMinYMin"
|
|
5850
5860
|
});
|
|
5851
5861
|
var span = makeSvgSpan(["overlay"], [svgNode], options);
|
|
5852
5862
|
span.height = height;
|
|
5853
|
-
span.style.height = height
|
|
5854
|
-
span.style.width = width
|
|
5863
|
+
span.style.height = makeEm(height);
|
|
5864
|
+
span.style.width = makeEm(width);
|
|
5855
5865
|
return span;
|
|
5856
5866
|
};
|
|
5857
5867
|
|
|
@@ -6080,6 +6090,7 @@ var ordargument = function ordargument(arg) {
|
|
|
6080
6090
|
|
|
6081
6091
|
|
|
6082
6092
|
|
|
6093
|
+
|
|
6083
6094
|
var buildHTML_makeSpan = buildCommon.makeSpan; // Binary atoms (first class `mbin`) change into ordinary atoms (`mord`)
|
|
6084
6095
|
// depending on their surroundings. See TeXbook pg. 442-446, Rules 5 and 6,
|
|
6085
6096
|
// and the text before Rule 19.
|
|
@@ -6339,10 +6350,10 @@ function buildHTMLUnbreakable(children, options) {
|
|
|
6339
6350
|
// falls at the depth of the expression.
|
|
6340
6351
|
|
|
6341
6352
|
var strut = buildHTML_makeSpan(["strut"]);
|
|
6342
|
-
strut.style.height = body.height + body.depth
|
|
6353
|
+
strut.style.height = makeEm(body.height + body.depth);
|
|
6343
6354
|
|
|
6344
6355
|
if (body.depth) {
|
|
6345
|
-
strut.style.verticalAlign = -body.depth
|
|
6356
|
+
strut.style.verticalAlign = makeEm(-body.depth);
|
|
6346
6357
|
}
|
|
6347
6358
|
|
|
6348
6359
|
body.children.unshift(strut);
|
|
@@ -6438,10 +6449,10 @@ function buildHTML(tree, options) {
|
|
|
6438
6449
|
|
|
6439
6450
|
if (tagChild) {
|
|
6440
6451
|
var strut = tagChild.children[0];
|
|
6441
|
-
strut.style.height = htmlNode.height + htmlNode.depth
|
|
6452
|
+
strut.style.height = makeEm(htmlNode.height + htmlNode.depth);
|
|
6442
6453
|
|
|
6443
6454
|
if (htmlNode.depth) {
|
|
6444
|
-
strut.style.verticalAlign = -htmlNode.depth
|
|
6455
|
+
strut.style.verticalAlign = makeEm(-htmlNode.depth);
|
|
6445
6456
|
}
|
|
6446
6457
|
}
|
|
6447
6458
|
|
|
@@ -6460,6 +6471,7 @@ function buildHTML(tree, options) {
|
|
|
6460
6471
|
|
|
6461
6472
|
|
|
6462
6473
|
|
|
6474
|
+
|
|
6463
6475
|
function newDocumentFragment(children) {
|
|
6464
6476
|
return new DocumentFragment(children);
|
|
6465
6477
|
}
|
|
@@ -6654,7 +6666,7 @@ var SpaceNode = /*#__PURE__*/function () {
|
|
|
6654
6666
|
return document.createTextNode(this.character);
|
|
6655
6667
|
} else {
|
|
6656
6668
|
var node = document.createElementNS("http://www.w3.org/1998/Math/MathML", "mspace");
|
|
6657
|
-
node.setAttribute("width", this.width
|
|
6669
|
+
node.setAttribute("width", makeEm(this.width));
|
|
6658
6670
|
return node;
|
|
6659
6671
|
}
|
|
6660
6672
|
}
|
|
@@ -6667,7 +6679,7 @@ var SpaceNode = /*#__PURE__*/function () {
|
|
|
6667
6679
|
if (this.character) {
|
|
6668
6680
|
return "<mtext>" + this.character + "</mtext>";
|
|
6669
6681
|
} else {
|
|
6670
|
-
return "<mspace width=\"" + this.width + "
|
|
6682
|
+
return "<mspace width=\"" + makeEm(this.width) + "\"/>";
|
|
6671
6683
|
}
|
|
6672
6684
|
}
|
|
6673
6685
|
/**
|
|
@@ -7016,6 +7028,7 @@ var buildHTMLTree = function buildHTMLTree(tree, expression, settings) {
|
|
|
7016
7028
|
|
|
7017
7029
|
|
|
7018
7030
|
|
|
7031
|
+
|
|
7019
7032
|
var stretchyCodePoint = {
|
|
7020
7033
|
widehat: "^",
|
|
7021
7034
|
widecheck: "ˇ",
|
|
@@ -7213,7 +7226,7 @@ var svgSpan = function svgSpan(group, options) {
|
|
|
7213
7226
|
var path = new PathNode(pathName);
|
|
7214
7227
|
var svgNode = new SvgNode([path], {
|
|
7215
7228
|
"width": "100%",
|
|
7216
|
-
"height": _height
|
|
7229
|
+
"height": makeEm(_height),
|
|
7217
7230
|
"viewBox": "0 0 " + viewBoxWidth + " " + viewBoxHeight,
|
|
7218
7231
|
"preserveAspectRatio": "none"
|
|
7219
7232
|
});
|
|
@@ -7255,7 +7268,7 @@ var svgSpan = function svgSpan(group, options) {
|
|
|
7255
7268
|
|
|
7256
7269
|
var _svgNode = new SvgNode([_path], {
|
|
7257
7270
|
"width": "400em",
|
|
7258
|
-
"height": _height2
|
|
7271
|
+
"height": makeEm(_height2),
|
|
7259
7272
|
"viewBox": "0 0 " + viewBoxWidth + " " + _viewBoxHeight,
|
|
7260
7273
|
"preserveAspectRatio": aligns[i] + " slice"
|
|
7261
7274
|
});
|
|
@@ -7269,7 +7282,7 @@ var svgSpan = function svgSpan(group, options) {
|
|
|
7269
7282
|
height: _height2
|
|
7270
7283
|
};
|
|
7271
7284
|
} else {
|
|
7272
|
-
_span.style.height = _height2
|
|
7285
|
+
_span.style.height = makeEm(_height2);
|
|
7273
7286
|
spans.push(_span);
|
|
7274
7287
|
}
|
|
7275
7288
|
}
|
|
@@ -7291,10 +7304,10 @@ var svgSpan = function svgSpan(group, options) {
|
|
|
7291
7304
|
|
|
7292
7305
|
|
|
7293
7306
|
span.height = height;
|
|
7294
|
-
span.style.height = height
|
|
7307
|
+
span.style.height = makeEm(height);
|
|
7295
7308
|
|
|
7296
7309
|
if (minWidth > 0) {
|
|
7297
|
-
span.style.minWidth = minWidth
|
|
7310
|
+
span.style.minWidth = makeEm(minWidth);
|
|
7298
7311
|
}
|
|
7299
7312
|
|
|
7300
7313
|
return span;
|
|
@@ -7343,13 +7356,13 @@ var encloseSpan = function encloseSpan(inner, label, topPad, bottomPad, options)
|
|
|
7343
7356
|
|
|
7344
7357
|
var svgNode = new SvgNode(lines, {
|
|
7345
7358
|
"width": "100%",
|
|
7346
|
-
"height": totalHeight
|
|
7359
|
+
"height": makeEm(totalHeight)
|
|
7347
7360
|
});
|
|
7348
7361
|
img = buildCommon.makeSvgSpan([], [svgNode], options);
|
|
7349
7362
|
}
|
|
7350
7363
|
|
|
7351
7364
|
img.height = totalHeight;
|
|
7352
|
-
img.style.height = totalHeight
|
|
7365
|
+
img.style.height = makeEm(totalHeight);
|
|
7353
7366
|
return img;
|
|
7354
7367
|
};
|
|
7355
7368
|
|
|
@@ -7410,6 +7423,7 @@ function checkSymbolNodeType(node) {
|
|
|
7410
7423
|
|
|
7411
7424
|
|
|
7412
7425
|
|
|
7426
|
+
|
|
7413
7427
|
// NOTE: Unlike most `htmlBuilder`s, this one handles not only "accent", but
|
|
7414
7428
|
// also "supsub" since an accent can affect super/subscripting.
|
|
7415
7429
|
var htmlBuilder = function htmlBuilder(grp, options) {
|
|
@@ -7521,7 +7535,7 @@ var htmlBuilder = function htmlBuilder(grp, options) {
|
|
|
7521
7535
|
left -= width / 2;
|
|
7522
7536
|
}
|
|
7523
7537
|
|
|
7524
|
-
accentBody.style.left = left
|
|
7538
|
+
accentBody.style.left = makeEm(left); // \textcircled uses the \bigcirc glyph, so it needs some
|
|
7525
7539
|
// vertical adjustment to match LaTeX.
|
|
7526
7540
|
|
|
7527
7541
|
if (group.label === "\\textcircled") {
|
|
@@ -7553,8 +7567,8 @@ var htmlBuilder = function htmlBuilder(grp, options) {
|
|
|
7553
7567
|
elem: accentBody,
|
|
7554
7568
|
wrapperClasses: ["svg-align"],
|
|
7555
7569
|
wrapperStyle: skew > 0 ? {
|
|
7556
|
-
width: "calc(100% - " + 2 * skew + "
|
|
7557
|
-
marginLeft: 2 * skew
|
|
7570
|
+
width: "calc(100% - " + makeEm(2 * skew) + ")",
|
|
7571
|
+
marginLeft: makeEm(2 * skew)
|
|
7558
7572
|
} : undefined
|
|
7559
7573
|
}]
|
|
7560
7574
|
}, options);
|
|
@@ -7843,6 +7857,7 @@ defineFunction({
|
|
|
7843
7857
|
|
|
7844
7858
|
|
|
7845
7859
|
|
|
7860
|
+
|
|
7846
7861
|
var cdArrowFunctionName = {
|
|
7847
7862
|
">": "\\\\cdrightarrow",
|
|
7848
7863
|
"<": "\\\\cdleftarrow",
|
|
@@ -8105,7 +8120,7 @@ defineFunction({
|
|
|
8105
8120
|
var newOptions = options.havingStyle(options.style.sup());
|
|
8106
8121
|
var label = buildCommon.wrapFragment(buildGroup(group.label, newOptions, options), options);
|
|
8107
8122
|
label.classes.push("cd-label-" + group.side);
|
|
8108
|
-
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
|
|
8109
8124
|
// by the arrow height, not by the label.
|
|
8110
8125
|
|
|
8111
8126
|
label.height = 0;
|
|
@@ -8316,7 +8331,7 @@ defineFunction({
|
|
|
8316
8331
|
span.classes.push("newline");
|
|
8317
8332
|
|
|
8318
8333
|
if (group.size) {
|
|
8319
|
-
span.style.marginTop = calculateSize(group.size, options)
|
|
8334
|
+
span.style.marginTop = makeEm(calculateSize(group.size, options));
|
|
8320
8335
|
}
|
|
8321
8336
|
}
|
|
8322
8337
|
|
|
@@ -8329,7 +8344,7 @@ defineFunction({
|
|
|
8329
8344
|
node.setAttribute("linebreak", "newline");
|
|
8330
8345
|
|
|
8331
8346
|
if (group.size) {
|
|
8332
|
-
node.setAttribute("height", calculateSize(group.size, options)
|
|
8347
|
+
node.setAttribute("height", makeEm(calculateSize(group.size, options)));
|
|
8333
8348
|
}
|
|
8334
8349
|
}
|
|
8335
8350
|
|
|
@@ -8595,6 +8610,7 @@ defineFunction({
|
|
|
8595
8610
|
|
|
8596
8611
|
|
|
8597
8612
|
|
|
8613
|
+
|
|
8598
8614
|
/**
|
|
8599
8615
|
* Get the metrics for a given symbol and font, after transformation (i.e.
|
|
8600
8616
|
* after following replacement from symbols.js)
|
|
@@ -8629,7 +8645,7 @@ var centerSpan = function centerSpan(span, options, style) {
|
|
|
8629
8645
|
var newOptions = options.havingBaseStyle(style);
|
|
8630
8646
|
var shift = (1 - options.sizeMultiplier / newOptions.sizeMultiplier) * options.fontMetrics().axisHeight;
|
|
8631
8647
|
span.classes.push("delimcenter");
|
|
8632
|
-
span.style.top = shift
|
|
8648
|
+
span.style.top = makeEm(shift);
|
|
8633
8649
|
span.height -= shift;
|
|
8634
8650
|
span.depth += shift;
|
|
8635
8651
|
};
|
|
@@ -8702,20 +8718,20 @@ var makeGlyphSpan = function makeGlyphSpan(symbol, font, mode) {
|
|
|
8702
8718
|
|
|
8703
8719
|
var makeInner = function makeInner(ch, height, options) {
|
|
8704
8720
|
// Create a span with inline SVG for the inner part of a tall stacked delimiter.
|
|
8705
|
-
var width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4]
|
|
8721
|
+
var width = fontMetricsData["Size4-Regular"][ch.charCodeAt(0)] ? fontMetricsData["Size4-Regular"][ch.charCodeAt(0)][4] : fontMetricsData["Size1-Regular"][ch.charCodeAt(0)][4];
|
|
8706
8722
|
var path = new PathNode("inner", innerPath(ch, Math.round(1000 * height)));
|
|
8707
8723
|
var svgNode = new SvgNode([path], {
|
|
8708
|
-
"width": width
|
|
8709
|
-
"height": height
|
|
8724
|
+
"width": makeEm(width),
|
|
8725
|
+
"height": makeEm(height),
|
|
8710
8726
|
// Override CSS rule `.katex svg { width: 100% }`
|
|
8711
|
-
"style": "width:" + width
|
|
8727
|
+
"style": "width:" + makeEm(width),
|
|
8712
8728
|
"viewBox": "0 0 " + 1000 * width + " " + Math.round(1000 * height),
|
|
8713
8729
|
"preserveAspectRatio": "xMinYMin"
|
|
8714
8730
|
});
|
|
8715
8731
|
var span = buildCommon.makeSvgSpan([], [svgNode], options);
|
|
8716
8732
|
span.height = height;
|
|
8717
|
-
span.style.height = height
|
|
8718
|
-
span.style.width = width
|
|
8733
|
+
span.style.height = makeEm(height);
|
|
8734
|
+
span.style.width = makeEm(width);
|
|
8719
8735
|
return {
|
|
8720
8736
|
type: "elem",
|
|
8721
8737
|
elem: span
|
|
@@ -8924,7 +8940,7 @@ var sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum,
|
|
|
8924
8940
|
var svg = new SvgNode([pathNode], {
|
|
8925
8941
|
// Note: 1000:1 ratio of viewBox to document em width.
|
|
8926
8942
|
"width": "400em",
|
|
8927
|
-
"height": height
|
|
8943
|
+
"height": makeEm(height),
|
|
8928
8944
|
"viewBox": "0 0 400000 " + viewBoxHeight,
|
|
8929
8945
|
"preserveAspectRatio": "xMinYMin slice"
|
|
8930
8946
|
});
|
|
@@ -8993,7 +9009,7 @@ var makeSqrtImage = function makeSqrtImage(height, options) {
|
|
|
8993
9009
|
}
|
|
8994
9010
|
|
|
8995
9011
|
span.height = texHeight;
|
|
8996
|
-
span.style.height = spanHeight
|
|
9012
|
+
span.style.height = makeEm(spanHeight);
|
|
8997
9013
|
return {
|
|
8998
9014
|
span: span,
|
|
8999
9015
|
advanceWidth: advanceWidth,
|
|
@@ -9249,6 +9265,7 @@ var makeLeftRightDelim = function makeLeftRightDelim(delim, height, depth, optio
|
|
|
9249
9265
|
|
|
9250
9266
|
|
|
9251
9267
|
|
|
9268
|
+
|
|
9252
9269
|
// Extra data needed for the delimiter handler down below
|
|
9253
9270
|
var delimiterSizes = {
|
|
9254
9271
|
"\\bigl": {
|
|
@@ -9378,8 +9395,9 @@ defineFunction({
|
|
|
9378
9395
|
}
|
|
9379
9396
|
|
|
9380
9397
|
node.setAttribute("stretchy", "true");
|
|
9381
|
-
|
|
9382
|
-
node.setAttribute("
|
|
9398
|
+
var size = makeEm(delimiter.sizeToMaxHeight[group.size]);
|
|
9399
|
+
node.setAttribute("minsize", size);
|
|
9400
|
+
node.setAttribute("maxsize", size);
|
|
9383
9401
|
return node;
|
|
9384
9402
|
}
|
|
9385
9403
|
});
|
|
@@ -9638,19 +9656,19 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
9638
9656
|
scale = scale / newOptions.sizeMultiplier;
|
|
9639
9657
|
var angleHeight = inner.height + inner.depth + lineWeight + clearance; // Reserve a left pad for the angle.
|
|
9640
9658
|
|
|
9641
|
-
inner.style.paddingLeft = angleHeight / 2 + lineWeight
|
|
9659
|
+
inner.style.paddingLeft = makeEm(angleHeight / 2 + lineWeight); // Create an SVG
|
|
9642
9660
|
|
|
9643
9661
|
var viewBoxHeight = Math.floor(1000 * angleHeight * scale);
|
|
9644
9662
|
var path = phasePath(viewBoxHeight);
|
|
9645
9663
|
var svgNode = new SvgNode([new PathNode("phase", path)], {
|
|
9646
9664
|
"width": "400em",
|
|
9647
|
-
"height": viewBoxHeight / 1000
|
|
9665
|
+
"height": makeEm(viewBoxHeight / 1000),
|
|
9648
9666
|
"viewBox": "0 0 400000 " + viewBoxHeight,
|
|
9649
9667
|
"preserveAspectRatio": "xMinYMin slice"
|
|
9650
9668
|
}); // Wrap it in a span with overflow: hidden.
|
|
9651
9669
|
|
|
9652
9670
|
img = buildCommon.makeSvgSpan(["hide-tail"], [svgNode], options);
|
|
9653
|
-
img.style.height = angleHeight
|
|
9671
|
+
img.style.height = makeEm(angleHeight);
|
|
9654
9672
|
imgShift = inner.depth + lineWeight + clearance;
|
|
9655
9673
|
} else {
|
|
9656
9674
|
// Add horizontal padding
|
|
@@ -9689,10 +9707,10 @@ var enclose_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
9689
9707
|
|
|
9690
9708
|
if (/fbox|boxed|fcolorbox/.test(label)) {
|
|
9691
9709
|
img.style.borderStyle = "solid";
|
|
9692
|
-
img.style.borderWidth = ruleThickness
|
|
9710
|
+
img.style.borderWidth = makeEm(ruleThickness);
|
|
9693
9711
|
} else if (label === "angl" && ruleThickness !== 0.049) {
|
|
9694
|
-
img.style.borderTopWidth = ruleThickness
|
|
9695
|
-
img.style.borderRightWidth = ruleThickness
|
|
9712
|
+
img.style.borderTopWidth = makeEm(ruleThickness);
|
|
9713
|
+
img.style.borderRightWidth = makeEm(ruleThickness);
|
|
9696
9714
|
}
|
|
9697
9715
|
|
|
9698
9716
|
imgShift = inner.depth + bottomPad;
|
|
@@ -10309,22 +10327,22 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
10309
10327
|
// between them.
|
|
10310
10328
|
if (!firstSeparator) {
|
|
10311
10329
|
colSep = buildCommon.makeSpan(["arraycolsep"], []);
|
|
10312
|
-
colSep.style.width = options.fontMetrics().doubleRuleSep
|
|
10330
|
+
colSep.style.width = makeEm(options.fontMetrics().doubleRuleSep);
|
|
10313
10331
|
cols.push(colSep);
|
|
10314
10332
|
}
|
|
10315
10333
|
|
|
10316
10334
|
if (colDescr.separator === "|" || colDescr.separator === ":") {
|
|
10317
10335
|
var lineType = colDescr.separator === "|" ? "solid" : "dashed";
|
|
10318
10336
|
var separator = buildCommon.makeSpan(["vertical-separator"], [], options);
|
|
10319
|
-
separator.style.height = totalHeight
|
|
10320
|
-
separator.style.borderRightWidth = ruleThickness
|
|
10337
|
+
separator.style.height = makeEm(totalHeight);
|
|
10338
|
+
separator.style.borderRightWidth = makeEm(ruleThickness);
|
|
10321
10339
|
separator.style.borderRightStyle = lineType;
|
|
10322
|
-
separator.style.margin = "0
|
|
10340
|
+
separator.style.margin = "0 " + makeEm(-ruleThickness / 2);
|
|
10323
10341
|
|
|
10324
10342
|
var _shift = totalHeight - offset;
|
|
10325
10343
|
|
|
10326
10344
|
if (_shift) {
|
|
10327
|
-
separator.style.verticalAlign = -_shift
|
|
10345
|
+
separator.style.verticalAlign = makeEm(-_shift);
|
|
10328
10346
|
}
|
|
10329
10347
|
|
|
10330
10348
|
cols.push(separator);
|
|
@@ -10348,7 +10366,7 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
10348
10366
|
|
|
10349
10367
|
if (sepwidth !== 0) {
|
|
10350
10368
|
colSep = buildCommon.makeSpan(["arraycolsep"], []);
|
|
10351
|
-
colSep.style.width = sepwidth
|
|
10369
|
+
colSep.style.width = makeEm(sepwidth);
|
|
10352
10370
|
cols.push(colSep);
|
|
10353
10371
|
}
|
|
10354
10372
|
}
|
|
@@ -10386,7 +10404,7 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
10386
10404
|
|
|
10387
10405
|
if (sepwidth !== 0) {
|
|
10388
10406
|
colSep = buildCommon.makeSpan(["arraycolsep"], []);
|
|
10389
|
-
colSep.style.width = sepwidth
|
|
10407
|
+
colSep.style.width = makeEm(sepwidth);
|
|
10390
10408
|
cols.push(colSep);
|
|
10391
10409
|
}
|
|
10392
10410
|
}
|
|
@@ -10486,7 +10504,7 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) {
|
|
|
10486
10504
|
|
|
10487
10505
|
var gap = group.arraystretch === 0.5 ? 0.1 // {smallmatrix}, {subarray}
|
|
10488
10506
|
: 0.16 + group.arraystretch - 1 + (group.addJot ? 0.09 : 0);
|
|
10489
|
-
table.setAttribute("rowspacing", gap
|
|
10507
|
+
table.setAttribute("rowspacing", makeEm(gap)); // MathML table lines go only between cells.
|
|
10490
10508
|
// To place a line on an edge we'll use <menclose>, if necessary.
|
|
10491
10509
|
|
|
10492
10510
|
var menclose = "";
|
|
@@ -11563,7 +11581,7 @@ var genfrac_mathmlBuilder = function mathmlBuilder(group, options) {
|
|
|
11563
11581
|
node.setAttribute("linethickness", "0px");
|
|
11564
11582
|
} else if (group.barSize) {
|
|
11565
11583
|
var ruleWidth = calculateSize(group.barSize, options);
|
|
11566
|
-
node.setAttribute("linethickness", ruleWidth
|
|
11584
|
+
node.setAttribute("linethickness", makeEm(ruleWidth));
|
|
11567
11585
|
}
|
|
11568
11586
|
|
|
11569
11587
|
var style = adjustStyle(group.size, options.style);
|
|
@@ -12424,7 +12442,6 @@ defineFunction({
|
|
|
12424
12442
|
|
|
12425
12443
|
if (group.totalheight.number > 0) {
|
|
12426
12444
|
depth = calculateSize(group.totalheight, options) - height;
|
|
12427
|
-
depth = Number(depth.toFixed(2));
|
|
12428
12445
|
}
|
|
12429
12446
|
|
|
12430
12447
|
var width = 0;
|
|
@@ -12434,15 +12451,15 @@ defineFunction({
|
|
|
12434
12451
|
}
|
|
12435
12452
|
|
|
12436
12453
|
var style = {
|
|
12437
|
-
height: height + depth
|
|
12454
|
+
height: makeEm(height + depth)
|
|
12438
12455
|
};
|
|
12439
12456
|
|
|
12440
12457
|
if (width > 0) {
|
|
12441
|
-
style.width = width
|
|
12458
|
+
style.width = makeEm(width);
|
|
12442
12459
|
}
|
|
12443
12460
|
|
|
12444
12461
|
if (depth > 0) {
|
|
12445
|
-
style.verticalAlign = -depth
|
|
12462
|
+
style.verticalAlign = makeEm(-depth);
|
|
12446
12463
|
}
|
|
12447
12464
|
|
|
12448
12465
|
var node = new Img(group.src, group.alt, style);
|
|
@@ -12458,15 +12475,14 @@ defineFunction({
|
|
|
12458
12475
|
|
|
12459
12476
|
if (group.totalheight.number > 0) {
|
|
12460
12477
|
depth = calculateSize(group.totalheight, options) - height;
|
|
12461
|
-
|
|
12462
|
-
node.setAttribute("valign", "-" + depth + "em");
|
|
12478
|
+
node.setAttribute("valign", makeEm(-depth));
|
|
12463
12479
|
}
|
|
12464
12480
|
|
|
12465
|
-
node.setAttribute("height", height + depth
|
|
12481
|
+
node.setAttribute("height", makeEm(height + depth));
|
|
12466
12482
|
|
|
12467
12483
|
if (group.width.number > 0) {
|
|
12468
12484
|
var width = calculateSize(group.width, options);
|
|
12469
|
-
node.setAttribute("width", width
|
|
12485
|
+
node.setAttribute("width", makeEm(width));
|
|
12470
12486
|
}
|
|
12471
12487
|
|
|
12472
12488
|
node.setAttribute("src", group.src);
|
|
@@ -12537,6 +12553,7 @@ defineFunction({
|
|
|
12537
12553
|
|
|
12538
12554
|
|
|
12539
12555
|
|
|
12556
|
+
|
|
12540
12557
|
defineFunction({
|
|
12541
12558
|
type: "lap",
|
|
12542
12559
|
names: ["\\mathllap", "\\mathrlap", "\\mathclap"],
|
|
@@ -12576,10 +12593,10 @@ defineFunction({
|
|
|
12576
12593
|
// This code resolved issue #1153
|
|
12577
12594
|
|
|
12578
12595
|
var strut = buildCommon.makeSpan(["strut"]);
|
|
12579
|
-
strut.style.height = node.height + node.depth
|
|
12596
|
+
strut.style.height = makeEm(node.height + node.depth);
|
|
12580
12597
|
|
|
12581
12598
|
if (node.depth) {
|
|
12582
|
-
strut.style.verticalAlign = -node.depth
|
|
12599
|
+
strut.style.verticalAlign = makeEm(-node.depth);
|
|
12583
12600
|
}
|
|
12584
12601
|
|
|
12585
12602
|
node.children.unshift(strut); // Next, prevent vertical misplacement when next to something tall.
|
|
@@ -12702,7 +12719,8 @@ defineFunction({
|
|
|
12702
12719
|
|
|
12703
12720
|
|
|
12704
12721
|
|
|
12705
|
-
// 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
|
+
|
|
12706
12724
|
var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options, style, slant, baseShift) {
|
|
12707
12725
|
base = buildCommon.makeSpan([], [base]);
|
|
12708
12726
|
var subIsSingleCharacter = subGroup && utils.isCharacterBox(subGroup);
|
|
@@ -12742,7 +12760,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12742
12760
|
}, {
|
|
12743
12761
|
type: "elem",
|
|
12744
12762
|
elem: sub.elem,
|
|
12745
|
-
marginLeft: -slant
|
|
12763
|
+
marginLeft: makeEm(-slant)
|
|
12746
12764
|
}, {
|
|
12747
12765
|
type: "kern",
|
|
12748
12766
|
size: sub.kern
|
|
@@ -12755,7 +12773,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12755
12773
|
}, {
|
|
12756
12774
|
type: "elem",
|
|
12757
12775
|
elem: sup.elem,
|
|
12758
|
-
marginLeft: slant
|
|
12776
|
+
marginLeft: makeEm(slant)
|
|
12759
12777
|
}, {
|
|
12760
12778
|
type: "kern",
|
|
12761
12779
|
size: options.fontMetrics().bigOpSpacing5
|
|
@@ -12776,7 +12794,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12776
12794
|
}, {
|
|
12777
12795
|
type: "elem",
|
|
12778
12796
|
elem: sub.elem,
|
|
12779
|
-
marginLeft: -slant
|
|
12797
|
+
marginLeft: makeEm(-slant)
|
|
12780
12798
|
}, {
|
|
12781
12799
|
type: "kern",
|
|
12782
12800
|
size: sub.kern
|
|
@@ -12800,7 +12818,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12800
12818
|
}, {
|
|
12801
12819
|
type: "elem",
|
|
12802
12820
|
elem: sup.elem,
|
|
12803
|
-
marginLeft: slant
|
|
12821
|
+
marginLeft: makeEm(slant)
|
|
12804
12822
|
}, {
|
|
12805
12823
|
type: "kern",
|
|
12806
12824
|
size: options.fontMetrics().bigOpSpacing5
|
|
@@ -12819,7 +12837,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12819
12837
|
// A negative margin-left was applied to the lower limit.
|
|
12820
12838
|
// Avoid an overlap by placing a spacer on the left on the group.
|
|
12821
12839
|
var spacer = buildCommon.makeSpan(["mspace"], [], options);
|
|
12822
|
-
spacer.style.marginRight = slant
|
|
12840
|
+
spacer.style.marginRight = makeEm(slant);
|
|
12823
12841
|
parts.unshift(spacer);
|
|
12824
12842
|
}
|
|
12825
12843
|
|
|
@@ -12837,6 +12855,7 @@ var assembleSupSub = function assembleSupSub(base, supGroup, subGroup, options,
|
|
|
12837
12855
|
|
|
12838
12856
|
|
|
12839
12857
|
|
|
12858
|
+
|
|
12840
12859
|
// Most operators have a large successor symbol, but these don't.
|
|
12841
12860
|
var noSuccessor = ["\\smallint"]; // NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also
|
|
12842
12861
|
// "supsub" since some of them (like \int) can affect super/subscripting.
|
|
@@ -12950,7 +12969,7 @@ var op_htmlBuilder = function htmlBuilder(grp, options) {
|
|
|
12950
12969
|
} else {
|
|
12951
12970
|
if (baseShift) {
|
|
12952
12971
|
base.style.position = "relative";
|
|
12953
|
-
base.style.top = baseShift
|
|
12972
|
+
base.style.top = makeEm(baseShift);
|
|
12954
12973
|
}
|
|
12955
12974
|
|
|
12956
12975
|
return base;
|
|
@@ -13575,9 +13594,9 @@ defineFunction({
|
|
|
13575
13594
|
var height = calculateSize(group.height, options);
|
|
13576
13595
|
var shift = group.shift ? calculateSize(group.shift, options) : 0; // Style the rule to the right size
|
|
13577
13596
|
|
|
13578
|
-
rule.style.borderRightWidth = width
|
|
13579
|
-
rule.style.borderTopWidth = height
|
|
13580
|
-
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
|
|
13581
13600
|
|
|
13582
13601
|
rule.width = width;
|
|
13583
13602
|
rule.height = height + shift;
|
|
@@ -13595,18 +13614,18 @@ defineFunction({
|
|
|
13595
13614
|
var color = options.color && options.getColor() || "black";
|
|
13596
13615
|
var rule = new mathMLTree.MathNode("mspace");
|
|
13597
13616
|
rule.setAttribute("mathbackground", color);
|
|
13598
|
-
rule.setAttribute("width", width
|
|
13599
|
-
rule.setAttribute("height", height
|
|
13617
|
+
rule.setAttribute("width", makeEm(width));
|
|
13618
|
+
rule.setAttribute("height", makeEm(height));
|
|
13600
13619
|
var wrapper = new mathMLTree.MathNode("mpadded", [rule]);
|
|
13601
13620
|
|
|
13602
13621
|
if (shift >= 0) {
|
|
13603
|
-
wrapper.setAttribute("height",
|
|
13622
|
+
wrapper.setAttribute("height", makeEm(shift));
|
|
13604
13623
|
} else {
|
|
13605
|
-
wrapper.setAttribute("height", shift
|
|
13606
|
-
wrapper.setAttribute("depth",
|
|
13624
|
+
wrapper.setAttribute("height", makeEm(shift));
|
|
13625
|
+
wrapper.setAttribute("depth", makeEm(-shift));
|
|
13607
13626
|
}
|
|
13608
13627
|
|
|
13609
|
-
wrapper.setAttribute("voffset", shift
|
|
13628
|
+
wrapper.setAttribute("voffset", makeEm(shift));
|
|
13610
13629
|
return wrapper;
|
|
13611
13630
|
}
|
|
13612
13631
|
});
|
|
@@ -13616,6 +13635,7 @@ defineFunction({
|
|
|
13616
13635
|
|
|
13617
13636
|
|
|
13618
13637
|
|
|
13638
|
+
|
|
13619
13639
|
function sizingGroup(value, options, baseOptions) {
|
|
13620
13640
|
var inner = buildExpression(value, options, false);
|
|
13621
13641
|
var multiplier = options.sizeMultiplier / baseOptions.sizeMultiplier; // Add size-resetting classes to the inner list and set maxFontSize
|
|
@@ -13677,7 +13697,7 @@ defineFunction({
|
|
|
13677
13697
|
// that we're passing an options parameter we should be able to fix
|
|
13678
13698
|
// this.
|
|
13679
13699
|
|
|
13680
|
-
node.setAttribute("mathsize", newOptions.sizeMultiplier
|
|
13700
|
+
node.setAttribute("mathsize", makeEm(newOptions.sizeMultiplier));
|
|
13681
13701
|
return node;
|
|
13682
13702
|
}
|
|
13683
13703
|
});
|
|
@@ -13801,6 +13821,7 @@ defineFunction({
|
|
|
13801
13821
|
|
|
13802
13822
|
|
|
13803
13823
|
|
|
13824
|
+
|
|
13804
13825
|
defineFunction({
|
|
13805
13826
|
type: "sqrt",
|
|
13806
13827
|
names: ["\\sqrt"],
|
|
@@ -13859,7 +13880,7 @@ defineFunction({
|
|
|
13859
13880
|
|
|
13860
13881
|
|
|
13861
13882
|
var imgShift = img.height - inner.height - lineClearance - ruleWidth;
|
|
13862
|
-
inner.style.paddingLeft = advanceWidth
|
|
13883
|
+
inner.style.paddingLeft = makeEm(advanceWidth); // Overlay the image and the argument.
|
|
13863
13884
|
|
|
13864
13885
|
var body = buildCommon.makeVList({
|
|
13865
13886
|
positionType: "firstBaseline",
|
|
@@ -13987,6 +14008,7 @@ defineFunction({
|
|
|
13987
14008
|
|
|
13988
14009
|
|
|
13989
14010
|
|
|
14011
|
+
|
|
13990
14012
|
/**
|
|
13991
14013
|
* Sometimes, groups perform special rules when they have superscripts or
|
|
13992
14014
|
* subscripts attached to them. This function lets the `supsub` group know that
|
|
@@ -14078,7 +14100,7 @@ defineFunctionBuilders({
|
|
|
14078
14100
|
|
|
14079
14101
|
|
|
14080
14102
|
var multiplier = options.sizeMultiplier;
|
|
14081
|
-
var marginRight = 0.5 / metrics.ptPerEm / multiplier
|
|
14103
|
+
var marginRight = makeEm(0.5 / metrics.ptPerEm / multiplier);
|
|
14082
14104
|
var marginLeft = null;
|
|
14083
14105
|
|
|
14084
14106
|
if (subm) {
|
|
@@ -14089,7 +14111,7 @@ defineFunctionBuilders({
|
|
|
14089
14111
|
|
|
14090
14112
|
if (base instanceof SymbolNode || isOiint) {
|
|
14091
14113
|
// $FlowFixMe
|
|
14092
|
-
marginLeft = -base.italic
|
|
14114
|
+
marginLeft = makeEm(-base.italic);
|
|
14093
14115
|
}
|
|
14094
14116
|
}
|
|
14095
14117
|
|
|
@@ -15056,6 +15078,7 @@ var macros = _macros;
|
|
|
15056
15078
|
|
|
15057
15079
|
|
|
15058
15080
|
|
|
15081
|
+
|
|
15059
15082
|
//////////////////////////////////////////////////////////////////////
|
|
15060
15083
|
// macro tools
|
|
15061
15084
|
|
|
@@ -15677,7 +15700,7 @@ defineMacro("\\TeX", "\\textrm{\\html@mathml{" + "T\\kern-.1667em\\raisebox{-.5e
|
|
|
15677
15700
|
// We compute the corresponding \raisebox when A is rendered in \normalsize
|
|
15678
15701
|
// \scriptstyle, which has a scale factor of 0.7 (see Options.js).
|
|
15679
15702
|
|
|
15680
|
-
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]);
|
|
15681
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
|
|
15682
15705
|
|
|
15683
15706
|
defineMacro("\\KaTeX", "\\textrm{\\html@mathml{" + ("K\\kern-.17em\\raisebox{" + latexRaiseA + "}{\\scriptstyle A}") + "\\kern-.15em\\TeX}{KaTeX}}"); // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
|
|
@@ -18102,7 +18125,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
|
|
|
18102
18125
|
/**
|
|
18103
18126
|
* Current KaTeX version
|
|
18104
18127
|
*/
|
|
18105
|
-
version: "0.13.
|
|
18128
|
+
version: "0.13.24",
|
|
18106
18129
|
|
|
18107
18130
|
/**
|
|
18108
18131
|
* Renders the given LaTeX into an HTML+MathML combination, and adds
|