Commit Graph

113 Commits

Author SHA1 Message Date
Erik Demaine
285c9fe0b6 Re includegraphics (#2053)
* Re-enable \includegraphics now that we have trust setting

This reverts commit 5806b240b3.

* Include Khan Academy test logo in repo and use in test (fix #1892)

* Update screenshots

* Update documentation

* Add tests, cleanup existing tests

* Update snapshots

* Enable trust testing (trust=true by default)
2019-07-22 00:15:29 +09:00
Erik Demaine
9c7f26b479 Fix argument font sizing in \fbox and \raisebox, fix font sizing in \TeX, \LaTeX, \KaTeX (#1787)
* Remove forced \normalsize in \raisebox

Fix #1786 (incorrect size of "E" in `\TeX`) by fixing `\raisebox` to
keep the current font size.  Previously, `\raisebox` was rendering its
second argument as if it were in `\normalsize\textrm{...}`; now,
the argument is just as if it were in `\textrm{...}`.

* Fix screenshots

* New "hbox" argument type to convert box-like arguments

* Review comments

* Fix \fbox to use hbox argument

* Render A in \LaTeX and \KaTeX in \scriptstyle (not \scriptsize)

* Add screenshot test

* Revert .sizing { width: min-content} thanks to #2044
2019-07-18 11:24:00 -04:00
Ron Kok
2dc8f8121a Support \operatorname* (#1899)
* Support \operatorname*

* Fix lint errors

* Fix YAML

* Update screenshots

* Break out a function to avoid code duplication

* Fix lint errors

* Restore wrapper span

* Update docs

* Reinstall color macros lost in merge

* Update screenshots

* Add type annotations, Move to utils file, add \limits to screenshots

* Fix lint errors

* Rearrange screen shot to fit onto page

* Update screenshots

* tweak location of utils.js and assembleSupSup.js
2019-07-17 21:38:44 -04:00
Erik Demaine
08df67b7cd Fix font choice in operators like \log (e.g. \boldsymbol{\log}) (#2041)
* Fix font choice in operators like \log (e.g. \boldsymbol{\log})

Fix #1971 by correctly passing arguments into the font choice for
the HTML handler for operators like \log.

* Extend BoldSymbol screenshot test

* Require options argument in mathsym to avoid this type of bug in the future

* Update screenshot
2019-07-16 15:08:17 -07:00
Ron Kok
fc79f79c78 Support Unicode \digamma (#2010)
* Support Unicode \digamma

* Update screenshotter images
2019-07-05 20:01:51 -04:00
Erik Demaine
19d9d83ad3 \color affects following \right, put array cells in their own groups (#1845)
* \color affects following \right

Fix #1844 by giving `leftright` nodes a `rightColor` attribute for how
to color the right bracket.  Now `\color` sets the macro
`\current@color` in the current environment (in particular, resetting
after `\right`), just like `color.sty` does in LaTeX.  This is used to
specially pass the current color into any following `\right` and then
into the `leftright` parse node.

* Add test

* Put each array cell in its own group/namespace

* Improve cell group isolation, add test and TODO

* Improve comments
2019-07-05 00:27:55 -04:00
Ron Kok
f9dafea6a6 Enable minRuleThickness in rendering options (#1964)
* Enable minRuleThickness in rendering options

* fix typo

* Fix lint errors

* Fix default

* Remove border from \colorbox

* Fix lint error

* Update array screenshot

* Add border to \fcolorbox

* Edit comment

* Add comment

* Pick up review comments

* Fix lint errors

* Edit \sqrt screenshot test

* Update screenshots

* Screenshot update take 2

* Improve \sqrt SVG paths

* Fix lint error
2019-05-25 18:39:16 -04:00
Ron Kok
3b60aee16c Support {smallmatrix}, {subarray}, and \substack (#1969)
* Support {smallmatrix}, {subarray}, and \substack

* Fix lint errors

* Update docs. Screenshots step 1.

* Screenshots step 2

* Screenshots step 3

* Pick up review comments

* Fixed arraycolsep for {smallmatrix}

* Fixed lint error

* Updated screenshots
2019-05-20 23:34:49 -04:00
Kevin Barabash
5806b240b3 disable \includegraphics until trust settings is merged (#1951)
* disable \includegraphics until trust settings is merged

* disable one more test
2019-04-28 17:52:27 -04:00
Ron Kok
64d1c4e590 Fix nested \dfrac (#1825)
* Fix nested \dfrac

* Update screen shots
2019-03-20 14:20:01 -04:00
Ron Kok
f5234a2f01 Fix \hphantom width (#1809)
* Fix \hphantom width

* Spin up phony screenshot test

* Make better choice of smash screenshot test

* Real screenshotter test

* Add strict mode

* Fix lint error

* useStrictBehavior

* Revert to previous strict setting

* useStrictBehavior "phantomSpacing"

* Fix tests via nonstrictSettings

* Fix documentation

* Remove bin|rel
2019-01-02 01:49:23 +09:00
Ron Kok
f713f324bd Support \includegraphics (#1620)
* Support \includegraphics

* Update screenshots

* Fix lint errors

* Fix more lint errors

* Fix lint errors take 3

* Add documentation, error messages

* Improve CSS

* Update domTree to coordinate with PR #1633

* Update screenshots

* fix flow errors

* Use same RegEx as href

* Fix lint error

* Accept raw ArgType

* Fix lint error

* fix flow error

* Add test
2018-11-01 18:43:41 -04:00
ylemkimon
ba8e224b8d Fix \mathit font and italic correction and add \mathnormal (#1700)
* Fix \mathit font (Math-Italic -> Main-Italic) and italic correction

* Rename mathit to mathdefault and mainit to mathit

* Add \mathnormal
2018-10-10 17:18:07 +09:00
Ron Kok
98dd7fc912 Fix \Large roots (#1485)
* Fix roots

* Update screenshots

* Added a test in a craven gambit to get a green check mark

* Adjust small radicals

* Fix lint error

* Update screenshots
2018-08-08 08:46:04 +09:00
Ron Kok
b2d38104cd Fix \fbox (#1550)
* Fix \fbox

* Fix lint errors

* Change negative space test from \fbox to \boxed
2018-08-04 20:32:06 -07:00
Ron Kok
aef9256419 Fix wide characters (#1549)
* Fix wide characters

* Add phony screenshots

* Try again with screenshotter

* Screenshotter general edit

* Getting closer

* Fix screenshotter test

* Update screenshots
2018-08-05 12:26:20 +09:00
Ron Kok
b43ed4b645 Support \pmb (#1418)
* Support \pmb

* Fix lint error

* Add phony screenshots

* Screenshots take two

* Screenshots take three

* Simplify copies

* Move determination of mclass from handler to htmlBuilder

* Change to a macro definition

* Update screenshots

* Pick up review comments

* Clean up nesting of braces

* Update screenshot
2018-07-22 17:46:12 -04:00
Ron Kok
db585fae54 Support \genfrac and \above (#1458)
* Support \genfrac and \above

* Accommodate delimiters inside groups

* Update screenshots take one`

* Update screenshots take two

* Fix flow error

* Fix lint error
2018-07-07 17:01:37 -07:00
Ron Kok
8621f5b76a Support \brace and \brack (#1453)
* Support \brace and \brack

* Update screenshots
2018-06-28 03:43:02 +09:00
Ryan Randall
062f8fbdbd Phantom text (#1449)
* Enabling phantom in text mode.

* Adding screenshots.
2018-06-26 17:50:20 +09:00
Ron Kok
3e932b1ecb Support \oiint and \oiiint (#1430)
* Support \oiint and \oiiint

* Fix sub. Add tests

* Add phony screenshots

* Add real screenshots
2018-06-19 09:41:00 -04:00
Erik Demaine
4a2903148e Automatic mrel/mbin spacing for \boldsymbol (#1388)
* Automatic mrel/mbin spacing for \boldsymbol

Fix #1154

* Add test

* Add missing mode

* Separate out \boldsymbol support to correct flow types

* Fix ternaries thanks to @ronkok's comment

* Revert package-lock.json

* Add screenshot test
2018-06-11 08:19:50 -04:00
Ron Kok
a5ef29fab1 Implement \colon as amsmath does (#1410)
* Implement \colon as amsmath does

* Remove \colon from symbols.js

* Update screenshots

* Pick up comments

* Replace screenshots
2018-06-07 04:24:41 +02:00
Ron Kok
93904c51ab Support \hdashline (#1407)
* Support \hdashline

Support `\hdashline` from package `arydshln`. This PR acts as a complement to PR #1395.

Similarly to #1395, the dashed line is rendered as `border-bottom-style: dashed;`. That does not exactly match the `dashsegment` and `dashgap` lengths in `arydshln`, but it does render black lines with sharp edges.

* Fixed top line position

* Add screenshots

* Fix lint error

* Fix another lint error

* Deleted HLine screenshots

* Pick up comments
2018-06-07 03:30:29 +02:00
Ron Kok
89e180c5a6 Support \widecheck (#1406)
Fixes #1221.

Implemented as an upside-down version of `\widehat`.
2018-06-04 21:05:07 -04:00
Erik Demaine
1e645198f7 Fix ligatures vs. \tt (#1379)
* Fix ligatures not always triggering

Example: \text{\rm --} would not cause ligature but should

* Remove ligatures in \texttt mode

* Add screenshot tests

* Fix MathML ligatures

* Fix type

* Handle \text... fonts in MathML building

* Remove leftover console deubgging
2018-06-04 20:29:25 -04:00
Zachary Riedlshah
4492eedb68 Added ability to create a dashed vertical line in arrays, using ':' (#1395)
* hacked together a dashed vertical bar

* Updated tests and spec.

* tidied up the screenshot template for arrays

* added the vertical lines at the end back

* Updated screenshots for arrays
2018-06-03 19:52:30 -04:00
Ron Kok
563b0d5f8f Improve \cancel (#1398)
* Fix \cancel

Fixes #1080.

Improve `\cancel` in three ways:

1. Better lateral spacing.
2. Steeper `\cancel` lines on single characters.
3. Treat height and depth to match the `cancel` package behavior, not its documentation.

* Update screenshots
2018-06-03 17:38:49 -04:00
Ron Kok
08b0045b92 Support \cfrac (#1392)
* Support \cfrac

This was an easier PR to write than #135 since KaTeX now has well established methods for pt-to-em conversions and nulldelimiter.

As in #135, this does not support the LaTeX optional argument for numerator justification.  It supports a `\cfrac #1 #2 ` syntax.

* Added screenshotter files

* fix ref to context in genfrac handler
2018-06-03 16:38:19 -04:00
Erik Demaine
3d5826c1da Implement \neq and \notin via macros like LaTeX's (#1400)
* Implement \neq and \notin via macros like LaTeX's

* Fix test
2018-06-03 16:01:16 -04:00
Ron Kok
a5e6b92ff1 Fix lap vertical alignment. (#1162)
* Fix lap vertical alignment.

Fixes issue #1153.

* Fix horizontal alignment

Wrap the entire lap pair with a mord.

* Support Unicode \ll and \lll

Fixes issue #1271

* Update screenshots

* Update screenshots

* generated updated screenshots for Lap

* Change double strut to single strut

* Delete screenshotter test

* Add (commented out) test

* Fix mis-spelled word
2018-05-25 03:27:15 +02:00
Erik Demaine
a0ddad338e Support \tag, \tag*, and \gdef (#1309)
* Tag sketch

* Drop objectAssign; already using Object.assign elsewhere

* Basic \gdef support

* Bug fix

* Finish \tag

* MathML numbers equations with <mlabeledtr>

* Fix flow bugs

* \gdef tests

* Add basic \tag tests

* Screenshot test for \tag

* \tag* test

* Add missing file

* Bug fix screenshot

* Major refactor

* Represent tag at top level of parse tree, requiring less hackery
  * No more \@tag function; it was essentially just doing \text
* Wrap tag in group so e.g. ( and ) are formatted the same
* Add `feed` method to MacroExpander for multiple inputs (for tag)
* Bug fixes in buildHTML, makeTextRow, _getBuilt (for display mode)
* Remove excess <mrow> wrapper when unnecessary

* Update screenshot from tag being wrapped in group

* Add maxExpand limit
2018-05-19 22:19:21 +02:00
Erik Demaine
4801ab875a Support for top-level \newline and \\ in inline math (#1298)
* Support for top-level \newline and \\ in inline math

This was a little tricky because `\\` was defined as an endOfExpression.
Instead made `\\` a termination specific to an array environment.
Outside an array environment, buildHTML handles the `cr` object,
resulting in a `.newline` class.  Currently this turns into a
`display: block` (with appropriate vertical spacing) only in inline math,
matching LaTeX.

* Simplify code

* Fix Jest errors

* NewLine screenshot test

* Bug fix: \\ only works at top level of inline

* Add \newline and \cr to test

* Switch test to pmatrix

* Add vertical space test

* Add \\ vs. \newline tests

* Fix flow errors

* Add \cr test

* Add documentation for \\ at top level

* Comment out newRow

* Fix commenting out
2018-05-13 09:58:24 -04:00
Ron Kok
74422e1462 Support \hline (#1306)
* Support \hline

Support `\hline`.

* Fix CSS

* Fix lint errors

* Add double \hline. Code Cleanup

* Reduce width of screenshot test

* Add screenshots

* Use consumeSpaces, read multiple \hlines

* Code cleanup

* Update screenshots
2018-05-12 13:51:14 -04:00
Erik Demaine
523df299e5 Line breaks for inline formulas (#1287)
* Line breaks for inline formulas

* Basic support for \allowbreak and \nobreak

* Fix spacing around \nobreak, and add documentation

* Backwards-compatibility _getBuilt to fix tests

* Put operator spacing on same line as operator

* One approach to ~

* Simplify \allowbreak/\nobreak, make ~/\nobreakspace prevent line breaks

* Adapt to #1295

* Prevent wrapping within a .base

* Implement \hspace* properly

* Fix flow error

* Update comment for regularSpace

* Update screenshots

* Move `width: min-content` from .katex into .base

* Fix screenshot

* Add min-width rule to .vlist-s

* Factor out hasClass method

* Cleanup nobreak test

* Pull out buildHTMLUnbreakable

* Fix \hspace* test (no longer the same as \hspace)

* Fix \nobreak handling

* Add screenshot test
2018-05-11 01:44:26 +02:00
Ron Kok
7b7b532fb6 Adjust \underset alignment and spacing (#1290)
* Support Unicode \ll and \lll

Fixes issue #1271

* Adjust \underset alignment and spacing

Fixes issue #1288.

1.  Fixes vertical alignment by keeping the base element on the baseline.
2. Assigns horizontal spacing to \underset in a manner that aligns with LaTeX `\binrel`

* Fix flow error

* Add comment

* Allow for shift of mathops

* Update screenshots

* Test for nested ordgroups

* Set \stackrel spacing class to mrel

* Fix lint error

* Better determination of atom type

* Add comment.

* Add `suppressBaseShift` to ParseNodeTypes
2018-05-10 13:13:37 +09:00
Erik Demaine
3e529dd5a0 Tilde \textasciitilde and fix ~ in \verb (#1286)
* \textasciitilde and fix ~ in \verb

* Add support for `\textasciitilde` which reproduces tilde character
  in text mode.
* Make `~` render as tilde instead of space within `\verb`,
  by manually mapping that character to `\textasciitilde`.
  This seems to be the only character that needs such manual mapping
  to reproduce LaTeX's `\verb` behavior.

* Add `, -, ', ~ to Verb screenshot test
2018-05-09 08:48:47 -04:00
Ron Kok
f01f504cfe Support some Unicode Mathematical Alphanumeric Symbols (#1232)
* Support some  Unicode Mathematical Alphanumeric Symbols

This PR adds support for some of the characters in Unicode range U+1D400 to U+1D7FF, [Mathematical Alphanumeric Symbols](https://www.unicode.org/charts/PDF/U1D400.pdf).  Specifically, it adds support for:
* A-Z a-z bold
* A-Z a-z bold italic
* A-Z a-z Fractur
* A-Z a-z sans-serif
* A-Z double struck
•	A-Z script

Addresses issue #1215 and parts of #260.

* Fix lint error

* Fix MathML, and pick up review comments

* Fix lint error

* Add text mode. Remove sans-serif.

* Fix lint error

* Fixed \mathrm, added screenshotter test

* Change screenshotter test to an array

* Add screenshots

* Picked up review comments. Add characters
2018-05-07 20:06:16 -04:00
Ron Kok
7fec5ae5dc Fix \underset (#1277)
* Fix \underset

This PR modifies `\underset` and `\overset` to align with LaTeX behavior when a superscript is applied after the `\underset`.  Fixes issue #1275.

I also changed the spacing from KaTeX `mop` to KaTeX `rmel`. The result seems to be a closer visual match to LaTeX.

* Update screenshots
2018-05-03 16:50:18 -04:00
Erik Demaine
812b350a5d Fix space width in \texttt (#1261)
* Fix space width in \texttt

Fix #1255 via https://github.com/KaTeX/katex-fonts/pull/41.
Also fix width metrics via https://github.com/KaTeX/katex-fonts/pull/42.

* Improve test

* Update screenshots
2018-04-21 19:52:18 -04:00
Erik Demaine
20b5a58451 Work around negative space bug in Chrome (#1194)
* 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`
2018-03-09 16:38:25 +01:00
Ryan Randall
7de91f73eb Nested Math in Non-Default Text Fix (#1111)
* Fixing nested math in non-default text. Added appropriate screenshot tests.

* Adding appropriate logic for buildMathML and resolving tests.

* Addressing Kevin's comment. Adding tests.

* Adding appropriate screenshots.

* Removing unnecessary data, adding consistent naming convention.

* Cleanup

* Handling possible edge cases.

* Updating per PR comments
2018-02-19 17:37:08 -05:00
Erik Demaine
627fc11f1b Support \underline in text mode (#1159)
* Support \underline in text mode

Fix #1158

* Add to LowerAccent test
2018-02-13 20:30:30 -05:00
Ron Kok
2aee354ca2 Support Reaction Arrows (#1078)
* 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
2018-02-04 15:52:22 -05:00
Ryan Randall
097d592b47 Merge branch 'master' into bolditalic 2018-01-28 14:54:35 -05:00
Kevin Barabash
c627de04d9 use correct spacing with tight styles (#1106) 2018-01-27 22:12:25 -05:00
Kevin Barabash
ea7a560191 add Main-BoldItalic font to allow nesting of \textit and \textbf 2018-01-27 11:32:14 -05:00
Kevin Barabash
f03849c831 update fonts and metrics so that accents are positioned correctly (#1094)
* 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
2018-01-26 19:46:57 -05:00
David Flanagan
53203ed92c Add a screenshot test to ensure that we don't inherit svg-only CSS properties (#1092)
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.
2018-01-25 14:02:06 -05:00
Erik Demaine
d822f04b9b \kern generates right-margin instead of left-margin. Fix #995 (#1019)
* \kern generates padding instead of margin. Fix #995

* Switch to marginRight

* Add screenshot tests
2017-12-28 23:03:08 -07:00