Commit Graph

189 Commits

Author SHA1 Message Date
Emily Eisenberg
bd6ebf23dd Merge pull request #54 from adammark/patch-1
Update README.md
2014-09-19 11:49:02 -07:00
Emily Eisenberg
73c33b015a Merge pull request #72 from evestera/setrelops
Added set theory and logic symbols
2014-09-18 22:06:33 -07:00
Erik Vesteraas
840ab70191 Added various set theory and logic symbols
\subset, \supset, \subseteq, \supseteq, \cap, \cup, \setminus,
\neg, \lnot, \top, \bot, \emptyset, \varnothing, \land, \lor,
\wedge, \vee, \notin, \nsubseteq, \nsupseteq, \models
2014-09-19 06:59:59 +02:00
Emily Eisenberg
5476c849c9 Merge pull request #44 from grizzilus/master
Fix license typo in README
2014-09-18 21:03:11 -07:00
Emily Eisenberg
1f9393476b Add CLA information in CONTRIBUTING.md
Auditors: alpert
2014-09-18 20:05:51 -07:00
Emily Eisenberg
ea5ee95dbe Warn when the website is in quirks mode
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
2014-09-17 15:13:56 -07:00
Emily Eisenberg
b7e55607cc Add skew and italic metrics for ttfs
Summary:
Add the ability to base the metrics for a TTF character on the metrics
from one of the TFM characters.

Test Plan:
 - Make sure the tests still work
 - Make sure huxley tests didn't change

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13217
2014-09-16 17:40:20 -07:00
Emily Eisenberg
e6b3cbe7c1 Add font metrics for \iint, \iiint
Also, fix the python dict keys so we actually get the metrics back into the
javascript correctly.

Fixes #56

Auditors: alpert
2014-09-16 16:00:30 -07:00
Adam Mark
5cfa59e5b6 Update README.md
Must specify UTF-8 in document for math characters to render properly.
2014-09-16 11:17:18 -04:00
Jeremy Engel
199bc00385 Fix license typo in README 2014-09-15 18:05:10 -07:00
Emily Eisenberg
aa7052d03a Merge pull request #39 from mgp/master
Fix links to JS source files
2014-09-15 13:24:28 -07:00
Mike Parker
faf69f238a Fix links to JS source files
These links were missing the `src` path component.
2014-09-15 12:51:29 -07:00
Emily Eisenberg
f76688b639 Bump version to v0.1.0
Also ready KaTeX for releasing

Auditors: alpert
2014-09-15 03:04:11 -07:00
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
032b8a63e6 Improve readme
Add good README and CONTRIBUTING files.

Auditors: alpert
2014-09-15 02:41:19 -07:00
Emily Eisenberg
38a6ce7990 Add a Dockerfile for huxley tests
Summary:
Add the dockerfile that I've been using to make huxley screenshots so
others can test their changes by making huxley screenshots. Include a readme
about how to use it correctly.

Test Plan: - Use the dockerfile by running the given commands, see it works

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D12773
2014-09-14 21:30:06 -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
f63af87f17 Add looots of comments
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
2014-09-14 19:23:39 -07:00
Ben Alpert
79a5687057 Add Travis badge to README
Auditors: emily
2014-09-14 16:02:52 -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
0d42a902ac Fix dots spacing
\cdots, \ddots, and \vdots are all ords, not puncts.

Test plan:
 - Make sure no huxley tests changed

Auditors: alpert
2014-09-13 19:25:15 -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
Ben Alpert
3e78a76a47 Enable travis-ci.org
This tests against Node 0.10 (latest stable) and 0.11 (latest dev).

Test Plan: Crossed fingers. In theory we'll see this at https://travis-ci.org/Khan/KaTeX as soon as I push it.

Auditors: emily
2014-09-12 17:50:39 -07:00
Emily Eisenberg
79ab06d88d Get rid of the lookahead-y dots
Summary:
The `\dots` and `\dots{c,o,b,i,m}` commands do more than just show characters,
they add extra space and `\dots` also looks ahead to determine what kind of
environment it is in (see [this math.sx post]
(http://tex.stackexchange.com/questions/122491/difference-of-the-dots)). We
can't support that yet, so remove them.

Also, add comments to the extract_ttf script to show what caracters we are
extracting metrics for.

Test Plan: - Make sure tests work

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13151
2014-09-12 17:29:49 -07:00
Emily Eisenberg
2920348bdd Fix large integrals in IE 8
IE 8 clips the \int sign when it is `display: inline-block`. This fixes that.

Test plan:
 - Make sure no huxley tests changed

Auditors: alpert
2014-09-12 16:27:48 -07:00
Emily Eisenberg
ad056abbaf Fix undefined maxFontSize
Fix getting a NaN maxFontSize in makeVList because symbolNodes don't have a
maxFontSize property.

Test plan:
 - Make sure no huxley screenshots changed

Auditors: alpert
2014-09-12 15:38:48 -07:00
Emily Eisenberg
6ee2ecf47e Add \dots commands
Add all of the \dots commands, and import their metrics from the ttf files.

Fixes #23

Auditors: alpert
2014-09-12 15:02:18 -07:00
Emily Eisenberg
71da6aa50f Add the ability to extract metrics from ttfs
Summary:
Upon switching over from ttf metrics to TeX metrics, we lost metrics for a
couple of the characters that are dynamically generated by TeX. Thus TeX doesn't
have metrics for them, but our fonts do have the characters because the MathJax
scripts also dynamically build them. This adds the ability to extract metrics
from the generated font files so that we can use the generated characters
correctly. A better solution would be to dynamically generate the characters
ourselves, but that is much harder, and will be left to a future time.

Test Plan:
 - Make sure typing "\neq \cong \text{ }" produces no warnings in the console.
 - Make sure huxley screenshots look the same

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13107
2014-09-12 14:59:28 -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
5cca3a299e Cleanup package.json
Add a license, main file, and add missing huxley dependency

Auditors: alpert
2014-09-12 02:23:00 -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
Ben Alpert
5b4fa72299 Remove pdiff from README
Test Plan: Crossed fingers.

Auditors: emily
2014-09-06 23:24:26 -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
Ben Alpert
5a94faac9e Render nothing for /?text=
Test Plan: Went to /?text=, saw nothing (instead of the default).

Auditors: emily
2014-09-05 23:57:29 -07:00
Emily Eisenberg
edb42c50f8 Clean up the Makefile, package.json
Make the makefile more sane, add minification of CSS, and add and remove
necessary npm modules.

Auditors: alpert
2014-09-05 13:24:31 -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
2d2d319287 Fix the docker command
Auditors: alpert
2014-08-30 22:42:26 -07:00
Emily Eisenberg
eb31c6880b Make \rules work in script and scriptscript sizes
Auditors: alpert
2014-08-30 22:41:32 -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