From 7e5e6a90d30e50cd819e259fd99245ccd5a36636 Mon Sep 17 00:00:00 2001 From: Emily Eisenberg Date: Fri, 9 Aug 2013 20:51:05 -0700 Subject: [PATCH] Add the \KaTeX command Summary: Add a command to print out a TeX-style logo for KaTeX. I think the code is okay, but suggestions for the design of the logo are most welcome (I'll post screenshots soon). Test Plan: Make sure \KaTeX renders, and the tests still succeed. Reviewers: alpert Reviewed By: alpert Differential Revision: http://phabricator.khanacademy.org/D3443 --- Parser.js | 5 +++++ buildTree.js | 12 ++++++++++++ static/katex.css | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/Parser.js b/Parser.js index b4f479ebb..98d42b93d 100644 --- a/Parser.js +++ b/Parser.js @@ -383,6 +383,11 @@ Parser.prototype.parseNucleus = function(pos) { throw new ParseError("Parse error: Expected numerator after '" + nucleus.type + "'"); } + } else if (nucleus.type === "\\KaTeX") { + return new ParseResult( + new ParseNode("katex", null), + nucleus.position + ); } else if (funcToType[nucleus.type]) { // Otherwise if this is a no-argument function, find the type it // corresponds to in the map and return diff --git a/buildTree.js b/buildTree.js index a77f930ea..86f631982 100644 --- a/buildTree.js +++ b/buildTree.js @@ -3,6 +3,8 @@ var Style = require("./Style"); var parseTree = require("./parseTree"); var utils = require("./utils"); +var ParseError = require("./ParseError"); + function Options(style, color) { this.style = style; this.color = color; @@ -197,6 +199,16 @@ var groupTypes = { namedfn: function(group, options, prev) { return makeSpan("mop" + options.color, [textit(group.value.slice(1))]); + }, + + katex: function(group, options, prev) { + return makeSpan("katex-logo", [ + makeSpan("k", [textit("K")]), + makeSpan("a", [textit("A")]), + makeSpan("t", [textit("T")]), + makeSpan("e", [textit("E")]), + makeSpan("x", [textit("X")]) + ]); } }; diff --git a/static/katex.css b/static/katex.css index 605181243..16c2806cb 100644 --- a/static/katex.css +++ b/static/katex.css @@ -165,3 +165,21 @@ big parens .katex .green { color: #28ae7b; } .katex .gray { color: gray; } .katex .purple { color: #9d38bd; } + +.katex .katex-logo .a { + font-size: 0.75em; + margin-left: -0.32em; + position: relative; + top: -0.2em; +} +.katex .katex-logo .t { + margin-left: -0.23em; +} +.katex .katex-logo .e { + margin-left: -0.1667em; + position: relative; + top: 0.2155em; +} +.katex .katex-logo .x { + margin-left: -0.125em; +}