Commit Graph

914 Commits

Author SHA1 Message Date
Erik Demaine
4a2903148e Automatic mrel/mbin spacing for \boldsymbol (#1388)
* Automatic mrel/mbin spacing for \boldsymbol

Fix #1154

* Add test

* Add missing mode

* Separate out \boldsymbol support to correct flow types

* Fix ternaries thanks to @ronkok's comment

* Revert package-lock.json

* Add screenshot test
2018-06-11 08:19:50 -04:00
Ron Kok
954ddf4172 Edit \lbrack and \rbrack (#1420) 2018-06-10 12:43:23 -04:00
Hossein Saniei
8b1e1b4886 [plugin system] Add a utility function (setFontMetrics) to extend builtin fontMetrics (#1269)
* Add and expose addFontMetrics function

* fix typo

* recreate package.json-lock

* Add setFontMetrics function to change the defualt metricMap - change getFontMetrics to getGlobalMetrics

* use new setFontMetrics on main KaTeX object

* fix package-lock.json error by rebuilding it

* Add appropriate tests

* update the snapshot
2018-06-09 20:42:35 -04:00
Ashish Myles
251283ffc1 Port buildHTML to @flow. (#1408)
* Port buildHTML to @flow.

* Address reviewer comments.

* Addressed reviewer comments.
2018-06-09 20:21:30 -04:00
Ron Kok
1dc261298e Add min-height to \rule (#1417)
* Add min-height to \rule

* Fix screenshots
2018-06-09 18:59:20 +02:00
Ron Kok
690285ad4b Remove redundant \lbrack and \rbrack (#1416)
* Remove redundant \lbrack and \rbrack

* Revert macros. Remove redundant code.

* Revert symbols
2018-06-09 18:51:59 +02:00
greenkeeper[bot]
f929f0a683 chore(package): update flow-bin to version 0.74.0 (#1414) 2018-06-07 14:33:23 -04:00
Erik Demaine
65569249be \newcommand, \renewcommand, \providecommand (#1382)
* \newcommand, \renewcommand, \providecommand

* Tests

* Add comment

* Add symbols to the set of already defined things

* Add implicitCommands, catch \hline outside array

* Add \relax

* Move isDefined to be a method of MacroExpander

* Namespace.has

* Reword error messages

* Add \hdashline given #1407
2018-06-07 13:39:39 +02:00
Ron Kok
a5ef29fab1 Implement \colon as amsmath does (#1410)
* Implement \colon as amsmath does

* Remove \colon from symbols.js

* Update screenshots

* Pick up comments

* Replace screenshots
2018-06-07 04:24:41 +02:00
Ron Kok
93904c51ab Support \hdashline (#1407)
* Support \hdashline

Support `\hdashline` from package `arydshln`. This PR acts as a complement to PR #1395.

Similarly to #1395, the dashed line is rendered as `border-bottom-style: dashed;`. That does not exactly match the `dashsegment` and `dashgap` lengths in `arydshln`, but it does render black lines with sharp edges.

* Fixed top line position

* Add screenshots

* Fix lint error

* Fix another lint error

* Deleted HLine screenshots

* Pick up comments
2018-06-07 03:30:29 +02:00
Ron Kok
89e180c5a6 Support \widecheck (#1406)
Fixes #1221.

Implemented as an upside-down version of `\widehat`.
2018-06-04 21:05:07 -04:00
Erik Demaine
1e645198f7 Fix ligatures vs. \tt (#1379)
* Fix ligatures not always triggering

Example: \text{\rm --} would not cause ligature but should

* Remove ligatures in \texttt mode

* Add screenshot tests

* Fix MathML ligatures

* Fix type

* Handle \text... fonts in MathML building

* Remove leftover console deubgging
2018-06-04 20:29:25 -04:00
Erik Demaine
4f9851fb0c Automatic submodule updating via husky tool (#1391)
* Automatic submodule updating via husky tool

* Update documentation
2018-06-04 20:22:12 -04:00
Ashish Myles
19d2aa63c3 Replace ParseNode<*> with a more accurate AnyParseNode and fix flow errors. (#1387)
* Replace ParseNode<*> with a more accurate AnyParseNode and fix flow errors.

* Allow "array" environment type spec to use any all symbol type.

Before this commit, it was constrained to use "mathord" and "textord", but a
recent change in HEAD resulted in a "rel" node being used in the spec for, e.g.
\begin{array}{|l||c:r::}\end{array}

* Address reviewer comments: rename `lastRow` to `row` in array.js.
2018-06-04 10:56:51 -04:00
Zachary Riedlshah
4492eedb68 Added ability to create a dashed vertical line in arrays, using ':' (#1395)
* hacked together a dashed vertical bar

* Updated tests and spec.

* tidied up the screenshot template for arrays

* added the vertical lines at the end back

* Updated screenshots for arrays
2018-06-03 19:52:30 -04:00
Erik Demaine
fcb32f058b Support \arraystretch as a macro definition (#1381)
* Support \arraystretch as a macro definition

Also add `expandMacro` and `expandMacroAsText` helpers to `MacroExpander`.

* Remove excess defaulting

* Add test
2018-06-03 18:19:23 -04:00
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