katex 0.16.7 → 0.16.8
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 +1 -1
- package/dist/katex.js +17 -5
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +17 -5
- package/package.json +1 -1
- package/src/ParseError.js +15 -5
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
|
|
|
@@ -18297,7 +18309,7 @@ var katex = {
|
|
|
18297
18309
|
/**
|
|
18298
18310
|
* Current KaTeX version
|
|
18299
18311
|
*/
|
|
18300
|
-
version: "0.16.
|
|
18312
|
+
version: "0.16.8",
|
|
18301
18313
|
|
|
18302
18314
|
/**
|
|
18303
18315
|
* 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
|
}
|