* Work around negative space bug in Chrome
Fix#984
The screenshot test is still somewhat defective, showing a space before
the "post" text (a period). This seems limited to the screenshotter, however,
as it works fine in the tester via
http://localhost:7936/?text=%5Cfbox%7B%5C%241%2C%5C!000%2C%5C!000%7D%5CKaTeX&display=0&after=.
* Update screenshots
* Switch to inherited `width: min-content`
* Padding over \sqrt and Paths for frac-line
This replaces two earlier PRs.
* Restore reaction arrows
* regenerate screenshots
* Set line padding in a constant
* Update with latest master
* Fix lint error
* update screenshots
* Support Reaction Arrows
This PR is written to supply reaction arrows for a future `mhchem` extension. `mhchem` uses seven reaction arrows. Four of them correspond to extensible arrows already available in KaTeX. This PR creates the other three.
These arrows will also be useful to chemists writing about reactions when `mhchem` is unavailable.
Three new extensible arrows are introduced: `\xrightleftarrows`, `\xrightequilibrium`, and `\xleftequilibrium`.
These names are not `mhchem`’s user-facing function names. In `mhchem`, users would call these arrows with syntax such as: `\ce{A<-->B}`, or `\ce{A<=>>B}`, or `\ce{A<<=>B}`. I’ve provided names that look more like the other extensible arrow names. That’s probably worth some discussion.
* generate screenshots for ReactionArrows
* Increase overlap in arrow shaft
To prevent a small gap when rendering in very large font sizes.
* Adjust upper text vert alignment. Add warning.
* Limit alignment adjustment to \xleftequilibrium
* generate screenshots for reaction arrows
* 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
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.
* Use JS for spacing between atoms instead of CSS
Summary:
This is the first step towards creating an intermediate representation
that can be used to generate HTML, SVG, and Canvas commands for rendering.
By generating spans that contain the width of the spaces instead of
relying on CSS sibling rules we'll be able to one day replaces the spans
with intermeidate 'Glue' nodes (in a later PR).
An added benefit of this approach is that is enables us to programmatically
change the values for thinspace, mediumspace, and thickspace which will
allow us to implement the \setlength command.
Test Plan:
- npm test
- dockers/Screenshotter/screenshotter.sh --verify
* fixed failures in BinCancellation, BoldSymbol, and OperatorName
* update screenshots
* don't use current size when determining size of spaces, update more screenshots
* fix spacing in SizingBaseline and StyleSwitching
* actually do the right thing for sizing groups
* fix \not for Chrome and Firefox
* do TODOs
* address feedback from the code review
* fix issue in delimsizing.js
* add TODO to think about a better solution in href.js
* fix typos, simplify href, be honest about paddingLeft for \not
* Create a separate entry point for webpack
Created a webpack entry point for KaTeX, which imports katex.less. As
flow[1] and jest[2] doesn't support CSS modules natively, a separate
entry point is used and it is not flowtyped.
[1] https://gist.github.com/lambdahands/d19e0da96285b749f0ef
[2] https://facebook.github.io/jest/docs/en/webpack.html
* Use webpack to build files
* Made webpack.config.js export valid webpack configuration
* Use:
browserify -> webpack
babelify -> babel-loader
UglifyJS CLI -> UglifyJsPlugin
Less CLI -> less-loader
cleancss -> cssnano in css-loader
build/fonts -> file-loader
* Inline CSS(Less) using style-loader and export them using
ExtractTextPlugin
* Add `watch` npm script calling `webpack --watch`
* Improve local testing(webpack-dev-server)
* Made webpackDevServer export a valid webpack configuration
* Compile Less and inline CSS using less-loader and style-loader
* Instead of copying files serve files from /static and use file-loader
* Remove old server.js and its dependencies
* Use webpack-dev-server in Screenshotter
* Include contrib in webpack-dev-server
+ Moved common configurations to webpack.common.js
* Rename webpackDevServer.js to webpack.dev...
to be consistent, avoid confusion with webpack-dev-server and follow
webpack configuration naming convention.
* Remove unnecessary conditional output.path
* Use map instead of reduce
+ Add comments regarding function arguments
* Remove unnecessary mkdir and clean build/* before build
* Use katex as external dependency instead of global variable in contrib
Fixes#692.
* Unblock codes as they are built as a module
* Update package-lock.json
* Add comments regarding devServer option
* Lint renamed webpack.dev.js
a0d8b33
* Export ES6 module and expose its default export
* Revert "Browserify hotfix (#1057)"
This reverts commit f6b509123b.
* Enables colors on the console when running the dev server in Screenshotter
* Add context to webpack configuration
Allows webpack to be run from other directories
* Move `rm -rf build/*` to npm scripts
* Check dependencies before build
* Move UglifyJsPlugin into config creation
* Let webpack handle ES6 modules
Do not transform modules to commonjs in Babel. However Jest doesn't not
support ES6 modules, so transfrom modules to commonjs when NODE_ENV is
`test`.
* Add documentation on testing in IE 9 and 10 using webpack-dev-server
Changed version range to include IE-compatible version
* Unicode accents
* Lexer now looks for combining dicritical marks and adds them to the same character
* Parser's `parseSymbol` now recognizes both combined and uncombined forms of Unicode accents, and builds accent objects just like the accent functions
* Added CJK support to math mode (not just text mode)
* Add invalid combining character test
* Add MathML test
* Add weak support for other Latin-1 characters
This maintains backwards compatibility, but it uses the wrong font.
There's a TODO to fix this later.
Also refactor symbol code to use for..of
* Update Unicode screenshot
* Remove dot from accented i and j (in math mode)
Also add dotless Unicode characters to support some accented i's and j's
* Fix \imath, \jmath, \pounds, and more tests
* Switch from for..of to .split().forEach()
Save around 800 bytes in minified code
* Fix split
* normalize() detection
* Convert back to vanilla for loops
* Fix merge
* Move normalize dependency to unicodeMake.js
* Make unicodeSymbols into a lookup table instead of macros
This is important for multi-accented characters.
* Add comments about when to run
* Move symbols definition into unicodeMake/Symbols.js
* Remove CJK support in text mode
* Add missing semicolon
* Refactor unicodeAccents to its own file
* Dotless i/j support in text mode
* Remove excess character mappings
* Fix Åå in math mode (still via Times)
* Update to support #1030
* Add accented Greek letter support (for supported Greek symbols)
* Update screenshot
* remove Æ, æ, Ø, ø, and ß from math mode test
* Fix frac lline
For frac-line, use an SVG line in an extra tall span.
I still need to think of a way to adust `vertical-separator`.
* Fix spaces in katex.less
* regenerate screenshots
* update HorizontalBraces and StrikeThrough screenshots
* 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
* 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
* 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
* 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
* Change frac-line from border to full span
Change `frac-line` and `vertical-separator`. Instead of using span borders, fill entire span using a `box-shadow`.
This change will enable more dependable engagement of the `min-height` CSS.
* Fix indentation
* Fix indent again
* Change box shadow to inline SVG
* Fix lint error
* regenerate screenshots after switching to SVG for fraction bars
* 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
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%
}}}
```
* 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).