From cab5af40b6a63208c20fbca8aebce4b359604983 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Sun, 28 Jul 2013 17:53:48 -0700 Subject: [PATCH] Always throw real ParseErrors Also sneak in a colon. Auditors: emily --- Lexer.js | 2 +- Parser.js | 4 ++-- katex.js | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Lexer.js b/Lexer.js index b1b07e09c..e06171d98 100644 --- a/Lexer.js +++ b/Lexer.js @@ -17,7 +17,7 @@ var normals = [ [/^[/|@."`0-9]/, "textord"], [/^[a-zA-Z]/, "mathord"], [/^[*+-]/, "bin"], - [/^[=<>]/, "rel"], + [/^[=<>:]/, "rel"], [/^[,;]/, "punct"], [/^'/, "'"], [/^\^/, "^"], diff --git a/Parser.js b/Parser.js index 98e171031..b4f479ebb 100644 --- a/Parser.js +++ b/Parser.js @@ -130,7 +130,7 @@ Parser.prototype.parseAtom = function(pos) { var node; if ((node = this.parseSuperscript(nextPos))) { if (sup) { - throw "Parse error: Double superscript"; + throw new ParseError("Parse error: Double superscript"); } nextPos = node.position; sup = node.result; @@ -138,7 +138,7 @@ Parser.prototype.parseAtom = function(pos) { } if ((node = this.parseSubscript(nextPos))) { if (sub) { - throw "Parse error: Double subscript"; + throw new ParseError("Parse error: Double subscript"); } nextPos = node.position; sub = node.result; diff --git a/katex.js b/katex.js index 34c4d972a..7b8dd4614 100644 --- a/katex.js +++ b/katex.js @@ -152,7 +152,8 @@ var buildGroup = function(style, color, group, prev) { } else if (group.type === "namedfn") { return makeSpan("mop" + color, [textit(group.value.slice(1))]); } else { - throw "Lex error: Got group of unknown type: '" + group.type + "'"; + throw new ParseError( + "Lex error: Got group of unknown type: '" + group.type + "'"); } };