katex 0.16.7 → 0.16.9
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 +10 -4
- package/contrib/copy-tex/README.md +2 -2
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +10 -4
- package/dist/katex.css +6 -1
- package/dist/katex.js +33 -11
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +30 -8
- package/package.json +1 -1
- package/src/ParseError.js +15 -5
- package/src/buildCommon.js +5 -1
- package/src/katex.less +6 -0
- package/src/symbols.js +4 -0
- package/src/wide-character.js +3 -2
package/dist/katex.mjs
CHANGED
|
@@ -90,13 +90,19 @@ class Token {
|
|
|
90
90
|
* about where in the source string the problem occurred.
|
|
91
91
|
*/
|
|
92
92
|
class ParseError {
|
|
93
|
-
// Error position based on passed-in Token or ParseNode.
|
|
93
|
+
// Error start position based on passed-in Token or ParseNode.
|
|
94
|
+
// Length of affected text based on passed-in Token or ParseNode.
|
|
95
|
+
// The underlying error message without any context added.
|
|
94
96
|
constructor(message, // The error message
|
|
95
97
|
token // An object providing position information
|
|
96
98
|
) {
|
|
99
|
+
this.name = void 0;
|
|
97
100
|
this.position = void 0;
|
|
101
|
+
this.length = void 0;
|
|
102
|
+
this.rawMessage = void 0;
|
|
98
103
|
var error = "KaTeX parse error: " + message;
|
|
99
104
|
var start;
|
|
105
|
+
var end;
|
|
100
106
|
var loc = token && token.loc;
|
|
101
107
|
|
|
102
108
|
if (loc && loc.start <= loc.end) {
|
|
@@ -105,7 +111,7 @@ class ParseError {
|
|
|
105
111
|
var input = loc.lexer.input; // Prepend some information
|
|
106
112
|
|
|
107
113
|
start = loc.start;
|
|
108
|
-
|
|
114
|
+
end = loc.end;
|
|
109
115
|
|
|
110
116
|
if (start === input.length) {
|
|
111
117
|
error += " at end of input: ";
|
|
@@ -135,14 +141,20 @@ class ParseError {
|
|
|
135
141
|
error += left + underlined + right;
|
|
136
142
|
} // Some hackery to make ParseError a prototype of Error
|
|
137
143
|
// See http://stackoverflow.com/a/8460753
|
|
144
|
+
// $FlowFixMe
|
|
138
145
|
|
|
139
146
|
|
|
140
147
|
var self = new Error(error);
|
|
141
148
|
self.name = "ParseError"; // $FlowFixMe
|
|
142
149
|
|
|
143
|
-
self.__proto__ = ParseError.prototype;
|
|
144
|
-
|
|
150
|
+
self.__proto__ = ParseError.prototype;
|
|
145
151
|
self.position = start;
|
|
152
|
+
|
|
153
|
+
if (start != null && end != null) {
|
|
154
|
+
self.length = end - start;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
self.rawMessage = message;
|
|
146
158
|
return self;
|
|
147
159
|
}
|
|
148
160
|
|
|
@@ -5158,6 +5170,10 @@ for (var _i3 = 0; _i3 < letters.length; _i3++) {
|
|
|
5158
5170
|
defineSymbol(text, main, textord, _ch3, wideChar);
|
|
5159
5171
|
wideChar = String.fromCharCode(0xD835, 0xDD04 + _i3); // A-Z a-z Fractur
|
|
5160
5172
|
|
|
5173
|
+
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5174
|
+
defineSymbol(text, main, textord, _ch3, wideChar);
|
|
5175
|
+
wideChar = String.fromCharCode(0xD835, 0xDD6C + _i3); // A-Z a-z bold Fractur
|
|
5176
|
+
|
|
5161
5177
|
defineSymbol(math, main, mathord, _ch3, wideChar);
|
|
5162
5178
|
defineSymbol(text, main, textord, _ch3, wideChar);
|
|
5163
5179
|
wideChar = String.fromCharCode(0xD835, 0xDDA0 + _i3); // A-Z a-z sans-serif
|
|
@@ -5265,8 +5281,9 @@ var wideLatinLetterData = [["mathbf", "textbf", "Main-Bold"], // A-Z bold uprigh
|
|
|
5265
5281
|
["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur
|
|
5266
5282
|
["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
|
|
5267
5283
|
["mathbb", "textbb", "AMS-Regular"], // k double-struck
|
|
5268
|
-
|
|
5269
|
-
["", "", ""], //
|
|
5284
|
+
// Note that we are using a bold font, but font metrics for regular Fraktur.
|
|
5285
|
+
["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // A-Z bold Fraktur
|
|
5286
|
+
["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // a-z bold Fraktur
|
|
5270
5287
|
["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
|
|
5271
5288
|
["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
|
|
5272
5289
|
["mathboldsf", "textboldsf", "SansSerif-Bold"], // A-Z bold sans-serif
|
|
@@ -5442,10 +5459,15 @@ var makeOrd = function makeOrd(group, options, type) {
|
|
|
5442
5459
|
|
|
5443
5460
|
var isFont = mode === "math" || mode === "text" && options.font;
|
|
5444
5461
|
var fontOrFamily = isFont ? options.font : options.fontFamily;
|
|
5462
|
+
var wideFontName = "";
|
|
5463
|
+
var wideFontClass = "";
|
|
5445
5464
|
|
|
5446
5465
|
if (text.charCodeAt(0) === 0xD835) {
|
|
5466
|
+
[wideFontName, wideFontClass] = wideCharacterFont(text, mode);
|
|
5467
|
+
}
|
|
5468
|
+
|
|
5469
|
+
if (wideFontName.length > 0) {
|
|
5447
5470
|
// surrogate pairs get special treatment
|
|
5448
|
-
var [wideFontName, wideFontClass] = wideCharacterFont(text, mode);
|
|
5449
5471
|
return makeSymbol(text, wideFontName, mode, options, classes.concat(wideFontClass));
|
|
5450
5472
|
} else if (fontOrFamily) {
|
|
5451
5473
|
var fontName;
|
|
@@ -18297,7 +18319,7 @@ var katex = {
|
|
|
18297
18319
|
/**
|
|
18298
18320
|
* Current KaTeX version
|
|
18299
18321
|
*/
|
|
18300
|
-
version: "0.16.
|
|
18322
|
+
version: "0.16.9",
|
|
18301
18323
|
|
|
18302
18324
|
/**
|
|
18303
18325
|
* Renders the given LaTeX into an HTML+MathML combination, and adds
|
package/package.json
CHANGED
package/src/ParseError.js
CHANGED
|
@@ -12,15 +12,21 @@ import type {AnyParseNode} from "./parseNode";
|
|
|
12
12
|
* about where in the source string the problem occurred.
|
|
13
13
|
*/
|
|
14
14
|
class ParseError {
|
|
15
|
+
name: "ParseError";
|
|
15
16
|
position: number | void;
|
|
16
|
-
// Error position based on passed-in Token or ParseNode.
|
|
17
|
+
// Error start position based on passed-in Token or ParseNode.
|
|
18
|
+
length: number | void;
|
|
19
|
+
// Length of affected text based on passed-in Token or ParseNode.
|
|
20
|
+
rawMessage: string | void;
|
|
21
|
+
// The underlying error message without any context added.
|
|
17
22
|
|
|
18
23
|
constructor(
|
|
19
24
|
message: string, // The error message
|
|
20
25
|
token?: ?Token | AnyParseNode, // An object providing position information
|
|
21
|
-
):
|
|
26
|
+
): ParseError {
|
|
22
27
|
let error = "KaTeX parse error: " + message;
|
|
23
28
|
let start;
|
|
29
|
+
let end;
|
|
24
30
|
|
|
25
31
|
const loc = token && token.loc;
|
|
26
32
|
if (loc && loc.start <= loc.end) {
|
|
@@ -31,7 +37,7 @@ class ParseError {
|
|
|
31
37
|
|
|
32
38
|
// Prepend some information
|
|
33
39
|
start = loc.start;
|
|
34
|
-
|
|
40
|
+
end = loc.end;
|
|
35
41
|
if (start === input.length) {
|
|
36
42
|
error += " at end of input: ";
|
|
37
43
|
} else {
|
|
@@ -60,12 +66,16 @@ class ParseError {
|
|
|
60
66
|
|
|
61
67
|
// Some hackery to make ParseError a prototype of Error
|
|
62
68
|
// See http://stackoverflow.com/a/8460753
|
|
63
|
-
|
|
69
|
+
// $FlowFixMe
|
|
70
|
+
const self: ParseError = new Error(error);
|
|
64
71
|
self.name = "ParseError";
|
|
65
72
|
// $FlowFixMe
|
|
66
73
|
self.__proto__ = ParseError.prototype;
|
|
67
|
-
// $FlowFixMe
|
|
68
74
|
self.position = start;
|
|
75
|
+
if (start != null && end != null) {
|
|
76
|
+
self.length = end - start;
|
|
77
|
+
}
|
|
78
|
+
self.rawMessage = message;
|
|
69
79
|
return self;
|
|
70
80
|
}
|
|
71
81
|
}
|
package/src/buildCommon.js
CHANGED
|
@@ -165,9 +165,13 @@ const makeOrd = function<NODETYPE: "spacing" | "mathord" | "textord">(
|
|
|
165
165
|
// Math mode or Old font (i.e. \rm)
|
|
166
166
|
const isFont = mode === "math" || (mode === "text" && options.font);
|
|
167
167
|
const fontOrFamily = isFont ? options.font : options.fontFamily;
|
|
168
|
+
let wideFontName = "";
|
|
169
|
+
let wideFontClass = "";
|
|
168
170
|
if (text.charCodeAt(0) === 0xD835) {
|
|
171
|
+
[wideFontName, wideFontClass] = wideCharacterFont(text, mode);
|
|
172
|
+
}
|
|
173
|
+
if (wideFontName.length > 0) {
|
|
169
174
|
// surrogate pairs get special treatment
|
|
170
|
-
const [wideFontName, wideFontClass] = wideCharacterFont(text, mode);
|
|
171
175
|
return makeSymbol(text, wideFontName, mode, options,
|
|
172
176
|
classes.concat(wideFontClass));
|
|
173
177
|
} else if (fontOrFamily) {
|
package/src/katex.less
CHANGED
package/src/symbols.js
CHANGED
|
@@ -816,6 +816,10 @@ for (let i = 0; i < letters.length; i++) {
|
|
|
816
816
|
defineSymbol(math, main, mathord, ch, wideChar);
|
|
817
817
|
defineSymbol(text, main, textord, ch, wideChar);
|
|
818
818
|
|
|
819
|
+
wideChar = String.fromCharCode(0xD835, 0xDD6C + i); // A-Z a-z bold Fractur
|
|
820
|
+
defineSymbol(math, main, mathord, ch, wideChar);
|
|
821
|
+
defineSymbol(text, main, textord, ch, wideChar);
|
|
822
|
+
|
|
819
823
|
wideChar = String.fromCharCode(0xD835, 0xDDA0 + i); // A-Z a-z sans-serif
|
|
820
824
|
defineSymbol(math, main, mathord, ch, wideChar);
|
|
821
825
|
defineSymbol(text, main, textord, ch, wideChar);
|
package/src/wide-character.js
CHANGED
|
@@ -45,8 +45,9 @@ const wideLatinLetterData: Array<[string, string, string]> = [
|
|
|
45
45
|
["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
|
|
46
46
|
["mathbb", "textbb", "AMS-Regular"], // k double-struck
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
["", "", ""],
|
|
48
|
+
// Note that we are using a bold font, but font metrics for regular Fraktur.
|
|
49
|
+
["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // A-Z bold Fraktur
|
|
50
|
+
["mathboldfrak", "textboldfrak", "Fraktur-Regular"], // a-z bold Fraktur
|
|
50
51
|
|
|
51
52
|
["mathsf", "textsf", "SansSerif-Regular"], // A-Z sans-serif
|
|
52
53
|
["mathsf", "textsf", "SansSerif-Regular"], // a-z sans-serif
|