Commit Graph

844 Commits

Author SHA1 Message Date
Ron Kok
a02859033a Support Unicode Symbols (#950)
* Support Unicode Symbols

This is the third in a series of PRs to give KaTeX the ability to recognize Unicode character input. This one supports some but not all letter-like symbols and some other symbols. All the characters in this PR will produce `textord` atoms in `math` mode.

The list is not comprehensive. It’s a bit eclectic. Some of these characters are important. Others were just easy to include. A few important characters are omitted because it wasn’t clear to me which is the best way to implement them. I’ll address those characters in future PRs.

* Add comments. Remove RegEx.

* Fix omitted parens
2017-11-24 14:19:22 -05:00
Erik Demaine
ecad4de4ce Single-character macros like active characters (#973)
* Single-character macros like active characters

* Rewrite README according to @kevinbarabash's comment
2017-11-24 13:40:23 -05:00
Ron Kok
b2698d35ec Change frac-line from border to full span (#976)
* Change frac-line from border to full span

Change `frac-line`  and `vertical-separator`.  Instead of using span borders, fill entire span using a `box-shadow`.

This change will enable more dependable engagement of the `min-height` CSS.

* Fix indentation

* Fix indent again

* Change box shadow to inline SVG

* Fix lint error

* regenerate screenshots after switching to SVG for fraction bars
2017-11-24 11:41:53 -05:00
Hiromi Ishii
fd82c4fad0 Implemented `\href' command (#923)
* Implements `\href' command.

* Added `functions/href.js`.
* Added `domTree.anchor` and `buildCommon.makeAnchor` functions.
* Make `buildHTML.getTypeOfDomTree` exported.

* Reflects the code reviews

* Create new argType "url" to treat link string in math appropriately
* Stop using too shorten variable names
* Start using template strings

* Adopts template literal

* Elaborates on glueing

* If-clause restructuring

* Solved confusing explanation

* Allow balanced braces in url

* Adds unit-test for \href

* Adds snapshot tests
2017-11-23 23:23:35 -05:00
Ron Kok
75af19c5bb Change \undertilde to \utilde (#948)
* Change \undeertilde to \utilde

In PR #670, I made an error. The function that should have been `\utilde` I named instead `\undertilde`.

There is an `\undertilde` from the `wsuipa` package, but it is a text-mode non-stretchy function. The proper command name is `\utilde`, a math-mode, stretchy function from packge `undertilde`.

This PR fixes my error.

* Fix screenshotter test
2017-11-23 23:16:37 -05:00
Erik Demaine
d59647dfa7 Fix node_modules exclusion in webpack server (#981) 2017-11-22 22:01:05 -05:00
Erik Demaine
fd2544f8f9 Output port number of server, and lint fixes (#980) 2017-11-22 21:54:21 -05:00
Ron Kok
69aff05024 Support Unicode Big Operators (#961)
* Support Unicode Big Operators

This is the sixth in a series of PRs to give KaTeX the ability to recognize Unicode character input.

This is the final PR in this series that will submit characters in bulk. After this, there come some characters whose alias or atom type was not obvious. I'll turn in PRs for them, too, but only after they are vetted.

* Move constants outside of main functions

* Replace ∫ with \u222b

* Add backslash
2017-11-22 20:48:33 -05:00
Ron Kok
1f8a4f0490 Support Unicode Arrows (#947)
* Support Unicode Arrows

This is the second in a series of PRs to give KaTeX the ability to recognize Unicode character input.

All the characters in this PR will produce `rel` atoms.
2017-11-22 10:11:29 -05:00
Ron Kok
6325685a9f Support Unicode Negated Relations (#952)
* Support Unicode Negated Relations

This is the fifth in a series of PRs to give KaTeX the ability to recognize Unicode character input.

All the characters in this PR will produce `rel` atoms.

* Add parse tests

* Fix AMS functions

Fix a brain cramp.

* Add internal aliases to code comments
2017-11-22 08:37:53 -05:00
Ron Kok
22dd4f3a28 Append ApplyFunction to math functions (#960)
* Append ApplyFunction to math functions

As described at: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4

Character U+2061 is the same as ⁡. Ref: https://www.w3schools.com/charsets/ref_html_entities_a.asp

* Add comment for \u2061
2017-11-22 08:21:56 -05:00
Hiromi Ishii
6f1661f7da Implements \mathchoice command (#969)
This PR implements `\mathchoice` function.
I once created PR on the wrong branch. Sorry for the mess.

This is particularly useful when one defines custom macro for "big operators".
For example:

```latex
\newcommand{\infdisj}{%
  \mathop{%
    \mathchoice{% display
      \bigvee\hspace{-2ex}\bigvee%
    }{          % inline
      \bigvee\hspace{-1.75ex}\bigvee%
    }{          % script
      \bigvee\hspace{-1.4ex}\bigvee%
    }{          % scriptscript
      \bigvee\hspace{-1ex}\bigvee%
}}}
```
2017-11-22 07:34:05 -05:00
Ron Kok
2d32263998 Support Unicode Binary Operators (#951)
This is the fourth in a series of PRs to give KaTeX the ability to recognize Unicode character input.

All the characters in this PR will produce `bin` atoms.
2017-11-21 12:20:56 -05:00
Ron Kok
839f872faa Fix linefeed test (#964)
I must have been asleep when I wrote the tests for PR#949.
2017-11-12 20:34:22 -05:00
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