Commit Graph

8 Commits

Author SHA1 Message Date
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
ylemkimon
45a58f8d30 Update lockfile, fix test reporting, throwOnError on yarn start test page (#1798)
* Update lockfile

* Fix test reporting

* Set throwOnError on `yarn start` test page
2018-12-23 18:46:25 -05:00
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
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
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
Erik Demaine
acccce801d \def support (and \gdef and \global\def) (#1348)
* Nested environments of macro definitions

* Rename environment -> namespace

* \def support

* Clean up \df@tag at beginning

* \global\def support

* Fix \global via new setMacro helper

* Fix caching behavior and build array on top of it

Also avoid double lookup of macros

* Add tests

* Add argument tests

* Remove global pointer

* Note about macros object being modified

* add __defineMacro

* Add \global\def test

* More \global tests

* Constant-time lookup

Rewrite to use an "undo" stack similar to TeX, so get and set are
constant-time operations.  get() still has to check two objects: one with all
current settings, and then the built-ins.  Local set() sets the current value
and (when appropriate) adds an undo operation to the undo stack.  Global set()
still takes time linear in the number of groups, possibly changing the undo
operation at every level.

`Namespace` now refers to a space of things like macros or lengths.

* Add \def to-dos

* Put optional arguments in their own group

* Rename `pushNamespace` -> `beginGroup`

* Wrap each expression in a group namespace

* Add comments
2018-05-28 21:58:57 +02:00
Erik Demaine
a0ddad338e Support \tag, \tag*, and \gdef (#1309)
* Tag sketch

* Drop objectAssign; already using Object.assign elsewhere

* Basic \gdef support

* Bug fix

* Finish \tag

* MathML numbers equations with <mlabeledtr>

* Fix flow bugs

* \gdef tests

* Add basic \tag tests

* Screenshot test for \tag

* \tag* test

* Add missing file

* Bug fix screenshot

* Major refactor

* Represent tag at top level of parse tree, requiring less hackery
  * No more \@tag function; it was essentially just doing \text
* Wrap tag in group so e.g. ( and ) are formatted the same
* Add `feed` method to MacroExpander for multiple inputs (for tag)
* Bug fixes in buildHTML, makeTextRow, _getBuilt (for display mode)
* Remove excess <mrow> wrapper when unnecessary

* Update screenshot from tag being wrapped in group

* Add maxExpand limit
2018-05-19 22:19:21 +02: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