Commit Graph

51 Commits

Author SHA1 Message Date
Emily Eisenberg
35d9d972fd Move js files into src/
Test plan:
- Make sure huxley tests, jasmine tests, make build, make metrics, make test all
  still work.

Auditors: alpert
2014-09-15 02:50:34 -07:00
Emily Eisenberg
6b674873ea Rename katex.process to katex.render
Test plan:
 - Make sure tests work and huxley tests didn't change

Auditors: alpert
2014-09-14 21:20:27 -07:00
Emily Eisenberg
9dc767041d Improve build process
Summary:
Improve the build process by combining the CSS files, automatically
selecting font files to include, and building .tar.gz and .zip files.

Test Plan:
 - Make sure tests work
 - Make sure huxley screenshots didn't change
 - Make sure zip and tar.gz files contain only files we want to distribute

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13159
2014-09-14 19:31:38 -07:00
Emily Eisenberg
0dca731da6 Add accents
Summary:
Add support for math-mode accents. This involves a couple changes.
First, in order to correctly position the accents, we must know the kern between
every character and the "skewchar" in that font. To do this, we improve our tfm
parser to run the mini-kern-language and calculate kerns. We then export these
into fontMetrics.js.

Then, we add normal support for accents. In particular, we do some special
handling for supsubs around accents. This involves building the supsub
separately without the accent, and then replacing its base with the built
accent.

Finally, the character in the fonts for the \vec command is a combining unicode
character, so it is shifted to the left, but none of the other characters do
this. We add some special handling for \vec to account for this.

Fixes #7

Test Plan:
 - Make sure tests pass
 - Make sure no huxley screenshots changed, and the new one looks good

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13157
2014-09-13 21:30:35 -07:00
Emily Eisenberg
90573fcaf2 Fix rendering of lists in \left/\right
Test plan:
 - Make sure tests work
 - Make sure screenshots didn't change, and new screenshot looks good

Auditors: alpert
2014-09-13 16:56:15 -07:00
Ben Alpert
7df5b4bba8 Add code for generating HTML
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
2014-09-12 17:59:26 -07:00
Emily Eisenberg
f52c84c187 Add limit operators
Summary:
Add support for all of the other operators, including the ones with symbols and
limits. This also fixes the bug where subscripts were shifted the same amount as
subscripts.

To accomplish this, the domTree.textNode has been repurposed into symbolNode
which is no longer an actual text node, but instead represents an element with a
single symbol in it. This lets us access properties like the italic correction
of a symbol in a reasonable manner without having to recursively look through
children of spans.

Depends on D13082

Fixes #8

Test Plan:
 - Make sure tests work
 - Make sure huxley screenshots didn't change much, and new screenshot looks good

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13122
2014-09-12 14:58:58 -07:00
Emily Eisenberg
29b00ee6b7 Add vlist builder for more consistent stacking
Summary:
Add a way to automatically build vlists correctly. Previously, we built
vlists manually in ~4 different places, which made it difficult to manage
changes, and led to a large amount of duplication in the less. This also fixes
the vlist construction in safari, where the `display: inline-table` wasn't being
applied because of CSS specificity. This leads to the only significant change in
the huxley tests, with the vertical spacing.

Test Plan:
 - Make sure the tests still work
 - Make sure most of the huxley screenshots didn't change, and that the new
   changes are insignificant.
 - Make sure vlists now work in Safari
 - Make sure the change to the VerticalSpacing screenshot is caused by the
   fix-baseline span now correctly applying `display: inline-table` by creating
   the construct in master and adding `display: inline-table !important` to the
   `.fix-ie` css rule

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13082
2014-09-12 14:41:31 -07:00
Emily Eisenberg
403dca64ab Improve testing
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
2014-09-12 13:30:30 -07:00
Emily Eisenberg
0be77d4e6f Add style changing functions
Summary:
Add \displaystyle, \textstyle, \scriptstyle, and \scriptscriptstyle commands.
Added tests and huxley screenshots for everything that looks different in
displaystyle vs normal style.

Fixes #24.

Test Plan:
 - See new tests work, and old tests still work
 - See no huxley screenshots changed, and new screenshot looks good

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13079
2014-09-10 17:10:38 -07:00
Emily Eisenberg
a76f6eb985 Make all the lines the correct sizes
Fix the \frac and \overline lines so they actually render at the correct sizes
(i.e. don't get smaller when in script and scriptscript sizes). This also seems
to fix #33.

Test Plan:
 - Make sure new huxley screenshot look good.
 - Render
     \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} =
     1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}}
     {1+\frac{e^{-8\pi}} {1+...} } } }
   at small font sizes like 30pt and smaller, see that it looks much better

