diff --git a/Lexer.js b/Lexer.js index 139e24254..dadaa68ad 100644 --- a/Lexer.js +++ b/Lexer.js @@ -17,6 +17,7 @@ var normals = [ [/^[*+-]/, 'bin'], [/^[=<>]/, 'rel'], [/^[,;]/, 'punct'], + [/^'/, "'"], [/^\^/, '^'], [/^_/, '_'], [/^{/, '{'], diff --git a/Parser.js b/Parser.js index 6c3298c70..19ca61651 100644 --- a/Parser.js +++ b/Parser.js @@ -78,6 +78,10 @@ Parser.prototype.parseSuperscript = function(pos) { // Throw an error if we didn't find a group throw "Parse error: Couldn't find group after '^'"; } + } else if (sup.type === "'") { + var pos = sup.position; + return new ParseResult( + new ParseNode("textord", "\\prime"), sup.position); } else { return null; } @@ -179,18 +183,78 @@ var colorFuncs = [ // For example, if the lexer returns something of type "colon", we should // return a node of type "punct" var copyFuncs = { - "textord": ["textord"], + "textord": [ + "textord", + "\\angle", + "\\infty", + "\\prime" + ], "mathord": ["mathord"], - "bin": ["bin", "\\pm", "\\div", "\\cdot"], - "open": ["open", "\\lvert"], - "close": ["close", "\\rvert"], - "rel": ["rel", "\\leq", "\\geq", "\\neq", "\\nleq", "\\ngeq"], - "spacing": ["\\qquad", "\\quad", "\\space", "\\ ", "\\,", "\\:", "\\;"], - "punct": ["punct", "\\colon"], - "namedfn": ["\\arcsin", "\\arccos", "\\arctan", "\\arg", "\\cos", "\\cosh", - "\\cot", "\\coth", "\\csc", "\\deg", "\\dim", "\\exp", "\\hom", - "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh", "\\tan", - "\\tanh"] + "bin": [ + "bin", + "\\cdot", + "\\circ", + "\\div", + "\\pm", + "\\times" + ], + "open": [ + "open", + "\\lvert" + ], + "close": [ + "close", + "\\rvert" + ], + "rel": [ + "rel", + "\\geq", + "\\gets", + "\\leftarrow", + "\\leq", + "\\neq", + "\\ngeq", + "\\nleq", + "\\rightarrow", + "\\to" + ], + "spacing": [ + "\\ ", + "\\,", + "\\:", + "\\;", + "\\qquad", + "\\quad", + "\\space" + ], + "punct": [ + "punct", + "\\colon" + ], + "namedfn": [ + "\\arcsin", + "\\arccos", + "\\arctan", + "\\arg", + "\\cos", + "\\cosh", + "\\cot", + "\\coth", + "\\csc", + "\\deg", + "\\dim", + "\\exp", + "\\hom", + "\\ker", + "\\lg", + "\\ln", + "\\log", + "\\sec", + "\\sin", + "\\sinh", + "\\tan", + "\\tanh" + ] }; // Build a list of all of the different functions in the copyFuncs list, to diff --git a/katex.js b/katex.js index d6ad0bcbe..a3d6aa684 100644 --- a/katex.js +++ b/katex.js @@ -151,19 +151,28 @@ var charLookup = { "*": "\u2217", "-": "\u2212", "`": "\u2018", - "\\cdot": "\u22C5", - "\\lvert": "|", - "\\rvert": "|", - "\\pm": "\u00b1", - "\\div": "\u00f7", - "\\leq": "\u2264", - "\\geq": "\u2265", - "\\neq": "\u2260", - "\\nleq": "\u2270", - "\\ngeq": "\u2271", "\\ ": "\u00a0", + "\\angle": "\u2220", + "\\cdot": "\u22c5", + "\\circ": "\u2218", + "\\colon": ":", + "\\div": "\u00f7", + "\\geq": "\u2265", + "\\gets": "\u2190", + "\\infty": "\u221e", + "\\leftarrow": "\u2190", + "\\leq": "\u2264", + "\\lvert": "|", + "\\neq": "\u2260", + "\\ngeq": "\u2271", + "\\nleq": "\u2270", + "\\pm": "\u00b1", + "\\prime": "\u2032", + "\\rightarrow": "\u2192", + "\\rvert": "|", "\\space": "\u00a0", - "\\colon": ":" + "\\times": "\u00d7", + "\\to": "\u2192" }; var textit = function(value) {