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.
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
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
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
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
- 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
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
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
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.
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.
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
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
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
Summary: Theoretically this allocates way less. In practice it seems to be exactly the same speed.
Test Plan: make test
Reviewers: emily
Reviewed By: emily
Differential Revision: https://phabricator.khanacademy.org/D16621
Summary:
Add an auto-render extension to render math on a page. It
exposes a global function (maybe we should attach it to `katex`?) to
render math in an element. It comes with a README on how to use it.
Also, make `make build` build the minified file.
Fixes#26
Test Plan:
- Visit http://localhost:7936/contrib/auto-render/
- See that all of the math renders correctly
- `make test`
Reviewers: alpert, kevinb
Reviewed By: kevinb
Differential Revision: https://phabricator.khanacademy.org/D16620
Summary:
The greediness of the `\color` function wasn't set correctly,
leading to expressions like `\color{red}\text{a}` parsing correctly,
when they shouldn't. (This is based on how MathJax parses, since TeX
doesn't have a `\color` function, so MathJax is the standard).
Test Plan:
- Make test
- See that `\color{red}\text{a}` doesn't parse (like MathJax)
- See that `\color{red}{\text{a}}` does parse (like MathJax)
- See that `\color{red}\frac12` doesn't parse (like MathJax)
- See that `\color{red}{\frac12}` does parse (like MathJax)
- See that `\red\text{a}` doesn't parse (like MathJax)
- See that `\red{\text{a}}` does parse (like MathJax)
- See that `\red\frac12` doesn't parse (like MathJax)
- See that `\red{\frac12}` does parse (like MathJax)
Reviewers: alpert
Reviewed By: alpert
Differential Revision: https://phabricator.khanacademy.org/D17130
Summary:
Using \phantom with non-phantom math in Perseus doesn't render to be the
same size because \phantom uses MathJax and the non-phantom math uses KaTeX.
Implementing \phantom in KaTeX should solve this alignment issue.
Test Plan:
[x] write (and run) unit tests
[x] create (and run) screenshotter tests
Reviewers: emily
Reviewed By: emily
Differential Revision: https://phabricator.khanacademy.org/D16720
Summary:
Create our own screenshotting script which takes screenshots. This
improves over huxley for a couple reasons:
- It makes the screenshots the correct size (for some reason, huxley struggles
with this).
- Its configuration matches more with what we want (we don't need multiple
screenshots or interaction, we just want a single static shot)
- It runs faster
I also changed the docs to reflect this change.
Test Plan:
- Make sure all of the tests that were in the Huxleyfile are now in ss_data.json
- Run the screenshotter docker
- Make sure all of the images look reasonable and don't change (except
sometimes the Lap test, which has some strange pixel-positioning
differences...)
Reviewers: kevinb
Reviewed By: kevinb
Differential Revision: https://phabricator.khanacademy.org/D16731