Auditors: alpert
2014-09-10 16:30:38 -07:00
Emily Eisenberg
0c9e9738c3 Fix our parsing strategy so it is the same as (or very similar to) TeX's
Summary:
Rewrote the parser to make this work, and added a bunch of tests to make sure
this does work. In the process, refactored all of our functions into a separate
file, functions.js. Added a bunch of comments to Parser.js. Also, update jasmine
so we can make our tests better, and add a lint_blacklist.txt to not lint bad
jasmine stuff.

Fixes #10
Fixes #12

Test Plan:
- Make sure all of the tests still work, and all of the new ones work also
- Make sure huxley screenshots didn't change

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D12989
2014-09-09 23:18:37 -07:00
Emily Eisenberg
925c96dbe2 Add square roots (\sqrt)
Summary:
Follow the TeXbook instructions on how to construct square roots. Using
makeCustomSizedDelim, this becomes nearly trivial.

Test Plan:
 - Make sure normal tests work
 - Make sure the new huxley test looks good, and other huxley tests haven't changed.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D12918
2014-09-06 15:08:23 -07:00
Emily Eisenberg
fed954bb16 Remove pdiff, now that we have huxley
Auditors: alpert
2014-09-05 13:00:29 -07:00
Emily Eisenberg
c3f758c319 Add support for \left and \right
Summary:
Added stacked delimiter support for more delimiters. Split out delimiter
functions into its own file, and split out some tree building functions into a
common file. Supports the empty `.` delimiter with \left and \right, and doesn't
try to produce huge /, \backslash, <, or > delimiters. Depends on D7844

Test input:

\left( \left) \left[ \left\lbrack \left] \left\rbrack \left\{ \left\lbrace
\left\} \left\rbrace \left\lfloor \left\rfloor \left\lceil \left\rceil
\left\langle \left\rangle \left/ \left\backslash \left| \left\vert \left\|
\left\Vert \left\uparrow \left\Uparrow \left\downarrow \left\Downarrow
\left\updownarrow \left\Updownarrow {x^{x^{x^{x^{x^{x^{x^{x^{x^{x^x}}}}}}}}}}
\right.\right.\right.\right.\right.\right.\right.\right.\right.\right.
\right.\right.\right.\right.\right.\right.\right.\right.\right.\right.
\right.\right.\right.\right.\right.\right.\right.\right.

