Commit Graph

491 Commits

Author SHA1 Message Date
Ron Kok
b362fc0b39 fix: Apply operator spacing to Unicode ∙ ∘ ∖ (#3584)
* Apply operator spacing to Unicode ∙ ∘ ∖

* Appease Semantic Versioning.

* Fix website build issue

* Tweak docs to space final bin correctly

Co-authored-by: Erik Demaine <edemaine@mit.edu>
2022-03-13 14:38:16 -04:00
Ron Kok
1f8512577b fix: \mathinner MathML when invoked as a denominator. (#3501)
* fix: \mathinner

* Write a better test for \mathinner

Fixes #3500
2022-01-12 12:32:54 -05:00
Erik Demaine
52c4778b15 feat: \nonumber/\notag support, \tag per row of {align} (#2952)
* feat: \nonumber and \notag support

Support `\nonumber` (and equivalent `\notag`) using a global macro
`\@eqnsw` to track whether one occurs in each row, similar to how
amsmath uses global `\@eqnswtrue`/`\@eqnswfalse`.

Fix #2950

* Remove duplicate mention of align*

* Working version of \tag within {align}

* Simpler subparse mechanism

* Fix flow errors, clarifying set-to-undefined

* Document that \tag works in rows

* Add screenshot tests

* Add Jest tests

* Add Safari screenshot

* Commit message about fixing \tag

Fixes #2379

* Apply suggestions from code review

Co-authored-by: ylemkimon <y@ylem.kim>

* Revise and move getAutoTag

* Fix handling of split

* Remove unnecessary feedTokens

Co-authored-by: ylemkimon <y@ylem.kim>

Co-authored-by: ylemkimon <y@ylem.kim>
2021-11-01 06:40:06 +09:00
ylemkimon
40109f6248 feat: implement \relax as no-op function (#3384)
* feat: implement \relax as no-op function

BREAKING CHANGE: `\relax` is now implemented as a function. It'll stop
expansions and parsing, so the behavior around `\relax` may change.
For example, `\kern2\relax em` will no longer work.
2021-10-31 12:46:43 +09:00
Ron Kok
09ee1c8867 fix: round dimensions to 4 places (#2460)
* Round distances to 4 places

* Revert numbers in mathMLTree.js

* Update Jest test

* fix: round dimension to 4 places via makeEm

* test: update screenshots

* docs: add link to this PR

Co-authored-by: ylemkimon <y@ylem.kim>
2021-10-31 03:28:45 +09:00
renovate[bot]
9b7f10f7c9 chore(deps): update selenium/standalone-firefox docker tag to v20210929 [skip netlify] (#3294)
* chore(deps): update selenium/standalone-firefox docker tag to v20210929 [skip netlify]

* test: update screenshots

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: ylemkimon <y@ylem.kim>
2021-10-30 16:52:35 +09:00
Erik Demaine
6d6d627ca4 perf: Avoid vertical-align:0em style (#3358)
Avoid emitting `vertical-align:0em` by protecting each such style
setting with an `if`.

Fixes #3351

Co-authored-by: ylemkimon <y@ylem.kim>
2021-10-26 23:10:20 +00:00
Erik Demaine
23d20c446f chore(tests): fix use of jest-diff (#3215)
Jest 27 changed the signature for jest-diff.
This bug only arises from failing tests.
2021-08-31 14:08:10 +09:00
Erik Demaine
a6f29e3612 fix: remove local macros upon parse error (#3114)
Close all groups after parse, in particular in case of parse error,
completing `Namespace`'s simulation of local definitions.

Fixes #3122

Co-authored-by: ylemkimon <y@ylem.kim>
2021-08-28 22:59:24 +00:00
Erik Demaine
ff1734f7c4 fix: \char support for >16-bit Unicode characters (#3006)
* fix: \char support for >16-bit Unicode characters

`String.fromCharCode` only supports Unicode characters up to 16-bit.
`String.fromCodePoint` from ECMAScript 2015 supports all Unicode code points.
Unfortunately, IE doesn't support the latter, so use former as fallback.

Fixes #3004

Co-authored-by: ylemkimon <y@ylem.kim>
2021-08-29 07:55:05 +09:00
Erik Demaine
952fb844da feat: text-mode cedilla accent via \c (#3036)
* feat: text-mode cedilla accent via \c

Add text-mode accent function `\c` and corresponding Unicode support.

Part of #638

Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>

* Update screenshots

Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>
2021-08-28 22:29:53 +00:00
ylemkimon
ea409eaf1d fix(fonts): update fonts dependencies (#2866)
* fix(fonts): update fonts dependencies

* chore(fonts): fix buildMetrics for Python 3

* fix(fonts): update fonts

* test: update screenshots

* docs: update reference to katex-fonts

* chore: use Python 3

* fix(fonts): update fonts

* test: update screenshots

* Use explicit path

* Command-line arguments aren't actually supported

* Small buildMetrics fixes

* Add build:{fonts,metrics} script

* Lock versions of font-related dependencies

* Install minimal texlive

* Install fontforge

Co-authored-by: Erik Demaine <edemaine@mit.edu>
2021-08-29 07:06:42 +09:00
Kelly Littlepage
910e523633 fix: Correct invalid box-sizing property, adjusting spacing of \angl (#3053)
* fix: Correct invalid box-sizing property

Closes #3052

* Add Safari screenshot

Co-authored-by: Erik Demaine <edemaine@mit.edu>
2021-07-21 10:50:11 -04:00
ylemkimon
67064cd2a4 test(screenshotter): update screenshots (#3032) 2021-05-19 16:13:53 -04:00
renovate[bot]
9c0fd964ee chore(deps): update selenium/standalone-firefox docker tag to v20210422 [skip netlify] (#2999)
* chore(deps): update selenium/standalone-firefox docker tag to v20210422 [skip netlify]

* test(screenshotter): update screenshots

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Young Min Kin <mail@ylem.kim>
2021-05-20 01:51:25 +09:00
ylemkimon
b2a5d77a10 test(screenshotter): update Includegraphics-safari (#3030) 2021-05-18 13:56:21 -04:00
Erik Demaine
93b56cfb0b chore(screenshotter): Improve screenshotter for Safari (#3015)
* Fix when Docker returns IPv4 and IPv6 addresses

* Ensure images load before screenshotting

* Fix bugs from review

* Update test/screenshotter/test.html

Co-authored-by: ylemkimon <y@ylem.kim>
2021-05-17 22:45:11 +00:00
Erik Demaine
f779bac684 fix: matrix environment with zero or inconsistent columns (#3018)
Previously, the matrix family of environments assumed that the number of
columns was given by the number of columns in the first row.  This
didn't work when there were zero rows, and it didn't handle the case
where future rows have more columns than the first (which is visible
when using an alignment other than `c`, such as `\begin{matrix*}[r]`).

Fixes #3017

Co-authored-by: ylemkimon <y@ylem.kim>
2021-05-14 21:11:44 +00:00
Erik Demaine
0e9acce9be feat: Allow text-mode accents in math mode, except in strict mode (#3009)
* feat: Allow text-mode accents in math mode, except in strict mode

LaTeX only issues a warning when using e.g. `\r` in math mode.
KaTeX will now do the same with the default `strict` setting of `warn`.

Fixes #2983

* Fix accent mode

Co-authored-by: ylemkimon <y@ylem.kim>
2021-05-14 21:08:39 +00:00
Ron Kok
9b4acc971c fix: Correct for negative margin in integrand lower limits (#2987)
* fix: Correct for negative margin in integrand lower limits.

* Adjust for width limit.

* Update screenshots.

* Update Safari screenshot.

* Catch null subGroup.

* Remove redundant code.
2021-05-11 21:26:35 -04:00
Nfer Zhuang
1cb62799c6 fix: MathML for stretchy accents. #2990 (#2991)
* fix #2990

fix make stretchycode to textNode bug.

* fix: fix stretchy.js@mathMLnode line too long

* chore(screenshotter): update stretchy snapshots

* fix: remove dup '\' in cdrightarrow cdleftarrow and cdlongequal

* test: add stretchy MathML builder test case

Co-authored-by: nferzhuang <nferzhuang@tencent.com>
Co-authored-by: Ron Kok <ronkok@comcast.net>
2021-05-06 20:31:52 -07:00
Ron Kok
980b004023 fix: binom delimiter size in scriptscriptstyle. (#2976)
Co-authored-by: Erik Demaine <edemaine@mit.edu>
2021-05-06 18:27:10 +00:00
Erik Demaine
c85250d14e fix: Correctly parse \ followed by whitespace (#2877)
* fix: Correctly parse \ followed by whitespace

LaTeX parses `\` followed by whitespace including up to one newline
as equivalent to `\ `.  (With multiple newlines, you get paragraph
breaks.)

Fix #2860.

* Improve comments

* Avoid second RegExp match in control words

* Document capturing groups

Co-authored-by: Ron Kok <ronkok@comcast.net>
2021-05-05 18:54:41 -07:00
Ron Kok
3f7163daf5 fix: Support \S and \P in math mode (#2977)
Co-authored-by: Erik Demaine <edemaine@mit.edu>
2021-05-02 15:57:39 -04:00
Ron Kok
fbda0b1136 fix: Avoid crash when \operatorname has \limits (#2979) 2021-05-02 15:47:22 -04:00
Erik Demaine
01ae7f8eef fix: Respect catcode in macro expansion and set ~'s catcode correctly (#2949)
Support single characters having a catcode of 13 (active) or 12 (other),
and expand a macro defined for the character only if it's active.
This enables defining `~` as a macro, but avoiding expansion in URLs.

Fix #2924

Co-authored-by: ylemkimon <y@ylem.kim>
2021-04-24 19:33:01 +00:00
Erik Demaine
24332e053c fix(array): Keep single empty row in AMS environments (#2947)
* fix(array): Keep single empty row in AMS environments

In particular prevents empty equation-numbered environment (e.g. `{align}`)
from crashing.

Fix #2944

* Add tests

Co-authored-by: ylemkimon <y@ylem.kim>
2021-04-24 19:28:16 +00:00
ylemkimon
c5b06e7eb9 chore: move test fonts to the main repo (#2834)
Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>
2021-03-23 06:23:49 +00:00
ylemkimon
7300952ae1 test: update Firefox screenshots (#2845) 2021-03-22 13:54:23 +09:00
renovate[bot]
65cfd4bf86 chore(deps): update dependency js-yaml to v4 [skip netlify] (#2723)
* chore(deps): update dependency js-yaml to v4 [skip netlify]

* Update ss_data.js

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: ylemkimon <y@ylem.kim>
2021-01-12 04:38:18 +09:00
Ron Kok
84981da3bf fix: Remove topEnv parameter. (#2712)
* fix: Remove topEnv parameter.

* Set test to default strictness

Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>
2021-01-11 10:00:03 -08:00
Erik Demaine
6b4e80bfbb fix(builder): combine characters together in all expressions (#2080)
* Combine characters together in all expressions

Call `tryCombineChars` in `buildExpression`

* update screenshots, exclude 'coverage' from lint

* update MathML snapshots

* don't combine two 'mbin's or two 'mord's

* update screenshots

* update screenshots

Co-authored-by: ylemkimon <y@ylem.kim>
Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>
2020-12-30 10:34:01 -05:00
Ron Kok
1f509a3b75 feat: Support \underbar (#2713)
* feat: Support \underbar

* Update screenshots
2020-12-30 10:15:17 -05:00
Ron Kok
cd9ee27ac6 fix: Prevent global group from adversely affecting color. (#2703)
Co-authored-by: ylemkimon <y@ylem.kim>
2020-12-29 14:52:41 -05:00
Ron Kok
4a8a6a38ce fix: Use SVGs to avoid gaps in tall delimiters. (#2698)
* fix: Use SVGs to avoid gaps in tall delimiters.

* Add \vert and \Vert

* Update screenshots

* Define verts array outside of function.

* Revert height-finding logic.

* Update screenshots

* Pick up review comments.

* Update CD screen shots
2020-12-28 16:50:09 -05:00
Ron Kok
75a3af9725 feat: Support {CD} (#2396)
* Support {CD}

* Edit screenshotter test to fit on one page

* Update screenshots

* Remove bogus Safari screenshot

* Edit documentation to avoid tag conflicts and explain delimiters

* Add type annotations

* Add bogus safari screenshot

* Update with real Safari screenshot

* Set label vertical alignment

* Revise call to parseExpression() per PR 2085 changes to macro parsing

* Update Firefox screenshot

* Pick up review comments

* Add unit tests and snapshot.

* Tighten up label collection.

* Better loop index

* remove extra space

* Picked up comments. Added a parse check. Added a test.

Co-authored-by: ylemkimon <y@ylem.kim>
Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>
Co-authored-by: Kevin Barabash <kevinb7@gmail.com>
2020-12-27 13:45:31 -05:00
Ron Kok
ef09291288 fix: Improve MathML for math operators with subscripts (#2596)
* Improve MathML for math operators with subscripts

* Add TODO re: MathML spacing

Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>
2020-12-18 18:14:12 -05:00
Ron Kok
17e86b985a fix: Remove premature CD screenshotter images (#2641)
* Remove premature CD screenshotter images

* Recommit for semantic pull request

Co-authored-by: ylemkimon <y@ylem.kim>
2020-11-15 05:48:48 +09:00
Ron Kok
753c82f360 fix: Support Armenian characters (#2618)
* Support Armenian characters

* Update docs

Co-authored-by: ylemkimon <y@ylem.kim>
2020-11-15 05:44:31 +09:00
Ron Kok
60aecbdfe2 feat: Support \vcenter and \hbox (#2452)
* Support \vcenter, \raise, \lower, and \hbox

* Update screenshots

* Edit docs for strict and hbox to

* Fix typo for \hbox to

* Update Safari screenshot

* Augment docs for \vcentcolon

* Edit vcenter MathML comment.

* Remove pointless class from vcenter MathML

* Withdraw \raise and \lower

* Updatae Chrome and Firefox screenshots

* Update Safari screenshot

* Delete allowedInArgument setting

Co-authored-by: ylemkimon <y@ylem.kim>

* Update Chrome and Firefox screenshots

* Update Chrome and Firefox screenshots take 2

* Update screenshot

Co-authored-by: ylemkimon <y@ylem.kim>
2020-11-14 18:45:14 +09:00
Ron Kok
c8042ccb55 fix: MathML \lim\limits in Safari (#2556)
Co-authored-by: ylemkimon <y@ylem.kim>
2020-10-03 21:11:24 +09:00
renovate[bot]
7418057e3a chore(deps): update selenium/standalone-firefox docker tag to v3.141.59-20200826 [skip netlify] (#2544)
* chore(deps): update selenium/standalone-firefox docker tag to v3.141.59-20200826 [skip netlify]

* Update screenshots

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: ylemkimon <y@ylem.kim>
2020-09-26 02:53:23 +09:00
renovate[bot]
94c374c7c1 chore(deps): update selenium/standalone-chrome docker tag to v3.141.59-20200826 [skip netlify] (#2543)
* chore(deps): update selenium/standalone-chrome docker tag to v3.141.59-20200826 [skip netlify]

* Update screenshots

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: ylemkimon <y@ylem.kim>
2020-09-26 02:04:28 +09:00
ylemkimon
5a90558116 feat(function): add allowedInArgument instead of greediness property (#2134)
* Remove `greediness` property

Use boolean `grouped` property instead, which is more consistent with 
LaTeX.

BREAKING CHANGE: \cfrac, \color, \textcolor, \colorbox, \fcolorbox are 
no longer grouped.

* Rename grouped to allowedInArgument

* Reenable tests

* Update documentation

* Fix typo

Co-authored-by: Kevin Barabash <kevinb@khanacademy.org>
2020-09-07 13:38:17 +09:00
Ron Kok
37990cc5b3 feat: Support matrix*, pmatrix*, bmatrix*, Bmatrix*, vmatrix*, and Vmatrix*. (#2488)
* Support matrix*, pmatrix*, bmatrix*, Bmatrix*, vmatrix*, and Vmatrix*

* Add tests and docs

* Delete screeshotter tests

* Fix column alignment and add bogus screenshot files

* Update real Chrome and Firefox screenshots.

* Update Safari screenshot

* Dedupe code in array.js

* Edit payload in array.js

* Edit again, correctly this time.
2020-09-06 09:56:09 -07:00
ylemkimon
dc5f97aaa2 feat(macro): improve argument parsing (#2085)
* Improve macro argument parsing

* Make \above a primitive command

* Fix screenshotter data

* Normalize argument where necessary

* Improve argument location info

* Update comments

* Minor refactor

* Modularize group parsers

* Allow braced and blank size argument

for non-strict mode and \genfrac, respectively.

* Minor refactor & update comments

* Remove raw option in parseStringGroup

* Update tests

* Fix { delimited parameter

* Update tests

* Update tests

* Normalize argument in \genfrac

* Update tests

* Consume space before scanning an optional argument

* Fix \\, \newline, and \cr behavior

* Fix flow error

* Update comments

* Remove unnecessary mode switching

Parser mode affects neither fetch nor consume.

* Allow single (active) character macro

* Add function property `primitive`

* Set \mathchoice and \*style primitive

* Separate size-related improvements out to #2139

* Fix flow error

* Update screenshots

* Update demo example

* Add a migration guide

* Fix capitalization

* Make a primitive function unexpandable

* Update screenshots

* Update screenshots

* Revert "Document \def doesn't support delimiters (#2288) (#2289)"

This reverts commit f96fba6f7f.

* Update comments, errors, and tests

* Update screenshots
2020-09-06 12:56:13 +09:00
Ron Kok
010b267dd6 fix: Support MathML \oiint and \oiiint (#2461)
* fix: Support MathML \oiint and \oiiint

* Update direct input section of docs
2020-08-30 15:44:34 -07:00
Ron Kok
b22b69c3a8 fix: \injlim typo (#2459)
* Fix typo in \injlim

* Just to satisfy Semantic Pull Request
2020-08-26 09:14:18 -07:00
Ron Kok
794dc7a213 feat: support AMS log-like symbols (#2429)
* Support AMS log-like symbols

* Update documentation

* Update \limits info in documentation
2020-08-18 05:28:42 +09:00
Ron Kok
b59ca67530 feat: support Unicode ◯, U+25EF (#2430)
* Support Unicode U+25EF \bigcirc

* Update documentation
2020-08-17 20:35:24 +09:00