Commit Graph

780 Commits

Author SHA1 Message Date
Ashish Myles
d969322dd2 Port mathMLTree to @flow. (#957) 2017-11-12 16:06:38 -05:00
Hiromi Ishii
1a640a465e Implements the alignedat environment for flexible math spacing (#930)
* Implements the alignat environment for flexible math spacing

* Renames alignat[*] to alignedat and factors out duplicate code of aligned and alignedat as alignedHandler

* Adds aligned at to screenshotter

* alignedat screenshots

* Implements the alignat environment for flexible math spacing

* Renames alignat[*] to alignedat and factors out duplicate code of aligned and alignedat as alignedHandler

* Adds aligned at to screenshotter

* alignedat screenshots

* fix style nit

* fix lint
2017-11-11 20:36:09 -05:00
Ron Kok
3e344535ff Fix #946 (#949)
* Fix #946

Issue #946 identified a case in which `array.js` ate the final row of a well-written `aligned` environment.

This PR modifies code from PR #479 to fix this problem and to also continue to eat a trailing `\\` submitted to any environment.

* Fix bug and add tests

* Add final newline to test.

Doh!
2017-11-11 19:12:13 -05:00
Ashish Myles
991bfd5669 Port stretchy to @flow. (#934)
* Port stretchy to @flow.

* Removed added quotes on object keys.

* Responded to comments.

* Stretchy: Added assertion on expected number of SVG children.
2017-11-11 18:56:06 -05:00
Sergio García Prado
067697e2e5 Added ng-katex link to readme.md (#959) 2017-11-11 18:28:03 -05:00
Kevin Barabash
632f5af1c3 Migrate genfrac, lap, smash, op, mod, and katex into their own files in src/functions (#871)
Fixes #869
2017-11-11 17:45:44 -05:00
Hiromi Ishii
25db6095a1 Fixes #941 (#942) 2017-10-17 15:11:18 -04:00
Ron Kok
bd4e1464a0 Support Unicode relations (#933)
* Support Unicode relations

This is the first in a series of PRs to give KaTeX the ability to recognize Unicode character input. The code in this PR follows the style of PR #410.
All the characters in this PR will produce rel atoms. I’ll submit PRs for other atom types later.

* Fix lint error.

* Correct mapping errors

This commit fixes a brain cramp of mine.
2017-10-17 09:06:41 -04:00
Ashish Myles
305a35c3a5 Change buildCommon.makeVList params to struct for better type-safety. (#940)
* Change buildCommon.makeVList params to struct for better type-safety.

This is towards #939.

The expected structure of the makeVList params depends on the `positionType`
parameter. To allow this to be strictly-typed using flow, this PR combines the
co-related parameters into a single struct.

* Add type for makeVList param in comments for documentation.
2017-10-17 07:43:10 -04:00
Kevin Barabash
b4c5dfaf20 Bump master to v0.10.0-pre 2017-10-15 16:49:24 -04:00
Ashish Myles
ca5a924672 Port utils to @flow. (#935)
* Port utils to @flow.

* Responded to comments.
2017-10-15 16:40:17 -04:00
Ashish Myles
06aec05a57 Export svgGeometry to @flow. (#936) 2017-10-15 16:22:21 -04:00
Erik Demaine
2f88abed98 Simplify get() now that we don't need it to ignorespaces (#928)
* Simplify get() now that we don't need it to ignorespaces

Continuation of #912

* Remove commented-out code

* Drop get() alias, rename unget() to pushToken(), use it
2017-10-15 12:33:13 -04:00
Ron Kok
50d120d614 Prevent disappearing fraction lines. (#931)
* Prevent disappearing fraction lines.

Set a CSS min-height that will ensure that fraction lines will display at least one screen pixel.

Addresses issues #824 and #916.

* Change from dppx to dpi

Change the break point spec from 2dppx to 192dpi. They mean the same thing. I'm making the change because IE supports dpi but not dppx.
2017-10-14 18:16:31 -04:00
Erik Demaine
7f6f59ef8a Lint .less files with stylelint (#925)
Lint .less files with stylelint. Fix #921

In particular, prevent tabs.
2017-10-10 11:14:09 -04:00
Erik Demaine
3280652bd6 Fix space handling (#912)
Fixes several issues with space handling: (fix #910)
1. "Control symbols" (as they're called in the TeXbook), such as `\\`, should
   not have spaces eaten after them (only "control words" such as `\foo`).
2. In math mode, spaces should be consumed at the parser level, not the
   gullet level.  This enables `\\ [x]` to parse differently from `\\[x]`
3. Eat spaces between arguments, so `\frac x y` still works.
   (This used to work only because math mode ate all spaces.
    The analog in text mode wouldn't have worked.)

Also eat spaces in initial arguments in math mode, and before ^ and _ in atoms.
2017-10-10 10:09:37 -04:00
Ron Kok
49f95e61eb Edit link to Function Support page (#922)
On README, change a link from the wiki's function support page to the HTML function support page.
2017-10-09 07:35:30 -04:00
Ron Kok
61ec41146c Convert nested SVGs to single-level SVGs (#909)
* Convert nested SVGs to single-level SVGs

This PR evades a Safari bug which causes nested SVGs to zoom improperly.  Fixes the remainder of issue #883.

* Add omitted word

* Fix lint errors

* update screenshots

* Pick up review comments

* Clean up variable names

Remove two more redundant variables.
2017-10-08 15:20:47 -06:00
Ryan Randall
141afa091a Fixing CJS modules and Globals (#920)
* Working CJS modules.

* Changing cjs imports to es6.
2017-10-08 10:56:07 -06:00
Erik Demaine
c4fed02329 webpack server: add disableHostCheck option (#915)
Allow server to be accessed from anywhere, which is useful for
testing.  This potentially reveals the source code to the world,
but this should not be a concern for testing open-source software.
2017-10-05 15:26:49 -04:00
Kevin Barabash
2e27d4248b Bump master to v0.10.0-pre 2017-10-05 11:40:49 -06:00
Kevin Barabash
610513c012 ensure that build/ exists (#918)
Test Plan:
- `rm -rf build`
- `make dist`
- see that `make` completes normally
2017-10-05 11:35:03 -06: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
Ashish Myles
1c1b3c81b6 Replace ParseFuncOrArgument with type-safer alternative. (#901)
* Replace ParseFuncOrArgument with type-safer alternative.

In the process, document consequences of implementation
details that make type-safety difficult to implement.

* Parser: Added assertFuncOrArg to ensure type-safety.

* Responded to comments.

* Made token mandatory for ParsedFuncOrArgOrDollar.
2017-09-27 10:04:31 -06:00
Ryan Randall
fbffdc5fc7 Webpack dev server (#902)
* Initial webpack config. Moving to ES6 modules. Some module cleanup.

* WIP

* WIP

* Removing commented out code.

* Removing old deps.

* Removing the build script (used for testing).

* Working tests.

* Switching to node api over cli.

* Updating per comments. Still need to fix server.js to properly run the selenium tests.

* Cleaning up the config.

* More cleanup.

* Bringing back server.js for selenium tests.

* Bringing back old dependencies.

* Adding back eslint rules for webpack config. Final cleanup for webpack config.

* Pointing to correct pre-existing module versions. Adding some extra logic to server.js to ensure it gets transpiled properly.

* Getting make build to work again. Updating package.json with some shortcut scripts.

* Resolving conflict.

* Reverting back to commonjs modules.

* Removing extra spaces in babelrc
2017-09-26 12:16:35 -06:00
Kevin Barabash
eaef0127c5 Add support for comments, fixes #20 (#884) 2017-09-25 21:50:27 -06:00
Ashish Myles
6de5446913 Parser: Separate mandatory and optional arguments in parseArguments (#903)
* Parser: Make parseArguments() more DRY.

* Parser: Separate args and optional args for type strictness.
2017-09-25 20:37:29 -06:00
Ashish Myles
59bed2ad08 Add SourceLocation to encapsulate Token/ParseNode debug information. (#904)
* Add SourceLocation to encapsulate Token/ParseNode debug information.

* Specify concrete Token text type as it captures type mismatches.

* Responded to comments.
2017-09-25 14:29:41 -04:00
Erik Demaine
f10ea4cbeb Implement \verb (#614)
* Implement \verb

* Implement @gagern's comments

* \verb: look up characters one at a time.

* Add screenshot test for \verb

* Add error tests for \verb

* Include space symbol in typewriter font, and fix single quotes

This is based on https://github.com/Khan/MathJax-dev/pull/2
which hasn't been accepted yet at the time this commit is made.

* Add \verb* tests

* \verb should use Typewriter-Regular font!

* Switch \verb to use text mode and no-break space.

* Screenshot update with Typewriter-Regular

* \verb test: fix *, add commas to make spaces clear

* Fix spaces and style handling

* Implement @kevinbarabash's comments

* Make error clearly an assertion failure

* verb screenshot for Chrome
2017-09-21 23:43:05 -04:00
Ashish Myles
c47655cc0e Correct @flow types. Refactor some Parser code for stricter typing. (#896)
* Correct @flow types in defineFunction and types.

* Parser: Split parseFunction into two for stricter typing.
2017-09-20 23:33:49 -04:00
Kevin Barabash
ca6ea4c580 refactor defineEnvironment to also accept HTML and MathML builders (#875)
* refactor defineEnvironment to also accept HTML and MathML builders, fixes #870

* make argTypes mandatory, remove unused props from EnvProps, use while(true)
2017-09-20 00:05:18 -04:00
Ron Kok
fd45669f7c Upgrade \sqrt zoom and width (#890)
* Fix \sqrt zoom in Safari

This PR evades a Safari bug which causes nested SVGs to zoom improperly. `\sqrt` and single-ended arrow SVGs have been modified.

These have been converted from nested SVGs to single level. Their long tails are now sliced off using CSS `overflow: hidden`.

Safari will still improperly zoom any double-ended stretchy arrows and horizontal braces.

* Fix \sqrt{}

Even if the function argument is empty, still render an SVG whose width equals the surd glyph.

* Fix tall \sqrt when scaled

* update screenshots affected by sqrt fixes

* more screenshots after changes to fix sqrt

* Pick up review comments
2017-09-18 19:24:20 -04:00
Christopher
6e75ebdc2d Fix #337 - Array/Matrix trim trailing empty line (#479) 2017-09-16 20:44:26 -04:00
Ron Kok
db1cccdeab Support \colorbox and \fcolorbox (#886)
* Support \colorbox and \\fcolorbox

These are functions from the `color` package. They accept text, not math. They also have padding similar to `\fbox`.

Because of the padding, the code in `buildHTML` is intermixed with the `\fbox` code. I have not (yet) created a new file in the functions folder. This way, the reviewer gets a cleaner diff.

* Fix lint error

* colorbox screenshots

* Pick up review comments
2017-09-16 00:55:13 -04:00
Ron Kok
9b63ddabb4 Support \And (#881)
& as a bin atom, per AMS.
2017-09-15 00:54:09 -04:00
Ron Kok
a358c5a94c Use mpadded for \raisebox MathML (#876)
* Use mpadded for \raisebox MathML

* Add MathML snapshot
2017-09-13 21:29:09 -04:00
Kevin Barabash
dbc5a74ebd Allow test/lint scripts to run without requiring make (#878) 2017-09-13 10:01:39 -04:00
Ron Kok
4f63909d08 Support \operatorname. Resolve #145 (#866)
* Support \operatorname. Resolove #145

* Fix quote mark typo

* Fix test escapes

* Remove poorly written tests

* operatorname screenshots

* Remove nits

* Use documentFragment. Eliminate macro.
2017-09-10 23:33:51 -04:00
Ashish Myles
d8060ca9b4 Port functions.js to @flow. (#867)
* Make types in defineFunction stricter and prep for porting functions.js to flow.

* Add more explicit types to functions/delimsizing.js.

* Port functions.js to @flow.
2017-09-10 21:25:36 -04:00
Ashish Myles
ceefd4934f Remove the positions array computed by Parser's parseArguments(). (#864)
This array is computed incorrectly (it's always an array of undefineds)
and it's not used anywhere.
2017-09-09 22:22:46 -04:00
Ashish Myles
1c344ed6ee Port environments.js to @flow. (#862)
* Port environment.js to @flow.

* Updated per comments.
2017-09-09 20:31:32 -04:00
Ashish Myles
b4a00824d3 @flow: Correct argType to Array in defineFunction. (#860) 2017-09-09 18:09:02 -04:00
Ashish Myles
9e330194b8 Port symbol.js to @flow. (#858)
* Port symbol.js to @flow.

* Add a `Mode` @flow type and use it in `ParseNode`.
2017-09-09 17:54:47 -04:00
Xuming Zeng
0f9fb0a1ce To @flow: fontMetrics, fontMetricsData, Options, Settings, Style (#848)
*     To @flow: fontMetrics, fontMetricsData, Options, Settings, Style

* Don't overuse $Shape, improve type checking for fontMetrics*, make maxSize required in OptionsData and update callers.

* Remove eslintrc globals change, since eslint-plugin-flowtype makes it redundant.

* Remove extra ?s in Options and Settings

* Undo removal of width in fontMetrics and switch to `T | void` for nullable types in Options

* fix typing of FontMetrics
2017-09-09 17:21:52 -04:00
Ron Kok
ccf09786cc Improve SVG Performance (#841)
* Improve SVG Performance

This PR introduces three new classes:  `svgNode`, `pathNode`, and `lineNode`. SVG data is then loaded into the domTree exclusively via instances of these classes.

`innerHTML` is banished.

* Fix lint errors

* Fix \cancel typo

* Fix sqrt height

* Adjust min-lenght

Adjust some of the extensible arrows to get a min-length that matches glyph length of the long arrows in KaTeX Main font range from Unicode 27F5  to 27FC.

The accent arrows still get min-lengths that match the arrows in the Unicode 2100 range.

* regenerate screenshots after optimizing SVG code

* update DisplayStyle screenshot for Chrome

* update OverUnderset and Smash screenshots for Chrome as well

* Remove escapes from template strings

* Pick up review comments

* Fix lint errors

* Add comments
2017-09-08 23:27:47 -04:00
Ashish Myles
3818105868 Port unit.js to @flow. (#855)
* Port unit.js to @flow.

* Removed unnecesary types.
2017-09-07 10:00:46 -04:00
Ashish Myles
d46ca811c1 Add @flow to unicodeRegexes and change to ES6 exports. 2017-09-07 09:41:13 -04:00
Erik Demaine
588f5a1ee6 eslint-plugin-flowtype & upgrade to eslint@4 (#849)
* Add eslint-plugin-flowtype. Fix #844

Using the recommended settings for plugin.
This involved adding some spaces to some existing union types.

* Upgrade to eslint@4, fix spotted bugs

Switched to indent-legacy to allow e.g. comments to have extra indents.
2017-09-06 22:06:26 -04:00
Ashish Myles
cb7f166a7e To @flow: MacroExpander. (#845)
* To @flow: MacroExpander.

* Explicitly pass context into defineMacro called with a function.

Instead of binding `this` when `defineMacro` is invoked
with a function, we now pass an explicit context as a
parameter to the function. This is a bit more obvious
and is currently more type-safe due to a bug in `@flow`:
https://github.com/facebook/flow/issues/4809

* Per feedback, rename some types, fields, and variables.
2017-09-06 21:39:50 -04:00
Aria Buckles
feef4107df Fix match-at flow errors (#847)
Upgrade match-at and flow versions to resolve the match-at flow
errors, allowing us to remove match-at from the .flowconfig ignore

Test plan:

run `jest` and get the following output:

    PASS  test/unicode-spec.js
    PASS  test/errors-spec.js
    PASS  test/mathml-spec.js
    PASS  test/katex-spec.js (5.104s)

run `flow` and get:

    No errors!
2017-09-05 22:37:17 -04:00