mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 11:18:39 +00:00
added position property to ParseError
This commit is contained in:
@@ -29,6 +29,8 @@ function ParseError(message, lexer, position) {
|
||||
var self = new Error(error);
|
||||
self.name = "ParseError";
|
||||
self.__proto__ = ParseError.prototype;
|
||||
|
||||
self.position = position;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@@ -1040,3 +1040,13 @@ describe("An accent builder", function() {
|
||||
expect(getBuilt("\\vec )^2")[0].classes).not.toContain("mclose");
|
||||
});
|
||||
});
|
||||
|
||||
describe("A parser error", function () {
|
||||
it("should report the position of an error", function () {
|
||||
try {
|
||||
parseTree("\\sqrt}");
|
||||
} catch (e) {
|
||||
expect(e.position).toEqual(5);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user