Commit Graph

442 Commits

Author SHA1 Message Date
Martin von Gagern
befe1c1af7 Upgrade less to version 2 (#503)
This fixes a problem where the graceful-js dependency of the old less
version is incompatible with node 7, and will cause warnings on node 6.
The resulting katex.min.css is exactly the same as with the previous
version, so the major version upgrade does not seem to affect the outcome.

The less.Parser has been deprecated, and less.render is the supported
approach now, so we have to switch the development server to that.
2016-07-12 12:23:28 -07:00
Martin von Gagern
8c55aed39a Allow macro definitions in settings (#493)
* Introduce MacroExpander

The job of the MacroExpander is turning a stream of possibly expandable
tokens, as obtained from the Lexer, into a stream of non-expandable tokens
(in KaTeX, even though they may well be expandable in TeX) which can be
processed by the Parser.  The challenge here is that we don't have
mode-specific lexer implementations any more, so we need to do everything on
the token level, including reassembly of sizes and colors.

* Make macros available in development server

Now one can specify macro definitions like \foo=bar as part of the query
string and use these macros in the formula being typeset.

* Add tests for macro expansions

* Handle end of input in special groups

This avoids an infinite loop if input ends prematurely.

* Simplify parseSpecialGroup

The parseSpecialGroup methos now returns a single token spanning the whole
special group, and leaves matching that string against a suitable regular
expression to whoever is calling the method.  Suggested by @cbreeden.

* Incorporate review suggestions

Add improvements suggested by Kevin Barabash during review.

* Input range sanity checks

Ensure that both tokens of a token range come from the same lexer,
and that the range has a non-negative length.

* Improved wording of two comments
2016-07-08 12:24:31 -07:00
Shadaj Laddad
b49eee4de7 Updated Khan Academy colors to new colors
Summary: The KaTex renderer used to use old Khan Academy colors when displaying colored text. The configuration is now updated to have the new colors.

Test Plan:
- verified that colored text now uses the new colors in a browser
- running commands such as `\blueA{blueA}` will style the text in the blueA color from the configuration

Reviewers: emily, kevinb

Reviewed By: kevinb

Differential Revision: https://phabricator.khanacademy.org/D27963
2016-06-07 17:24:47 -07:00
Emily Eisenberg
26f06754e7 Merge pull request #490 from cbreeden/Fix#488-supsub-alignment
Fix #488 Subsup alignments
2016-06-01 15:10:50 -07:00
Christopher Breeden
3668bb084e add msupsub tag to scripts, fix #488 2016-06-01 16:57:56 -05:00
Andrey Mikhaylov (lolmaus)
b120b1c3d8 Fixed indentation in auto-render readme (#481) 2016-05-26 10:10:54 -07:00
Johannes Schmitz
1cf10c4cd6 Update CDN links to latest version (#478) 2016-05-23 11:42:27 -07:00
Kevin Barabash
9884ac3e8d Merge pull request #423 from Khan/kern
Add support for \kern
2016-04-19 21:22:24 -07:00
Emily Eisenberg
991f4eb096 Ignore release.sh in bower.json
Summary: We didn't have a rule for ignoring .sh files in the bower.json,
so it got included in the 0.6.0 release. Oops! This adds it to the
ignore file.

Test Plan:
 - ???

Auditors: kevinb
2016-04-15 18:48:24 -07:00
Emily Eisenberg
b62e1cf314 Make the release script correctly link to the new release page.
Test Plan:
 - Cross fingers!

Auditors: kevinb
2016-04-15 18:30:31 -07:00
Kevin Barabash
5991a6078b Bump master to v0.7.0-pre 2016-04-15 18:18:36 -07:00
Kevin Barabash
aa36c459ae don't do any linting/checking of the release commits
Summary:
We prevent any precommit checks so that we don't have to include
a "Test Plan" etc. in the release commit message.

Test Plan:
- ./release.sh 0.6.0 0.7.0

Auditors: emily
2016-04-15 18:14:13 -07:00
Kevin Barabash
0f7a1a06e9 Blacklist dist/** so that ka-lint doesn't barf on those files
Test Plan:
- ./release.sh 0.6.0 0.7.0

Auditors: emily
2016-04-15 18:11:31 -07:00
Kevin Barabash
36164b98ea Make it compatible with Mac
Test Plan:
- ./release 0.6.0 0.7.0

Auditors: emily
2016-04-15 18:09:14 -07:00
Kevin Barabash
363a6ba311 Merge pull request #461 from Khan/add-release
Add a release script.
2016-04-15 17:33:35 -07:00
Emily Eisenberg
224efafda8 Add a release script.
Summary: Make the release script that's been floating around in my gists
for a while into a real script.

Test Plan:
 - Comment out all the scary bits (the two pushes, and `npm
   publish`), and run:
 - `./release.sh 0.6.0`
 - Checkout the `v0.6.0` tag, see that it successfully modified
   package.json and bower.json to version 0.6.0, and built and committed
   the rest of the files.
 - `git tag -d v0.6.0`
 - `./release.sh 0.6.0 0.7.0`
 - Checkout master, see that it successfully made a commit bumping
   package.json and bower.json to 0.7.0-pre.

Reviewers: @kevinbarabash
2016-04-15 12:19:16 -07:00
Emily Eisenberg
ccd8f40028 Make make lint not automatically fix lint
Summary: Looks like there was lint, but `make lint` wasn't failing on it
because it would just automatically fix it! This removes the `--fix`
from `eslint` and fixes the lint.

Test Plan:
 - `make lint`

Auditors: kevinb
2016-04-15 12:08:14 -07:00
Ben Alpert
965b8a6164 Add \underline support (#456)
![image](https://cloud.githubusercontent.com/assets/6820/14412284/e63218b6-ff13-11e5-912c-fc6e30928b93.png)

Fixes #209.
2016-04-10 20:32:24 -07:00
Kevin Barabash
a33fa4fd64 Merge pull request #448 from Khan/fix-centered-subsuperscripts
Fix sub- and super-scripts not being centered inside of display math
2016-03-07 00:07:25 -08:00
Emily Eisenberg
229ce562ff Fix sub- and super-scripts not being centered inside of display math
It looks like the `text-align: center` is affecting the text in sub and
superscripts. Fixes #447

Test Plan:
 - Visit [this
   example](http://localhost:7936/?text=x%5El_%7Bi%5E%7Bl%2B1%7D%2Bi%2C%20j%5E%7Bl%2B1%7D%2Bj%2C%20d%7D)
 - Edit the HTML to add `<span class="katex-display">...</span>` around the
   `<span class="katex">` node.
 - See that the sub and superscripts are left-aligned, not centered

(It looks like we don't have a way to test this in the screenshotter for now)

@kevinb
2016-03-05 09:37:39 -08:00
Ben Alpert
d2079a6c9c Merge pull request #444 from mathiasbynens/https
README: Use HTTPS where possible
2016-03-02 11:35:47 -08:00
Mathias Bynens
d5359ef5bb README: Use HTTPS where possible
There’s no reason not to always use HTTPS. See https://github.com/konklone/cdns-to-https#background for more info.
2016-03-01 15:44:45 +01:00
Ben Alpert
83dea37b51 Merge pull request #436 from tirsen/master
Bundle css and fonts in npm package.
2016-02-19 11:23:35 -08:00
Jon Tirsen
a5207fef94 Bundle css and fonts in npm package. 2016-02-18 09:21:28 +01:00
Kevin Barabash
3083efba66 Add support for \kern
Summary:
This only supports em and ex units and doesn't handle vertical layouts.
Negative kerning works.

Test Plan:
- make test
- make screenshots (verify that d is slightly overlapping c in the screenshots)

Reviewers: emily
2015-12-30 18:14:29 -08:00
Kevin Barabash
c79fb58936 Revert previous change to make \centerdot like \cdot
Summary:
Alpert alerted me to the fact that \centerdot and \cdot are
not the same despite what MathJax thinks.

Test Plan:
- make serve
- load http://localhost:7936/
- see the `a \centerdot b` produces a small, bottom-aligned square

Auditors: alpert emily
2015-12-29 10:21:44 -08:00
Kevin Barabash
157bfb0cf5 \centerdot should produce the same glyph as \cdot
Summary:
Update the symbol definition for \centerdot so that it does
the same thing as \cdot.
Fixes https://github.com/Khan/KaTeX/issues/421.

Test Plan:
- make serve
- open http://localhost:7936/
- verify that `a \centerdot b` looks the same as `a \cdot b`

Auditors: emily
2015-12-29 10:00:17 -08:00
Kevin Barabash
9ad50178f1 Merge pull request #405 from Khan/eslint
Migrate to eslint
2015-12-04 17:42:06 -08:00
Kevin Barabash
14a58adb90 Migrate to eslint
Summary
We'd like contributors to use the same linter and lint rules that we use
internally.  This diff swaps out eslint for jshint and fixes all lint failures
except for the max-len failures in the test suites.

Test Plan:
- ka-lint src
- make lint
- make test

Reviewers: emily
2015-12-01 10:02:08 -08:00
Kevin Barabash
1a082e81d9 Merge pull request #406 from gagern/ffEmptyPage
Force Firefox to start up with an empty page
2015-12-01 08:17:47 -08:00
Martin von Gagern
0a53a775e8 Force Firefox to start up with an empty page
Otherwise it could happen that some Mozilla page gets shown which has a
minimal size larger than the 786px we're requesting.  And the screenshot
will span that entire page even if the window is smaller, resulting in a
failure to adjust screenshot size.

See http://kb.mozillazine.org/Browser.startup.homepage_override.mstone
and http://kb.mozillazine.org/Browser.startup.page for details.

Just in case, we also include the docker image digests in the travis build
log, to increase chances of reproducing what we get there.
2015-12-01 14:15:45 +01:00
Kevin Barabash
7cdb08bf7e Merge pull request #388 from gagern/updateSelenium
Update Selenium Docker images from 2.46.0 to 2.48.2
2015-11-30 21:19:29 -08:00
Kevin Barabash
3a15a8402f Merge pull request #398 from gagern/aligned
Introduce an aligned environment
2015-11-28 11:20:04 -08:00
Martin von Gagern
8201501d77 Introduce an aligned environment
This is almost like the align* environment, but it starts out in math mode,
so we don't have to worry about the fact that we have no real surrounding
text mode in KaTeX.  This is the first step towards align* and align.
2015-11-23 20:22:06 +01:00
Kevin Barabash
b9c4237ac2 Merge pull request #386 from gagern/nextToken
Avoid re-lexing, move position to internal state
2015-11-23 08:55:11 -08:00
Martin von Gagern
4debcb34af Avoid re-lexing, move position to internal state
Instead of passing around the current position as an argument, we now have a
parser property called pos to keep track of that.  Instead of repeatedly
re-lexing at the current position we now have a property called nextToken
which contains the token beginning at the current position.  We may need to
re-lex if we switch mode.  Since the position is kept in the parser state,
we don't need to return it from parsing methods, which obsoletes the
ParseResult class.
2015-11-23 17:40:56 +01:00
Kevin Barabash
5f275aa9c1 Merge pull request #385 from gagern/testErrors
Added unit tests for error messages
2015-11-21 08:54:50 -08:00
Martin von Gagern
e7195601e1 Added unit tests for error messages
This is an attempt to actually exercise all the code paths which can lead to
a ParserError exception (from malformed user input, without tinkering with
any KaTeX internals or exploiting a KaTeX bug).  It documents the current
state of affairs, without changing any error messages.  Comments indicate
future work, particularly with respect to the position often associated with
these error messages.
2015-11-21 15:38:26 +01:00
Kevin Barabash
4617f191e3 Merge pull request #389 from gagern/jasmine
Drop local copy of jasmine, multiple spec files in browser tests
2015-11-20 13:49:37 -08:00
Martin von Gagern
cc17f36edc Drop local copy of jasmine, multiple spec files in browser tests
Instead of having our own copy of jasmine in the repository, we use
jasmine-core as an npm dependency and load it from there.  That reduces the
size of the repository and helps keeping up to date.  We're not using the
transitive dependency on jasmine-core via jasmine, since the jasmine package
might change its dependency any day (although unlikely).

The katex-spec.js shipped from the server now includes all
`test/*[Ss]pec.js` (as matched via glob) so that additional spec files can
be created and will automatically get included in the browser-side test
suite.  The contrib specs are not included at this point.

Visit http://0.0.0.0:7936/test/test.html while running server.js to see this
in action and verify the lack of failures.
2015-11-12 18:34:31 +01:00
Kevin Barabash
bfb3827df1 Merge pull request #387 from gagern/jasmine
Switch from jasmine-node to jasmine itself
2015-11-12 08:56:06 -08:00
Kevin Barabash
1c50688cba Merge pull request #371 from stared/patch-1
Readme - set recent version (0.5.1) for CDN links
2015-11-12 08:16:30 -08:00
Martin von Gagern
4792dec8e5 Update Selenium Docker images from 2.46.0 to 2.48.2 2015-11-12 17:08:16 +01:00
Martin von Gagern
92034c17f9 Switch from jasmine-node to jasmine itself
Jasmine supports node these days, so there is no longer a need to use a
separate (and unmaintained) package to provide such bindings.

Making the switch exposed several misuses of the `toMatch` assertion in the
existing specification.  Most of them were converted to `toEqual`, since
`toMatch` is only for matching against regular expressions.
2015-11-10 12:38:49 +01:00
Kevin Barabash
21a26b807c Merge pull request #381 from gagern/travisScreenshots
Check screenshots on Travis using Docker and Selenium
2015-11-07 11:04:24 -08:00
Martin von Gagern
9fb04dbb2e Add verification mode to screenshotter
Now Travis can run the screenshotter in verification mode.  The files in the
repository will be seen as the expected outcome, and if the actual result
differs from that, it might be attempted four more times before the test
case is actually deemed failed.  A timeout between page load and screenshot
should allow any possible font issues to settle down.
2015-11-07 16:32:02 +01:00
Martin von Gagern
5ecbcf6808 Check screenshots on Travis using Docker and Selenium
Thanks to the docker service provided by Travis CI, we should be able to
download and use the Selenium docker images in order to run our
screenshotter and check whether all the screenshots match the images from
the repository.
2015-11-06 13:02:53 +01:00
Kevin Barabash
c20b8f8456 Merge pull request #369 from utensil/master
Add a link to symbol/function support preview page
2015-10-20 08:21:12 -07:00
utensil
dcc3214527 Add a link to symbol/function support preview page 2015-10-20 16:25:02 +08:00
Kevin Barabash
c6800749ab Merge pull request #372 from Newman101/Issue370
Resolved Issue #370
2015-10-19 10:29:26 -07:00