Commit Graph

305 Commits

Author SHA1 Message Date
Kevin Barabash
549c2bf858 Merge pull request #293 from gagern/matrices
Matrices should be of type ord
2015-07-10 09:52:49 -06:00
Martin von Gagern
6362e0f8f2 Test case demonstrating the desired spacing around an array 2015-07-10 17:37:53 +02:00
Martin von Gagern
8bff74ca09 Change group type of array from inner to ord
This is a consequence of Rule 8 of Appendix G of The Tex Book.
2015-07-10 17:37:53 +02:00
Martin von Gagern
f05ff9c5fa Offer some help working out the types of math formula atoms 2015-07-10 17:36:52 +02:00
Kevin Barabash
6357a34828 Merge pull request #303 from gagern/metrics
Improve font metrics creation
2015-07-10 09:07:59 -06:00
Martin von Gagern
b290d4ad76 Switch from fontforge to fonttools
The dependencies of fonttools are much lighter than fontforge, and since all
we need are some metrics, fonttools is very much up to that task.

This addresses issue #288.
2015-07-10 14:32:02 +02:00
Martin von Gagern
d26a67f220 Avoid non-determinisms related to font metric generation
We had some duplicate mappings in mappings to start with.  Now we have some
code to complain loudly about these, and all currently existing duplicates
have been dealt with.

We also had a problem where in some Python dict, existing stuff was using
strings as keys while new data would use numeric indices, thus not
overwriting the previous value.  Now we always use strings as keys.

Along the road, the italic dotless i and j symbols were changed
so that they now are taken from cmmi10 instead of cmti10.
2015-07-10 14:30:42 +02:00
Martin von Gagern
86115b8fce Format font metrix data to have one row for each glyph
This will make reviewing modifications easier, since the affected glyphs
will be more readily visible in the diff.
The formatting tool was applied to the existing data, instead of
regenerating the data, so the semantic content should be unmodified.
2015-07-10 14:30:42 +02:00
Martin von Gagern
1603162267 Save auto-generated font metrics data to separate JSON file
This separates auto-generated code from manually created code.
We need a more recent version of browserify to directly require JSON.
Note that the data was copied, not recreated, so it has not been changed.
This addresses issue #301.
2015-07-10 14:30:41 +02:00
Martin von Gagern
1f8610cebe Auto-detect python binary
We now try whether there is an executable called python2, and if so,
use that in preference to python when executing the metric computation.
Furthermore, we allow the user to specify the path of the python binary
using the PYTHON variable of make, i.e. “make PYTHON=/foo/python2 metrics”.
2015-07-09 14:44:01 +02:00
Kevin Barabash
6cf8c5aacb add a link to Examining TeX page on wiki to CONTRIBUTING.md
Auditors: emily
2015-07-08 23:38:40 -06:00
Kevin Barabash
8009059b7c Merge pull request #295 from gagern/fracspace
Improve horizontal spacing of fractions
2015-07-08 18:17:28 -06:00
Emily Eisenberg
d00caf6ed7 Merge pull request #298 from gagern/Bmatrix
Implement Bmatrix environment
2015-07-08 17:01:08 -07:00
Martin von Gagern
ec3cbb8656 Implement Bmatrix environment 2015-07-08 22:47:22 +02:00
Martin von Gagern
7dc8b68092 Improve horizontal spacing of fractions
A fraction is surrounded by a box of width \nulldelimiterspace on either side.
That size is 1.2pt and does not scale with the style or font size.
Furthermore, a \frac creates a brace-enclosed group which results in a
\mathord, not a \mathinner.
2015-07-07 10:03:34 +02:00
Kevin Barabash
a06744e941 Merge pull request #268 from gagern/texcmp
Generate reference images from LaTeX
2015-07-06 21:04:39 -06:00
Martin von Gagern
c562813afa Take snapshots of formulas rendered by LaTeX and compute visual diffs
The same test cases we use for our screenshots from Firefox are now also
being rendered by pdflatex, so the resulting images can be used as reference
for how things are supposed to look (if we concentrate on compatibility with
LaTeX).  To make comparisons even easier, the differences between LaTeX and
Firefox snapshots are rendered in a visual way, using different colors.

Discussed in pull request #268.
2015-07-06 15:54:14 +02:00
Kevin Barabash
7be056c1f4 Merge pull request #283 from kevinb7/kevinb7-patch-4
Update CONTRIBUTING.md
2015-07-03 10:17:09 -06:00
Kevin Barabash
53b0a9ad7a Update CONTRIBUTING.md
added "Pull Requests" section with some guidelines, plus some addition code style guidelines.

fix grammar and be more specific about splitting large pull request

