Commit Graph

812 Commits

Author SHA1 Message Date
Kevin Barabash
bf080cd6a4 remove symlink to support devs using Windows (#1090) 2018-01-28 23:01:57 -05:00
Kevin Barabash
0eae99fb08 add \S and \P (#1110) 2018-01-28 17:32:19 -05:00
Ryan Randall
64d776eb4e Merge pull request #1101 from Khan/bolditalic
add Main-BoldItalic font to allow nesting of \textit and \textbf
2018-01-28 15:06:01 -05:00
Ryan Randall
097d592b47 Merge branch 'master' into bolditalic 2018-01-28 14:54:35 -05:00
Kevin Barabash
c627de04d9 use correct spacing with tight styles (#1106) 2018-01-27 22:12:25 -05:00
Kevin Barabash
ea7a560191 add Main-BoldItalic font to allow nesting of \textit and \textbf 2018-01-27 11:32:14 -05:00
ccorn
e4fe1c89d4 Fixes #1093 (non-portable use of String method .includes) (#1097) 2018-01-27 00:54:14 -05:00
Kevin Barabash
f03849c831 update fonts and metrics so that accents are positioned correctly (#1094)
* update fonts and metrics so that accents are positioned correctly

* fix degree symbol, move more accents into the 0x2c0-0x2df range

* fix accents in Unicode screenshots

* update jest snapshots, update AccentsText to include requested characters

* update fonts submodule, add unicode chars to AccentsText test

* update submodules after merging its PR
2018-01-26 19:46:57 -05:00
David Flanagan
53203ed92c Add a screenshot test to ensure that we don't inherit svg-only CSS properties (#1092)
We want to inherit CSS properties that apply to both text and SVG
but we don't want to inherit styles that affect SVG without affecting text.

This patch adds a screenshot test to verify this.
2018-01-25 14:02:06 -05:00
David Flanagan
7b5083f982 Don't inherit SVG style properties from the environment. (#1089)
* Don't inherit SVG style properties from the environment.

We don't want to inherit styles that affect SVG painting unless those
styles also affect regular text rendering. This patch adds styles
to the stylesheet so that every svg element in KaTeX output starts
off with a known set of basic fill and stroke attributes.

This should resolve issue #1088

* Default to stroke:none for <path> elements
2018-01-25 09:01:37 -05:00
Kevin Barabash
63f541b6e6 Use JS for spacing between atoms instead of CSS (#1070)
* Use JS for spacing between atoms instead of CSS

Summary:
This is the first step towards creating an intermediate representation
that can be used to generate HTML, SVG, and Canvas commands for rendering.
By generating spans that contain the width of the spaces instead of
relying on CSS sibling rules we'll be able to one day replaces the spans
with intermeidate 'Glue' nodes (in a later PR).

An added benefit of this approach is that is enables us to programmatically
change the values for thinspace, mediumspace, and thickspace which will
allow us to implement the \setlength command.

Test Plan:
- npm test
- dockers/Screenshotter/screenshotter.sh --verify

* fixed failures in BinCancellation, BoldSymbol, and OperatorName

* update screenshots

* don't use current size when determining size of spaces, update more screenshots

* fix spacing in SizingBaseline and StyleSwitching

* actually do the right thing for sizing groups

* fix \not for Chrome and Firefox

* do TODOs

* address feedback from the code review

* fix issue in delimsizing.js

* add TODO to think about a better solution in href.js

* fix typos, simplify href, be honest about paddingLeft for \not
2018-01-24 23:03:36 -05:00
ylemkimon
d82424c618 Fix undefined devServer.app in screenshotter (#1085)
Fixes #1082, `TypeError: Cannot read property 'get' of undefined` on
Docker for Mac.
2018-01-23 11:58:07 -05:00
ylemkimon
732f2a84cc Export ES6 module in fontMetricsData.js (#1072)
* Export ES6 module in fontMetricsData.js

Use ES6 modules export(`export default`)

* Generate fontMetricsData.js

Export ES6 module in fontMetricsData.js(2382c66)
2018-01-23 08:27:34 -05:00
Kevin Barabash
2a2742453b extract accent and accentunder into their own files (#1048)
* extract accent and accentunder into their own files

* cleanup how we apply custom styles to accentBody wrappers

* address feedback from code review

* fix typo

* define a flow type for a CSS style

* clone 'style' object passed to methods in domTree

* forgot that we don't support object spread yet
2018-01-22 21:50:02 -05:00
Kevin Barabash
c71ee4bdd5 extract handling of implicit leftright groups (#1047)
* extract handling of implicit leftright groups

* address feedback from code review
2018-01-22 18:50:11 -05:00
David Flanagan
853e2a4fb7 Support more scripts in \text{} environments. (#1076)
* Support more scripts in \text{} environments.

This diff is a follow-up to PR #1060 which added support for Indic scripts.
In order to support Czech, Turkish and Hungarian text (at least) inside
\text{} environments, we need to recognize the Latin Extended A and B
Unicode blocks. The patch also adds support for Georgian, and enhances
support for Cyrillic by defining the entire Cyrillic unicode block instead
of defining symbols for a subset of Cyrillic letters as we did previously.

* Only return fontMetrics for supported Unicode scripts in text mode

The Unicode scripts listed in unicodeScripts.js are supported in text mode
but getCharacterMetrics() was returning fake metrics for them even in
math mode. This caused bad handling of \boldsymbol\imath

* use Mode from types.js
2018-01-22 00:53:17 -05:00
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