Added new exercise colors as macros

Summary:
On https://app.asana.com/0/34646644303310/33935538887378, @eater requested we add some new colors to KaTeX, which lives in the spin-off Khan/KaTeX open source project. (See screenshot for colors.) I added these colors to KaTeX so math typesetting tools in exercises have access to them.

I used "blueA", "blueB", etc. because dashes and numbers aren't supported in KaTeX/LaTeX functions.

The actual mapping of color name => hex value is in "Options", and the listing of colors available for typesetting is in "functions".

See also https://phabricator.khanacademy.org/D18158 for the related additions to utils/math.js and KAthJax.

Test Plan:
- Set up the KaTeX dev environment (instructions taken from https://github.com/Khan/KaTeX/blob/master/CONTRIBUTING.md):
```
cd KaTeX
make setup
make serve
```
- Now that the server is up and running, visit http://localhost:7936/ to try live typesetting. Enter the following LaTeX code to try the new colors:
```
\blueE{e=mc^2}
```
- Try other new colors including \redD, \mintC, \grayH, \kaBlue, etc.
- Old colors like \orange should still work.
- Run the Jasmine test suite at http://localhost:7936/test/test.html.

Reviewers: emily

Reviewed By: emily

Subscribers: nataliefitzgerald, eater, cameron, david

Differential Revision: https://phabricator.khanacademy.org/D18152
This commit is contained in:
hathix
2015-05-26 19:07:51 -07:00
parent 8691486392
commit 9869d59cad
3 changed files with 67 additions and 2 deletions

View File

@@ -654,6 +654,7 @@ describe("A text parser", function() {
describe("A color parser", function() {
var colorExpression = "\\blue{x}";
var newColorExpression = "\\redA{x}";
var customColorExpression = "\\color{#fA6}{x}";
var badCustomColorExpression = "\\color{bad-color}{x}";
@@ -683,6 +684,10 @@ describe("A color parser", function() {
expect(badCustomColorExpression).toNotParse();
});
it("should parse new colors from the branding guide", function(){
expect(newColorExpression).toParse();
});
it("should have correct greediness", function() {
expect("\\color{red}a").toParse();
expect("\\color{red}{\\text{a}}").toParse();