Commit Graph

951 Commits

Author SHA1 Message Date
Erik Demaine
e454eb3b3e Screenshotter chdir to KaTeX root directory (#1502)
* Screenshotter chdir to KaTeX root directory

Fix #1501.  This seems to be required for webpack, specifically
`babel-plugin-version-inline`, to run correctly.

* lint fix
2018-07-25 03:32:01 +09:00
Erik Demaine
9fe5e221e5 Switch from nomnom to commander (#1496)
* Switch from nomnom to commander

* Fix #1489
* --macro repeatable option replaced with single --macros option with ";"
  separator (until https://github.com/tj/commander.js/issues/674)
* Add missing --max-expand option
* Replace expired --unicode-text-in-math-mode option with --strict
  (https://github.com/Khan/KaTeX/issues/1483#issuecomment-405108291)
* Add instructions for how to run in the opening comments
* Clean up option doc strings

* Implement @ylemkimon's comments

* Fix try/const bug

* Fix use of --selenium-ip

It was a quirk that --seleniumIP worked.  --help lists --selenium-ip.

* Implement comments, restore --macro repeatable argument

* Cleanup

* Restore 0 default for maxExpand

* Fix more comments from @ylemkimon

* npm run dist -> npm run build

In preparation for #1500

* Fix line length error
2018-07-23 13:16:45 -04:00
Erik Demaine
cbd3afd738 Fix \not vertical alignment (#1497)
* Fix \not vertical alignment

Fix #1491 by changing from `position: absolute` to `position: relative`.

* Switch to \rlap implementation of \not

* Separate \not the macro from \not the symbol via \@not

* Fix test
2018-07-24 02:01:02 +09:00
ylemkimon
237986a7ca Change build directory to dist and cleanup NPM scripts (#1500)
* Move the build path to `dist`

* mkdir dist if not exists

* Remove build from .gitignore

* Delete `dist/` before building and when cleaning
2018-07-23 12:46:15 -04: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
Erik Demaine
74fb394bb5 Update fonts to remove \neq and \notin glyphs (#1499)
See https://github.com/KaTeX/katex-fonts/pull/53
2018-07-23 01:58:21 +09:00
greenkeeper[bot]
78870abbe8 Update css-loader to the latest version 🚀 and use postcss-loader and cssnano to minimize CSS (#1464)
* chore(package): update css-loader to version 1.0.0

* Require minimum Node 6.9

* Use `postcss-loader` and `cssnano` to minimize CSS

* chore(package): update lockfile

* Remove unnecessary `ident` and function

* chore(package): update cssnano to version 4.0.1
2018-07-22 15:37:19 +09:00
ylemkimon
71035c7111 Refactor test helpers (#1336)
* Refactor test helpers

* Combine common codes from `parse` and `build`, and dispatch using
`Mode`
* Remove `toNotBuild` and `toNotParse` and use `expect.not`
* Remove `Warning` and instead mock `console.warn`
* Add `expect.toHavePassed` and check whether parse/build succeeded
lazily
* Improve failed test `message`:
  - Use color
  - Print stack traces(excluding internals)
  - Print diff
  - Follow jest matcher output style

* Update helpers.js

* Remove toBeTruthy checks

getParsed throws an error if parsing fails.

* Used tagged literals

* Use .toHaveLength

* Use tagged literals

* Use to{Build,Parse}Like where possible

* Remove compareParseTree

* Use snapshot where possible

* Join into one line where <88 chars

* Revert console.warn() to throw an error

Merge `expectToWarn` to `expectKaTeX`, like
`expect.toFailWithParseError`

* Remove call to console.warn from stack traces

* Fix merge errors

* Remove `getTree`

* Move `_getBuilt` into `getBuilt`
* Move default settings and tagging literal support in to `getParsed` 
and `getBuilt`
* Remove stack traces clean-up
* Remove `toHavePassed` matcher

* Extract `expected` string construction into `printExpectedResult`
2018-07-21 19:06:07 -07:00
ylemkimon
c9947220b6 Remove codes that require expensive polyfill (#1469)
* Revert "Cleanup domTree.js to re-use code (#1305)"

This reverts commit 9bb48b83f1.

* Cleanup domTree.js to re-use code

* Extract common constructor/methods into functions

* Remove for...of

* Added eslint rule to disallow for...of

* Remove array destructuring

* Added eslint rule to disallow array destructuring

* Add eslint rule to disallow class inheritance

* Remove Object.keys and Object.assign

* Do not polyfill Object.freeze

* Babel: enable loose mode

* Undo disabling `linebreak-style`

* Move `children` initialization out of `initNode`

* Blacklist files for `no-restricted-syntax`

* Revert "Remove array destructuring"

This reverts commit c9d52c2db31c68cca77fea6ad774ee58b0632ff3.
2018-07-21 18:57:07 -07:00
Kevin Barabash
8eed4e2795 update fonts to use \not character without left side-bearing correction, fixes #1189 (#1267)
* update fonts to use \not character without left side-bearing correction, fixes #1189

* update katex-fonts submodule

* update katex-fonts submodule

* add comment

* Update fonts submodule

* Update screenshots
2018-07-22 04:17:07 +09:00
greenkeeper[bot]
e5cb511f5a chore(package): update flow-bin to version 0.77.0 (#1493)
* chore(package): update lock file
2018-07-21 20:18:44 +09:00
Ashish Myles
7150c2550d Port buildMathML to @flow. (#1486)
* Port buildMathML to @flow.

* Update code after sync. Address reviewer comments.
2018-07-18 23:04:41 +09:00
Erik Demaine
578877764d \@binrel command and refactor (#1487)
* \@binrel command and refactor

New `\@binrel{x}{y}` command renders `y` as if it's a bin/rel/ord like `x`.
This is equivalent to AMSTeX's `\binrel@{x}\binrel@@{y}`.
It will hopefully be useful for macros, such as `\pmb` (#1418).

Also refactor the (already duplicated) code for implementing this
functionality into buildCommon.binrelClass.

* Add tests; fix flow error

* Another test

* Move binrelClass to functions/mclass.js

* Remove expensive array destructuring polyfill
2018-07-17 19:49:50 -07:00
Ron Kok
8f5239c272 Fix \operatorname (#1461)
* Fix operatorname

* Update MathML

* Update screenshots

* Fix lint error

* Pick up comment

* Remove duplicate lines

* Fix lint error

* Remove duplicate code

* Replace \pi with \Pi in test

* Revise RegEx

* Update RegEx
2018-07-17 02:08:41 +09:00
Ashish Myles
f0976ade26 Refactor documentFragment and implement both HtmlDomNode and MathDomNode interfaces (stepping stone to port buildMathML to flow) (#1478)
* Make MathNodeClass include documentFragment for ergonomics.

* Separate out the HTML and MathML documentFragments.

These two documentFragments have different additional properties/methodsi
and limitations. This separation is needed for porting buildMathML to
flow.

* Coalesce the documentFragment subclasses to avoid subclassing polyfill.

* Make DomSpan and SvgSpan type aliases again instead of subclasses.

* Remove type MathNodeClass in favor of MathDomNode.

* Resolve $FlowFixMes by reordering variants of a union type.
2018-07-16 15:41:27 +09:00
ylemkimon
48e9058a06 Inline version using babel-plugin-version-inline (#1475)
* Inline version using `babel-plugin-version-inline`

* Fix `unicodeSymbols.js` generation
2018-07-16 03:41:03 +09:00
ylemkimon
9783ac1466 Make unicodeAccents.js ES6 module (#1477)
Use `babel-register` in `unicodeMake.js` to require ES6 module.
2018-07-15 13:54:54 -04:00
Erik Demaine
b7277049a4 \char character escaping and nicer MathML via \html@mathml (#1454)
* \html@mathml

Fix #1452

* Add missing file

* Implement \char (via internal \@char)

* Remove excess <mstyle> wrapper on \mathbin etc.

* Fix tests

* Add Unicode support for \copyright and \textregistered

Testing that this doesn't lead to an infinite loop thanks to \char` escaping.

* Add tests

* Use assertNodeType

* Switch from regex to lookup table, and no parseInt
2018-07-14 08:36:23 -04:00
Erik Demaine
33ef4bdc63 AsciiMath: link to asciimath2tex (#1474) 2018-07-13 14:19:59 +09:00
ylemkimon
747a98555d Remove tree cloning before building HTML (#1470)
* Reset `supSub.value.base` after building `supSubGroup`

* Remove tree cloning before building HTML

`buildExpression` is no longer destructive, added comment regarding it,
2018-07-12 00:28:56 +09:00
ylemkimon
35aece7763 Set documentFragment.style to empty object (#1471)
Remove `style` getter and setter in `documentFragment`
2018-07-11 11:09:42 -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
ylemkimon
0fb71c8bf8 Lint webpack.*.js (#1467)
* Lint webpack.*.js

* Fix webpack.analyze.js style
2018-07-07 13:17:05 -04:00
greenkeeper[bot]
00c91cdc35 chore(package): update flow-bin to version 0.76.0 (#1465)
* chore(package): update flow-bin to version 0.76.0

* chore(package): update lockfile
2018-07-08 00:07:14 +09:00
Ron Kok
f3c167c601 Support Unicode corners (#1459)
* Support Unicode corners

* Fix \lrcorner
2018-07-02 07:53:29 +09:00
Ron Kok
c599c613f0 Refactor genfrac.js (#1455) 2018-06-29 03:09:59 +09:00
ylemkimon
a8015d0feb Allow only allowed protocols in \href (#1440)
* Allow only allowed protocols in \href

Added `allowedProtocols` settings

* Fix a typo

* Allow boolean argument

* Allow wildcard(*) argument

Revert 'Allow boolean argument'
2018-06-27 19:51:12 -04:00
Ron Kok
8621f5b76a Support \brace and \brack (#1453)
* Support \brace and \brack

* Update screenshots
2018-06-28 03:43:02 +09:00
ylemkimon
518379aed5 lexer: Remove match-at dependency, use RegExp (#1447)
* lexer: Remove `match-at` dependency, use RegExp

* chore(package): update flow-bin to version 0.75.0

* Fix flow error

* Remove unused flow libs

* Minor fix

* Throw an error when `RegExp.exec` jumps
2018-06-28 03:13:27 +09:00
Ron Kok
12dcb05209 Fix arrowheads for mhchem <--> (#1451)
* Fix arrowheads for mhchem <-->

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

* Adding screenshots.
2018-06-26 17:50:20 +09:00
Ryan Randall
f7880acb02 Expose dom tree (#1446)
* Exposes domTree

* Exposing domTree

* Update per comment.
2018-06-25 15:47:23 -04:00
greenkeeper[bot]
6195f2f176 chore(package): update eslint to version 5.0.0 (#1448)
* chore(package): update eslint to version 5.0.0

* chore(package): update lockfile
2018-06-23 13:26:02 +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
ylemkimon
3f1b13e352 Fix Webpack global function definition, including hot module replacement (#1435)
* Upgrade webpack-cli to 3.0.1

* Wrap output.globalObject in parentheses

Fix global function definition, such as hot module update.
2018-06-17 08:19:02 -04:00
Erik Demaine
a7682e6220 Update READMEs to v0.10.0-beta (#1423)
8624d4ccff
2018-06-14 22:43:05 -04:00
Erik Demaine
ffe90a3ca1 Support \gdef in multiple equations in auto-render (#1425)
Within a single call to `renderMathInElement`, default `macros` to a shared
empty object (same as if you specified an object) so that global macros
defined via `\gdef` can be defined and shared.
2018-06-14 06:44:43 -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
954ddf4172 Edit \lbrack and \rbrack (#1420) 2018-06-10 12:43:23 -04:00
Hossein Saniei
8b1e1b4886 [plugin system] Add a utility function (setFontMetrics) to extend builtin fontMetrics (#1269)
* Add and expose addFontMetrics function

* fix typo

* recreate package.json-lock

* Add setFontMetrics function to change the defualt metricMap - change getFontMetrics to getGlobalMetrics

* use new setFontMetrics on main KaTeX object

* fix package-lock.json error by rebuilding it

* Add appropriate tests

* update the snapshot
2018-06-09 20:42:35 -04:00
Ashish Myles
251283ffc1 Port buildHTML to @flow. (#1408)
* Port buildHTML to @flow.

* Address reviewer comments.

* Addressed reviewer comments.
2018-06-09 20:21:30 -04:00
Ron Kok
1dc261298e Add min-height to \rule (#1417)
* Add min-height to \rule

* Fix screenshots
2018-06-09 18:59:20 +02:00
Ron Kok
690285ad4b Remove redundant \lbrack and \rbrack (#1416)
* Remove redundant \lbrack and \rbrack

* Revert macros. Remove redundant code.

* Revert symbols
2018-06-09 18:51:59 +02:00
greenkeeper[bot]
f929f0a683 chore(package): update flow-bin to version 0.74.0 (#1414) 2018-06-07 14:33:23 -04:00
Erik Demaine
65569249be \newcommand, \renewcommand, \providecommand (#1382)
* \newcommand, \renewcommand, \providecommand

* Tests

* Add comment

* Add symbols to the set of already defined things

* Add implicitCommands, catch \hline outside array

* Add \relax

* Move isDefined to be a method of MacroExpander

* Namespace.has

* Reword error messages

* Add \hdashline given #1407
2018-06-07 13:39:39 +02: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
Erik Demaine
4f9851fb0c Automatic submodule updating via husky tool (#1391)
* Automatic submodule updating via husky tool

* Update documentation
2018-06-04 20:22:12 -04:00