Commit Graph

244 Commits

Author SHA1 Message Date
Emily Eisenberg
51d751f96d Make text operators <mi>s
Summary: According to the MathML spec [about
identifiers](http://www.w3.org/TR/MathML3/chapter3.html#id.3.2.3.3),
text function names should be <mi>s. This fixes that.

Fixes #202

Test plan:
 - `make test`

Auditors: alpert
2015-03-13 08:11:21 -07:00
Emily Eisenberg
2f552af02d Make our own screenshotting script instead of using huxley
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
2015-03-12 16:40:15 -07:00
Emily Eisenberg
d9396c205a Merge pull request #196 from PeterDaveHello/patch-1
bump version number to v0.2.0 in cdn url
2015-03-12 07:28:44 -07:00
Emily Eisenberg
e1fb6e667c Merge pull request #176 from janmarthedal/bin-symbols
Make \bigtriangledown, \oplus and others Bin operators (and not Ord)
2015-03-10 08:37:46 -07:00
Emily Eisenberg
91376a4d26 Fix MathML CSS
Summary: Make the CSS rules that hide the MathML rendering not
`!important`, so that they can be overridden. Also, remove the useless
`math.katex` rule.

Fixes #197

Test plan:
 - `make test`
 - See that huxley screenshots haven't changed

Auditors: alpert
2015-03-09 12:22:43 -07:00
Peter Dave Hello
ba3bbe7558 bump version number to v0.2.0 in cdn url 2015-03-08 13:53:43 +08:00
Ben Alpert
c901083e59 Release 0.2.0 2015-03-01 18:44:07 -08:00
Emily Eisenberg
aaeab1200c Add MathML rendering to improve accessibility
Summary:
This adds support for rendering KaTeX to both HTML and MathML
with the intent of improving accessibility. To accomplish this, both
MathML and HTML are rendered, but with the MathML visually hidden and
the HTML spans aria-hidden. Hopefully, this should produce much better
accessibility for KaTeX.

Should fix/improve #38

Closes #189

Test Plan:
 - Ensure all the tests, and the new tests, still pass.
 - Ensure that for each of the group types in `buildHTML.js`, there is a
   corresponding one in `buildMathML.js`.
 - Ensure that the huxley screenshots didn't change (except for
   BinomTest, which changed because I fixed a bug in `buildHTML` where
   `genfrac` didn't have a `groupToType` mapping).
 - Run ChromeVox on the test page, render some math. (for example,
   `\sqrt{x^2}`)
   - Ensure that a mathy-sounding expression is read. (I hear "group
     square root of x squared math").
   - Ensure that nothing else is read (like no "x" or "2").
 - Ensure that MathML markup is generated correctly and is interpreted
   by the browser correctly by running
   `document.getElementById("math").innerHTML =
   katex.renderToString("\\sqrt{x^2}");` and seeing that the same speech
   is read.

Reviewers: john, alpert

Reviewed By: john, alpert

Subscribers: alpert, john

Differential Revision: https://phabricator.khanacademy.org/D16373
2015-03-01 18:33:20 -08:00
Ben Alpert
2349a1ed85 Merge pull request #127 from kevinb7/contrib_style_decls
Added rule to the style guide section for where to declare variables
2015-03-01 18:27:21 -08:00
Emily Eisenberg
fd18f6979e Add an optional settings argument to render calls
Summary:
Add the ability to pass in options to the render calls which contain information about the parse. This information is passed around to the parser and builder, which parse and render differently depending on the options. Currently, this includes an option to render the math in display mode (i.e. centered, block level, and in displaystyle).

Also added some changes to make it easier to add new data to functions (now that new data doesn't need to be copied into the ParseFuncOrArg data structure, it is looked up when it is needed) and has more sane support for the `'original'` argType (as suggested by pull request #93).

Test Plan:
 - Make sure tests and lint pass
 - Make sure huxley screenshots didn't change, and new screenshot looks correct

Reviewers: alpert

Reviewed By: alpert

Differential Revision: https://phabricator.khanacademy.org/D13810
2015-02-19 15:26:57 -08:00
Emily Eisenberg
d61a04c80d Fix up small problems with #126
Summary:
 - Some of the symbols were of the wrong type (I wrote some scripts to
   search the TeX source for the correct types for the symbols; I should
   put these somewhere for future reference)
 - Some of the symbols had the incorrect unicode replacement value. I
   copied what MathJax used for the ones that were wrong. In one case,
   something had the wrong font, so I used the one MathJax used.
 - Some symbols were duplicates of existing symbols, those were removed.
 - Some symbols are text symbols that aren't usable in math mode (maybe
   they should be text symbols?) (`\aa`, `\AA`, etc.)
 - Some symbols didn't seem to work/I couldn't figure out how to make
   them work. For example, `\imath` and `\jmath` require an italic font
   in KaTeX_Main, but we don't have the ability to do that yet. `\dots`
   was removed because it's not an ordinary symbol. `\*vert` were
   removed because I don't understand what they're for, nor what they
   should look like.
 - Some symbols weren't actually in the KaTeX fonts; to make sure they
   don't fall back to something weird, I removed them. (`\S`, `\pounds`,
   etc.)

Test plan:
 - `make test`
 - See that all of the symbols in: `\equiv \prec \succ \sim \perp
   \preceq \succeq \simeq \mid \ll \gg \asymp \parallel \bowtie \smile
   \sqsubseteq \sqsupseteq \doteq \frown \ni \propto \vdash \dashv \owns
   \ldotp \cdotp \aleph \forall \hbar \exists \nabla \flat \ell \natural
   \clubsuit \wp \sharp \diamondsuit \Re \heartsuit \Im \spadesuit
   \rmoustache \lmoustache \rgroup \lgroup \mp \ominus \uplus \sqcap
   \ast \sqcup \bigcirc \bullet \ddagger \wr \amalg \longleftarrow
   \Leftarrow \Longleftarrow \longrightarrow \Rightarrow \Longrightarrow
   \leftrightarrow \longleftrightarrow \Leftrightarrow
   \Longleftrightarrow \mapsto \longmapsto \nearrow \hookleftarrow
   \hookrightarrow \searrow \leftharpoonup \rightharpoonup \swarrow
   \leftharpoondown \rightharpoondown \nwarrow \rightleftharpoons \nless
   \nleqslant \nleqq \lneq \lneqq \lvertneqq \lnsim \lnapprox \nprec
   \npreceq \precnsim \precnapprox \nsim \nshortmid \nmid \nvdash
   \nvDash \ntriangleleft \ntrianglelefteq \subsetneq \varsubsetneq
   \subsetneqq \varsubsetneqq \ngtr \ngeqslant \ngeqq \gneq \gneqq
   \gvertneqq \gnsim \gnapprox \nsucc \nsucceq \succnsim \succnapprox
   \ncong \nshortparallel \nparallel \nVDash \ntriangleright
   \ntrianglerighteq \nsupseteqq \supsetneq \varsupsetneq \supsetneqq
   \varsupsetneqq \nVdash \precneqq \succneqq \nsubseteqq \unlhd \unrhd
   \nleftarrow \nrightarrow \nLeftarrow \nRightarrow \nleftrightarrow
   \nLeftrightarrow \vartriangle \hslash \triangledown \lozenge
   \circledS \measuredangle \nexists \mho \Finv \Game \Bbbk \backprime
   \blacktriangle \blacktriangledown \blacksquare \blacklozenge \bigstar
   \sphericalangle \complement \eth \diagup \diagdown \square \Box
   \Diamond \beth \daleth \gimel \digamma \varkappa \ulcorner \urcorner
   \llcorner \lrcorner \leqq \leqslant \eqslantless \lesssim \lessapprox
   \approxeq \lessdot \lll \lessgtr \lesseqgtr \lesseqqgtr \doteqdot
   \risingdotseq \fallingdotseq \backsim \backsimeq \subseteqq \Subset
   \sqsubset \preccurlyeq \curlyeqprec \precsim \precapprox
   \vartriangleleft \trianglelefteq \vDash \Vvdash \smallsmile
   \smallfrown \bumpeq \Bumpeq \geqq \geqslant \eqslantgtr \gtrsim
   \gtrapprox \gtrdot \ggg \gtrless \gtreqless \gtreqqless \eqcirc
   \circeq \triangleq \thicksim \thickapprox \supseteqq \Supset
   \sqsupset \succcurlyeq \curlyeqsucc \succsim \succapprox
   \vartriangleright \trianglerighteq \Vdash \shortmid \shortparallel
   \between \pitchfork \varpropto \blacktriangleleft \therefore
   \backepsilon \blacktriangleright \because \llless \gggtr \lhd \rhd
   \eqsim \Join \Doteq \dotplus \smallsetminus \Cap \Cup \doublebarwedge
   \boxminus \boxplus \divideontimes \ltimes \rtimes \leftthreetimes
   \rightthreetimes \curlywedge \curlyvee \circleddash \circledast
   \centerdot \intercal \doublecap \doublecup \boxtimes \dashrightarrow
   \dashleftarrow \leftleftarrows \leftrightarrows \Lleftarrow
   \twoheadleftarrow \leftarrowtail \looparrowleft \leftrightharpoons
   \curvearrowleft \circlearrowleft \Lsh \upuparrows \upharpoonleft
   \downharpoonleft \multimap \leftrightsquigarrow \rightrightarrows
   \rightleftarrows \twoheadrightarrow \rightarrowtail \looparrowright
   \curvearrowright \circlearrowright \Rsh \downdownarrows
   \upharpoonright \downharpoonright \rightsquigarrow \leadsto
   \Rrightarrow \restriction \yen \dag \ddag` look the same as they do
   in LaTeX and don't print any warnings about unknown font metrics.

Auditors: alpert
2015-02-18 16:28:05 -08:00
Emily Eisenberg
174af23734 Merge pull request #126 from jmeas/hi-symbols
The Big Symbols PR
2015-02-18 16:25:41 -08:00
Emily Eisenberg
ba67b89fe9 Merge pull request #184 from iamdanfox/remove-greek-fonts
Remove Greek fonts
2015-02-09 07:46:43 -08:00
Jan Marthedal Rasmussen
eedd397f18 Make \bigtriangledown, \oplus and others Bin operators (and not Ord) 2014-12-22 22:14:59 +01:00
Aria Buckles
cefda0ac2d update .arcconfig to https 2014-11-21 15:41:38 -08:00
Dan Fox
2231e782a4 Remove Greek fonts 2014-11-05 12:29:13 +00:00
Emily Eisenberg
a2f81d9d73 Make build/katex.less.css depend on static/fonts.less
Before, it only depended on `static/katex.less`. Now, make it a little
less general and depend on all less files, in case we add more in the
future.

Auditors: alpert
2014-11-03 18:55:57 -08:00
Ben Alpert
2ab14ea224 Point to CDNJS in README
Test Plan: http://jsbin.com/mirumuyeku/edit?html,js,output

Auditors: emily
2014-10-19 16:17:11 -07:00
Ben Alpert
a9d5a8782f Fix typos in README 2014-10-15 18:47:33 -07:00
Ben Alpert
c87511168d Add braces around displaystyle
This makes a difference for expressions like `2 \choose 3`.

Auditors: emily
2014-10-15 18:25:12 -07:00
Ben Alpert
f997bdd64b Release 0.1.1 2014-10-15 18:09:04 -07:00
Ben Alpert
d3ab5a1fc6 Update description in package.json 2014-10-15 18:08:21 -07:00
Ben Alpert
2cbee18010 Add \choose support
Test Plan: Looked at `1 + 2\choose {3 \over 4}`, npm tested.

Reviewers: emily

Reviewed By: emily

Differential Revision: http://phabricator.khanacademy.org/D13903
2014-10-15 16:05:58 -07:00
Ben Alpert
006a0a761c Add support for \{,d,t}binom
Test Plan: `\binom xy^{\binom xy^{\binom xy}}` looks like something. `\dbinom` and `\tbinom` also seem to work.

Reviewers: emily

Reviewed By: emily

Subscribers: jessie

Differential Revision: http://phabricator.khanacademy.org/D13315
2014-10-14 17:01:19 -07:00
Emily Eisenberg
10e9b4ec12 Add the ability to add woff2 files to the docker
Summary:
To complement pull request #142, add the ability to automatically
generate the woff2 files from within the docker. Add a script for copying out
the generated font files to make things easier. Remove the KaTeX_Greek font
files as well as the KaTeX_Win ones, since we don't use them and they're oddly
non-woff and non-eot specific?

Test Plan:
 - Build a new docker from the new Dockerfile
  - Make sure the woff2_compress program compiles
 - Follow the instructions in the README to build the fonts
  - Make sure the fonts correctly build
  - Make sure the copy_fonts.sh script copies the fonts out

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13637
2014-10-05 22:52:40 -07:00
Emily Eisenberg
4c00064f41 Merge pull request #142 from mathiasbynens/woff2
Add WOFF2 versions of the fonts
2014-10-03 16:38:56 -07:00
Emily Eisenberg
23d50e8633 Merge pull request #117 from jmeas/hi-jshint
Adds JSHint to the build step + code clean up
2014-10-01 18:53:39 -07:00
Jmeas
fec04614b8 Adds JSHint to the build system and tidies up code. 2014-10-01 21:28:46 -04:00
Emily Eisenberg
6aa70e33e4 Merge pull request #137 from cben/displaystyle
Mention `\displaystyle` workaround in README
2014-10-01 15:06:02 -07:00
Emily Eisenberg
def1a47935 Add optional arguments
Summary:
Add correct parsing of optional arguments. Now, things like `\rule` can shift
based on its argument, and parsing of `\sqrt[3]{x}` fails (correctly) because we
don't support that yet.

Also, cleaned up the lexing code a bit. There was a vestige of the old types in
the lexer (they have now been completely moved to symbols.js). As a byproduct,
this made it hard to call `expect("]")`, because it would look at the type of
the Token and the type for "]" was "close". Now, all functions just look at the
text of the parsed token, and in special occasions (like in the dimension lexer)
it can return some data along with it.

Test Plan:
 - Make sure tests still work, and new tests work
 - Make sure no huxley screenshots changed
 - Make EXTRA SURE `\sqrt[3]{x}` fails.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13505
2014-10-01 14:20:47 -07:00
Ben Alpert
cba70b51fe Make built files use only ASCII characters
Test Plan: Searched for `[^\x00-\x7f]` in vim and had no results, where there were before.

Reviewers: emily

Reviewed By: emily

Differential Revision: http://phabricator.khanacademy.org/D13459
2014-10-01 14:07:11 -07:00
Beni Cherniavsky-Paskin
80c4ca7c71 Mention \displaystyle workaround in README
until the question of display math API (#66) is decided either way...
2014-10-01 18:58:26 +03:00
Mathias Bynens
48870f05c1 Add WOFF2 versions of the fonts
Contrary to other web font formats, the new WOFF 2.0 Web Font compression format is optimized for file size, memory usage, and decompression speed.

WOFF2 has been supported in Chrome and Opera for a while now. See https://dev.opera.com/blog/opera-23/ for more info.
2014-10-01 11:54:53 +02:00
Jmeas
4da05ab772 Adds new symbols. 2014-09-29 13:42:19 -04:00
Emily Eisenberg
5722b45633 Merge pull request #101 from kevinb7/over
added support for \over
2014-09-27 01:32:30 -07:00
Kevin Barabash
c566ae6888 added support for \over
changed stopType (string) parameter to breakOnInfix (boolean)
renamed rewriteInfixNodes to handleInfixNodes

added a test for {1 \over 2} \over 3, fixed some grammar, and added code in the parser to squash superfluous ordgroups

removed squashOrdGroups and instead don't create an "ordgroup" if one already exists

removed unnecessary variable

moved variable declarations out of "if" statements
removed comment

Fixed style issue with where variables are declared and remove unnecessary comment from functions.js
2014-09-26 15:31:45 -06:00
Kevin Barabash
0189b96b92 added rule to the style guide section for where to declare variables 2014-09-25 14:32:37 -06:00
Ben Alpert
0236cdc619 Merge pull request #107 from dbieber/patch-2
Update CONTRIBUTING.md
2014-09-24 11:28:21 -07:00
Ben Alpert
5e535af75f Merge pull request #106 from dbieber/patch-1
Update CONTRIBUTING.md
2014-09-24 11:25:45 -07:00
Ben Alpert
240981e3a2 Merge pull request #70 from mathiasbynens/patch-1
README: Remove redundant `type` attribute
2014-09-23 22:16:25 -07:00
Emily Eisenberg
a18adfdfad Merge pull request #104 from kevinb7/error.position
added position property to ParseError
2014-09-23 14:04:17 -07:00
Kevin Barabash
afaec30d0a added position property to ParseError 2014-09-23 14:38:41 -06:00
David Bieber
5916e1287d Update CONTRIBUTING.md 2014-09-22 21:07:11 -07:00
David Bieber
bd795020f0 Update CONTRIBUTING.md
fix spelling of install
2014-09-22 21:05:19 -07:00
Emily Eisenberg
e0dece759f Merge pull request #91 from MandaBrown/teeny_tiny_typo_fix
Fixes a teeny tiny typo in a comment.
2014-09-22 14:25:28 -07:00
Emily Eisenberg
bd6f762f94 Improve the fonts.less experience
Summary:
Create a fonts.less file which generates identical css to fonts.css, but using
less rules to be more understandable and customizable. For example, add the
ability to change where the fonts directory is located (instead of mandating it
be located next to the less file), and add the ability to disable specific font
formats (like disable EOTs when IE8 support isn't needed).

Test Plan:
 - Ensure that the test page and huxley page still work
 - Ensure that the output of `./node_modules/.bin/lessc static/fonts.less` is
   the same as the original css by running both through
   `./node_modules/.bin/cleancss` and diffing them.
 - Ensure that the huxley screenshots haven't changed
 - Ensure that the build step still works

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D13326
2014-09-22 14:23:23 -07:00
Emily Eisenberg
824fb7fd2f Update huxley screenshots
Update huxley, and then use the Dockerfile to create new huxley screenshots.

Test plan:
 - Make sure generating new huxley screenshots works
 - Ensure that re-generating huxley screenshots produces no changes

Auditors: alpert
2014-09-22 13:58:19 -07:00
Ben Alpert
317564a173 Catch exceptions on test page
Summary: This makes typing into the box bearable with break-on-exception enabled.

Test Plan: Typed into box; I didn't blow up.

Reviewers: emily

Reviewed By: emily

Subscribers: jessie

Differential Revision: http://phabricator.khanacademy.org/D13314
2014-09-22 11:46:26 -07:00
Mandy Brown
fdc578563b Fixes a teeny tiny typo in a comment. 2014-09-19 21:29:50 -04:00
Emily Eisenberg
d2f41a19a5 Merge pull request #89 from patrickkang/master
Add \partial symbol
2014-09-19 12:34:00 -07:00