Commit Graph

159 Commits

Author SHA1 Message Date
Emily Eisenberg
1430ebaf06 Make ParseErrors differentiable from other Errors
Auditors: alpert
2013-07-22 14:46:13 -07:00
Ben Alpert
dd8923deca Dollar sign
Auditors: emily
2013-07-20 18:23:15 -07:00
Ben Alpert
41ad81d831 Make uppercase Greek letters use roman font
Fixes T1228.

Test Plan:
In `\Omega \omega`, Omega is roman and omega is italic.

Auditors: emily
2013-07-18 22:55:43 -07:00
Emily Eisenberg
383ca01434 Sync with Khan-exercises
Summary:
Add some things in to make this more useful to khan-exercises.
Notably, make KaTeX.process create and clean up its own .katex node, and rename
.mathmathmath -> .katex.

Test Plan: Make test, make sure the main page still renders stuff

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D3061
2013-07-17 15:43:55 -07:00
Ben Alpert
b101582aac printf not echo -n
Auditors: emily
2013-07-16 22:03:39 -07:00
Ben Alpert
c08fadfaa9 Parse single superscripts and subscripts
Summary:
Add the ability to parse lone `^x` and `_y`, etc. This basically just
involves more checking of cases in the increasingly ugly `parseAtom` function.
Also, now we manually check for the cases of double superscripts and
subscripts.

Test Plan: Make sure the tests pass. Make sure things like `^x` and `_y` parse.

Reviewers: emily

Reviewed By: emily

Differential Revision: http://phabricator.khanacademy.org/D3095
2013-07-16 22:00:54 -07:00
Emily Eisenberg
bcd6e8687f Fix the failing frac test
Summary: Also add some more frac tests

Auditors: alpert
2013-07-16 17:46:58 -07:00
Emily Eisenberg
975234e813 Fix some minor things
Summary: Fix llap/rlap again, fix lexing errors

Auditors: alpert
2013-07-15 12:12:15 -07:00
Ben Alpert
09311de814 Add Greek letters
Summary: Fixes T1190.

Test Plan: `\alpha \beta \gamma \delta \epsilon \varepsilon \zeta \eta \theta \vartheta \iota \kappa \lambda \mu \nu \xi \omicron \pi \varpi \rho \varrho \sigma \varsigma \tau \upsilon \phi \varphi \chi \psi \omega \Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega`

Reviewers: emily

Reviewed By: emily

Maniphest Tasks: T1190

Differential Revision: http://phabricator.khanacademy.org/D3054
2013-07-14 22:54:01 -07:00
Ben Alpert
a5840aae4b Add more symbols
Summary:
', \angle, \circ, \gets, \infty, \leftarrow, \prime, \rightarrow, \times, \to

Fixes T1191.

Reviewers: emily

Reviewed By: emily

Maniphest Tasks: T1191

Differential Revision: http://phabricator.khanacademy.org/D3053
2013-07-14 22:53:43 -07:00
Ben Alpert
c774b69de8 Make contains() actually work in IE8
Summary: IE8 doesn't have indexOf on arrays!

Reviewers: emily

Reviewed By: emily

Differential Revision: http://phabricator.khanacademy.org/D3052
2013-07-14 22:46:00 -07:00
Ben Alpert
ed9d62d98c Inherit fraction bar color from surrounding text
Test Plan: Fractions look okay in Chrome, Firefox, IE.

Reviewers: emily

Reviewed By: emily

Differential Revision: http://phabricator.khanacademy.org/D3051
2013-07-14 22:41:03 -07:00
Ben Alpert
e29fe0c683 Grosser color support for prettier results
Test Plan: `\orange{x}\blue{-4}`, `\orange{x-}\blue{-4}` look the same after desaturation as `x-4` and `x--4`. In addition, `\orange{x}\blue{{-4}}` looks appropriately atrocious (i.e., has no space whatsoever).

Reviewers: emily

Reviewed By: emily

Differential Revision: http://phabricator.khanacademy.org/D3050
2013-07-14 21:34:05 -07:00
Ben Alpert
e472b0ba9d Add TeX style support
Test Plan:
`\blue\frac12 + \frac{2(y-z)}{2+\frac1{7+\frac31}} \div \orange{\arctan x^{2+\frac43}_{2}} * 2^{2^{2^2}}` looks reasonable, as does
`\blue\frac12 + \dfrac{2(y-z)}{2+\frac1{7+\frac31}} \div \orange{\arctan x^{2+\frac43}_{2}} * 2^{2^{2^2}}`.

Reviewers: emily

Reviewed By: emily

Differential Revision: http://phabricator.khanacademy.org/D3047
2013-07-14 16:55:46 -07:00
Emily Eisenberg
ed82784cba Non-capturing regex, don't catch some exceptions
Auditors: alpert
2013-07-13 20:55:35 -07:00
Emily Eisenberg
a831e94a51 Remove dependency on underscore
Summary:
Remove all uses of underscore. For the things we actually need, make a
"util" file and put them in there.

