* 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
* Convert nested SVGs to single-level SVGs
This PR evades a Safari bug which causes nested SVGs to zoom improperly. Fixes the remainder of issue #883.
* Add omitted word
* Fix lint errors
* update screenshots
* Pick up review comments
* Clean up variable names
Remove two more redundant variables.
* 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
* Fix \sqrt zoom in Safari
This PR evades a Safari bug which causes nested SVGs to zoom improperly. `\sqrt` and single-ended arrow SVGs have been modified.
These have been converted from nested SVGs to single level. Their long tails are now sliced off using CSS `overflow: hidden`.
Safari will still improperly zoom any double-ended stretchy arrows and horizontal braces.
* Fix \sqrt{}
Even if the function argument is empty, still render an SVG whose width equals the surd glyph.
* Fix tall \sqrt when scaled
* update screenshots affected by sqrt fixes
* more screenshots after changes to fix sqrt
* Pick up review comments
* 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
* Improve SVG Performance
This PR introduces three new classes: `svgNode`, `pathNode`, and `lineNode`. SVG data is then loaded into the domTree exclusively via instances of these classes.
`innerHTML` is banished.
* Fix lint errors
* Fix \cancel typo
* Fix sqrt height
* Adjust min-lenght
Adjust some of the extensible arrows to get a min-length that matches glyph length of the long arrows in KaTeX Main font range from Unicode 27F5 to 27FC.
The accent arrows still get min-lengths that match the arrows in the Unicode 2100 range.
* regenerate screenshots after optimizing SVG code
* update DisplayStyle screenshot for Chrome
* update OverUnderset and Smash screenshots for Chrome as well
* Remove escapes from template strings
* Pick up review comments
* Fix lint errors
* Add comments
* 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
* 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`.
* 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).
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.
* 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.
* 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.
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
* 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.
So `\text{Hi}` becomes one <span...>Hi</span>, rather than two
<span...>H</span><span...>i</span>.
This allows the font renderer to apply kerning, which changes some
test output.