Commit Graph

346 Commits

Author SHA1 Message Date
Kevin Barabash
b2432e8ad2 make all classes in domTree.js PascalCase and make them named exports (#1636)
* make all classes in domTree.js PascalCase and make them named exports

* add eslint rule to enforce capitalization, fix failures

* address feedback
2018-08-19 23:49:21 +09:00
Ashish Myles
fcc5c4420a Rename .value to .body in "ordgroup". (#1609) 2018-08-13 23:17:23 +09:00
Ashish Myles
8492a7532b Rename .value to .text or .color where applicable. (#1606)
* Update comment for defineFunction handler.

* Rename .value to .text in all token-style ParseNodes.

* Rename symbolNode's .value to .text.

* Rename color-token's .value to .color.
2018-08-13 20:58:46 +09:00
ylemkimon
d81caf1477 Fix requiring symbols in test/symgroups.js (#1592) 2018-08-13 01:34:27 +09:00
Erik Demaine
00a23b682f Test that \neq is in a group (#1574) 2018-08-09 12:37:51 +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
50c0240349 Support mediawiki (#1558)
* Support mediawiki

* Fix lint error

* Fix link to deprecated syntax

* Change In master to display of functions
2018-08-08 07:49:38 +09:00
Ashish Myles
f3a9bd4b3d Flatten "styling", "text", and "array" ParseNodes. (#1559)
* Flatten "styling" ParseNode.

* Flatten "text" ParseNode.

* Flatten "array" ParseNode.
2018-08-07 14:26:40 +09:00
Ashish Myles
5b6ffd7b9d Flatten a bunch of non-pervasive ParseNode types (part 2) (#1552)
* Flatten "operatorname" ParseNode.

* Flatten "overline" ParseNode.

* Flatten "raisebox" ParseNode.

* Flatten "rule" ParseNode.

* Flatten "sizing" ParseNode.

* Flatten "smash" ParseNode.

* Flatten "sqrt" ParseNode.

* Flatten "underline" ParseNode.

* Flatten "enclose" ParseNode.

* Flatten "environment" ParseNode.

* Flatten "genfrac" ParseNode.

* Flatten "htmlmathml" ParseNode.

* Flatten "infix" ParseNode.

* Flatten "kern" ParseNode.

* Flatten "lap" ParseNode.

* Flatten "color" ParseNode.
2018-08-06 14:59:44 +09:00
Ashish Myles
1506dc1d88 Flatten a bunch of non-pervasive ParseNode types (part 1) (#1551)
* Flatten "url" ParseNode.

* Flatten "href" ParseNode.

* Flatten "verb" ParseNode.

* Flatten "tag" ParseNode.

* Flatten "cr" ParseNode.

* Flatten "delimsizing" ParseNode.

* Flatten "middle" ParseNode.

* Flatten "leftright" ParseNode.

* Flatten "leftright-right" ParseNode.

* Flatten "mathchoice" ParseNode.

* Remove unused ParseNode type "mod".

* Flatten "mclass" ParseNode.

* Flatten "font" ParseNode.

* Flatten "phantom" ParseNode.

* Flatten "hphantom" ParseNode.

* Flatten "vphantom" ParseNode.
2018-08-06 11:49:43 +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
Ashish Myles
fd6690b988 Flatten ParseNodes: "supsub" and related ("accent", "accentUnder", "horizBrace", "xarrow", "op"). (#1542) 2018-08-03 14:06:02 +09:00
Ashish Myles
7e97a382ec Introduce "atom" parse node to coalesce various symbol nodes. (#1541) 2018-08-02 20:46:40 +09:00
Erik Demaine
2202aa774f Comments without terminating newlines, \href fixes, \url support (#1529)
* Comments without terminating newlines in nonstrict mode

Fix #1506 by allowing single-line comments (`%` without terminating newline)
in nonstrict mode.  `Lexer` and `MacroExpander` now store the `Settings`
object, so the `Lexer` can complain about missing newline according to the
`strict` setting.  I filtered this out from the snapshot tests with a slightly
different `replacer`.

* Reimplement \href like \verb, add \url

Major restructuring to lex URL arguments differently, e.g. to support
`\href%{hello}` and `\href{http://foo.com/#test%}{hello}`.  The new URL
parsing code is simpler, but involves a special case in `parseSymbol`
like `\verb`.

Also add support for `\url` while we're here.

* Cleanup

* Fix flow errors and improve error messages

* Add \url to documentation

* Improve doc formatting
2018-07-31 14:13:30 -04: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
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
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
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
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
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
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
f3c167c601 Support Unicode corners (#1459)
* Support Unicode corners

* Fix \lrcorner
2018-07-02 07:53:29 +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
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
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
Ron Kok
1dc261298e Add min-height to \rule (#1417)
* Add min-height to \rule

* Fix screenshots
2018-06-09 18:59:20 +02: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
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
Erik Demaine
fcb32f058b Support \arraystretch as a macro definition (#1381)
* Support \arraystretch as a macro definition

Also add `expandMacro` and `expandMacroAsText` helpers to `MacroExpander`.

* Remove excess defaulting

* Add test
2018-06-03 18:19:23 -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
97d6229e9b Add vertical kern to \vdots (#1402)
* Add vertical kern to \vdots

Fixes #620.

* Replaced screenshots
2018-06-03 15:46:51 -04:00
Ron Kok
3e0ad9fd48 Support Unicode ≲ ⩽ ⪅ ≶ ⋚ ⪋ (#1389)
Add six more Unicode relation characters to `symbols.js`.

Fixes issue #1384.
2018-05-31 20:31:41 -04:00
Ron Kok
9d40d662b3 Make letter tests strict (#1385)
* Make letter tests strict

The recently added rendering mode `strict:"warn"` will allow any Unicode characters to be accepted. We expect `strict: true` to be pickier than that.

This PR sets `strict: true` on tests in `katex-spec.js` that should enforce that pickiness.

* Pick up comments

* Fix import of strictSettings
2018-05-31 16:26:25 -04:00
Erik Demaine
417383e002 Rewrite spacing commands as macros (#1156)
* Rewrite spacing commands as macros

Fix #1130 by defining `\!`, `\negthinspace`, `\,`, `\thinspace`, `\:`,
`\medspace`, `\;`, `\thickspace`, `\negmedspace`, `\negthickspace`,
`\enspace`, `\enskip`, `\qquad`, `\quad` as macros.

Fix #1036 by defining a new `SpaceNode` in mathMLTree that recognizes
all special space amounts from
https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html

* Fix <mspace> rendering and add a test to catch it

* Update screenshots

* Wrap special space characters in <mtext>

* Update screenshots

* Fix MathML escaping behavior

* Fix flow typos

* Fix Unicode-chrome

* Reimplement mod operators in terms of macros

* Rerun ModScript

* Remove excess table entries (now already macros)

* Fix bmod
2018-05-29 08:43:52 -04:00
Ron Kok
70a4733175 Support Unicode ⟂ ¬ ⊨ ‼ ∌ (#1377)
* Support Unicode ⟂ ¬ ⊨ ‼ ∌

* Fix code points
2018-05-29 15:10:31 +09:00
Kevin Barabash
e1614995e3 enforce consistent object brace spacing (#1376) 2018-05-28 23:31:44 +02:00