Commit Graph

577 Commits

Author SHA1 Message Date
Eddie Kohler
4480f2c987 Correct computation of TeX sizes. (#755)
* Em and mu sizes are relative to current font's quad metric,
  which might not be "1em" in CSS terms.
* We don't need the `emPerEx` metric, because we want to convert
  TeX `ex` to CSS `em`, not TeX `ex` to TeX `em`. The `xHeight`
  metric does that already: it is relative to font size.
* Mu sizes scale with the style, em and ex do not (empirically
  checked; agrees with rule 2 of TeXbook Appendix G).
  This corrects a bug in b866cd5224 (in which em scaled),
  and a bug in previous versions (in which mu did not scale).
* Correct rule sizes. Previous comment---"the sizes of rules are
  absolute"---was misleading. Rule sizes are NOT absolute---in
  \large size, a rule denominated in 'em' is larger. But the 'em'
  unit is not sensitive to styles. So now a 1em rule will be the
  same size in super/subscript, as it should be, but an 18mu rule
  will change size in super/subscript, as it should.

Note a TODO.
2017-07-09 17:23:00 -04:00
Eddie Kohler
782484eb75 Set maxFontSize on rules. (#744)
This is needed in vlists, as in #646, to make fontsize-ensurer
nodes big enough.
2017-07-08 20:22:29 -04:00
Eddie Kohler
f43b00b50f Screenshotter: Add --diff and --attempts options. (#736)
--diff produces a texcmp-like diff in test/screenshotter/diff.
2017-07-06 08:49:34 -04:00
Eddie Kohler
1704d3b003 Speed up screenshot by avoid a full page + asset load for each test
The slowest part of screenshotter tests is the page load, probably
because so many assets must be loaded over the slow docker
connection. On my laptop this takes ~4s per test. The new default
avoids this cost by rendering new TeX on the existing
page. For second and subsequent tests, use `executeAsyncScript`
to call KaTeX, rather than performing a full page + asset load.
(If too many errors happen in `--verify` mode, we fall back to
full loads.)  The `--reload` flag will enable the previous behavior.

On my laptop, a full verify (chrome + FF) used to take 12m20s+.
It now takes 2m23s, a speed up of 6x.
2017-07-04 00:13:57 -04:00
Hossein Saniei
a019f36f8a Upgrade the source to use ES6 syntax including classes, import and static properties (#679)
* Add babel transform-class-properties to have static class properties

* Upgrade Lexer and Parser files to use ES6 classes

* Update eslint max line length to 90 character (more indent because of using ES6 classes)

* Upgrade eslint and jasmin to support ES stage-2 features

* Use static properties to place constants near their functions

* Migrate all remaining sources to ES6 syntax

* Increase eslint max line length to 84

* Remove non-babelified endpoint in dev server.js

* Clean up server.js functions after removing browserified

* Make screenshotter not to use babel endpoint as we babelify everything now
2017-07-03 08:09:21 -04:00
Erik Demaine
0edd3d1bbb Implement \coloneqq, \colonequals, etc. based on mathtools and colonequals (#727)
Fix #657 (modulo #725)
2017-06-30 14:52:37 -04:00
Eddie Kohler
f23bf3fe63 Associate font metrics with Options, not Style. (#743)
* Associate font metrics with Options, not Style.

Font metrics are associated with a given font and size combination.
Before KaTeX understood sizing commands, sizes were associated with
a Style. That's not true now. So instead of `style.metrics`, use
`options.fontMetrics()`, since `options` knows the font and the
size.

This is a cleanup commit with no visible effects on most tests (there
could be some small effect on size + style combinations). It will
make other changes possible later.
2017-06-30 13:50:28 -04:00
Erik Demaine
ebaa3feab3 Mention texcmp (#753) 2017-06-30 13:42:39 -04:00
Eddie Kohler
87b9123200 Correct handling of unbraced kerns followed by spaces. (#751)
Did not realize that `Parser.nextToken.text` can contain spaces
(it can). Handle that.
2017-06-30 13:40:41 -04:00
Eddie Kohler
aa1722c8b6 Vertically center single-character \mathop. (#745)
* Vertically center single-character \mathop.

Fix #726.

* Add screenshotter test
2017-06-30 08:49:00 -07:00
Eddie Kohler
b866cd5224 Fix interaction between styles and sizes. (#719)
* Fix interaction between styles and sizes by implementing styles as sizes.

Rather than having both `textstyle` CSS classes and `size5` CSS classes
affect the font size (and step on each other), implement sizes more the
way TeX does: a command like `\displaystyle` changes the current size.

This is actually a simplification, since now only `size` affects the size.
Simplifies CSS and computation. Many screenshotter tests change; they
change to be more like TeX. For instance, `\sqrt` fixes some
discrepancies in size treatment.

Also:

Remove the `Options.withX()` methods in favor of `.havingX()`, which
might return the same `options`.

Remove `Style.cls()` and `Style.reset()`.

Remove `Options.reset()`. You should never modify an `Options`; they
should change only by the `havingX()` methods.

* Implement TeX sizing for scriptsize/scriptscriptsize.

At every size level. Also make the sizes match TeX to the last decimal.

* Review comments.
2017-06-27 20:55:14 -04:00
Ron Kok
4f57d53f6e Show correct browser support (#737)
* Show correct browser support

KaTeX runs in IE 9 but not in IE 8. This PR edits the README and
Contributing files to reflect that fact.

Resolves issue #377.

* Show correct browser support

KaTeX runs in IE 9 but not in IE 8. This PR edits the README and
Contributing files to reflect that fact and adds Edge to browser list.

Resolves issue #377.
2017-06-25 17:50:31 -04:00
Erik Demaine
a36709d239 Add documentation for how to run auto-render example (#740) 2017-06-25 17:47:46 -04:00
Kevin Barabash
29fc2d56d4 Remove duplicate comment 2017-06-16 00:00:43 -04:00
Ron Kok
eff7653c51 Support stretchy wide elements. (#670) 2017-06-15 23:47:51 -04:00
Erik Demaine
eaa7f3a17d Fix high contrast mode better, thanks to @GeeLaw (#733) 2017-06-15 19:01:58 -04:00
Alex Pearce
60b1969a01 Support all render options in auto-render.
Closes #690.
2017-06-14 10:50:14 -04:00
Erik Demaine
25dde7f841 Implicit \color, explicitly grouped \textcolor (#619) 2017-06-12 23:11:27 -04:00
Martin von Gagern
ad0abbd4e9 Update texcmp to ubuntu 17.04 and avoid mounted host directory (#722)
* Update texcmp to ubuntu 17.04 and avoid mounted host directory

Switch to linux 17.04 in order to have a version of nodejs which understands
ES6 syntax, for the sake of a consistent codebase.
Avoid mounting the host directory, but use “docker cp” instead to transfer
files between host and container.  This should avoid ownership and
permission issues.
Support macros with positional arguments.
Fix one overline example which caused LaTeX failure due to missing braces.

* Extract texcmp results as current user

This allows running the texcmp.sh script using sudo on afs.

* Change texcmp conversion to gray

As per #708, this should increase compatibility with older versions of
imagemagick, and might also do a better job of preserving the original sRGB
color space.

* Abandon tar and use plain docker cp instead

Thanks to Erik Demaine for suggesting this.

* Move npm install into creation of texcmp docker image
2017-06-11 16:02:06 -04:00
Erik Demaine
06d6c96894 Add \jot lineskip to aligned environment, switch contents to displaystyle, and add gathered (#725) 2017-06-10 17:10:29 -04:00
Kevin Barabash
95af9379da Merge pull request #724 from edemaine/highcontrast
Support Windows high-contrast mode. Fix #716
2017-06-10 16:07:00 -04:00
Erik Demaine
7fdb1eed81 Implement $...$ within \text via styling node (#637) 2017-06-10 16:03:22 -04:00
Erik Demaine
a564c0aeef Support Windows high-contrast mode. Fix #716 2017-06-10 12:58:55 -04:00
Kevin Barabash
9913242245 Merge pull request #718 from kohler/fix-711
Fix #711 issue with multiple superscripts.
2017-06-06 20:38:10 -04:00
Eddie Kohler
3af23fd8a4 Fix #711 issue with multiple superscripts.
The previous code incorrectly implemented TeXbook rules. First off,
the font metrics at issue should be those for the superscript/
subscript style, not the main style. Secondly, the metrics should be
scaled by the font size.

This changes some screenshotter tests (and they look more like TeX
now).
2017-06-05 23:52:16 -04:00
Kevin Barabash
9f3f445360 Merge pull request #684 from edemaine/anglebracket
Support <, >, | and many \text... commands in text mode
2017-05-16 20:19:38 -04:00
Kevin Barabash
78be8d4a29 Merge pull request #697 from edemaine/implies
Add \iff, \implies, \impliedby support
2017-05-16 20:02:39 -04:00
Erik Demaine
1428136e52 Support <, >, |, and long-form symbols. Fix #662
Add long-form aliases for various text symbols

* \textgreater is an alias for > in text mode
* \textless is an alias for < in text mode
* \textbar is an alias for | in text mode
* \textdollar is an alias for \$ in text mode
* \textunderscore is an alias for \_ in text mode
* \textbraceleft is an alias for \{ in text mode
* \textbraceright is an alias for \} in text mode
* \textless is an alias for < in text mode
* \textgreater is an alias for > in text mode
* \textbar is an alias for | in text mode
* \textbardbl is an alias for \| in text mode
* \textendash is an alias for -- in text mode
* \textemdash is an alias for --- in text mode
* \textquoteleft is an alias for ` in text mode
* \textquoteright is an alias for ' in text mode
* \textquotedblleft is an alias for `` in text mode
* \textquotedblright is an alias for '' in text mode
* \textdagger is an alias for \dag in text mode
* \textdaggerdbl is an alias for \ddag in text mode
* \textsterling is an alias for \pounds in text mode
* \dag, \ddag work in text mode
* \circledR, \checkmark, \pounds work in text mode too
* Extend Symbols1 test to test \pounds and \textdollar in \text
* Add note about \pounds in text vs. math mode
2017-05-16 18:03:47 -04:00
Erik Demaine
46f34181e3 Add \iff, \implies, \impliedby support. Fix #190.
* Based on @ronkok's code, but without \mathrel as it's absent
  from amstex.sty.
* Add toBuild tests to ensure these operators expand.
2017-05-16 17:50:06 -04:00
Kevin Barabash
e4b93379fb Merge pull request #699 from edemaine/middle
Refactor and comment space splicing code
2017-05-13 15:07:05 -04:00
Erik Demaine
5165cc48e6 Refactor and comment space splicing code 2017-05-12 09:33:14 -04:00
Eddie Kohler
7192bd6595 Fix #683.
Shift spaces back into the replacement middle delimiter.
2017-05-12 09:28:49 -04:00
Tab Atkins Jr
b9e7b6898f Rephrase displayMode description to be clearer (#648)
* Clarify meaning of true and false
* Clarify inline vs. block
2017-04-27 19:02:19 -04:00
Kevin Barabash
429c1f6f52 Merge pull request #678 from edemaine/symbols
Fix font typo math -> main
2017-04-15 20:55:53 -04:00
Kevin Barabash
2c92a9a368 Merge pull request #605 from gagern/overset
Builtin macros, macro arguments, \overset and \underset
2017-04-15 20:39:01 -04:00
Erik Demaine
171e38f28a Old font command support: \rm, \sf, \tt, \bf, \it (#675)
Squashed:
* \rm, \sf, \tt, \bf, \it support
* Fix space consumption after macros without arguments
* Add tests for old font commands
2017-04-07 22:06:23 +01:00
Erik Demaine
1379c2666e Fix font typo math -> main 2017-04-07 14:51:57 -04:00
Martin von Gagern
3a95d8889b Added screenshotter tests for overset and underset 2017-04-05 21:43:21 +01:00
Martin von Gagern
28ad473e4a Indicate missing support for delimited macros 2017-04-05 21:43:12 +01:00
Martin von Gagern
e2763a3007 Support \bgroup and \egroup 2017-04-05 21:43:04 +01:00
Martin von Gagern
96d1e6aea7 Introduce defineMacro function
… as suggested by Erik Demaine, to future-proof the code.
2017-04-05 21:42:48 +01:00
Martin von Gagern
7ec455083f Builtin macros, macro arguments, overset and underset
* Ship predefined macros with the library, in macros.js.
* Allow macro arguments #1 and so on, with argument count deduced from string.
* Use these features to implement \overset and \underset, fixes #484.
2017-04-05 21:42:38 +01:00
Noxx
40ec1b92b8 Fixed missing verb in README (#668) 2017-03-14 11:53:20 -04:00
Tab Atkins Jr
f3df1ccbac Use utils.deflt for Settings (#649)
Rather than duplicate the definition of the undefined-defaulter, use the version already present in utils.
2017-01-27 07:54:05 +01:00
Sergey Pashinin
fdd83db65a fix #509: added some international operators (#647)
* fix #509: added some international operators

* trailing comma
2017-01-26 15:04:18 -05:00
Kevin Barabash
742e512172 Merge pull request #642 from gagern/release
Fix release script after experience from 0.7.1 release
2017-01-23 07:53:48 -05:00
Kevin Barabash
3fea3dfbbc Merge pull request #635 from gagern/fontDiff
Set up a diff attribute and textconv instructions for font files
2017-01-22 19:57:03 -05:00
Kevin Barabash
301d7cfb1a Merge pull request #639 from gagern/printSize
Show compressed sizes correctly
2017-01-22 19:27:17 -05:00
Kevin Barabash
7aa84d010c Merge pull request #644 from gagern/readmeMacros
Describe site-provided macros in README
2017-01-22 18:21:51 -05:00
Martin von Gagern
59c4e008db Fix case of string in README 2017-01-22 22:39:57 +01:00