Summary:
KaTeX doesn't work correctly in quirks mode. Warn in the console and disable
rendering if that happens.
Test Plan:
- Make sure the test still loads and renders math
- Make sure a warning is thrown when the doctype is removed, and no more math
is rendered
- Make sure the tests pass both on the web and with `make test`
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D13192
Summary:
Add comments everywhere! Also fix some small bugs like using Style.id
instead of Style.size, and rename some variables to be more descriptive.
Fixes#22
Test Plan:
- Make sure the huxley screenshots didn't change
- Make sure the tests still pass
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D13158
Test Plan: Ran unit tests. Looked at `\blue{\displaystyle \left(\dfrac{a^\sigma}{\sin \theta}\right\Updownarrow \intop_{1/2}^{z^z} \sum_{i=0}^\infty x \,dx}` in Chrome and saw the future in my eyes.
Reviewers: emily
Reviewed By: emily
Subscribers: jessie
Differential Revision: http://phabricator.khanacademy.org/D13154
Summary:
Move dom creation into katex.js so our tests can test non-dom things, and add
some buildTree tests. Add some checks make utils.js work in node. Add support
for jasmine-node, to allow for command line unit testing.
Test Plan:
- Make sure tests work, in both the browser and with `make test`
- Make sure huxley screenshots didn't change
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D13125
If there's an exception while parsing (because it's something katex doesn't support), the output doesn't get cleared. Typically when this happens, we'll fall back to MathJax and render that in a different element, leaving the previous KaTex-formatted math plus the new MathJax-formatted math next to each other in the page, which is never what you'd want.
Test Plan: Using the fallback mechanism in khan-exercises utils/tex.js, render something katex can deal with, like "3", then using the same element, reprocess with something katex can't deal with, like "\approx 3". Previously the result would be "3 \approx 3" (with the first 3 being left over from the original katex rendering. With this change, only the "\approx 3" remains on the page.
Auditors: alex, alpert
Summary:
This diff does a couple different things:
- There is now a metrics/ folder, which contains the property files describing
the metrics if the fonts, as well as a script for reading and printing the
metrics in javascript.
- Fractions and superscripts/subscripts are now rendered in slightly different
ways now (notably, no use of inline-table). This allows for much more precise
positioning of the superscripts, subscripts, numerators, and denominators,
while still having an appropriate baseline. Also, there is no longer a
sup/sub/supsub distinction, there are only supsubs with null sup/sub.
- Using the new font metrics and by implementing the formulas found in The TeX
Book, Appendix G, the heights and depths of all of the sub-expressions in a
formula are now calculated. These are currently used to:
- Correctly position superscripts, subscripts, numerators, and denominators
- Adjust the height and depth of the overall expression so it takes up the
appropriate space
- Because we have to add attributes (height and depth) to every attribute, I
have changed the way DOM nodes are assembled. Now, instead of assembling the
DOM elements inline (which is a problem because we need to track
height/depth, and we shouldn't (and can't in IE 8) attach raw attributes to DOM
nodes), we assemble a pseudo-DOM structure with the extra information, and
then actually assemble it at the very end.
The main page also now has an updated expression to show off and test the new
and improved parsing.
Test Plan:
View the main page, make sure that the expression renders. Make sure
that the tests pass. Make sure that expressions have the correct calculated
height (this is most easily tested by viewing them on the main page and making
sure that the top of the expression lines up with the bottom of the input box).
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D3442
Summary:
Pull node making into a separate module, make an "options" param for
the make_ functions, and pull the different types of groups into separate
functions.
Test Plan: Open the homepage, make sure everything still works.
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D3368
Summary: This makes it more annoying to use locally, because it goes
away when you type something bad, but is much more useful in use in
khan-exercises and perseus.
Auditors: alpert
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
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
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
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
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
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
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