Commit Graph

504 Commits

Author SHA1 Message Date
James Lee
549104c5a8 auto-renderer README.md - added integrity (#591)
Integrity generated from https://www.srihash.org/
Reference: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
2017-01-13 12:15:57 +01:00
James Lee
90ba0e341d README.md - added integrity (#590)
Integrity generated from https://www.srihash.org/
Reference: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
2017-01-13 12:15:28 +01:00
Kevin Barabash
56f3d1db47 Don't cascade .eslintrc
eslint will automatically merge .eslintrc files in the parent folder without "root": true
2017-01-12 22:53:10 -05:00
Kevin Barabash
c56de9e323 Merge pull request #625 from gagern/morgan
Use morgan to log requests in the dev server
2017-01-12 10:15:20 -05:00
Martin von Gagern
79d53bd29f Use morgan to log requests in the dev server
This is motivated by the recent switch to Express 4.
Without this commit, “make serve” will print the following message:

Error: Most middleware (like logger) is no longer bundled
with Express and must be installed separately.  Please see
https://github.com/senchalabs/connect#middleware.
2017-01-12 09:52:29 +01:00
Martin von Gagern
4ead46c4ab Describe using auto renderer in html head (#623)
Describe using auto renderer in html head

Motivated by #621.
2017-01-11 21:04:52 +01:00
Martin von Gagern
59b87539b9 Merge pull request #622 from gagern/commas
Revert "Remove trailing commas for IE 9 compatibility"
2017-01-11 20:56:39 +01:00
Martin von Gagern
896aeac81b Fix some indentation and comma inconsistencies
This makes eslint happy again.
2017-01-11 13:30:11 +01:00
Martin von Gagern
53e416e296 Revert "Remove trailing commas for IE 9 compatibility"
This reverts commit 4d2e46e7f6.

Having trailing commans makes diffs easier to read as it avoids modifying a
line just to add a trailing comma if there is another item to add at the end
of a list.  There are plans to switch to ES6 notation and to translate that
to ES5 as part of the build process.  Since that translation would remove
trailing commas, the IE9 problems that originally motivated the commit
should vanish soon.
2017-01-11 13:26:00 +01:00
Kevin Barabash
677290336a Merge pull request #612 from gagern/updates
Update dependencies to more recent version
2017-01-10 11:09:02 -05:00
Martin von Gagern
90e25fecc2 Update dependencies to more recent version
All these version ranges include the latest version at the time of this
commit, except for the selenium webdriver.  There version 3 is incompatible
with version 2, and switching to a version 3 library appears to require
switching to version 3 docker images as well, which would entail using
different browser versions which in turn would lead to differences for a
large number of screenshots.  That doesn't appear warranted at this time.
2017-01-09 15:09:43 +01:00
Emily Eisenberg
8f46eeaf1b Bump master to v0.8.0-pre 2017-01-06 19:50:50 -08:00
Emily Eisenberg
225baffef4 And make the release script actually work again.
Summary: The previous commit made the `sed` lines do the same thing on mac and
linux. Unfortunately they didn't actually work. Whoops.

Test Plan:
 - Run `./release.sh` a couple times and become horribly confused before
   realizing what's going on.

@kevinb
2017-01-06 19:47:47 -08:00
Emily Eisenberg
4327e85796 Make the release script compatible with both mac and linux
Curse you BSD and GNU sed being so different!

Test Plan:
 - Run `sed -i.bak -e 's|boo|blah|' blah` on both a linux and mac computer

@kevinb
2017-01-06 19:32:22 -08:00
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
Kevin Barabash
74d55ee0ea Merge pull request #598 from gagern/screenshotter
Load full-window page before adjusting browser window size
2017-01-05 09:17:17 -05:00
Erik Demaine
1ca7363460 \ldots in text mode; add \textellipsis & \mathellipsis (#597) 2017-01-03 16:47:53 +01:00
Martin von Gagern
ca1a511cc4 Load full-window page before adjusting browser window size
Experimenting with selenium-webdriver@3.0.1 and Firefox 50.1.0 I observed
screenshots having a height of merely 8 pixels.  Presumably the margin or
padding of an otherwise empty document.  So in order to get the actual size
of the document area, the screenshotter now loads a document which fills the
entire viewport.
2017-01-03 15:53:25 +01:00
Eddie Kohler
7c83021009 Support \bmod, \pmod, \pod, and \mod. 2016-12-31 20:51:20 -05:00
Kevin Barabash
f742fbf9f2 Merge pull request #580 from kohler/muunits
Support "mu"-denominated sizes and \mkern
2016-12-19 14:31:04 -07:00
Eddie Kohler
81bc24808b Support \mkern as an alias for \kern. 2016-12-19 13:43:33 -05:00
Eddie Kohler
d5cedc55c9 Support "mu" units for sizes.
18mu is 1em.

And use emPerEx when converting ex to em, rather than xHeight.
(Previously some places used emPerEx and others used xHeight.)
2016-12-19 13:42:27 -05:00
Kevin Barabash
3900936f63 Merge pull request #586 from tabatkins/patch-1
Misspelled variable "candiate"
2016-12-16 18:25:32 -05:00
Tab Atkins Jr
d43f24ea91 Misspelled variable "candiate"
All uses have the same misspelling, so this wasn't a functionality bug, but still better to have things spelled correctly in the source. ^_^
2016-12-16 13:12:45 -08:00
Kevin Barabash
fdebbe3a18 Merge pull request #579 from kohler/kernarg
Allow unbraced kerns, such as \kern1em.
2016-12-08 23:38:04 -05:00
Kevin Barabash
831c5b8d99 Merge pull request #578 from kohler/middle
Handle \middle.
2016-12-08 23:35:36 -05:00
Eddie Kohler
530ec97e74 Allow unbraced kerns, such as \kern1em.
This is actually the *only* syntax TeX allows; braced kern units
are invalid.
2016-12-08 23:26:31 -05:00
Kevin Barabash
95f2f46bf5 Merge pull request #581 from kohler/stylespacing
BUG FIX: Correct spacing next to symbols when styles switch.
2016-12-08 22:56:23 -05:00
Eddie Kohler
e449b2d61a Handle \middle. 2016-12-08 16:41:19 -05:00
Eddie Kohler
72362ecf88 Correct spacing next to symbols when styles switch.
Two nodes were sharing a list of classes, which led to the style
change applying multiple times. Fix that.
2016-12-08 16:20:32 -05:00
Kevin Barabash
7433638fda Merge pull request #573 from kohler/kwork
Fix atom-spacing, add text-mode fonts, and miscellany
2016-12-05 16:56:00 -05:00
Eddie Kohler
81f9a410a0 Add text-mode definitions of symbols like \$. 2016-12-05 16:05:39 -05:00
Eddie Kohler
e1c5f5db1c Add support for \text{rm,it,bf,tt,sf,normal}.
And allow \text to nest inside \text.
2016-12-05 16:05:22 -05:00
Eddie Kohler
576380c11c Text mode: Combine adjacent spans when possible for cleaner HTML.
So `\text{Hi}` becomes one <span...>Hi</span>, rather than two
<span...>H</span><span...>i</span>.

This allows the font renderer to apply kerning, which changes some
test output.
2016-12-05 15:59:10 -05:00
Eddie Kohler
b88bc7723d Italic correction should not be applied to characters in text mode.
This requires changes to screenshotter tests that assumed italic
correction was applied in text mode.
2016-12-05 15:59:10 -05:00
Eddie Kohler
4297eb1276 Unicode punctuation works. 2016-12-05 15:59:05 -05:00
Eddie Kohler
e0407a19a0 Support \atop.
Add Jasmine test and update screenshotter test.
2016-12-05 15:58:26 -05:00
Eddie Kohler
f8e0c91de4 Support \stackrel (#468). 2016-12-05 15:48:05 -05:00
Eddie Kohler
6bb62b11b4 Support \mathop, \mathrel, \mathbin, \mathpunct, etc. class commands.
These commands set their arguments in a given TeX math class. Use
the existing "op" type for \mathop (to support \limits); introduce
a new "mclass" type for the other classes.

Fixes #482. Tests borrowed from #485 (cbreeden).
2016-12-05 15:48:05 -05:00
Eddie Kohler
982e7be597 Calculate math classes from outputs, not inputs.
It's important to get spacing right that the domTree classes reflect
math atom types. So use those types exclusively, rather than
repeating the type mapping twice (once when building spans, once in
getTypeOfGroup).

* Remove getTypeOfGroup.
* Add getTypeOfDomTree (simpler).
* Adjust supsub type calculation.
* Adjust delimsizing internals.
2016-12-05 15:48:05 -05:00
Eddie Kohler
dc79b91dbf Mark delimiters with the proper class (mopen or mclose).
This fixes some atom spacing issues. Update the BinCancellation
screenshotter test.
2016-12-05 15:48:04 -05:00
Eddie Kohler
1a99e7a2e9 The \llap and \rlap commands always generate "mord" atoms.
This is how TeX does it.
2016-12-05 15:48:04 -05:00
Eddie Kohler
c951df4269 Fix #4.
Post-process the list of atoms after they are created, changing
binary operators to ordinary atoms according to the TeXbook's
rules. This makes the `prev` argument redundant, so drop it.

This commit assumes that the math class (mop/mbin/mrel/etc.) comes
first in the `classes` list, if present. Add a TODO to change the
signature of `makeSpan/makeSymbol` to enforce this invariant.
2016-12-05 15:47:06 -05:00
Eddie Kohler
9d3cdf694c Fix spacing between groups to match TeX spacing (#567)
* Internal: Pass full `options` objects to makeSpan/makeSymbol.

Not just the current color. This will facilitate applying options
to built nodes in a standardized way, rather than changing all
callsites.

* Add style switching test: text and scriptstyle in the same group.

* Apply style-specific spacing using different CSS coding.

Specifically, infer style from a class on the *current* element,
rather than the parent element. Use "mtight" class to denote elements
with tight spacing (scriptstyle or scriptscriptstyle). Apply that
class automatically based on options.

* Fix #533, #534, #541.

- #534: Implement getTypeOfGroup for font groups.
- #533, #541: Improve the ways spaces are applied to lists. Since
  CSS adjacency implements mathematical spacing, it's incorrect to
  introduce "convenience spans" for spaces and display changes into
  the generated HTML -- those spans break adjacency. Apply display
  changes directly, and shift space spans into adjacent atoms.

Requires updates to two screenshotter tests, LimitControls and
SupSubLeftAlignReset. The new results for these tests are closer
to TeX output than the old results.

Also requires updates to Jasmine tests, since those assumed output
structures that have changed.

* Fix #136: Size commands generate fragments, not spans.

This is so the size commands don't hide the types of their enclosed
atoms. Addresses #136.

This slightly changes the vertical position of the Sizing test. Not
sure the vertical position matters, so change the test.
2016-11-28 12:55:54 -05: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
Martin von Gagern
94dad8029d Check out test fonts in screenshotter.sh (#570)
This ensures that running screenshots as indicated by the screenshotter
readme will correctly render the Unicode examples, even if not run on
Travis.  It also fixes the commit ID of the unicode fonts.

One alternative would have been using a git submodule.  But as many tools
will initialize submodules automatically, that would mean big downloads for
anyone using such a tool to clone KaTeX.

Another alternative would be tweaking the server to fetch the files on
demand if the local copy is unavailable.  But that would cause additional
network overhead, so grabbing the files just once should be simpler.
2016-11-23 09:38:47 -05:00
Eddie Kohler
7b5580b1fa Screenshotter: Obey --katex/selenium-ip options under --container. (#566)
Some Docker configs, such as Docker for Mac, need explicit --katex-ip
and --selenium-ip options. Obey those options.
2016-11-22 11:23:32 +01:00
Kevin Barabash
22957d40f6 Use style specific FONTDIM metrics (#545)
Summary:
FONTDIM metrics include metrics like sup2, sup3, etc. which are used for
position sub/super-scripts, fractions, delimiters, etc.  TeX uses three
different font styles: textfont2 (DISPLAY & TEXT), scriptfont2 (SCRIPT), and
scriptscriptfont2 (SCRIPTSCRIPT) and has different sets of metrics for each.
This diff adds style specific metrics for better TeX compliance.

Notable squashed commits:
- Recreated screenshots (martin)
- fix getEmPerEx to use getXHeight
- regularize how we access options.style, remove unnecessary newlines
- use var style = options.style in more places in buildHTML
2016-11-04 07:45:08 +01:00
Matthew Rothenberg
ace67541a0 Create CODE_OF_CONDUCT.md (#553) 2016-11-02 22:02:47 -04:00
Martin von Gagern
0ebbc25672 Add build artifacts to .gitignore and allow installing dependencies without building KaTeX
* Let git ignore .npm-install.stamp and dist

The former is created for most makefile targets after dependencies have been
retrieved.  The latter is created by typical operations like “make” without
arguments or “npm install”.  Having these around is to be expected.

Adding this to .gitignore should NOT affect npm packaging, since that is
based on a whitelist in package.json which does mention dist.

* Allow installing dependencies without actually building KaTeX

We have been using “npm install” to install dependencies, but since that
also does build KaTeX itself, it may fail if e.g. there are any style guide
violations.  Now we only fetch dependencies but do not build KaTeX itself.

The make conditionals used here are not part of POSIX make but a GNU
extension.  But we already use functionality not mandated by POSIX (namely
many of the functions like “wildcard”), so this should not make portability
any worse than it already is.
2016-11-02 21:24:59 -04:00