Commit Graph

893 Commits

Author SHA1 Message Date
greenkeeper[bot]
59a25fe3d9 Update webpack-cli to the latest version 🚀 (#1397)
* chore(package): update webpack-cli to version 3.0.0

* chore(package): update lockfile
2018-06-02 14:54:29 -04:00
Kevin Barabash
9d2722f879 update function handlers to return a ParseNode (#1393)
* update function handlers to return a ParseNode

* remove FlowFixMes
2018-06-02 13:05:15 -04:00
Ron Kok
3e0ad9fd48 Support Unicode ≲ ⩽ ⪅ ≶ ⋚ ⪋ (#1389)
Add six more Unicode relation characters to `symbols.js`.

Fixes issue #1384.
2018-05-31 20:31:41 -04:00
Ron Kok
9d40d662b3 Make letter tests strict (#1385)
* Make letter tests strict

The recently added rendering mode `strict:"warn"` will allow any Unicode characters to be accepted. We expect `strict: true` to be pickier than that.

This PR sets `strict: true` on tests in `katex-spec.js` that should enforce that pickiness.

* Pick up comments

* Fix import of strictSettings
2018-05-31 16:26:25 -04:00
Ashish Myles
b738e3f4d7 Separate parsing of \left and \right for improved type safety. (#1386) 2018-05-30 22:49:44 -04:00
Erik Demaine
788aa420be Change maxExpand limit to 1000 (#1383) 2018-05-31 09:45:36 +09:00
ylemkimon
3796faaf5e Update package-lock.json (#1378) 2018-05-29 11:46:50 -04:00
Erik Demaine
417383e002 Rewrite spacing commands as macros (#1156)
* Rewrite spacing commands as macros

Fix #1130 by defining `\!`, `\negthinspace`, `\,`, `\thinspace`, `\:`,
`\medspace`, `\;`, `\thickspace`, `\negmedspace`, `\negthickspace`,
`\enspace`, `\enskip`, `\qquad`, `\quad` as macros.

Fix #1036 by defining a new `SpaceNode` in mathMLTree that recognizes
all special space amounts from
https://www.w3.org/TR/2000/WD-MathML2-20000328/chapter6.html

* Fix <mspace> rendering and add a test to catch it

* Update screenshots

* Wrap special space characters in <mtext>

* Update screenshots

* Fix MathML escaping behavior

* Fix flow typos

* Fix Unicode-chrome

* Reimplement mod operators in terms of macros

* Rerun ModScript

* Remove excess table entries (now already macros)

* Fix bmod
2018-05-29 08:43:52 -04:00
Ron Kok
978148ec6e Fix auto-render \\[…] bug (#1375)
Fixes issue #1075.

Currently, a row separator such as `\[0.3em]` will cause the auto-render extension to fail if the row separator is placed between `\(…\)` math delimiters.

This PR re-orders the array of left delimiters that get searched for, putting `\[` last in the list.  This, `\\[0.3em]` is no longer mistaken for a math delimiter.
2018-05-29 15:31:23 +09:00
Ron Kok
70a4733175 Support Unicode ⟂ ¬ ⊨ ‼ ∌ (#1377)
* Support Unicode ⟂ ¬ ⊨ ‼ ∌

* Fix code points
2018-05-29 15:10:31 +09:00
Kevin Barabash
e1614995e3 enforce consistent object brace spacing (#1376) 2018-05-28 23:31:44 +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
Kevin Barabash
3ec752f5f1 Make ParseNodeTypes more regular (#1373)
Make ParseNodeTypes more regular: make 'size' and 'url' node values be objects.
2018-05-28 12:55:59 -04:00
greenkeeper[bot]
659b4e30c8 Update dependencies to enable Greenkeeper 🌴 (#1368)
* chore: add Greenkeeper config file

* chore(package): update dependencies

* chore(package): update dependencies

* docs(readme): add Greenkeeper badge

* Exclude "dockers/texcmp/package.json",

* Revert "dockers/texcmp/package.json"

Reverts ddc6aa9e05d9e3a7e1e960c7c62f15b8dbff70a9
2018-05-28 05:37:36 +02:00
ylemkimon
25e07a7df6 Upgrade to webpack 4 (#1337) 2018-05-28 05:20:33 +02:00
Ron Kok
5a9e4c1708 Fix wide character spacing (#1371)
* Fix wide character spacing

Fixes issue #1360

* Add test

* Use concat
2018-05-28 05:11:59 +02:00
Ron Kok
2974639877 Fix coloneq etc (#1372)
Fix issue #1333.

`\coloneq` and several similar functions are written as macros. When expanded, these result in atoms like ":" and "=" placed adjacent to each other at the top level. So they exposed to a split by an automatic line break.

This PR wraps each of these macros in an `\mathrel{ }`. This prevents the line break.
2018-05-28 11:28:02 +09:00
Ron Kok
d41b0b010a Fix nested \tfrac (#1370)
Fixes issue #1352.
2018-05-28 10:59:23 +09:00
Ashish Myles
e3fb2f95ae Update flow version and address type errors. (#1369) 2018-05-27 16:19:10 -04:00
Ashish Myles
9cde0336d3 Correct (type-wise) raisebox's usage of sizing's buildHtml. (#1361)
* Correct (type-wise) raisebox's usage of sizing's buildHtml.

* Move HTML and MathML groupTypes into defineFunction.

Currently, functions defined in functions/* import all exports from buildHtml
and buildMathML, but they should never use `groupTypes` directly as it loses
type-safety. They should instead use more type-safe `htmlBuilder`s and
`mathmlBuilder`s exported directly from other definitions `functions/*` to allow
flow to catch errors.

* Rename groupTypes to groupBuilders.
2018-05-27 16:24:30 +09:00
Erik Demaine
d9fe716d0e Update contrib READMEs to jsdelivr v0.10.0-alpha (#1362)
This is particularly important as update-sri.js only updates jsdelivr links.

I was able to get update-sri.js to do the heavy lifting (computing checksums)
after updating the links in general, and downloading v0.10.0-alpha from CDN.
2018-05-26 21:54:43 +02:00
Ashish Myles
9e2d5b1256 Move "supsub" handers into functions/supsub.js and add flow types. (#1359)
* Move "supsub" handlers to functions/subsub.js.

* Add flow types to functions/supsub.js.

* Simplify getBaseElem's output type based on all existing uses.

Before supsub was ported to flow, it had an instance where it could pass a
nullable to isCharacterBox which would pass it into getBaseElem and receive a
false. The refactor and strict typing of supsub now ensures that only a
non-nullable value is passed in to isCharacterBox and getBaseElem.

* Remove warnings at the top of buildMathML and buildHTML.

* Fix silly mistake.
2018-05-27 02:40:37 +09:00
Ashish Myles
1e629a0310 Export htmlBuilder from accent, horizBrace, and op for supsub. (#1349)
* Export htmlBuilder from accent, horizBrace, and op for supsub.

* Addressed review comments.
2018-05-25 12:28:58 +09:00
Ron Kok
a5e6b92ff1 Fix lap vertical alignment. (#1162)
* Fix lap vertical alignment.

Fixes issue #1153.

* Fix horizontal alignment

Wrap the entire lap pair with a mord.

* Support Unicode \ll and \lll

Fixes issue #1271

* Update screenshots

* Update screenshots

* generated updated screenshots for Lap

* Change double strut to single strut

* Delete screenshotter test

* Add (commented out) test

* Fix mis-spelled word
2018-05-25 03:27:15 +02:00
ylemkimon
ef666c18da Update dependencies: less(-loader), uglifyjs-webpack-plugin, request (#1343) 2018-05-23 16:13:06 +02:00
ylemkimon
41ac2456f0 Add missing v prefix to the size badge URL (#1342)
* Add missing `v` prefix to the size badge URL

* Add missing `v` prefix to badge URL update script
2018-05-23 09:05:32 -04:00
Ashish Myles
4c3439192f Move "ordgroup" and "tag" builders into functions/*. (#1339)
* Move "ordgroup" builders to functions/ordgroup.js.
* Move "tag" MathML builder to functions/tag.js.
2018-05-22 22:18:39 -04:00
Erik Demaine
485c509879 Cleanup MathML <mrow>, <mtext>, <mn> (#1338)
* Avoid unnecessary <mrow> wrapping

buildMathML gains two helpers:
* `makeRow` helper wraps an array of nodes in `<mrow>`,
  unless the array has length 1, in which case no wrapping is necessary.
* `buildExpressionRow` for common case of `makeRow(buildExpression(...))`

* Combine adjacent <mtext>s in all cases

No more need for `makeTextRow` helper or anything fancy in text MathML handler.

* Concatenate <mn>s and decimal point into single <mn>

Fix #203

* Fix snapshots
2018-05-21 22:56:34 -04:00
Ashish Myles
ef9cd5c172 Spacing (#1335)
* Move "spacing" builders to functions/symbolsSpacing.js.

* Add flow types to functions/symbolsSpacing.js.

* Address reviewer comments.
2018-05-21 16:22:23 +02:00
ylemkimon
74e84e72d2 Add regenerate option to the screenshotter (#1220)
* Add regenerate option to the screenshotter

Save new screenshot when match fails

* Ignore Chrome debug log file

* CircleCI: Generate only failed screenshots

* CircleCI Test

* Revert "CircleCI Test"

This reverts commit 5d3afb2602f32470eeba7767748faba177ba933e.

* Rename `regenerate` to `new`

* Add ` /test/screenshotter/new/` to .gitignore
2018-05-21 08:06:50 -04:00
Ashish Myles
34cf5c2f81 Move HTML and MathML builders for symbol groups into src/functions/{symbolsOp,symbolsOrd}.js. (#1334)
* Move HTML and MathML builders for symbol groups into src/functions/{symbolsOp,symbolsOrd}.js.
2018-05-20 22:07:35 -04:00
Ashish Myles
ff8ca60584 Horiz brace (#1332)
* Move "horizBrace" to functions/horizBrace.js.

* Add flow types to functions/horizBrace.js.

* Remove blank lines and warning comment in functions.js.

* Remove import comments and alphabetize functions/ imports in functions.js.
2018-05-20 23:33:20 +02:00
Ashish Myles
28dfa91fb5 Move "xArrow" into functions/arrow.js and add flow types. (#1327)
* Move "xArrow" into functions/arrow.js.

* Add flow types to functions/arrow.js.

* Address review comments.
2018-05-20 04:41:39 +02:00
Ashish Myles
35d6181a95 Move "raisebox" into functions/raisebox.js. (#1331) 2018-05-20 03:53:51 +02:00
Ashish Myles
ea7003ff6e Move environment delimiter handling to functions/environment.js. (#1329) 2018-05-20 03:44:36 +02:00
Ashish Myles
fabae7c658 Move infix operator handling into functions/genfrac.js. (#1328) 2018-05-20 03:36:20 +02:00
Kevin Barabash
5aad11eff3 Bump master to v0.11.0-pre 2018-05-19 20:49:11 -04: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
Ashish Myles
99b2afa935 Specify flow output types for htmlBuilder and mathmlBuilder. (#1324)
* Specify flow output types for htmlBuilder and mathmlBuilder.

* Add TODOs to refactor to improve the return type of mathmlBuilder.
2018-05-19 02:27:52 +02:00
Ashish Myles
f49a524da7 Move "mclass" node logic to functions/mclass. (#1325)
* Move "mclass" node logic to functions/mclass.
2018-05-18 12:44:28 -04:00
Ashish Myles
73e0c13d10 Move the rest of the ops from functions.js to functions/ops.js. (#1323) 2018-05-18 09:59:03 -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
Adam Kulidjian
4a3d6a526f changelog for KaTeX - complete w/ links (#1322) 2018-05-18 04:39:58 +02:00
Erik Demaine
369b5a8276 Allow all Unicode symbols in nonstrict mode (#1217)
Change symbol parsing to allow all Unicode symbols when the appropriate strict setting allows it.  By default, this allows all symbols, but the user will get (probably two) warnings about them.
2018-05-17 11:33:01 -04:00
Ashish Myles
431434258d Make htmlBuilder and mathmlBuilder params type-safe. (#1312)
* Make htmlBuilder and mathmlBuilder params type-safe.

Also correct and refine some of the ParseNode types.
2018-05-17 10:38:48 -04:00
Ryan Randall
7eed150c48 Documenting String.raw (#1198)
* Documenting String.raw

* Typo

* Rewrite String.raw doc
2018-05-17 22:27:56 +09:00
Erik Demaine
1ed99d9ff3 Strict setting controls \newline display-mode behavior; fix MacroExpander space handling (#1314)
* Strict setting controls \newline display-mode behavior

* Bug-fix space handling in macros

Whitespace after a \controlWord is now handled within the lexer, not by the
MacroExpander.  This way, \\ expanding to \newline doesn't accidentally
cause spaces to get consumed.

* Rename nonstrict -> reportNonstrict; strictBehavior -> useStrictBehavior

* Second category of errorCodes
2018-05-16 09:37:41 -04:00
Erik Demaine
7ab4f76e16 Implement strict mode (replacing unicodeTextInMathMode) (#1278)
* Implement strict mode (replacing unicodeTextInMathMode)

Add new "strict" setting (default value false) that can take a boolean
(whether to throw an error or silently ignore), string ("ignore",
"warn", or "error"), or a function possibly returning such a value.
This enables a variety of ways of handling or ignoring transgressions
from "true" LaTeX behavior, making KaTeX easier to use while still
providing the ability for strict LaTeX adherance.

Resolve #1226, implementing that spec, for two existing
transgressions from regular LaTeX:

* src/functions/kern.js had some errors and warnings about use of
  (units in) math vs. text mode commands.
* The former setting unicodeTextInMathMode (not in any released version)
  needed to be set to true to enable Unicode text symbols in math mode.

Now these are controlled by the strict setting.  By default, KaTeX is now
very permissive, but if desired, the user can request warnings or errors.

* Rewrite strict description

* Add tests for strict functions

* Stricter type for strict

* Switch default strict setting to "warn"

* Fix new flow error

* Fix another flow bug
2018-05-13 14:27:30 -04:00
Erik Demaine
4801ab875a Support for top-level \newline and \\ in inline math (#1298)
* Support for top-level \newline and \\ in inline math

This was a little tricky because `\\` was defined as an endOfExpression.
Instead made `\\` a termination specific to an array environment.
Outside an array environment, buildHTML handles the `cr` object,
resulting in a `.newline` class.  Currently this turns into a
`display: block` (with appropriate vertical spacing) only in inline math,
matching LaTeX.

* Simplify code

* Fix Jest errors

* NewLine screenshot test

* Bug fix: \\ only works at top level of inline

* Add \newline and \cr to test

* Switch test to pmatrix

* Add vertical space test

* Add \\ vs. \newline tests

* Fix flow errors

* Add \cr test

* Add documentation for \\ at top level

* Comment out newRow

* Fix commenting out
2018-05-13 09:58:24 -04:00
Erik Demaine
bb1dc0c431 throwOnError documentation bug fix (#1308)
3613885da1 (r28950405)
2018-05-12 22:31:21 -04:00