* To @flow: MacroExpander.
* Explicitly pass context into defineMacro called with a function.
Instead of binding `this` when `defineMacro` is invoked
with a function, we now pass an explicit context as a
parameter to the function. This is a bit more obvious
and is currently more type-safe due to a bug in `@flow`:
https://github.com/facebook/flow/issues/4809
* Per feedback, rename some types, fields, and variables.
Upgrade match-at and flow versions to resolve the match-at flow
errors, allowing us to remove match-at from the .flowconfig ignore
Test plan:
run `jest` and get the following output:
PASS test/unicode-spec.js
PASS test/errors-spec.js
PASS test/mathml-spec.js
PASS test/katex-spec.js (5.104s)
run `flow` and get:
No errors!
* copy-tex contrib module
* Factor out replacement code
* Fix lint
* Support for more browsers, in particular Firefox
* Use for loop instead of Array.forEach
* Use replaceChild if replaceWith is unavailable
* Browserify to remove let etc.
* Fix HTML handling, in particular for Edge
* Convert DocumentFragment to HTML directly (via children' outerHTML)
* Set HTML content *before* text content; Edge takes the last only
* Handle .katex-html and .katex-mathml separately
* Implement option 2: CSS user-select: all
Also fix auto-render.js build location
* Revise documentation according to @kevinbarabash's comments
* Split copy-tex.js into it + katex2tex.js
This supports re-use of code in a custom copy handler.
* Document custom copy handler
* Add missing file
* 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
* 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
* 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
src/functions.js was returning two properties referring to the base; since buildHTML runs `JSON.parse(JSON.stringify(tree))` to get an immutable copy, that meant we'd traverse and serialize and parse an exponentially-sized tree.
Test Plan: `\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{\breve{A}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}` renders instantly; previously, it reliably timed out with even half that depth.
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.
* Added MathJax compatibility script
* Removed make integrity, which release.sh handles
* Renamed scripts
* Use katex.render (and options) instead of manually string munging
* Rewrote code based on feedback
* Renamed file correctly
* Extended README with an example of usage
* Removed CDN paths in place of an abstract path
* Revert "Removed CDN paths in place of an abstract path"
This reverts commit 857f8de2e449d9ac5a3d8eab5104dac561c533c4.
* Replace versions with `...`, with note to avoid confusing users
* Revert some `...` replacements to files that do exist.
* Reduce SVG
1. Edit to reduce redundancy in SVG code. Save 5 KB in size of stretchy.js
2. Bug fix: Use correct path geometry for `\xleftharpoondown`.
* remove unnecessary fill='currentcolor'
* 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
* Modernize font creation
* Automate the build process, instead of writing a complicated manual
* Update sources used by the docker image away from google code
* Exclude MathJax-dev checkout from docker image, to allow image reuse
* Try to keep the individual image layers small by combining RUN commands
and removing temporary files used only during each individual step
* Allow creating fonts from local directory
Also use hash of Dockerfile to compute image tag, in order to ensure
creation of a new image if the Dockerfile changes.
* make glob syntax work on MacOS
* 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:
Now that we're using ES6 import statements in our source code
it makes it difficult for people to consume the katex package
as a node module unless they're using node.js version 8.x.
This diff points the node entry to dist/katex.js which
is the compiled version of katex.js.
Test Plan:
- publish
- create a new project node project and add the new npm katex package as a deep
- require katex in a test file and run it using node.js version 6.x
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
Summary:
My version of git and the online docs for git-diff show --exit-code as
the option to return the status code, not --exit-status. This commit
updates release.sh to use --exit-code in place of --exit-status.
Test Plan:
- ./release.sh 0.8.0 0.9.0
Auditors: emily
* 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).
Some delicate surgery is required on the `vlist-s` table-cell CSS.
Problem with #768 reported by @ronkok; issue #779. Fixes:
* `font-size: 1px` (rather than `font-size: 0.05em`) solves render
issues with user overrides of the `.katex` `font-size`.
* Also fix a width issue.
* 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
Replace console.error with a configurable option. This mimcs the current
default behaviour to guaranteee compatibility with previous versions.
Update errorCallback to the README.md
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.
Previously, we added a `oneDone` promise *every time a test attempt
failed*. This decremented the count of remaining tests once per
failed attempt. As a result, Chrome tests didn't run to the end.