Commit Graph

17 Commits

Author SHA1 Message Date
Ben Alpert
fe346f56ca Add \langle and \rangle
Auditors: alex
2014-01-16 22:32:24 -08:00
Ben Alpert
330b1f5873 Add \le, \ge, \ne symbols
Auditors: eater
2014-01-13 13:37:27 -08:00
Ben Alpert
c8ba6a698f Add \in
Auditors: eater
2014-01-10 11:56:42 -08:00
Ben Alpert
20994d7351 Prevent line breaks immediately after math
For whatever reason, `<inline-block/>,` allows a break in between the block and the comma. `<nobr><inline-block/></nobr>,` doesn't.

Auditors: emily
2013-12-16 05:46:04 -08:00
Ben Alpert
302f5502ef Add \approx as a symbol
This is important because the interactive graph labels use \approx now for polygon sides and it feels really sluggish with MathJax.
2013-11-21 22:15:25 -08:00
Ben Alpert
f3225ee7ee Add percent sign
Auditors: emily
2013-09-13 16:10:34 -07:00
Ben Alpert
2efa794fd3 Add \triangle
Auditors: emily
2013-08-27 18:33:40 -07:00
Emily Eisenberg
8a8a9505cb Fix sizing
Make sizing blocks inline-block

Auditors: alpert
2013-08-22 17:14:55 -07:00
Emily Eisenberg
387c159a8e Add sizing functions (like \small)
Summary:
Right now, when the size gets bigger, this still doesn't work, so there's a
check to prevent that. However, functions that go smaller (like `\small`,
`\tiny`, etc) do work. Also, we can't seem to use the sizing functions inside
of fractions (so something like `\dfrac{\small\frac{x}{y}}{z}` doesn't work).
However, the most prominent use case is `\small` as the outer-most object, so
this is still helpful. This commit has the parsing and stuff to handle all of
it, but it'll throw an error if you try to do something that doesn't work. (For
the record, "doesn't work" means "looks bad", not "throws an unexpected
error").

Test Plan:
Make sure things like `\small x` work, and things like `\Huge x` and
`\frac{\small x}{y}` don't.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D3619
2013-08-21 20:22:24 -07:00
Ben Alpert
944b55a6b0 Make supsub work with empty nucleus
Auditors: emily
2013-08-17 16:14:06 -07:00
Emily Eisenberg
920dd0bef9 Add some AMS characters
Summary:
\nleq and \ngeq are AMS characters, so add support for parsing and
showing those. Also, add font metrics from the ams_regular font.

Test Plan:
View `\ngeq \geq`, make sure that they look the same but with a
slash through `\ngeq`. View `a \ngeq b`, make sure there's the right spacing
for a rel.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D3547
2013-08-14 17:39:24 -07:00
Ben Alpert
7f25fd7dc9 Parse metrics directly from .ttf files
Summary:
Fixes T1325.

This has the advantage of not having to do the mapping manually. Also it means that characters like \neq are included in the mapping, so this resolves T1323 as well.

I opted to group the metrics by character instead of by metric type because I think it'll gzip better and it makes getCharacterMetrics simpler anyway.

Test Plan: The test page looks identical to the pixel to my eye.

Reviewers: emily

Reviewed By: emily

Maniphest Tasks: T1323, T1325

Differential Revision: http://phabricator.khanacademy.org/D3535
2013-08-14 10:57:00 -07:00
Emily Eisenberg
9fc357b8a1 Add italic correction
Summary: Add margin to the right of characters that have italic correction.

Test Plan:
Look at `f'` and `C'` before and after. Note that they both now look
good at small font sizes (like 17pt).

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D3534
2013-08-14 10:51:09 -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
Emily Eisenberg
5788a76dcf Do bin -> ord for all the correct types
Fixes T1303

Auditors: alpert
2013-08-10 03:23:46 -07:00
Emily Eisenberg
7e5e6a90d3 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
2013-08-09 20:51:05 -07:00
Emily Eisenberg
cfb9f2b31b Refactor some stuff
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
2013-08-06 14:12:06 -07:00