Commit Graph

948 Commits

Author SHA1 Message Date
Ron Kok
563b0d5f8f Improve \cancel (#1398)
* Fix \cancel

Fixes #1080.

Improve `\cancel` in three ways:

1. Better lateral spacing.
2. Steeper `\cancel` lines on single characters.
3. Treat height and depth to match the `cancel` package behavior, not its documentation.

* Update screenshots
2018-06-03 17:38:49 -04:00
Ron Kok
08b0045b92 Support \cfrac (#1392)
* Support \cfrac

This was an easier PR to write than #135 since KaTeX now has well established methods for pt-to-em conversions and nulldelimiter.

As in #135, this does not support the LaTeX optional argument for numerator justification.  It supports a `\cfrac #1 #2 ` syntax.

* Added screenshotter files

* fix ref to context in genfrac handler
2018-06-03 16:38:19 -04:00
Erik Demaine
3d5826c1da Implement \neq and \notin via macros like LaTeX's (#1400)
* Implement \neq and \notin via macros like LaTeX's

* Fix test
2018-06-03 16:01:16 -04:00
Ron Kok
97d6229e9b Add vertical kern to \vdots (#1402)
* Add vertical kern to \vdots

Fixes #620.

* Replaced screenshots
2018-06-03 15:46:51 -04:00
Erik Demaine
32fe81ae40 Enable output modules to be used in browser or Node (#1401)
This makes cli.js work again from the Node command line

Workaround from https://github.com/webpack/webpack/issues/6522
2018-06-02 19:33:46 -04:00
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