Test Plan:
Make sure the test still succeed, and that the main page still
works.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D3043
2013-07-13 20:42:19 -07:00
Emily Eisenberg
0da85483c4 Remove Parser options usage
Summary: Now, have katex catch and print exceptions instead of the
parser

Auditors: alpert
2013-07-13 18:15:17 -07:00
Emily Eisenberg
20658a95b6 Add \ in front of functions in the parser
Auditors: alpert
2013-07-13 16:13:05 -07:00
Emily Eisenberg
38e2d600fd Allow some functions to have letters after them
Summary: Allow there to be letters immediately after \ , \;, \,, \:.

Test Plan: Run the tests

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D3031
2013-07-13 00:05:41 -07:00
Emily Eisenberg
5871d1756f Fix typo, so we actually test x_x_x
Auditors: alpert
2013-07-12 23:17:32 -07:00
Emily Eisenberg
4122fa2b99 Rewrite the parser
Summary:
Make our own parser that doesn't use jison, so that we can handle
funny TeX syntax, and to make it smaller.

Test Plan: Make sure the tests pass with the new parser.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D3029
2013-07-12 23:16:30 -07:00
Emily Eisenberg
507a552ffd Add some basic testing using jasmine
Summary:
Make some tests that test the parser. So far, there are no DOM tests,
but maybe later.

Test Plan:
Run `make serve` and then visit `/test/test.html`. Make sure all the
tests pass.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D2987
2013-07-11 18:32:44 -07:00
Emily Eisenberg
adb8b5d671 Rename everything to KaTeX
Summary: Rename all instances of mjlite -> katex

Test Plan: Run the local server, make sure things still work.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D2977
2013-07-10 14:08:50 -07:00
Emily Eisenberg
c9c305d304 Un-combine ords
Auditors: alpert
2013-07-10 12:11:39 -07:00
Emily Eisenberg
a9d79e58c4 Split out backtick because it's special
Auditors: spicyj
2013-07-09 22:41:38 -07:00
Emily Eisenberg
d747063d42 Add some more symbols to appropriate categories
Auditors: spicyj
2013-07-09 22:33:09 -07:00
Emily Eisenberg
90dfae6924 Attempt to merge ords together
Summary:
Try not to waste spans by putting a bunch of numbers or letters
together into the same ord box. I don't think that this breaks any of the
current stuff.

Test Plan:
Write lots of expressions that have ords in them. Make sure that all
the reasonable ords are grouped together, and that the formatting still works.

Reviewers: spicyj

Reviewed By: spicyj

Differential Revision: http://phabricator.benalpert.com/D52
2013-07-09 22:31:19 -07:00
Emily Eisenberg
42cc8b1a12 Add ops
Summary: Add named functions like \sin, \cos, etc.

Reviewers: spicyj

Reviewed By: spicyj

Differential Revision: http://phabricator.benalpert.com/D51
2013-07-09 22:04:33 -07:00
Emily Eisenberg
4a3ed8dce0 Remove accidental second arguments
Auditors: spicyj
2013-07-09 21:15:01 -07:00
Emily Eisenberg
a95b93789a Make {} turn things into ords
Auditors: spicyj
2013-07-09 21:14:04 -07:00
Emily Eisenberg
29fde5d364 Correctly style fracs as inners
Summary:
Turn fracs into inners like they should be, instead of using the
previous dumb hack.

Test Plan: Make sure \dfrac still works

Reviewers: spicyj

Reviewed By: spicyj

Differential Revision: http://phabricator.benalpert.com/D50
2013-07-09 21:05:14 -07:00
Emily Eisenberg
a0eff74be3 Add punctuation
Summary: Add punctuation, like ",", ";", and "\colon"

Reviewers: spicyj

Reviewed By: spicyj

Differential Revision: http://phabricator.benalpert.com/D49
2013-07-09 21:01:04 -07:00
Emily Eisenberg
66a43f551d Add llap and rlap
Summary:
By the powers of Greyskull (and maybe css) we have vanquished the
great and powerful llap! All hail!

Test Plan: Add some \llap and \rlap. Make sure it's positioned correctly.

Reviewers: spicyj

Reviewed By: spicyj

Differential Revision: http://phabricator.benalpert.com/D48
2013-07-09 16:02:44 -07:00
Emily Eisenberg
b016015d4e Sync styles with khan-exercises
Summary:
Get the styles into a form that they can be directly copied over to
khan-exercises, with no changes. Mostly just changing #math to .mathmathmath
and adding a font style and size.

Test Plan: Make sure that the local test still works.

Reviewers: spicyj

Reviewed By: spicyj

