Commit Graph

491 Commits

Author SHA1 Message Date
ylemkimon
babc60c428 test: add missing screenshots for safari (#2423) 2020-08-13 06:43:44 -07:00
Ron Kok
42cc5e507e feat: Support \phase (#2406)
* Support \phase

* Update screenshots

* Update documentation

* Add a11y test

* Edit MathML notation to phasorangle

* Move code to enclose.js

Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>
2020-08-13 00:08:36 -04:00
Ron Kok
26e0a05221 feat: Support \mathstrut (#2416)
* feat: Support \mathstrut

* Update screenshots
2020-08-12 23:45:33 -04:00
ylemkimon
36f9788cd6 chore(screenshotter): support Browserstack and test on Safari 13.1 (#2306)
* Support Browserstack in screenshotter

* Support Browserstack in CircleCI

* Test screenshots on Safari 13.1

* Don't run Safari screenshotter on forked PRs

* Update a screenshot

* Ignore *.log in .gitignore
2020-08-04 01:45:10 +09:00
Ron Kok
ab5936a6e7 feat: support {equation}, {equation*}, and {split} (#2369)
* Support {equation}, {equation*}, and {split}

* Update screenshots

* Allow {split} at top level

* Move equation column number check to to ParseArray

* Add token to ParseError

* Sharpen parameters passed to parseArray

* Add token information

* Update an {array} spec in screenshotter

* Adjust {array} screenshotter spec

* Make a non-strict error call when {array} argument specifies too few columns.

* Move context checks to a helper function.
2020-08-04 01:35:41 +09:00
ylemkimon
4a6f776941 test: mock console implementation (#2363)
Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>
2020-08-03 13:05:17 +09:00
ylemkimon
f9cd9de100 test(screenshotter): move coverage to Jest (#2324)
* Move screenshotter coverage collection to Jest testing

Fixes #1885.

* Update screenshotter-spec.js

* Update screenshotter-spec.js

Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>
2020-08-02 17:58:40 -04:00
ylemkimon
1ffb638da8 Fix test/symgroups.js (#2314)
I forgot to change it in #1595.

Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>
2020-08-02 17:09:51 -04:00
Ron Kok
2f37dc9104 feat: support {align}, {align*}, {alignat}, and {alignat*} (#2341)
* Support {align}, {align*}, {alignat}, and {alignat*}

* Specify display mode for screenshots

* Add bogus screenshots

* Some screenshotter progress

* Update screenshots
2020-07-29 00:02:08 +09:00
Ron Kok
80b0e3dc20 Support {gather} and {gather*} (#2183)
* Support `gather` and `gather*`

* Add bogus screenshots

* Add correct screenshots

* Fix typo

* Update screenshots

* Improve error handling

* Scope styles inside .katex{}

* Revert console.log to console.error
2020-07-27 06:56:39 -07:00
Ron Kok
05d1e7caf1 feat: support MathML \big, \bigg, \Big, and \Bigg (#2332)
* Support MathML \big, \bigg, etc

* Add stretchy attribute

* Update mathml-spec.js.snap

Co-authored-by: ylemkimon <y@ylem.kim>
2020-07-26 04:26:00 +09:00
ylemkimon
8a24907518 build(deps): update dependencies (#2301)
* Bump flow version

* Bump jest version

* Bump eslint version

* Bump rollup version

* Bump webpack version

* Bump misc dependencies and update lockfile

* Update lockfile

* Bump commander version

* Bump misc dependencies

* Bump istanbul version

* Bump docusaurus version

* Update lockfile

* Explicitly declare dependencies

* Bump caniuse-lite version

* Update lockfile

* Bump commander version

* Bump webpack and css-loader version

* Bump flow version
2020-07-25 11:38:29 -07:00
Ron Kok
e76857ec03 feat: support \angl and \angln (#2334)
* Support \angl and \angln

* Update screenshots

* Update documentation
2020-07-25 22:53:11 +09:00
Ron Kok
611fe6b698 Support \origof and \imageof (#2283)
* Support \origof and \imageof

* Fix documentation table

Co-authored-by: ylemkimon <mail@ylem.kim>
2020-07-17 17:20:23 +09:00
ylemkimon
3dd1ed45b4 Run screenshotter using Chrome 83 and Firefox 76 (#2304)
* Run screenshotter using Chrome 83 and Firefox 76

* Update screenshots

* Update NegativeSpace-chrome screenshot

The new screenshot is correct as per #1194.

* Update Units-chrome screenshot

The new screenshot is correct as per #732 and compared to Firefox.

* Update screenshots
2020-07-14 08:48:55 -07:00
ylemkimon
1a8f682155 Fix missing metrics for space (0x20) and no-break space (0xa0) (#2298)
* Fix missing metrics for space (0x20) and no-break space (0xa0)

* Update a screenshot

* Update font submodule

* Add a regression test
2020-07-13 03:38:34 +09:00
Ron Kok
2c5a3b8fdc Set MathML of \boldsymbol{textord} to bold, not bold-italic (#2299)
* Set \boldsymbol{textord} to bold, not bold-italic

* Finish adding files.
2020-07-11 21:10:11 -04:00
ylemkimon
d1c0468ef8 Reorganize some glyphs, simplify font selection, break \mathcal{123} (#2156)
* Reorganize some glyphs

* Remove mathdefault

Numerals are textord and it was never reachable.

* Use PUA for \imath and \jmath

* Update katex-fonts

* Update tests

* Update src/buildCommon.js

* Update screenshots

* Add comment regarding usage of PUA in \imath and \jmath

* Update fonts

Co-authored-by: Erik Demaine <edemaine@mit.edu>
2020-07-11 14:54:28 -04:00
Erik Demaine
1512de5b35 Reset to leftmost spacing mode after newline (#1841)
* Reset to leftmost spacing mode after newline

Newlines have class "mspace newline" but shouldn't be fully ignored:
they should reset the spacing mode back to "leftmost" so as to not
accidentally create trailing spaces at end of lines.  Fix #1828.

* Update snapshots

* Add root detection, and treat newline specially only then

Co-authored-by: ylemkimon <mail@ylem.kim>
2020-07-11 12:36:51 -04:00
Erik Demaine
7523e9714a \boldsymbol not italic for textords such as Greek (#2290)
* \boldsymbol not italic for textords such as Greek

Fix #2225: `\boldsymbol{\Omega}` will now produce a bold upright Omega
instead of a bold italic Omega.  This only affects `textord` symbols within
`\boldsymbol`, mimicking the no-font case in `makeOrd` which distinguishes
`textord` from `mathord` in a similar way.

* Update screenshots

Co-authored-by: Ron Kok <ronkok@comcast.net>
2020-07-09 09:22:33 -07:00
Ron Kok
1764d25048 Support \minuso (#2213)
* Support \minuso

* Update screenshots

* Add MathML version

* Add BIN spacing

* Update screenshots

* Add Unicode character

* Delete duplicate macro

Co-authored-by: Erik Demaine <edemaine@mit.edu>
2020-07-08 19:28:43 -04:00
Ron Kok
d6e8575942 Fix jagged parentheses (#2234)
* Fix jagged parentheses

* Update screenshots

* Coordinate overlap with repeat element length.

* Fix lint error.

Co-authored-by: Erik Demaine <edemaine@mit.edu>
2020-07-08 18:20:42 -04:00
Ron Kok
467052ce21 Enable an empty \substack (#2278) 2020-07-08 15:50:50 -04:00
Ron Kok
4d99b4c8ac Enable empty environment (#2258) 2020-05-17 09:33:11 -04:00
Ron Kok
d49da10d79 Fix under accent depth (#2252)
* Fix under accent depth

* Update screenshots
2020-05-02 18:16:36 +09:00
Ron Kok
69a22d3cfb Support MathML display mode (#2220) 2020-03-24 02:28:43 +09:00
ylemkimon
9917d1ce84 Add support for \expandafter, \noexpand, \edef, \let, and \long (#2122)
* Add support for \expandafter

* Add support for \noexpand

* Add support for \edef

* Update comments

* Allow \long before macro definition

* Update documentation

* Update comments

* Fix defPrefix

* Add support for \let

* Update documentation

* Print error token

* Update documentation

* Check whether command is expandable

* Add tests

* Fix token order

* Make noexpand a Token property

* Throw error if control sequence is undefined when expanding

* Rename expandableOnly to expandOnly

* Make unexpandable macro property

* Move \expandafter to macros.js

* Add TODO

* Fix merge conflict

* Update a test case

* Remove unused functions in MacroContextInterface

* Update comments

* Refactor code

* Move \noexpand to macros

* Update MacroExpander.js

* Add a test case

* Separate control sequence check to a function

* Add support for \futurelet

* Separate RHS getter to a function

* Update documentation

* Move expandOnly logic to expandOnce

* Refactor code and update comments

Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>
2020-03-11 12:14:34 +09:00
Erik Demaine
3cb9bd78bb Fix delimiter error message (#2186)
* Fix delimiter error message

Avoid "circular structure" error message by avoiding JSON.stringify on a
parse structure when getting an invalid delimiter type (e.g. ordgroup).
Instead, report type of delimiter when it's invalid.  Fixes #2184.

* Fix and add tests
2020-01-04 18:10:11 +09:00
Rui Okada
4b905064ab Add bra-ket notation (#2162)
* Add bra-ket notation

* Fix typo

* Remove ketbra

* Remove ketbra, add Bra and Ket

* Add Bra/Ket and fix a typo in bra's source

* Fix bra-ket typo in docs

* Fix bra-ket escape typo in docs

* Replace bra-ket pipe with \vert in docs
2019-12-11 22:02:19 -05:00
ylemkimon
800cdb2d23 Cleanup font build scripts & minor font updates (#2155)
* Minor font updates

* Update screenshots

* Cleanup build scripts
2019-12-07 13:11:45 +09:00
ylemkimon
b1eeeecf91 Move \global and \def to functions (#2138)
* Add parseNode type `internal`

* Move \def and \newcommand to functions

* Fix Flow error

* Separate \global

Move \newcommand back to macros for now

* Rename assignment.js to def.js

* Update test cases

* Add comments

* Update a test case
2019-12-04 20:07:19 -05:00
ylemkimon
0d8830af30 Add \message, \errmessage, and \show for debugging (#2135)
* Add \message, \errmessage, and \show for debugging

* Remove unnecessary parentheses

* add tests for \message and \errmessage
2019-12-01 18:24:47 -05:00
ylemkimon
e5333ad04d Add HTML extension (#2082)
* Add html extension

* Fix flow error

* Update documentation

* Add tests

* Call buildA11yStrings for "html" node

* Throw ParseError when parsing \htmlData fails

* Improve documentation

* Add a screenshotter test

* Add dummy screenshot

* Update screenshots
2019-12-01 17:49:28 -05:00
Erik Demaine
9d8195c793 Reword unicode test comments (#2161) 2019-12-01 21:11:14 +09:00
Karl Traunmüller
8fcfe97e11 Fix test that was checking numerator instead of denominator (#2160)
* Test was checking numerator instead of denominator

* fixed a typo
2019-11-30 09:33:20 -05:00
Ron Kok
d1cee3cf3d Support {rcases} and {drcases} (#2149)
* Support {rcases} and {drcases}

* Fix lint error

* Update screenshots
2019-11-10 18:36:02 +09:00
Ron Kok
a92e39d810 Fix laps
* Fix lap with flex

* Fix lint error

* Fix more lint errors

* Fix indentation in test spec

* Update screenshots

* remove .glue class
2019-11-01 02:23:28 +09:00
Erik Demaine
0cdb28b256 \@ifnextchar consumes spaces (#2118)
* \@ifnextchar consumes spaces

Fix #2117 by fixing our implementation of \@ifnextchar to match LaTeX's:
consuming spaces before checking the next character.  See #2117 for details.

* Update MacroContextInterface
2019-10-13 00:33:30 +09:00
Erik Demaine
1eda0e86a0 Add support for \cal (#2116)
Fix #2115 by adding \cal to list of old-style font commands.
(Surprisingly tiny change!)
Add tests for all old-style font commands.
2019-10-10 20:46:10 -04:00
Ciro Santilli,Opinions and content are my own, not my employer's,2018新疆改造中心,1989六四事件,1999法轮功 ,2019 996.ICU, 2018包子露宪,2015 710律师劫,2015巴拿马文件 邓家贵,2017低端人口,2008西藏骚乱scriptalert(1)/script
36595343b7 Create globalGroup option to place definitions in global scope (#2091)
If true, this allows \newcommand definitions to persist across calls to
renderToString.

Fix https://github.com/KaTeX/KaTeX/issues/2070
2019-09-22 15:03:44 -04:00
Erik Demaine
2a3013d72a Fix parse timing by separating consume() into fetch() and consume() (#2054)
* Fix parse timing by separating consume() into fetch() and consume()

Fix #1989, and generally cleanup parse timing (many fewer hoops to jump
through) by defining two methods on parser:

1. `consume()` marks the current token (`nextToken`) as "done", but
   doesn't yet fetch the next token (setting `nextToken` to `null`).
2. `fetch()` fetches the next token if we don't already have one
   (e.g., if last token was `consume()`d).

Before this change, `consume()` did both actions.  By separating them,
and allowing the parser to live in a state for a while where `nextToken`
is `null`, it is far easier to change settings (in particular, math/text
mode and catcodes) before reading the next token, in a way that depends
on what we're parsing.  For example, if an argument should be treated in
text mode, we can just set the mode in the argument parser, instead of
when the previous token was consumed.  Similarly, if an argument should
be treated as a URL, we can just set the catcode of `%` in the URL
argument parser, and reset it after.  We no longer have to take care to
reset things before calling `consume()`.

This change mostly involves changing `this.nextToken` to `this.fetch()`.
In a perfect world, we could use slightly fewer calls to `this.fetch()`,
but Flow doesn't realize that `this.nextToken` will be non-null after a
call to `this.fetch()`, so we need to use a few more calls to
`this.nextToken()` or a few more local `nextToken` variables.

* Remove now-unnecessary consumeMath

* Update Parser.js
2019-08-21 16:14:42 +09:00
Erik Demaine
081b44ab57 Use current font for accents (#2066)
* Use current font for accents

Fix #353 using `buildCommon.makeSymbol` to automatically determine font
for the accent symbol.

* Fix screenshots

* Fix flow error

* Fix file permissions
2019-08-20 22:40:40 +09:00
Erik Demaine
3b6ed48f5b Unicode characters in math render in text mode (#2040)
* Unicode characters in math render in text mode

Improve #2031 by rendering all supported Unicode text characters (via
supportedCodepoints) in text mode, mimicking wrapping them in `\text`,
thereby using metrics of letter M as usual.

* Add tests

* Improve documentation

* Implement review comments
2019-08-08 20:33:09 -04:00
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
Erik Demaine
403126e56d Do not force sizing groups to display inline-block (#2044)
Fix #1788 by removing `display:inline-block` rule from `.sizing`.
I don't see why a sizing change cares about the display mode, and it
fixes the interaction between `makeVList` and sizing commands.
It should also allow me to remove a `.sizing { width:min-content }` rule
that I had to add in #1787.
2019-07-16 17:00:24 -04:00
Erik Demaine
3800dc49c1 [breaking] trust setting to indicate whether input text is trusted (#1794)
* trust option to indicate whether input text is trusted

* Revamp into trust contexts beyond just command

* Document new trust function style

* Fix screenshot testing

* Use trust setting in \url and \href

* Check `isTrusted` in `\url` and `\href` (so now disabled by default)
* Automatically compute `protocol` from `url` in `isTrusted`, so it
  doesn't need to be passed into every context.

* Document untrusted features in support list/table

* Existing tests trust by default

* remove allowedProtocols and fix flow errors

* remove 'allowedProtocols' from documentation

* add a comment about a flow error, rename urlToProtocol to protocolFromUrl

* add tests test that use function version of trust option

* default trust to false in MathML tests

* fix test title, remove 'trust: false' from test settings since it's the default
2019-07-08 21:57:23 -04:00
Ron Kok
fc79f79c78 Support Unicode \digamma (#2010)
* Support Unicode \digamma

* Update screenshotter images
2019-07-05 20:01:51 -04:00