Commit Graph

424 Commits

Author SHA1 Message Date
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
Ron Kok
2139adffdb Prevent gaps in tall delimiters (#1986)
* Prevent gaps in tall delimiters

* Improve lap vertical alignment

* Fix lint errors

* Remove outdated comment

* Move a declaration out of makeStackedDelim()

* Update screenshots
2019-07-05 10:16:24 -04:00
Ron Kok
2b83935064 Improve MathML for classes (#1929)
* Improve MathML for classes

* Fix lint errors

* Fix another lint error

* Simplify MathML resulting from single character box

* Fix lint errors

* make some of the arrays in our html/mathml helper functions readonly
2019-07-05 01:14:05 -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
elbaro
88d9a8a4df Add \plim (#1952)
* Add \plim

* tweak position of argmin and plim in support table
2019-06-01 20:20:26 -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
17e89efdfc Fix \pmb (#1924)
* Fix \pmb

* Update screenshots

* Use \mathbf for MathML
2019-05-25 11:03:03 +09: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
Ron Kok
6b0f06df21 Improve MathML fonts (#1965) 2019-05-19 19:24:34 -04:00
Ron Kok
9822414733 Render MathML directly (#1966)
* Render MathML

* Fix lint error

* Change from main api to rendering options
2019-05-13 19:31:04 -04:00
Ben Dyer
4f2da04e5d Add test for double square brackets to katex-spec (#1956) 2019-05-12 23:25:25 -04:00
Erik Demaine
5aad8f9f32 Test for duplicate symbols/macros (#1955)
* Test for duplicate symbols/macros

We've had a few cases where we accidentally include the same symbol or macro
definition in both macros.js and symbols.js.  This new test automatically
detects these scenarios during Jest testing.

* Fix lint errors
2019-04-28 19:52:39 -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
Tesla_Ice_Zhang
6bb312f687 Support double-square curly braces (#1953)
* Support double-square curly braces

Signed-off-by: ice1000 <ice1000kotlin@foxmail.com>

* Rename `llbrace` to `lBrace`

* Address comments: add mathml

* Fix code style

* Fix doc

* Add to docs/support_table
2019-04-25 07:23:00 -07:00
ylemkimon
b9deec098f Load fonts before running screenshotter (#1891) 2019-04-07 18:15:05 +09:00
ylemkimon
7d7c55c4c7 Approximate font metrics only when metrics don't exist (#1898)
Fix non-existent metrics error for \eth
2019-04-06 18:24:32 -04:00
Erik Demaine
070883532a Support \textup and \textmd (#1921)
* Support \textup and \textmd

This PR adds support for `\textup` and `\textmd`, which are the inverses of
`\textit` and `\textbf`.  Unlike bare `\text`, they result in `textup` and
`textmd` classes being applied, but those have no CSS rules, so they act the
same as bare `\text`.

Fixes #1909.

* Add documentation

* Add unsupported font commands
2019-04-06 02:51:11 +09:00
Ron Kok
ab7b7826ff \Improve MathML for \colorbox and \fcolorbox (#1914)
* Add border color

* Fix lint errors

* Edit to persuade flow its okay.

* Add \colorbox
2019-04-04 18:19:19 +09:00