Commit Graph

12 Commits

Author SHA1 Message Date
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
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
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
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
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
Erik Demaine
7b22eeb64a Move test helpers into common modules (#1318)
* Move test helpers into common modules

* helpers.js gets all the helper functions
* setup.js gets the common Jest setup (serializer, expect extensions)

* Exclude test from coverage testing

* @ylemkimon's comments: parsing -> building, settings || defaultSettings

* Default argument for settings

* Fix lint errors

* @ylemklemon's comment: use buildAndSetResult

* Use template literals
2018-05-18 09:45:19 -04:00
Erik Demaine
49e673a59c Stop throwing ParseError when throwOnError is false (#1169)
* Stop throwing ParseError when throwOnError is false

`render`, `renderToString`, etc. now catch ParseError and render it to the
raw LaTeX (with proper escaping) and a hover title with the error.

Along the way:
* Use new `katex.__renderToDomTree` in katex-spec's `_getBuilt`.
  (This was necessary to get the new error handling in `_getBuilt`.)
* Fix jest results which must always be functions, not strings.

* fix lint

* Fix flow error

Leave error type unspecified, as we check it with instanceof.

* Update katex-spec.js
2018-05-09 22:18:50 +09:00
Ryan Randall
7de91f73eb Nested Math in Non-Default Text Fix (#1111)
* Fixing nested math in non-default text. Added appropriate screenshot tests.

* Adding appropriate logic for buildMathML and resolving tests.

* Addressing Kevin's comment. Adding tests.

* Adding appropriate screenshots.

* Removing unnecessary data, adding consistent naming convention.

* Cleanup

* Handling possible edge cases.

* Updating per PR comments
2018-02-19 17:37:08 -05:00
Kevin Barabash
4bec90be0c extract font functions and implicit color function (#1119)
* extract font functions and implicit color function

* remove oldFontFuncs from Parser.js

* allow old font commands in text mode
2018-01-31 10:03:30 -05:00
Kevin Barabash
f80d0afee8 extract sizing and styling implicit functions (#1116)
* extract sizing and styling implicit functions

* add BreakToken type
2018-01-30 07:13:01 -05:00
Kevin Barabash
71e0b35b27 allow sizing commands inside optional groups (#885)
* allow sizing commands inside optional groups

* allow color, old font, and style commands inside optional groups
2017-10-03 11:30:59 -06:00