Commit Graph

425 Commits

Author SHA1 Message Date
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
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
newman101
f039068fae Updated link label 2015-10-19 18:18:18 +01:00
newman101
bc4693a71b Resolved Issue #370 2015-10-19 16:57:04 +01:00
Piotr Migdał
69130d6a19 Readme - set recent version (0.5.1) for CDN links 2015-10-19 16:53:05 +02:00
Kevin Barabash
d87ee4f78f Merge pull request #366 from Khan/add_width_to_font_metrics
Add a build step to generate extended metrics that additionally contain glyph widths
2015-10-16 14:41:31 -07:00
Kevin Barabash
1573e1eed6 Add a build step to generate extended metrics that additionally contain glyph widths
Summary:
The ability to use pre-determined character widths will benefit alternative
layout engines such as gagern's canvas layout engine.  I would also like to
experiment would using CSS transforms to absolutely position each glyph.  This
diff adds a new make rule, make extended_metrics, which generates metrics that
also containing glyph widths.

Test Plan:
- run `make extended_metrics`
- verify that fontMetricsData.js contains entries with 5 numbers instead of 4

Reviewers: emily alpert
2015-10-16 14:31:08 -07:00
Kevin Barabash
ee88cc3c11 Merge pull request #363 from gagern/modeStateful
Make mode part of the internal state of the parser
2015-10-05 16:36:05 +00:00
Kevin Barabash
9aab9c1efe Merge pull request #361 from crepererum/feature/gt_lt
Add \gt and \lt
2015-10-05 16:32:49 +00:00
Marco Neumann
95e568ed6b Add \gt and \lt 2015-10-05 08:34:03 +02:00
Martin von Gagern
cabc08598b Make mode part of the internal state of the parser
This is the first step towards #266.
2015-10-04 20:35:43 +02:00
Kevin Barabash
e9f4b07611 Merge pull request #364 from gagern/lexerRewrite
Refactor lexer, avoiding some mode-specific distinctions
2015-10-03 13:31:51 -07:00
Martin von Gagern
d423bec089 Rewrote lexer, avoiding some mode-specific distinctions
There are two main motivations for this commit.  One is unicode input, which
requires unicode characters to get past the lexer.  See discussion in #261.
The second is in preparation for #266, where we'd deal with one token of
look-ahead but might be lexing that token in an unknown mode in some cases.
The unit test shipped with this commit addresses the latter concern, since
it checks that a math-mode-only token may immediately follow some text mode
content group.

In this new implementation, all the various things that could get matched
have been collected into a single regular expression.  The hope is that
this will be beneficial for performance and keep the code simpler.
The code was written with Unicode input in mind, including non-BMP codepoints.

The role of the lexer as a gate keeper, keeping out invalid TeX syntax, has
been abandoned.  That role is still fulfilled by the symbols and functions
tables, though, since any input which is neither a symbol nor a command is
still considered invalid input, even though it lexes successfully.
2015-10-02 20:06:03 +02:00
Kevin Barabash
95e2f1c8d7 Merge pull request #356 from gagern/callingConvention
New calling convention for functions and environments
2015-10-01 08:42:52 -07:00
Martin von Gagern
30f7a1c5bf New calling convention for functions and environments
Fixes issue #255.

Mixing the variable number of arguments a function receives from TeX code
with the fixed arguments which the parser provides can cause some confusion.
After this change, a handler will receive exactly two arguments: one is a
context object from which things provided by the parser can be accessed by
name, which allows for simple extensions in the future.  The other is the
list of TeX arguments, passed as an array.

If we ever switch to EcmaScript 2015, we might want to use its destructuring
features to name the elements of the args array in the function head.  Until
then, destructuring that array manually immediately at the beginning of the
function seems like a useful convention to easily find the meaning of these
arguments.
2015-10-01 13:15:44 +02:00
Kevin Barabash
a81c4fe78d Merge pull request #362 from Khan/array_font_metrics
Use an array of values instead of object literals to save space in fontMetricsData.js
2015-09-30 10:00:23 -07:00
Kevin Barabash
6a10237017 Use an array of values instead of object literals to save space in fontMetricsData.js
Test Plan: make test

Reviewers: emily
2015-09-29 22:16:03 -07:00
Kevin Barabash
fdbdb28617 Merge pull request #346 from gagern/splitSymbols
Reformat symbol table
2015-09-25 14:56:18 -07:00
Kevin Barabash
f25829df58 Redirect people to gitter instead of freenode 2015-09-25 14:35:23 -07:00