Differential Revision: http://phabricator.benalpert.com/D47
2013-07-09 15:53:35 -07:00
Emily Eisenberg
2478a385ae Add spacing functions
Summary: Add \qquad, \quad, \;, etc. Fixes T7

Test Plan:
Add some spacings. Make sure that they look reasonable widths.
Especially, if you add a space (`\space`), make sure that it doesn't disappear
because the spacing disappears.

Reviewers: spicyj

Reviewed By: spicyj

Maniphest Tasks: T7

Differential Revision: http://phabricator.benalpert.com/D46
2013-07-09 15:32:54 -07:00
Emily Eisenberg
a30a39247f Add a thin space around fractions
Auditors: spicyj
2013-07-09 15:31:09 -07:00
Emily Eisenberg
8d85aa464e Add rels
Summary: Add a bunch of rels, and their css and stuff.

Test Plan: Add some rels. Rejoice.

Reviewers: spicyj

Reviewed By: spicyj

Differential Revision: http://phabricator.benalpert.com/D45
2013-07-09 00:57:03 -07:00
Emily Eisenberg
9d2ac2c132 Make the makefile better
Auditors: spicyj
2013-07-09 00:09:01 -07:00
Ben Alpert
d5c2a6fb38 Make things sort of work in IE8
Summary:
Uploaded the OTFs from eab3322d to fontsquirrel with the following config:

```
{"mode":"expert","formats":["ttf","woff","eotz"],"tt_instructor":"default","fix_vertical_metrics":"Y","fix_gasp":"xy","add_spaces":"Y","add_hyphens":"Y","fallback":"none","fallback_custom":"100","options_subset":"none","subset_custom":"","subset_custom_range":"","css_stylesheet":"stylesheet.css","filename_suffix":"","emsquare":"2048","spacing_adjustment":"0"}
```

Now we have this beauty in IE8:

{F213}

and it looks similar in Chrome. Now I guess we just need square roots so we can stop disseminating the wrong quadratic formula.

Reviewers: xymostech

Reviewed By: xymostech

Differential Revision: http://phabricator.benalpert.com/D43
2013-07-08 22:48:14 -07:00
Emily Eisenberg
2c067161df Add color support
Summary: Not true `\color`, but `\blue`, `\red`, etc.

Test Plan:
Add `\blue`, etc around stuff, see that it makes pretty colors
appear.

Reviewers: spicyj

Reviewed By: spicyj

Differential Revision: http://phabricator.benalpert.com/D44
2013-07-08 15:48:56 -07:00
Emily Eisenberg
0d901b4da4 Make the lexer errors actually work
Auditors: spicyj
2013-07-08 15:37:26 -07:00
Emily Eisenberg
f97aad13b7 Make large fractions actually work
Summary:
Also, rename it to '\dfrac', because it's more like a display fraction

Auditors: spicyj
2013-07-07 22:43:16 -07:00
Ben Alpert
2643f72a9d Tweaks to lexer, incl. matching func all at once
Reviewers: xymostech

Reviewed By: xymostech

Differential Revision: http://phabricator.benalpert.com/D42
2013-07-07 21:27:08 -07:00
Emily Eisenberg
eab3322db3 Use our own local (awesome) fonts
Summary: Build or own fonts from MathJax's repo, and use those instead.

Test Plan: Use the new fonts, enjoy!

Reviewers: spicyj

Reviewed By: spicyj

Differential Revision: http://phabricator.benalpert.com/D41
2013-07-07 21:20:22 -07:00
Emily Eisenberg
8f99433c80 Use our own lexer, not jison's
Summary:
Build our own lexer and inject it into jison's parser, because jison's
lexer notation is confusing and annoying, and it doesn't let us do some fun
stuff.

Test Plan: Run stuff, make sure it still works.

Reviewers: spicyj

Reviewed By: spicyj

Differential Revision: http://phabricator.benalpert.com/D40
2013-07-07 21:13:43 -07:00
Ben Alpert
33625f7b08 Catch server errors and return 500
Reviewers: xymostech

Reviewed By: xymostech

Differential Revision: http://phabricator.benalpert.com/D39
2013-07-07 14:13:25 -07:00
Emily Eisenberg
3caccbf933 Get rid of some forgotten elems
Auditors: alpert
2013-07-07 12:15:32 -07:00
Emily Eisenberg
00d775f420 Don't make undefined classNames
Auditors: spicyj
2013-07-06 00:52:25 -07:00
Ben Alpert
4bc599966f Create node server to replace 'make watch'
Reviewers: xymostech

Reviewed By: xymostech

Differential Revision: http://phabricator.benalpert.com/D38
2013-07-05 22:55:10 -07:00
Ben Alpert
afb29f5df3 Use browserify and "modules"
Reviewers: xymostech

Reviewed By: xymostech

Differential Revision: http://phabricator.benalpert.com/D37
2013-07-05 21:44:44 -07:00