Commit Graph

746 Commits

Author SHA1 Message Date
ylemkimon
5f32b71c85 Use webpack to build files and webpack-dev-server for testing (#1068)
* Create a separate entry point for webpack

Created a webpack entry point for KaTeX, which imports katex.less. As
flow[1] and jest[2] doesn't support CSS modules natively, a separate
entry point is used and it is not flowtyped.

[1] https://gist.github.com/lambdahands/d19e0da96285b749f0ef
[2] https://facebook.github.io/jest/docs/en/webpack.html

* Use webpack to build files

* Made webpack.config.js export valid webpack configuration
* Use:
browserify -> webpack
babelify -> babel-loader
UglifyJS CLI -> UglifyJsPlugin
Less CLI -> less-loader
cleancss -> cssnano in css-loader
build/fonts -> file-loader
* Inline CSS(Less) using style-loader and export them using
ExtractTextPlugin
* Add `watch` npm script calling `webpack --watch`

* Improve local testing(webpack-dev-server)

* Made webpackDevServer export a valid webpack configuration
* Compile Less and inline CSS using less-loader and style-loader
* Instead of copying files serve files from /static and use file-loader
* Remove old server.js and its dependencies

* Use webpack-dev-server in Screenshotter

* Include contrib in webpack-dev-server

+ Moved common configurations to webpack.common.js

* Rename webpackDevServer.js to webpack.dev...

to be consistent, avoid confusion with webpack-dev-server and follow
webpack configuration naming convention.

* Remove unnecessary conditional output.path

* Use map instead of reduce

+ Add comments regarding function arguments

* Remove unnecessary mkdir and clean build/* before build

* Use katex as external dependency instead of global variable in contrib

Fixes #692.

* Unblock codes as they are built as a module

* Update package-lock.json

* Add comments regarding devServer option

* Lint renamed webpack.dev.js

a0d8b33

* Export ES6 module and expose its default export

* Revert "Browserify hotfix (#1057)"

This reverts commit f6b509123b.

* Enables colors on the console when running the dev server in Screenshotter

* Add context to webpack configuration

Allows webpack to be run from other directories

* Move `rm -rf build/*` to npm scripts

* Check dependencies before build

* Move UglifyJsPlugin into config creation

* Let webpack handle ES6 modules

Do not transform modules to commonjs in Babel. However Jest doesn't not
support ES6 modules, so transfrom modules to commonjs when NODE_ENV is
`test`.

* Add documentation on testing in IE 9 and 10 using webpack-dev-server

Changed version range to include IE-compatible version
2018-01-21 19:48:25 -05:00
ylemkimon
4a11c3166d Move auto-render-spec.js to ./test (#1071)
Fixed jest not running auto-render-spec.js
+ Changed `require` to `import`
2018-01-17 08:44:48 -08:00
Gleb Mazovetskiy
ffcbaf1b98 Add katex-ruby to the libraries list (#1067) 2018-01-16 21:40:23 -05:00
Erik Demaine
a32f82a8ea Add support for \aa, \AA, \lq, \rq, \lbrack, \rbrack (#1069)
* Add support for \aa, \AA, \lq, \rq, \lbrack, \rbrack

The lack of \aa and \AA was reported in #1066.  Added these
via simple macros, with supporting tests.  Also add \lq, \rq,
\lbrack, \rbrack as aliases for "`", "'", "[", "]" which were
in the same area of latex.ltx.

* removed duplicate comment
2018-01-16 12:07:50 -05:00
Kevin Barabash
0599e09a2d Bump master to v0.10.0-pre 2018-01-14 17:39:59 -05:00
raoulb
745322095c Add read/write file cli parameters (#882)
* Add some more command line options

* Use nomnom for proper option parsing

* Handle macros
2018-01-14 17:35:41 -05:00
nickkolok
f6b509123b Browserify hotfix (#1057) 2018-01-14 17:16:12 -05:00
David Flanagan
7fe6af2a82 Add basic support for Indic scripts in addition to CJK. (#1060)
This patch just makes KaTeX recognize Unicode codepoints in the
range \u0900-\u109f so that those South and Southeast Asian scripts
do not get automatically rejected.

The patch also generalizes the way that Unicode blocks are handled
to make it easier to add support for new scripts in the future.
src/unicodeRegexes.js is replaced with the new file src/unicodeScripts.js
2018-01-12 19:14:31 -05:00
Erik Demaine
d6609f7319 Make a more working example in README. Fix #1049 (#1050)
This is an attempt to flesh out the required <head> tags needed to make a full
working example of autorender, including KaTeX itself, to help people get
started with KaTeX.
2017-12-31 17:01:30 -07:00
Kevin Barabash
159cf422bc Remove support for .eot font files, fixes #893 (#1051) 2017-12-30 12:15:02 -07:00
Kevin Barabash
357d6783a4 extract sqrt, enclose, and verb into their own files (#1040)
* extract sqrt, enclose, and verb into their own files

* add returns types in utils.js and update the  comment

* rebase, fix location of  comment
2017-12-29 13:37:09 -07:00
Kevin Barabash
5cc795eaaa flow typings for parser.js (#1041)
flow typings for parser.js
2017-12-29 13:26:22 -05:00
Erik Demaine
63733f796a Update testing infrastructure NPM packages (#1044)
* Update testing infrastructure NPM packages

Travis is currently failing all tests.  This should fix it,
as documented in https://github.com/eslint/eslint/issues/9767

* Add package-lock.json
2017-12-29 10:06:26 -07:00
Erik Demaine
484d44ee70 Unicode accents (#992)
* Unicode accents

* Lexer now looks for combining dicritical marks and adds them to the same character
* Parser's `parseSymbol` now recognizes both combined and uncombined forms of Unicode accents, and builds accent objects just like the accent functions
* Added CJK support to math mode (not just text mode)

* Add invalid combining character test

* Add MathML test

* Add weak support for other Latin-1 characters

This maintains backwards compatibility, but it uses the wrong font.
There's a TODO to fix this later.

Also refactor symbol code to use for..of

* Update Unicode screenshot

* Remove dot from accented i and j (in math mode)

Also add dotless Unicode characters to support some accented i's and j's

* Fix \imath, \jmath, \pounds, and more tests

* Switch from for..of to .split().forEach()

Save around 800 bytes in minified code

* Fix split

* normalize() detection

* Convert back to vanilla for loops

* Fix merge

* Move normalize dependency to unicodeMake.js

* Make unicodeSymbols into a lookup table instead of macros

This is important for multi-accented characters.

* Add comments about when to run

* Move symbols definition into unicodeMake/Symbols.js

* Remove CJK support in text mode

* Add missing semicolon

* Refactor unicodeAccents to its own file

* Dotless i/j support in text mode

* Remove excess character mappings

* Fix Åå in math mode (still via Times)

* Update to support #1030

* Add accented Greek letter support (for supported Greek symbols)

* Update screenshot

* remove Æ, æ, Ø, ø, and ß from math mode test
2017-12-28 23:32:45 -07:00
Erik Demaine
d822f04b9b \kern generates right-margin instead of left-margin. Fix #995 (#1019)
* \kern generates padding instead of margin. Fix #995

* Switch to marginRight

* Add screenshot tests
2017-12-28 23:03:08 -07:00
Kevin Barabash
7702ffa5b6 add package-lock.json so our builds are repeatable 2017-12-28 22:54:56 -07:00
Kevin Barabash
d470cc0b3f Add a 'common issues' section to the README (#1034) 2017-12-27 08:51:20 -08:00
Kevin Barabash
7229f02d8f Implement correct macros for liminf and limsup, fixes #111 (#887)
* Implement correct macros for liminf and limsup, fixes #111

* fix nits
2017-12-26 17:11:10 -07:00
Ryan Randall
c883b3d54d Merge pull request #1037 from rrandallcainc/Removing-Unnecessary-CSS
Removing katex-logo css, as it's no longer used.
2017-12-26 18:50:36 -05:00
Kevin Barabash
1dd1082628 Merge branch 'master' into Removing-Unnecessary-CSS 2017-12-26 16:30:49 -07:00
Ron Kok
c62f814765 Fix frac-line (#1025)
* Fix frac lline

For frac-line, use an SVG line in an extra tall span.

I still need to think of a way to adust `vertical-separator`.

* Fix spaces in katex.less

* regenerate screenshots

* update HorizontalBraces and StrikeThrough screenshots
2017-12-26 16:17:06 -07:00
Ryan Randall
c559b916da Removing katex-logo css, as it's no longer used. 2017-12-26 16:35:01 -05:00
Erik Demaine
d6791b7961 Make accents zero width (#1033)
* Make accents zero width

Make the width of an accented character equal to the width of the character,
by making accents zero width.  In particular, fixes #1028 (`\ddot\imath`).

This involved reworking all of the accent offset machinery, in particular
skew and accent-hungarian.  A bit cleaner now.

Also added support for the new width character metrics in symbolNode.

* Update AccentsText test

* Fix comment
2017-12-25 11:48:32 -07:00
Kevin Barabash
d19ac4029a add glyph widths to fontMetricsData.js (#1032) 2017-12-22 13:10:11 -07:00
Kevin Barabash
522b238e20 add \ae, \AE, \oe, \OE, \o, \O, \ss with unicode support for those characters in text mode (#1030) 2017-12-22 12:42:43 -07:00
Kevin Barabash
2b2cf73f2e add \i and \j for text mode (#1029) 2017-12-22 13:57:31 -05:00
Erik Demaine
c30edaaf5b Implement \TextOrMath, \@secondoftwo (#1024)
* Implement \TextOrMath, \@secondoftwo

* Parser now tells MacroExpander about mode switching.  (This seems preferable
  to a circular reference between Parser and MacroExpander.)
* Implement \TextOrMath
* Improve when we switch modes so that this actually works,
  in all cases except single-symbol arguments.
* Add \@secondoftwo to match \@firstoftwo.
* Add comments documenting all the conditional macros

* Define type for switchMode

* Fix mode detection for ligatures

* Switch mode before the call to parseSymbol() in parseGroup

This fixes the Colorbox screenshot test.
2017-12-21 21:43:27 -07:00
Ryan Randall
2d439f076a Merge pull request #1022 from edemaine/buildhtml
Add buildHTMLTree
2017-12-18 16:49:03 -05:00
Erik Demaine
d8994df1d4 Rename to use 'render' terminology, add docs 2017-12-18 11:24:50 -05:00
Erik Demaine
4b69eb7a7e Add buildHTMLTree 2017-12-18 11:24:50 -05:00
Ron Kok
4410d48d5c Fix \vec (#1018)
* Fix \vec

In accent \vec, replace the combining font glyph with an SVG.

* Fix lint error

* update screenshots containing vectors

* update HorizontalBraces
2017-12-17 22:05:21 -07:00
Ryan Randall
50765a0ccd Stacking text commands (#1009)
* Adding support for SansSerif-Bold

* Updating to include SansSerif Italic.

* WIP

* Working text stacking

* More robust screenshot.

* Don't want to break users :)

* Updating per PR comments.

* Fixing Unicode and updating snapshots.

* Adding suggested tests.

* Opting to use old method for unit testing.

* Adding TODO
2017-12-13 09:10:23 -05:00
Alexander Terenin
cf23517499 Added support for bold italic symbols (#1011)
* added support for \boldsymbol

* added \boldsymbol tests

* added \boldsymbol screenshots

* added \bm, snapshot, updated screenshots

* updated snapshot for \boldsymbol

* properly display \imath and 2 in boldsymbol

* implemented \boldsymbol for +

* fix typo, remove boldsymbolLetters hardcode

* make comment about using Main-Bold more general

* fixed trailing space CI error
2017-12-12 23:09:52 -05:00
Ryan Randall
36ca9beaa7 Exposing the build tree. (#1017)
* Exposing the build tree.

* Warning users about internal representation.
2017-12-10 20:03:10 -05:00
Ron Kok
46176c1d69 Support Unicode middle dot (#1015)
* Support Unicode middle dot

This PR adds support for Unicode characters U+00B7 MIDDLE DOT and U+22C5 DOT OPERATOR.

* Use escapes for tests. Edit macro comment.
2017-12-10 16:16:45 -05:00
Ashish Myles
73db0a2352 delimiter.js: Don't assign sizeMultiplier to span in prep for porting to flow. (#1006) 2017-12-06 21:54:57 -05:00
Kevin Barabash
9e6eb3a219 replace dockers/MathJaxFonts with KaTeX/katex-fonts submodule (#891) 2017-11-28 07:25:03 -05:00
Kevin Barabash
4cbc4d3cd9 cache node_modules on travis-ci, fixes #1001 (#1002) 2017-11-28 00:42:51 -05:00
Ron Kok
28c55ebedc Change \xLongequal to \xlongequal (#997)
Fix a spelling mistake from PR #670.
2017-11-27 23:55:51 -05:00
Kevin Barabash
1b20414526 extract color and text commands into their own files in functions sub-directory (#998) 2017-11-27 23:50:07 -05:00
Kevin Barabash
98203ad6ba extract overline, underline, and rule into their own files (#999) 2017-11-27 23:42:55 -05:00
Erik Demaine
7036eb85cd \kern fixes, \hskip support, \TeX, \LaTeX, \KaTeX (#974)
* Refactor \kern, proper \mkern support, add \hskip

* Move \kern, \mkern into functions directory
* Add \hskip, \mskip support (but without supporting plus/minus)
* Properly separate \kern, \hskip from \mkern, \mskip.
  (The former work in both modes, and don't support mu units.
  The latter work only in math mode and only support mu units.)

* Render \kern etc. using MathML <mspace>

* Implement \TeX macro

* Implement \LaTeX

* New KaTeX logo \katex

* Rename hskip.js -> kern.js

* Tweak katex \kern to 0.16em

* \katex kern -.17em

* Compute A raise height in \LaTeX and \katex

* Switch mu unit errors to warnings

* LaTeX screenshot test

* Replace \KaTeX with macro definition

* Update screenshots with \KaTeX in them

* Fix font selection for \*TeX macros
2017-11-27 14:40:38 -05:00
Erik Demaine
f6a377b91c Avoid negative space in \bmod. (#984)
This is a workaround for #836 for the command case of using \bmod,
without changing any spacing (and making the code and generated output
slightly more efficient).  In particular, fix #982.
2017-11-26 20:24:31 -05:00
Kevin Barabash
2ca6c3c73b Bump master to v0.10.0-pre 2017-11-26 18:34:59 -05:00
Ron Kok
0bde52f04f Support Unicode \mid (#993)
Map ∣, U+2223, to `\mid`
2017-11-26 18:32:01 -05:00
Ashish Myles
1d8cf3fa08 Port katex, buildTree, parseTree to @flow. (#989) 2017-11-25 22:10:14 -05:00
Ron Kok
dc0c3970c2 Support Unicode ∴ and ∵ (#991)
* Support Unicode ∴ and ∵

* Add comments
2017-11-25 20:00:58 -05:00
Erik Demaine
c103693dce "use strict" in ss_data.js (#986) 2017-11-25 18:14:53 -05:00
Ashish Myles
4a313d56a6 Simplify HTML generation logic for \\cancel, \\bcancel, \\xcancel. (#988) 2017-11-24 22:54:34 -05:00
Georges Dupéron
d773b17963 Adds \notni character ∌ (#710)
* Added \\not\\ni character ∌

* remove \notin from symbols.js

reason: we don't have the glyph yet
2017-11-24 16:01:29 -05:00