Update CONTRIBUTING.md
2015-07-03 10:14:06 -06:00
Kevin Barabash
87b2cc95bf Merge pull request #284 from kevinb7/kevinb7-patch-5
Updated Makefile so that it "make dist" works on OS X
2015-07-02 14:36:28 -06:00
Kevin Barabash
2e9fdee780 Merge pull request #285 from kevinb7/kevinb7-patch-6
Added a link to the list of commands on the wiki.
2015-07-02 14:34:24 -06:00
Kevin Barabash
1a11eb46b2 Added a link to the list of commands on the wiki. 2015-07-01 20:21:55 -06:00
Kevin Barabash
39489ab479 Update Makefile
```cp --recursive``` isn't supported on Mac OS X so use ```cp -R``` instead.
2015-07-01 20:18:40 -06:00
Kevin Barabash
1ac6b41990 Merge pull request #280 from JeffEverett/master
Add two AMS symbols: checkmark and circledR
2015-07-01 07:24:11 -06:00
Jeff Everett
eaf89dd45d Add two AMS symbols: checkmark and circledR 2015-07-01 01:57:57 -06:00
Kevin Barabash
41e3fa6659 Merge pull request #279 from gagern/cases
Implement cases environment
2015-07-01 00:08:36 -06:00
Martin von Gagern
758bdba31e Implement cases environment
See issue #278.  Although the official definition makes use of @{…}
notation, we use custom spacing instead, since that seems easier for now.
2015-07-01 08:05:08 +02:00
Emily Eisenberg
7f1b53cbfd Fix arc lint
Summary: Move the linting configuration to `.arclint` so that `arc lint`
works again.

Test plan:
 - `arc lint`

Auditors: alpert
2015-06-26 13:57:02 -07:00
Emily Eisenberg
8931e5b45c Cleanup Makefile
Summary: Ensure that `make dist` is idempotent, and make sure comments
don't get printed out.

Test plan:
 - `make dist`
 - `make dist` again
 - See that there's no `katex` directory in `dist/`
 - See that no comments are printed out during `make dist`

Auditors: alpert
2015-06-20 12:22:04 -07:00
Emily Eisenberg
c18d3ad6c4 Remove font files and auto-render from bower's main
Summary: Bower's bower.json spec says to not include font/image files,
and only to include one file per filetype.

Test plan:
 - `make dist`, commit the result
 - Run `bower install /path/to/KaTeX#master` from /tmp
 - See that this succeeds, and `bower list --paths` has katex.min.js and
   katex.min.css for the KaTeX entry

Auditors: alpert, kevinb
2015-06-20 12:06:30 -07:00
Kevin Barabash
4ea7d38b5c Summary: add "main" field instead of "name" to bower.json
Test plan:
 - Run `bower install katex` from /tmp
 - Verify that there are no errors when running the command
 - Verify that `bower_components/katex/dist/` contains all the build files
 - Verify that the version is 0.4.2

Auditors: emily
2015-06-20 11:08:58 -06:00
Kevin Barabash
b11a1b97b7 Summary:
- Add "main" field to bower.json to prevent errors during installation.
- Bump version to 0.4.1 in bower.json and package.json

https://github.com/Khan/KaTeX/issues/181

Test plan:
 - Run `bower install katex` from /tmp
 - Verify that there are no errors when running the command
   and that `bower_components/katex/dist/` contains all the build files

Auditors: emily
2015-06-20 11:00:41 -06:00
Emily Eisenberg
2060ebaf21 Add a bower.json
Summary: Add a bower.json so KaTeX can be included using bower.

Test plan:
 - Run `bower install /path/to/KaTeX#this-commit` from /tmp
 - See that `bower_components/KaTeX` contains only the full `dist/`
   directory

Auditors: alpert
2015-06-18 15:29:28 -07:00
Emily Eisenberg
75296a3fef Add a dist rule to the Makefile
Summary: Adds a `dist` rule to the Makefile which builds the `dist/`
directory with all of the built files in it.

Test plan:
 - `make dist`

Auditors: alpert
2015-06-18 15:22:12 -07:00
Kevin Barabash
32e8ffef4f Merge pull request #246 from gagern/matrices
Matrices, arrays, environments
2015-06-18 14:35:48 -06:00
Martin von Gagern
397dcb303b Simplify stacked delimiters
Using a loop to determine the number of symbols we need is intuitive but
hardly efficient.  A Math.ceil in this situation is much better.

After that ceil or the loop that it replaced, the total height should be
equal to the minimal height plus an integral number times the height of the
repeat symbol.  That integer equals (half) number of loop iterations in the
original code, and the repeatCount variable in my new code.  So later on,
the quotient (repeatHeight / repeatHeightTotal) should be an integer, at
least up to numeric errors.  Applying ceil instead of round to that is
asking for these numeric errors to seriously break stuff.  Just reusing the
repeatCount is much simpler, shorter and more elegant.

