Commit Graph

19 Commits

Author SHA1 Message Date
Emily Eisenberg
4d2e46e7f6 Remove trailing commas for IE 9 compatibility
Summary: IE 9 doesn't like trailing commas. When we introduced eslint, we added
a bunch of trailing commas, which makes IE 9 sad.

Test Plan:
 - `make lint`
 - Visit http://localhost:7936/ using IE 9 on browserstack.
 - See that the math loads, and there are no errors in the F12 developer tools.

@kevinb
2017-01-06 19:06:01 -08:00
Martin von Gagern
be96695586 Improved Docker for Mac support (#568)
* Exit cleanly after invalid screenshot test name

This avoids waiting forever.

* Auto-detect host IP in Docker for Mac environment

This checks all available network addresses to find one which the Selenium
container can connect to.  That way we don't have to analyze network
settings or similar to figure out the main public IP address of the machine.

* Make server less sensitive to current working directory

That way it becomes possible to run screenshotter.js from within the
Screenshotter directory, and still server all files as intended.
2016-11-27 18:57:53 -05:00
Kevin Barabash
ec62ec39d8 Add support for Latin-1, Cyrillic, and CJK characters inside \text{} (#508)
Summary:
This diff provides support for Latin-1, Cyrillic, and CJK characters
inside \text{} groups.  For Latin-1 and Cyrillic characters we use
glyph metrics from a glyph from Basic Latin that has roughly the same
bounding box.  We use the metrics for a capital 'M' to approximate the
full-width CJK characters.  Half-width characters are not supported yet.

Test Plan:
- make test
- make screenshots

Reviewers: emily
2016-08-01 17:51:40 -07:00
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
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
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
Martin von Gagern
9752d02748 Automatically start a development server
This avoids one of the few requirements we have left: you no longer have to
start a KaTeX development server, the script will do it for you, using a
random port number.

To reproduce the old behaviour, explicitely state --katex-port=7936.
2015-07-15 15:41:29 +02:00
Martin von Gagern
11970ee965 Update development server for new browserify version
Current browserify no longer accepts an options hash to the bundle method.
2015-07-14 09:51:20 +02: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
cd9bca4a89 Add basic auto-render extension
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
2015-04-01 15:57:10 -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
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
Ben Alpert
bff85c638b Compile .less on demand for test page
Test Plan: Opened test page in Chrome and IE8, saw math.

Reviewers: emily

Reviewed By: emily

Differential Revision: http://phabricator.khanacademy.org/D7581
2014-03-20 20:22:07 -07:00
Emily Eisenberg
0a3a2271f4 Add ability to calculate heights/depths
Summary:
This diff does a couple different things:

 - There is now a metrics/ folder, which contains the property files describing
   the metrics if the fonts, as well as a script for reading and printing the
   metrics in javascript.
 - Fractions and superscripts/subscripts are now rendered in slightly different
   ways now (notably, no use of inline-table). This allows for much more precise
   positioning of the superscripts, subscripts, numerators, and denominators,
   while still having an appropriate baseline. Also, there is no longer a
   sup/sub/supsub distinction, there are only supsubs with null sup/sub.
 - Using the new font metrics and by implementing the formulas found in The TeX
   Book, Appendix G, the heights and depths of all of the sub-expressions in a
   formula are now calculated. These are currently used to:
    - Correctly position superscripts, subscripts, numerators, and denominators
    - Adjust the height and depth of the overall expression so it takes up the
      appropriate space
 - Because we have to add attributes (height and depth) to every attribute, I
   have changed the way DOM nodes are assembled. Now, instead of assembling the
   DOM elements inline (which is a problem because we need to track
   height/depth, and we shouldn't (and can't in IE 8) attach raw attributes to DOM
   nodes), we assemble a pseudo-DOM structure with the extra information, and
   then actually assemble it at the very end.

The main page also now has an updated expression to show off and test the new
and improved parsing.

Test Plan:
View the main page, make sure that the expression renders. Make sure
that the tests pass. Make sure that expressions have the correct calculated
height (this is most easily tested by viewing them on the main page and making
sure that the top of the expression lines up with the bottom of the input box).

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D3442
2013-08-13 18:16:43 -07:00
Emily Eisenberg
4122fa2b99 Rewrite the parser
Summary:
Make our own parser that doesn't use jison, so that we can handle
funny TeX syntax, and to make it smaller.

Test Plan: Make sure the tests pass with the new parser.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D3029
2013-07-12 23:16:30 -07:00
Emily Eisenberg
507a552ffd Add some basic testing using jasmine
Summary:
Make some tests that test the parser. So far, there are no DOM tests,
but maybe later.

Test Plan:
Run `make serve` and then visit `/test/test.html`. Make sure all the
tests pass.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D2987
2013-07-11 18:32:44 -07:00
Emily Eisenberg
adb8b5d671 Rename everything to KaTeX
Summary: Rename all instances of mjlite -> katex

Test Plan: Run the local server, make sure things still work.

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D2977
2013-07-10 14:08:50 -07:00
Ben Alpert
33625f7b08 Catch server errors and return 500
Reviewers: xymostech

Reviewed By: xymostech

Differential Revision: http://phabricator.benalpert.com/D39
2013-07-07 14:13:25 -07:00
Ben Alpert
4bc599966f Create node server to replace 'make watch'
Reviewers: xymostech

Reviewed By: xymostech

Differential Revision: http://phabricator.benalpert.com/D38
2013-07-05 22:55:10 -07:00