* 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
* Fix color support for stretchy, strikethrough, and fbox
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`.
* Add a maxSize option to limit user-specified sizes (#109)
* Simplify maxSize logic and add unit test
* Clamp negative maxSize to zero
* Use a default maxSize of infinity to remove branching in calculateSize
Previously, the parser accepted all letters of the
alphabet for hex digits in HTML colors, and allowed any
number of digits. Now, only well-formed HTML hex colors
are allowed.
* 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
* Improve \sqrt
Make \sqrt out of inline SVGs to ensure a perfect match at the junction between surd and viniculum.
* Tweak for kern clarity
* Fix lint error
* regenerate screenshot tests with sqrts
* Correct advance
Edit the SVG paths so that they have the correct left bearing and advance width values.
This will correct the spacing on the left side of each surd and it will also improve the placment of a root indice.
* Revise scriptstyle surds
In the `main` size, delimiters *do* scale with scriptstyle and scriptscriptstyle.
* update screenshot images containing sqrts
* Use inline SVG for stretchy elements
Replace all background-images with inline SVG code.
Pros:
* `\color` works in all browsers, even IE/Edge
* Better printing
* Much simpler CSS
* No links to background-images
* No `mask`
* No browser-detection
* No external SVG files
* Faster first rendering
Cons
* No image caching
* Heavier HTML load
* Larger JavaScript file
* `\cancel` line is in `px` units, not `em` units
* Remove static/images from make file
* Change \cancel from px to em
* regenerate screenshots for functions using inline svg
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`.
Summary: (@kevinbarabash)
This diff extracts MathML builder tests out into a separate file and
updates them to use jest snapshot testing. It updates the output of
prime ' from using identifier nodes <mi> to operator nodes <mo>. It
also updates large operators with limits to use munderover instead
of msupsub. I added an option to remove unnecessary mrows to buildGroup.
Right now it's only used for by groupTypes.supsub. I'll see if it can be used
elsewhere (everywhere?) in a follow up PR.
Test Plan:
- make test w/o errors
- verify mathml snapshots contain the desired markup
* Improve rule coding.
* Rule widths (overline, underline, fraction, sqrt) actually scale
with the current font size in AMS-TeX. Implement that. (Sqrt is
a special case: the rule width depends on the font size *of the
surd*.)
* Change the CSS coding for rules. The old, complex coding prevented
variable-width lines and may have contributed to issues like #696.
Its purpose, according to 0a3a2271f4,
was IE8 support; but KaTeX no longer supports IE8.
* The 0.5px offset makes larger sizes better, smaller sizes worse.
Smaller sizes seem more important.
* Cleanup (intended to be squashed).
* Make KaTeX work in Quirks mode
Summary: In issue #601, it was noticed that the KaTeX bug with the fraction
bars overlapping the text was occuring with an XHTML doctype. This indicated
that the bug we were seeing was caused by both quirks mode and limited-quirks
mode (which is a version of quirks mode with fewer quirks and is enabled for
various doctypes including some XHTML ones).
Based on the [quirks spec](https://quirks.spec.whatwg.org/), it appears that
there are only two quirks in limited-quirks mode, both having to do with a
line-height calculation. @gagern figured out that if we added some zero-width
spaces in our elements, we would stop triggering the quirk, which would make
our fractions render correctly in limited-quirks mode.
I implemented that change, and ran the screenshotter in limited-quirks mode.
There were several other places that suffered from the same quirk, but were
also easily fixed via adding zero-width spaces. I then ran the screenshotter in
quirks mode, and discovered that (once an appropriate meta charset was added),
everything looked correct still.
So, this diff fixes all of the places that the limited-quirks mode quirks
affect our rendering, and removes the warning about rendering in quirks mode.
I also added support to our screenshotter to render things in both no-quirks
and quirks mode, to ensure that things don't break in the future. I copied the
non-quirks images to the quirks images, and ran the screenshotter with
`--verify` to make sure that they look the same.
I have some thoughts that I'd like to hear opinions about:
- I'm not super happy with how the screenshot tests work. Ideally we'd test
both quirks mode and non-quirks mode against the same images, since we'd
like them to be the same. I'm not sure how to make that work well, though,
since then people wouldn't be able to tell if it's a quirks-mode problem or
not.
- I removed the doctype in the testing page file, so all testing would now be
done in quirks-mode. Not sure if we really want that.
- I need to test this in IE, but it looks like the trailing commas change we
made with eslinting is causing problems (cause IE doesn't like trailing
commas).
Test Plan:
- `./dockers/Screenshotter/screenshotter.sh --verify`
* Compare quirks mode against same screenshot files
Now the screenshotter itself can run more than one mode. It does serve the
HTML file from its own JavaScript code now, so that it can include different
doctype headers without needing distinct files for each. There is a
provision to mark specific tests as quirky in case they produce different
results depending on the mode.
* Some cleaning up and comments
* Restore access to the babelified version of the HTML page for screenshots
* Reference unicode fonts using absolute path names
This avoids issues caused by the fact that the dynamically generated
ss-render.html is mounted to a different location than the test.html from
which it is derived.
* do chrome screenshots first
* remove commented out code, simplify hadle_search_string call
TeX and CSS treat line heights in fundamentally different ways. In
TeX, every character is treated as a box of its precise height and
depth; the line height (\baselineskip) applies after characters have
been assembled into lines. In CSS, in contrast, every character
creates a "line box" corresponding to the accompanying font. When
characters of different fonts and sizes are placed into the same
span, the resulting line box contains the line boxes of all children.
This is unfortunate because, for example, we want `\frac{1}{2}` to
behave in vertical spacing contexts like it is exactly as tall and
deep as the visible fraction (which is the TeX behavior). Given CSS
constraints, though, in most contexts the fraction has extra vertical
space: the line boxes for the numerator and denominator create
padding. For small boxes, this isn't so bad. To really see the
problem put a tall rule in the denominator of a fraction, or check
out the VerticalSpacing screenshotter test, which has way more space
than it should.
Solving this problem in CSS is difficult. There is no easy way to get
rid of the extra line boxes.
But there is *a* way, namely tables. A table-cell with vertical-align
top, bottom, or middle is ignored for the purposes of line height
calculation.
So in this commit, makeVList puts its contents into a
vertical-align:bottom table-cell (to clear unwanted line boxes), with
an extra row used to represent depth.
Many Chrome screenshotter tests change. This is because Chrome rounds
table dimensions to integral numbers of pixels, while it uses
sub-pixel positioning for non-table displayed tabs. That makes many
vlists a fraction of a pixel wider than they used to be.
Summary:
The reasons for switching to jest:
- easy snapshot testing so that we can easily verify the structure of the parse tree and MathML tree
- easy compilation of ES6 features for tests as we continue to expand our use of ES6
Test Plan:
- npm test
* 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.
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.
* 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
* 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.
* 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
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).
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
* 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.
* 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.
As babelify is slow, it may be desriable to not run it during development.
This is OK if the browser is recent enough to understand ES6 natively.
(This does not include current Firefox due to it having problems with
for(const … in …), https://bugzilla.mozilla.org/show_bug.cgi?id=1094995.)
For older browsers, or to check issues possibly introduced by babelify,
adding /babel as the first component of the path will switch to a version
which has been processed by babelify. This is also used for screenshots.
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.
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