Test Plan:
 - Run the test input, see that it works
 - Run the tests, see that they work
 - Look at huxley screenshots (not here yet :( ) and make sure they look good

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D11602
2014-09-04 21:58:43 -07:00
Emily Eisenberg
513ae30fe1 Update fonts from the mathjax fonts Docker
Summary:
This incorporates the changes to add a KA copyright, and to generate the woffs
from the ttfs, not the otfs.

Test Plan:
 - Run huxley tests, see very little has changed (it looks like all the images
   shifted back down ~1/2 pixel, the opposite of what happened in ad97dab19c
   when we started making our own woffs, which means we probably are now
   generating woffs the same way fontsquirrel does)

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D12889
2014-09-04 17:54:15 -07:00
Emily Eisenberg
25374ea193 Change the scriptstyle size from 2/3em to 0.7em
Summary:
I don't know why we originally used 2/3em for scriptstyle, but both TeX
and MathJax use 0.7em for the scriptstyle size.

Test Plan:
- Look at huxley tests, make sure everything that changed is due to the change
  in font size

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D12869
2014-09-04 00:56:52 -07:00
Emily Eisenberg
e418fd9ee3 Update metrics using TeX metrics instead of TTF metrics
Summary:
Instead of using the metrics from our generated TTF files, use the fonts that
TeX ships with. Pull the mapping out of the MathJax-dev repo from makeFF to get
the correct mapping of metrics to font characters, and use our own tfm reader to
extract metrics out of the tfm files into a useable format. Add a README and
Makefile rule to make this process easier in the future.

Also remove the silly 0.05em we put on supsubs because our italic correction
works now.

Test Plan:
- Run huxley tests, see that changes are because of font metric changes.
- See that the extension piece of `\bigl |` now extends above the top, as it is
  supposed to.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D12867
2014-09-03 20:12:00 -07:00
Emily Eisenberg
f17bbf1b05 Add the '\rule' command for drawing boxes
Summary:
Supports the 'ex' and 'em' units for sizes. Doesn't support the optional depth
argument.

Test Plan:
 - See that the huxley test looks good, and nothing else changed
 - See that the tests pass

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D12777
2014-08-29 14:45:27 -07:00
Ben Alpert
a75bf1afc2 Add \scriptspace after superscripts and subscripts
Summary: Plain TeX assigns `\scriptspace=0.5pt`, which is used in Rules 18bcd in the TeXbook's Appendix G.

Test Plan:
- Look at `x^{x^{x_{x_{x_{x_x}}}}}\biggr|`, see a gap that looks similar to the one produced by real TeX.
- Look at the huxley tests, see that they look reasonable. Make sure that all changes to other huxley tests are now correct, and only changed because of this.

Reviewers: emily

Reviewed By: emily

Subscribers: jessie

Differential Revision: http://phabricator.khanacademy.org/D12763
2014-08-29 12:28:43 -07:00
Emily Eisenberg
056cba64ec Add some text next to the math in the vertical test
Auditors: alpert
2014-08-27 01:17:02 -07:00
Emily Eisenberg
04f13b9be8 Fix font sizing issues
Summary:
In LaTeX, large delimiters are the same font size as they are at a normal size,
regardless of the actual size. This means that we need to scale up the font size
in the inner nodes, which is annoying because we run into the same problem we
had with \Huge, etc in those nodes. Thus, this fixes both problems at once.

The problem was that when we used our baseline-align-hack and then increased the
font size inside of one of the middle (display: block and height: 0) nodes, the
node with the increased font size would shift downards (misaligning its
baseline). To fix this, we add a method for calculating the maximum font size
used in each of the nodes, and adding a small node with this font size to each
of the other nodes (including the fix-ie node). This shifts all of the nodes
down the same amount, and gets their baselines aligned.

Test Plan:
 - Do dumb things by putting \Huge and \big in places they shouldn't be, and
   make sure they behave responsibly
 - Do the same thing in IE 8, 9, 10, 11, Safari, Firefox, and make sure they all
   behave the same (to some approximation)
 - Make sure the new huxley image looks good, and the images that changed don't
   have significant changes

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D12684
2014-08-27 01:12:15 -07:00
Emily Eisenberg
efaf8b57b9 Remove console.log
Reviewers: alpert
2014-08-20 00:41:13 -07:00
Emily Eisenberg
ad97dab19c Update fonts from MathJax
Summary:
Also, rename all of our uses of fonts to use the uppercased versions. We want to
use the uppercase versions because it makes updating and modifying the fonts
much easier (since the font names inside the actual font files are uppercased).

Test Plan:
  - Make sure the huxley screenshots look good (You can compare a diff of them
    on github at
    f90d093361
    By my eye, it seems like some things have moved up ~1/2 pixel, and some of
    the fonts have maybe slightly changed shape, like the large `b` in
    SizingBaseline)

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D11979
2014-08-06 17:52:26 -07:00
Emily Eisenberg
fe6b67817c Add support for \overline
Summary:
Follow the instructions in the TeX book for drawing \overlines. This uses the
same code as fractions to produce the bars. Also added the ability to cramp
styles (i.e. T -> T' and T' -> T').

Test Plan:
 - Look at `\overline{x}`, `\overline{\dfrac{x}{y}+z}`, and
   `\blue{\overline{x}}` to make sure they look good.
 - Make sure the tests work
 - Make sure the huxley tests look good (Not here yet :( )

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D11604
2014-08-05 17:48:10 -07:00
Emily Eisenberg
100798847b Add delimiter sizing
Summary:
Make delimiter sizing work. This involved
 - Adding the symbols for the remaining delimiters (like `\lfloor` and `\{`)
 - Adding metrics for the size1, size2, size3, and size4 fonts
 - Parsing delimiter sizing functions
 - Using the big fonts when possible, otherwise building large copies of the
   delimiters from scratch

Test Plan:
 - See that
   `\bigl\uparrow\Bigl\downarrow\biggl\updownarrow\Biggl\Uparrow
    \Biggr\Downarrow\biggr\Updownarrow\bigm/\Bigm\backslash\biggm|
    \Biggm|\big\lceil\Big\rceil\bigg\langle\Bigg\rangle\bigl(\Bigl)
    \biggl[\Biggl]\Biggr\{\biggr\}\Bigr\lfloor\bigr\rfloor`
   parses correctly (this contains all of the delimiters, and all of the sizing
   modes)
 - See that the huxley tests didn't change, and the new one looks good
 - See the normal tests work

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D7844
2014-08-05 16:43:43 -07:00
Emily Eisenberg
07e8d468de Start using a docker to take huxley screenshots
These are the current screenshots using the docker created with this Dockerfile:

https://gist.github.com/xymostech/68d885cb6a4ff7a6e2ed

The screenshots are deterministic, so this will be the preferred way to create
huxley screenshots from now on.

Auditors: alpert
2014-08-05 14:38:18 -07:00
Emily Eisenberg
a66d285532 Switch from using huxley to node-huxley
Huxley had some strange problems where screenshots kept getting messed up by
becoming different sizes than they were before. Node-huxley seems to have fixed
this problem, so we'll try using that instead.

Also, fix the sizing tests to the new syntax.

Auditors: alpert
2014-07-10 18:28:43 -07:00
Emily Eisenberg
02935f7dde Add an 'implicit group' parser, use with sizing
Summary:
Implicit groups are objects that act like groups but don't have brackets around
them. This is used for things like sizing functions or font-change functions
that can occur in the middle of the group, but act like they apply to a group
after them which stops when the current group stops. E.g. `Hello {world \Large
hello} world` produces normal, normal, Large, normal text. (Note, I just came up
with the name implicit group, I don't think this is actually how it is parsed in
LaTeX but it fits nicely with the current parsing scheme and seems to work
well).

For now, apply this to the sizing functions (we don't have any other functions
that act like this). Also note that this doesn't really do much practically
because we limit sizing functions to only be on the top level of the expression,
but it does let people do `\Large x` and get a large `x`, without having to add
braces.

Test Plan:
 - Run the tests, see they work
 - Make sure `abc \Large abc` looks correct

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D10876
2014-07-10 16:06:19 -07:00
Ben Alpert
e46dd418b3 Ignore whitespace following \text
Summary:
In something like `\text {hello, world}` we want to ignore the first space but not the second. This suggests to me that perhaps we shouldn't be in text-lexing mode until we actually see the first curly brace, so this changes us to do that.

Note that this disallows doing unbraced text things now; it seemed nontrivial to lex a single text character while ignoring spaces. We should probably fix it sometime, but for now we'll fall back to MathJax anyway so I'm not super concerned.

We should also add a huxley test for this.

Test Plan: `\text {2x 2}` rendered `2x 2` in a non-italic font.

Reviewers: jack, emily

Reviewed By: emily

Differential Revision: http://phabricator.khanacademy.org/D9376
2014-05-30 12:29:32 -07:00
Emily Eisenberg
3173a6e53e Make supsubs work correctly with character boxes
Summary:
In rule 18a. of the TeX book, it says we're supposed to set `u` and `v` to 0 if
the nucleus is a character box. Character boxes are loosely defined, but through
experimentation they are anything that contains a single character, including
ordgroups with a single element in them. This change makes KaTeX follow this
rule, and fixes T2404.

Test Plan:
- Make sure the new huxley screenshot looks good
- Make sure none of the huxley tests have changed

Reviewers: alpert

Reviewed By: alpert

Maniphest Tasks: T2404

Differential Revision: http://phabricator.khanacademy.org/D8275
2014-04-17 14:44:30 -04:00
Emily Eisenberg
5416b92d5d Make rlap test a little easier to find errors in
Summary: See rKATc22d8644cc7f45443c6c0756ab64f2dfc2b454e0.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D7967
2014-04-14 21:52:52 -04:00
Emily Eisenberg
c22d8644cc Fix a weird bug with rlap
For some reason, when you have a nested elements that look like
  `display: inline-block; > position: relative; > position: absolute;`
then the `position: absolute;` element is shifted down a bunch. If there is
anything* else inside either of the other two elements, then this behavior
disappears. (This can be seen at [this fiddle](http://jsfiddle.net/qZXRr/). We
have this structure when we create `\llap` and `\rlap`s, and this weird behavior
So, to fix this I added an empty `display: inline-block;` span inside the llap
to fix this.

Test plan:
 - See that the new huxley image looks good
 - Test this in a bunch of browsers and see they also look good

Auditors: alpert
2014-03-29 23:33:05 -04:00
Emily Eisenberg
b5ef06b52d Fix our getTypeOfGroup function
Add in the missing `'sizing'` entry, put the `'text'` entry in the correct
place, and replace `groupToType.ord` (a null value) with `groupToType.mathord`
(something real).

Test Plan:
 - See that `^3+` now puts the correct space before the `+`
 - See the new huxley test works, and nothing else has changed

Auditors: alpert
2014-03-28 23:50:18 -04:00
Emily Eisenberg
4154c370ec Add tie symbol (~)
Summary:
Add real support for the tie symbol. Also, get rid of any of the
leftover bad support

Test Plan:
 - See the new normal tests succeed
 - See huxley tests didn't change except the new ones, which looks good

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D7772
2014-03-27 19:23:15 -04:00
Emily Eisenberg
d729ba5281 Add a \color command for custom colors
Summary:
Keep track of the color inside the style now, and use that when we are
rendering things. Added a custom lexing mode to handle lexing colors correctly.
Prefixed the old katex colors (internally) with "katex-" to distinguish them
from CSS colors.

Test Plan:
 - Run the normal tests, see they work
 - Run the huxley tests, see that they didn't change except for the color one
   which looks right

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D7763
2014-03-27 12:34:45 -04:00
Emily Eisenberg
7723d3dcaf First attempt at \text function
Summary:
Make all of the parsing functions keep track of whether they are
parsing in math mode or text mode. Then, add a separate lexing function to lex
text mode, which is different than the normal mode because it does weird things
with spacing and allows a different set of characters.

Test Plan:
 - See that the normal tests work
 - See that the huxley screenshot looks reasonable
 - See that none of the other huxley screenshots changed

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D7578
2014-03-26 22:17:41 -04:00
Ben Alpert
bff85c638b Compile .less on demand for test page
Test Plan: Opened test page in Chrome and IE8, saw math.

Reviewers: emily

Reviewed By: emily

Differential Revision: http://phabricator.khanacademy.org/D7581
2014-03-20 20:22:07 -07:00
Emily Eisenberg
204270fa0d Somehow manage to fix the sizing bugs
Summary:
Remove a single `vertical-align: top`, and somewhow it now works. May
the gods of CSS have mercy on us. Also added some tests.

Test Plan:
 - See that the huxley tests don't have any changes
 - See that the new huxley screenshots look reasonable
 - Run the normal tests and see that they work

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D7494
2014-03-20 21:36:37 -04:00
Emily Eisenberg
63fda74202 Make marginRight work in firefox
Summary:
`.style["margin-right"]` doesn't work in firefox, but
`.style.marginRight` does.

Test Plan:
- Look at `b\llap{f}` in chrome and firefox
- Make sure it looks the same (or at least very similar) in both

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D7476
2014-03-17 23:44:36 -04:00
Emily Eisenberg
a7820b12ff Add huxley screenshot tests
Summary:
Add in a testing page, which just renders the location hash in the body. Use
this to make some screenshot tests in huxley. Note, these screenshots were made
in Firefox on a Linux computer, so running the tests somewhere else might
produce something else.

Test Plan:
- Serve KaTeX (`make serve`)
- Run a Selenium Server (I used selenium 2.40.0)
- Run `huxley` from the test/huxley/ directory
- Ensure that all of the tests pass

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D7258
2014-03-11 16:29:45 -06:00
Alex Lopatin
a3663ce17c Basic perceptual diffing support for KaTeX
Summary:
This commit adds an HTML file for creating perceptual diffs (pdiff.html),
a reference screenshot of that HTML file (pdiff.png), and a quick script
for comparing that screenshot to a newly generated one (pdiff.js).

Also added a basic README.

Test Plan: make pdiff

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D6415
2014-01-29 16:29:21 -08:00
Alex Lopatin
8c179252c5 Added \cong + fixed comment copypasta.
Test Plan: Parses and renders locally.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D6393
2014-01-28 16:13:51 -08:00
Ben Alpert
944b55a6b0 Make supsub work with empty nucleus
Auditors: emily
2013-08-17 16:14:06 -07:00
Emily Eisenberg
0a3a2271f4 Add ability to calculate heights/depths
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
2013-08-13 18:16:43 -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
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