Commit Graph

67 Commits

Author SHA1 Message Date
Kevin Barabash
ea7a560191 add Main-BoldItalic font to allow nesting of \textit and \textbf 2018-01-27 11:32:14 -05:00
Kevin Barabash
f03849c831 update fonts and metrics so that accents are positioned correctly (#1094)
* update fonts and metrics so that accents are positioned correctly

* fix degree symbol, move more accents into the 0x2c0-0x2df range

* fix accents in Unicode screenshots

* update jest snapshots, update AccentsText to include requested characters

* update fonts submodule, add unicode chars to AccentsText test

* update submodules after merging its PR
2018-01-26 19:46:57 -05:00
David Flanagan
53203ed92c Add a screenshot test to ensure that we don't inherit svg-only CSS properties (#1092)
We want to inherit CSS properties that apply to both text and SVG
but we don't want to inherit styles that affect SVG without affecting text.

This patch adds a screenshot test to verify this.
2018-01-25 14:02:06 -05:00
Erik Demaine
d822f04b9b \kern generates right-margin instead of left-margin. Fix #995 (#1019)
* \kern generates padding instead of margin. Fix #995

* Switch to marginRight

* Add screenshot tests
2017-12-28 23:03:08 -07:00
Kevin Barabash
7229f02d8f Implement correct macros for liminf and limsup, fixes #111 (#887)
* Implement correct macros for liminf and limsup, fixes #111

* fix nits
2017-12-26 17:11:10 -07:00
Erik Demaine
d6791b7961 Make accents zero width (#1033)
* Make accents zero width

Make the width of an accented character equal to the width of the character,
by making accents zero width.  In particular, fixes #1028 (`\ddot\imath`).

This involved reworking all of the accent offset machinery, in particular
skew and accent-hungarian.  A bit cleaner now.

Also added support for the new width character metrics in symbolNode.

* Update AccentsText test

* Fix comment
2017-12-25 11:48:32 -07:00
Ryan Randall
50765a0ccd Stacking text commands (#1009)
* Adding support for SansSerif-Bold

* Updating to include SansSerif Italic.

* WIP

* Working text stacking

* More robust screenshot.

* Don't want to break users :)

* Updating per PR comments.

* Fixing Unicode and updating snapshots.

* Adding suggested tests.

* Opting to use old method for unit testing.

* Adding TODO
2017-12-13 09:10:23 -05:00
Alexander Terenin
cf23517499 Added support for bold italic symbols (#1011)
* added support for \boldsymbol

* added \boldsymbol tests

* added \boldsymbol screenshots

* added \bm, snapshot, updated screenshots

* updated snapshot for \boldsymbol

* properly display \imath and 2 in boldsymbol

* implemented \boldsymbol for +

* fix typo, remove boldsymbolLetters hardcode

* make comment about using Main-Bold more general

* fixed trailing space CI error
2017-12-12 23:09:52 -05:00
Erik Demaine
7036eb85cd \kern fixes, \hskip support, \TeX, \LaTeX, \KaTeX (#974)
* Refactor \kern, proper \mkern support, add \hskip

* Move \kern, \mkern into functions directory
* Add \hskip, \mskip support (but without supporting plus/minus)
* Properly separate \kern, \hskip from \mkern, \mskip.
  (The former work in both modes, and don't support mu units.
  The latter work only in math mode and only support mu units.)

* Render \kern etc. using MathML <mspace>

* Implement \TeX macro

* Implement \LaTeX

* New KaTeX logo \katex

* Rename hskip.js -> kern.js

* Tweak katex \kern to 0.16em

* \katex kern -.17em

* Compute A raise height in \LaTeX and \katex

* Switch mu unit errors to warnings

* LaTeX screenshot test

* Replace \KaTeX with macro definition

* Update screenshots with \KaTeX in them

* Fix font selection for \*TeX macros
2017-11-27 14:40:38 -05:00
Ron Kok
75af19c5bb Change \undertilde to \utilde (#948)
* Change \undeertilde to \utilde

In PR #670, I made an error. The function that should have been `\utilde` I named instead `\undertilde`.

There is an `\undertilde` from the `wsuipa` package, but it is a text-mode non-stretchy function. The proper command name is `\utilde`, a math-mode, stretchy function from packge `undertilde`.

This PR fixes my error.

* Fix screenshotter test
2017-11-23 23:16:37 -05:00
Hiromi Ishii
6f1661f7da Implements \mathchoice command (#969)
This PR implements `\mathchoice` function.
I once created PR on the wrong branch. Sorry for the mess.

This is particularly useful when one defines custom macro for "big operators".
For example:

```latex
\newcommand{\infdisj}{%
  \mathop{%
    \mathchoice{% display
      \bigvee\hspace{-2ex}\bigvee%
    }{          % inline
      \bigvee\hspace{-1.75ex}\bigvee%
    }{          % script
      \bigvee\hspace{-1.4ex}\bigvee%
    }{          % scriptscript
      \bigvee\hspace{-1ex}\bigvee%
}}}
```
2017-11-22 07:34:05 -05:00
Hiromi Ishii
1a640a465e Implements the alignedat environment for flexible math spacing (#930)
* Implements the alignat environment for flexible math spacing

* Renames alignat[*] to alignedat and factors out duplicate code of aligned and alignedat as alignedHandler

* Adds aligned at to screenshotter

* alignedat screenshots

* Implements the alignat environment for flexible math spacing

* Renames alignat[*] to alignedat and factors out duplicate code of aligned and alignedat as alignedHandler

* Adds aligned at to screenshotter

* alignedat screenshots

* fix style nit

* fix lint
2017-11-11 20:36:09 -05:00
Kevin Barabash
71e0b35b27 allow sizing commands inside optional groups (#885)
* allow sizing commands inside optional groups

* allow color, old font, and style commands inside optional groups
2017-10-03 11:30:59 -06:00
Erik Demaine
f10ea4cbeb Implement \verb (#614)
* Implement \verb

* Implement @gagern's comments

* \verb: look up characters one at a time.

* Add screenshot test for \verb

* Add error tests for \verb

* Include space symbol in typewriter font, and fix single quotes

This is based on https://github.com/Khan/MathJax-dev/pull/2
which hasn't been accepted yet at the time this commit is made.

* Add \verb* tests

* \verb should use Typewriter-Regular font!

* Switch \verb to use text mode and no-break space.

* Screenshot update with Typewriter-Regular

* \verb test: fix *, add commas to make spaces clear

* Fix spaces and style handling

* Implement @kevinbarabash's comments

* Make error clearly an assertion failure

* verb screenshot for Chrome
2017-09-21 23:43:05 -04:00
Christopher
6e75ebdc2d Fix #337 - Array/Matrix trim trailing empty line (#479) 2017-09-16 20:44:26 -04:00
Ron Kok
db1cccdeab Support \colorbox and \fcolorbox (#886)
* Support \colorbox and \\fcolorbox

These are functions from the `color` package. They accept text, not math. They also have padding similar to `\fbox`.

Because of the padding, the code in `buildHTML` is intermixed with the `\fbox` code. I have not (yet) created a new file in the functions folder. This way, the reviewer gets a cleaner diff.

* Fix lint error

* colorbox screenshots

* Pick up review comments
2017-09-16 00:55:13 -04:00
Ron Kok
4f63909d08 Support \operatorname. Resolve #145 (#866)
* Support \operatorname. Resolove #145

* Fix quote mark typo

* Fix test escapes

* Remove poorly written tests

* operatorname screenshots

* Remove nits

* Use documentFragment. Eliminate macro.
2017-09-10 23:33:51 -04:00
Erik Demaine
ca224eda81 Support for \raisebox (#685)
* Rough support for \raisebox

* Fix bounding box thanks to @kevinbarash and @ronkok

* Use calculateSize to support all currently supported units (ex, em, mu).
* Shift height and depth in all cases.

* Add screenshot test

* Rename transform -> raisebox

* Switch to normalsize in raisebox

* Attempt at using makeVList

* Significant rewrite, now working well

* rename textFunctionStyles to textFunctionFonts
2017-09-04 20:49:10 -04:00
Erik Demaine
6857689946 Advanced macro support and magic \dots (#794)
* Advanced macro support and magic \dots

* Fix \relax behavior

* Use \DOTSB in \iff, \implies, \impliedby

* Add multiple expansion test

* Implement some of @kevinbarash's comments

* More @kevinbarabash comments

* Token moved from merge

* Add type to defineMacro

* @flow
2017-09-04 20:27:04 -04:00
Ron Kok
092aa0c767 Add \smash, laps, spaces, and phantoms (#833)
* Add \smash, laps, spaces, and phantoms

1. Support `\smash`, including the optional argument from AMS.

2. Change `\llap` and `\rlap` so that they render in text style. Repeat: This *changes* KaTeX behavior.

3. Add `\mathllap` and `\mathrlap`. These will act as they do  in `mathtools` and as in previous KaTeX versions of `\llap` and `\rlap`.

4. Add `\mathclap` and `\clap`.

5. Add `\hphantom` and \vphantom`.

6. Add `\thinspace`, `\medspace`, `\thickspace`

7. Add `\hspace`.

This work will resolve issue #270 and parts of #50 and #164.

A. Perlis has written a [concise description](https://www.math.lsu.edu/~aperlis/publications/mathclap/perlis_mathclap_24Jun2003.pdf) of items 1 thru 5. Except for `\smash`'s optional argument. It's described in the [AMS User's Guide](http://texdoc.net/texmf-dist/doc/latex/amsmath/amsldoc.pdf).

Item 6 also comes from the AMS User's Guide.

* Fix test spec

* Exploit makeVList for smash

* update smash and phantom screenshots for chrome

* Pick up review comments

* Change test from \llap to \mathlap

\llap is fundamentally a text-mode function. We should not expect it to work correctly when given math-mode arguments. So test \mathllap instead.

* Correct \llap macro

A correction. The previous macro returned an error if given an argument with math-mode content, such as x^2.

The corrected macro will not return an error. It will instead return well rendered math, but letters are in `\mathrm` font.

* update \llap, \rlap, \clap macros to use \textrm

* update Lap screenshots
2017-09-02 14:04:30 -04:00
Kevin Barabash
c6647e3303 Added support for \not (#140)
* Added support for \not

* fix grammar in comment
2017-08-23 13:24:17 -04:00
Erik Demaine
201193233e Support for \' \` \^ \~ \= \u \. \" \r \H \v text-mode accents (#802)
* Support for \' \` \^ \~ \= \u \. \" \r \H \v text-mode accents

* bug fix

* Possible Safari fix

* Forbid text accents in math mode

* Switch to noncombining characters for most accents. Revert Safari change.

* Add tests

* Found non-combining diaresis accent too
2017-08-23 03:18:33 -04:00
Xuming Zeng
d01c73c312 Fix color support for stretchy, strikethrough, and fbox (#792)
Summary:
Stuff like `\red{\overbrace{AB}}` works now in addition to `\color{red}{\overbrace{AB}}`. Strikethrough now respects color. The Firefox in the screenshotter doesn't seem to support `background-image` + `mask`, but I manually tested that the latest Firefox does.

Test plan:
Ran `make`, then tested in latest Chrome and Firefox to ensure color support was working, then ran `make screenshots`.
2017-08-15 22:25:31 -04:00
Kevin Barabash
e00738d16f Accept all existing Greek letters using unicode characters in math mode (#410)
Test Plan:
- make test
- run screenshot tests on travis-ci
2017-08-14 00:31:43 -04:00
Erik Demaine
a0bedcce8e Support absolute TeX units (#732)
* Support absolute TeX units

* Implement @kohler's comments

* Rewrite unit documentation according to @kohler's comments
2017-08-11 18:30:06 -04:00
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
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
Ron Kok
eff7653c51 Support stretchy wide elements. (#670) 2017-06-15 23:47:51 -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
Erik Demaine
7fdb1eed81 Implement $...$ within \text via styling node (#637) 2017-06-10 16:03:22 -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
Eddie Kohler
7192bd6595 Fix #683.
Shift spaces back into the replacement middle delimiter.
2017-05-12 09:28:49 -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
Martin von Gagern
3a95d8889b Added screenshotter tests for overset and underset 2017-04-05 21:43:21 +01:00
Martin von Gagern
e2763a3007 Support \bgroup and \egroup 2017-04-05 21:43:04 +01:00
Erik Demaine
a738185704 Fix x'^2 (#636)
* Fix x'^2
* Add screenshot for x'^2
* x^2' should fail.  Add and fix multiple prime/superscript tests.
2017-01-19 19:50:16 +01:00
Erik Demaine
f1c02226cc Change cell style to 'text' in {array}, {matrix}, {cases}. Add {darray} and {dcases}. (#606)
* Change cell style to 'text' in {array}, {matrix}, {cases}.
* Add {darray} and {dcases} which use display style for their cells.
* Add ArrayMode test with \frac's inside {array} in display mode.
2017-01-15 22:17:45 +01:00
Eddie Kohler
7c83021009 Support \bmod, \pmod, \pod, and \mod. 2016-12-31 20:51:20 -05:00
Kevin Barabash
831c5b8d99 Merge pull request #578 from kohler/middle
Handle \middle.
2016-12-08 23:35:36 -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
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
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
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