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.
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
* 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.
* 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.
* 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.
* 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