Having distinct topSymbolCount and bottomSymbolCount seems pointless, since
the only reason why these could ever be different is due to the fact that
bottomRepeatHeight was computed using topHeightTotal, which looks like a
bug.  The old loop and new ceil assume a symmetric repeatCount.
2015-06-18 22:24:40 +02:00
Martin von Gagern
2f7a54877a Implement environments, for arrays and matrices in particular
This commit introduces environments, and implements the parser
infrastructure to handle them, even including arguments after the
“\begin{name}” construct.  It also offers a way to turn array-like data
structures, i.e. delimited by “&” and “\\”, into nested arrays of groups.
Environments are essentially functions which call back to the parser to
parse their body.  It is their responsibility to stop at the next “\end”,
while the parser takes care of verifing that the names match between
“\begin” and “\end”.  The environment has to return a ParseResult, to
provide the position that goes with the resulting node.

One application of this is the “array” environment.  So far, it supports
column alignment, but no column separators, and no multi-column shorthands
using “*{…}”.  Building on the same infrastructure, there are “matrix”,
“pmatrix”, “bmatrix”, “vmatrix” and “Vmatrix” environments.  Internally
these are just “\left..\right” wrapped around an array with no margins at
its ends.  Spacing for arrays and matrices was derived from the LaTeX
sources, and comments indicate the appropriate references.

Now we have hard-wired breaks in parseExpression, to always break on “}”,
“\end”, “\right”, “&”, “\\” and “\cr”.  This means that these symbols are
never PART of an expression, at least not without some nesting.  They may
follow AFTER an expression, and the caller of parseExpression should be
expecting them.  The implicit groups for sizing or styling don't care what
ended the expression, which is all right for them.  We still have support
for breakOnToken, but now it is only used for “]” since that MAY be used to
terminate an optional argument, but otherwise it's an ordinary symbol.
2015-06-18 22:24:40 +02:00
Emily Eisenberg
5cf5617c09 Merge pull request #245 from mjbshaw/display-mode-cli
Add display mode to the CLI
2015-06-10 14:47:11 -07:00
Michael Bradshaw
42afd97f03 Add display mode to the CLI 2015-06-10 07:15:53 -07:00
Ben Alpert
0a0a3430b5 Bump version in README
Fixes #241.
2015-06-05 02:00:15 -07:00
hathix
9869d59cad 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
2015-05-26 19:07:51 -07:00
John Resig
8691486392 Merge pull request #227 from jeresig/parseTree
Expose a new .__parse() method for generating a parse tree from a math expression
2015-05-07 11:09:48 -04:00
John Resig
b9eb8c74e0 Expose a new .__parse() method for generating a parse tree from a math expression. 2015-05-04 15:59:18 -04:00
Emily Eisenberg
c87b20aadd Merge pull request #225 from jeresig/clone-buildhtml
buildHTML's buildExpression is destructive, changing the tree object.
2015-05-01 11:43:09 -07:00
John Resig
3875af8763 buildHTML's buildExpression is destructive, changing the tree object, this clones the object first before manipulating it. 2015-05-01 11:53:22 -04:00
Ben Alpert
1f90b36518 Add JSON as a global in .jshintrc 2015-04-26 17:22:42 -07:00
Ben Alpert
b29b8c40ea [auto-render] Don't stop parsing when one expression fails
Summary: Fixes #223.

Test Plan: Opened http://127.0.0.1:7936/contrib/auto-render/, saw `$\unsupported$` in page and error in console, but other expressions rendered. Made test.

Reviewers: emily

Reviewed By: emily

Differential Revision: https://phabricator.khanacademy.org/D17543
2015-04-26 17:04:11 -07:00
Emily Eisenberg
af8c1307f7 Add better lint checking.
Summary:
Make the lint checker check more files. Also, make arc run the
linter.

Test Plan:
 - `arc lint`
 - `make lint`

Reviewers: kevinb, alpert

Reviewed By: alpert

Differential Revision: https://phabricator.khanacademy.org/D17509
2015-04-22 18:55:20 -07:00
Emily Eisenberg
eef108b2dd Fix lint
Test plan:
 - `npm test`

Auditors: alpert
2015-04-22 15:33:26 -07:00
Emily Eisenberg
c48de165e8 Add optional arguments to \sqrt
Summary:
Use the TeX definitions of `\root` to get the optional `\sqrt`
argument in the right place. Also add the MathML version.

Fixes #48

Test Plan:
 - `make test`
 - See that the images look good

Reviewers: kevinb, alpert

Reviewed By: alpert

Differential Revision: https://phabricator.khanacademy.org/D17236
2015-04-22 15:26:10 -07:00