Commit Graph

812 Commits

Author SHA1 Message Date
Ashish Myles
cbfcd57162 Type correction to allow documentFragment to be children of span. (#1247)
* Type correction to allow documentFragment to be children of span.

This is necessary because documentFragments are put in spans in some cases --
e.g. src/functions/sqrt.js. Not sure why this wasn't caught by the type system.
It's possible that it might be happening in buildHTML as well -- it is not yet
been typed and thus violations of the existing types haven't yet had a change to
be caught.
2018-04-06 00:20:51 -04:00
Lukas Drgon
0f17ac5080 Change CDN links (#1243) 2018-04-04 21:54:00 +09:00
dudko
f35c41883c List react-katex in Libraries (#1236)
* List react-katex in Libraries

* Added react-latex

* Fix capitalization

* Move React libraries above Ruby library
2018-03-31 09:33:01 -04:00
ylemkimon
1c5a7ed232 Fix anchor.toMarkup (#1246)
* Fix anchor.toMarkup

* Add space between `a`(tag name) and `href`(attribute name)
* Remove `this.href` appended to `markup` in the template literal

* Add regression test on #1245
2018-03-31 08:44:27 -04:00
Ashish Myles
850a0713cb Treat svg-wrapping spans differently from DOM-wrapping spans. (#1239)
* Treat svg-wrapping spans differently from DOM-wrapping spans.

In preparation for the conversion of buildHTML to @flow, separate the two
different uses of domTree.span -- one to wrap a single SVG and one to wrap
arbitrary DOM nodes. This separation is to help avoid type issues that pop up
due to buildHTML methods accessing the .children field of spans as if they are
DOM elements and not SVG ones.

* Simplify the domTree DOM definitions based on separation of two span types.
2018-03-27 22:47:15 -04:00
Erik Demaine
e31cceed58 Add metrics for \S and \P (#1224)
Just updating to latest katex-fonts submodule.
2018-03-16 15:52:59 +09:00
Erik Demaine
95ea3e3095 Fix cli.js: add nomnom dependency, add -u option (#1218)
* Fix cli.js: add nomnom dependency, add -u option

* Add `nomnom` dependency (not dev dependency): fix #1216
* Add -u option for new `unicodeTextInMathMode` option

* Reword color option doc

* Fix comments from review
2018-03-15 22:28:23 +09:00
Erik Demaine
4f29c5a942 Support \( and fix instant mode switching for $, \(, \text (#1213)
* Fix #1212 by supporting `\(...\)` in addition to `$...$` inline math nested inside `\text`. This turned out to be harder than one would think because of the way `$` was being handled specially, while `\(` needed to be handled as a function, which immediately consumed the `\(` token, which meant that the first following token got consumed in text mode instead of math mode (unlike `$` where we could switch the mode before consumption).
* Added new `consumeMode` setting for functions which tells the parser to switch modes just for the consumption of the command token.
* Now that we're working with functions, move all the `$` handling code into `functions/math.js`.  Somewhat bizarrely, we can define `$` as a function (nearly identical to `\(`) and it all works (just like we can have single-character macros).  This move removed a lot of messy stuff from `Parser.js`: `ParsedDollar`, `ParsedFuncOrArgOrDollar`, `newDollar`, `assertFuncOrArg`, and at least three explicit checks for `if (... === "$")`.
* Moved the `consume()` for the command token from `parseSymbol` to `parseGivenFunction`.  This ended up not being strictly necessary, but seems conceptually cleaner.
* Partially address #1027 by setting `consumeMode: "text"` for `\text` commands.  As a result, `\text` now instantly switches the mode to `"text"`, so even an unbraced macro argument will properly detect text mode.  I added a test for this, which is a slightly weaker form of #1027.
2018-03-14 10:54:36 -04:00
Ashish Myles
5bcdeec4ad Format buildHTML groupType definitions in preparation for adding types. (#1206)
* Format buildHTML groupType definitions in preparation for adding types.

1) Collapse groupType definitions (a bunch of functions all of the same type
   defined on the groupType object) into a single object in preparation for
   putting types only on the base object.
2) Do minor reformatting to account for the +4 indent above which pushes some
   lines past 80 characters.
3) Do other minor formatting changes for readability, taking advantage of ES6.

* Review fixes.
2018-03-14 23:38:35 +09:00
Ron Kok
65b47430b5 Support Unicode delimiters (#1207)
* Support Unicode delimiters

This PR adds support for the Unicode versions of \lfloor, \rfloor, \lceil, \rceil, \lgroup, \rgroup, \lmoustache, \rmoustache, \ulcorner, \urcorner, \llcorner, and \lrcorner.

All the mappings agree with `unicode math`

* Change tests from Parse to Build
2018-03-13 09:21:19 -03:00
Erik Demaine
0d3cf000d2 Add \yen support to text mode (#1208)
Fix #1204 by adding `\yen` support to text mode.

More generally, I checked all the text+mode symbols supported by
[amsfonts](http://mirrors.ctan.org/fonts/amsfonts/doc/amsfonts.pdf)
(see Section 6), and found that `\yen` is the only one lacking text-mode
support.
2018-03-13 02:22:04 +01:00
Erik Demaine
75b55a63b1 Add display/displayMode toggle on test page (#1193)
* Add display/displayMode toggle on test page

* Fix #1035
* Refactor query parsing code to promote re-use
* Also add support for (unescaped) single-character macros

* Rewrite to use query-string

* Restore modes on package*json
2018-03-12 01:15:09 +01:00
Ron Kok
b148d5da71 Support Unicode ° (#1203)
Oddly, `unicode-math-table.txt` does not contain an entry for U+00B0. But `\degree` is surely the correct mapping.
2018-03-10 13:19:13 -05:00
Erik Demaine
abfb641d7a Fix \nobreakspace, refactor "regular space" checking (#1200)
* Fix \nobreakspace, refactor "regular space" checking

Fix #1199 by adding \nobreakspace to the list of commands/symbols that
behave like a regular space character.  Refactor to put that list in one
place, and use an object so it checks instantly instead of sequentially.

* Copy test from #1201
2018-03-10 00:14:42 +01:00
Ryan Randall
017eb7b91d Implementing analyze script (#1197) 2018-03-09 17:13:02 +01:00
Erik Demaine
20b5a58451 Work around negative space bug in Chrome (#1194)
* Work around negative space bug in Chrome

Fix #984

The screenshot test is still somewhat defective, showing a space before
the "post" text (a period).  This seems limited to the screenshotter, however,
as it works fine in the tester via
http://localhost:7936/?text=%5Cfbox%7B%5C%241%2C%5C!000%2C%5C!000%7D%5CKaTeX&display=0&after=.

* Update screenshots

* Switch to inherited `width: min-content`
2018-03-09 16:38:25 +01:00
ylemkimon
06e0393abc Online screenshot diff/generation using CircleCI (#1187)
* Add CircleCI config for online screenshot verification/generation

* Remove `Checkout unicode fonts` step

Unicode-fonts are now a submodule, which is checked out in `Checkout submodule` step.

* Always generate new screenshots
2018-03-06 00:47:41 -05:00
Ashish Myles
0ce53e7631 Port spacingData and unicodeSymbols to @flow. (#1195)
* Port spacingData and unicodeSymbols to @flow.

* Review fixes.

* Made Measurement an exact object type.
2018-03-05 23:43:01 -05:00
ylemkimon
96ad6e0f4f Add unicode-fonts as submodule (#1182)
* Add unicode-fonts as submodule

Removed checkout process from screenshotter.sh.

* Rename test-fonts submodule and update repo URL
2018-03-05 23:29:19 -05:00
Ashish Myles
9e22012619 Port delimiter.js to @flow. (#1177)
* Port delimiter.js to @flow.

* Responded to comments.
2018-03-01 19:57:10 -08:00
Ron Kok
56cfc7cf86 Fix contenteditable mode (#1179)
`makeVList` sets depth with an empty span for which it defines a height. But Chrome, in contenteditable mode only, treats that span as if it contains some text.  The resulting `min-height` can over ride our desired depth.

So we insert an empty span inside the `depthStrut` span.
2018-02-27 13:06:58 -05:00
Erik Demaine
aed1c1e564 unicodeTextInMathMode setting (#1117)
* unicodeTextInMathMode setting

* When `unicodeTextInMathMode` is `true`, accented letters from
  `unicodeSymbols.js`, and CJK and other supported languages,
  get added support in math mode (as requested in #895).
* When `unicodeTextInMathMode` is `false, all of these stop working in
  math mode, and are only supported in text mode (matching XeTeX behavior).
  Note that this is a backwards incompatibility with some 0.9.0 alpha/betas.

* Fix handling of Unicode characters ð, Å, å

* Fix double handling of ð (math maps to \eth, not special Unicode character)
* Remove Åå special math handling, thanks to #1125

* Forbid extraLatin when unicodeTextInMathMode is false
2018-02-19 21:25:20 -05: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
Erik Demaine
b341034d2b Add tests for __* internal interface (#1170)
Inspired by codecov
2018-02-19 10:39:16 -05:00
Kevin Barabash
298b482c18 Bump master to v0.10.0-pre 2018-02-18 16:55:16 -05:00
Erik Demaine
0854bb9f15 Add a paragraph about injection safety (#1161)
* Add a paragraph about injection safety

* Rewrite into Security and Handling errors

* minor edits to the suggested whitelist
2018-02-17 14:48:33 -05:00
Kevin Barabash
789aabe7a1 add .codecov.yml and disable patch coverage (#1164) 2018-02-17 14:11:06 -05:00
Ron Kok
95ffb4fad4 Padding over \sqrt and Paths for frac-line (#1143)
* Padding over \sqrt and Paths for frac-line

This replaces two earlier PRs.

* Restore reaction arrows

* regenerate screenshots

* Set line padding in a constant

* Update with latest master

* Fix lint error

* update screenshots
2018-02-17 13:56:13 -05:00
Erik Demaine
bceb7bd163 Fix handling of Unicode characters ð, Å, å (#1157)
* Fix double handling of ð (math maps to \eth, not special Unicode character)
* Remove Åå special math handling, thanks to #1125
2018-02-13 23:27:02 -05:00
Erik Demaine
627fc11f1b Support \underline in text mode (#1159)
* Support \underline in text mode

Fix #1158

* Add to LowerAccent test
2018-02-13 20:30:30 -05:00
ylemkimon
439cea3e6e Improve JS spacing (#1103)
* Remove dummy spans for spacing around \href

Spacing around \href is handled in the `buildHTML`

* Make bin cancellation aware of children of fragment and anchor

+ Added getOutermostNode function

* Fix tight spacing not applied

* Add surrounding argument to html.buildExpression

It is an array consisting type of nodes that will be added to the left
and the right, and if given, will be used to determine bin cancellation
and spacings of outermost nodes.

* Fix html.buildExpression call in leftright

* Add dummy span only when given

* Update buildHTML.js
2018-02-13 07:01:56 -05:00
Kevin Barabash
9b2101f6b4 move metrics to katex-fonts submodule (#1134)
* move metrics to katex-fonts submodule

* update katex-fonts submodule

* update katex-fonts submodule after pulling down changes
2018-02-11 16:36:13 -05:00
ylemkimon
3f69de5036 Update NPM scripts and documentation (#1146)
* Group more test npm scripts into `test:`

* Update documentations on the development workflow

* Update .travis.yml to match updated NPM scripts

* Run npm install in Travis
2018-02-11 16:11:59 -05:00
Ron Kok
d80be86015 Support Unicode colon equals (#1151)
* Support Unicode colon equals

This PR adds support for three Unicode characters: `≔` `≕` `⩴`

* Fix error in \Coloneqq
2018-02-09 07:58:23 -05:00
ylemkimon
383a68b935 Remove Makefile and migrate to NPM scripts (#1135)
* Remove Makefile and migrate to NPM scripts

* Update documentation/.arclint

* Check node version in prestart

* Group test npm scripts into `test:`
2018-02-06 12:39:24 -05:00
Ron Kok
73d80f595c Add \nobreakspace (#1145) 2018-02-05 21:17:36 -05:00
Kevin Barabash
f977c25d0d set up code coverage (#1140)
* set up code coverage

* add coverage badge
2018-02-05 09:33:31 -05:00
Ron Kok
2aee354ca2 Support Reaction Arrows (#1078)
* Support Reaction Arrows

This PR is written to supply reaction arrows for a future `mhchem` extension. `mhchem` uses seven reaction arrows. Four of them correspond to extensible arrows already available in KaTeX. This PR creates the other three.

These arrows will also be useful to chemists writing about reactions when `mhchem` is unavailable.

Three new extensible arrows are introduced: `\xrightleftarrows`, `\xrightequilibrium`, and `\xleftequilibrium`.

These names are not `mhchem`’s user-facing function names. In `mhchem`, users would call these arrows with syntax such as: `\ce{A<-->B}`, or `\ce{A<=>>B}`, or `\ce{A<<=>B}`. I’ve provided names that look more like the other extensible arrow names. That’s probably worth some discussion.

* generate screenshots for ReactionArrows

* Increase overlap in arrow shaft

To prevent a small gap when rendering in very large font sizes.

* Adjust upper text vert alignment. Add warning.

* Limit alignment adjustment to \xleftequilibrium

* generate screenshots for reaction arrows
2018-02-04 15:52:22 -05:00
Ron Kok
ea3b6abe32 Enable spacing functions in text mode (#1139)
* Enable spacing functions in text mode

Spacing functions such as `\;` or `\quad` should be accepted in either math mode or text mode

* Add tests

* Fix tests

* Fix lint error
2018-02-04 13:58:04 -05:00
ylemkimon
30854eb866 Enable hot module replacement(HMR) (#1100)
* Use ES6 in static/main.js

+ Lint static/main.js

* Enable hot module replacement(HMR) in webpack-dev-server

* Disable no-console in static/main.js

* Use seperate entry point/bundle for the test page(/static/main.js)
2018-02-01 13:33:49 -05:00
Kevin Barabash
603f12df8d add support for unicode angle brackets, single vertical bar, double vertical bar (#1123)
* add support for unicode angle brackets

* add tests, remove vertical bar changes

* fix 'message not a function' errors
2018-01-31 20:03:16 -05:00
Erik Demaine
684df05a86 Add support for \mathring (#1125)
Fix #1124. \mathring is the math-mode equivalent to the \r accent.
Support follows from a rather trivial symbol aliasing,
plus (for Unicode support) listing it in `unicodeAccents.js`.
2018-01-31 19:48:23 -05:00
ylemkimon
58c4c7c4a4 Set webpack-dev-server host to 0.0.0.0 (#1122)
webpack-dev-server CLI has a default value of localhost, which only
allows accessing locally. Setting to 0.0.0.0 allows to access the server
from the external. However, the open option will open 0.0.0.0:7936,
which is an invalid address, so it has been removed.
2018-01-31 19:00:40 -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
7b635f79cf move katex.less into src (#1120)
* move katex.less into src

* fix remaining paths for katex.less
2018-01-30 23:53:02 -05:00
Erik Demaine
95d5c59d31 Italic Greek capital letters (#1118) 2018-01-30 18:09:59 -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
03c5ce7f87 add perf tests, fixes #1053 (#1054) 2018-01-29 20:38:14 -05:00
Kevin Barabash
cf6743b2a8 Bump master to v0.10.0-pre 2018-01-28 23:41:01 -05:00
Kevin Barabash
2f88b093fb update package-lock.json so that release.sh will work 2018-01-28 23:39:11 -05:00