Commit Graph

882 Commits

Author SHA1 Message Date
Erik Demaine
49e673a59c Stop throwing ParseError when throwOnError is false (#1169)
* Stop throwing ParseError when throwOnError is false

`render`, `renderToString`, etc. now catch ParseError and render it to the
raw LaTeX (with proper escaping) and a hover title with the error.

Along the way:
* Use new `katex.__renderToDomTree` in katex-spec's `_getBuilt`.
  (This was necessary to get the new error handling in `_getBuilt`.)
* Fix jest results which must always be functions, not strings.

* fix lint

* Fix flow error

Leave error type unspecified, as we check it with instanceof.

* Update katex-spec.js
2018-05-09 22:18:50 +09:00
Erik Demaine
3e529dd5a0 Tilde \textasciitilde and fix ~ in \verb (#1286)
* \textasciitilde and fix ~ in \verb

* Add support for `\textasciitilde` which reproduces tilde character
  in text mode.
* Make `~` render as tilde instead of space within `\verb`,
  by manually mapping that character to `\textasciitilde`.
  This seems to be the only character that needs such manual mapping
  to reproduce LaTeX's `\verb` behavior.

* Add `, -, ', ~ to Verb screenshot test
2018-05-09 08:48:47 -04:00
Kevin Barabash
43bfaedbc8 move retrieveBaseFontName and retrieveFontStylesName into retrieveTextFontName (#1300) 2018-05-09 20:00:12 +09:00
Erik Demaine
5c159abfbb Switch makeGlue from .mord .rule to .mspace (#1295)
* Switch makeGlue from .mord .rule to .mspace

* Update screenshots
2018-05-08 15:28:53 -04:00
Erik Demaine
ba24d2073b Remove special \verb space handling now that space is in Typewriter-Regular (#1258)
* Remove special \verb space handling now that space is in Typewriter-Regular

* Fix screenshots
2018-05-07 21:07:53 -04:00
Erik Demaine
b74b2374e2 \copyright, \textregistered, \textcircled support (#1073)
* \copyright support

* Implement \textcircled, \copyright, \textregistered
2018-05-07 20:44:40 -04:00
Ron Kok
f01f504cfe Support some Unicode Mathematical Alphanumeric Symbols (#1232)
* Support some  Unicode Mathematical Alphanumeric Symbols

This PR adds support for some of the characters in Unicode range U+1D400 to U+1D7FF, [Mathematical Alphanumeric Symbols](https://www.unicode.org/charts/PDF/U1D400.pdf).  Specifically, it adds support for:
* A-Z a-z bold
* A-Z a-z bold italic
* A-Z a-z Fractur
* A-Z a-z sans-serif
* A-Z double struck
•	A-Z script

Addresses issue #1215 and parts of #260.

* Fix lint error

* Fix MathML, and pick up review comments

* Fix lint error

* Add text mode. Remove sans-serif.

* Fix lint error

* Fixed \mathrm, added screenshotter test

* Change screenshotter test to an array

* Add screenshots

* Picked up review comments. Add characters
2018-05-07 20:06:16 -04:00
Ron Kok
f25e08d618 Support Unicode ≘≙≚≛≝≞≟ (#1274)
* Support Unicode stackrel

Supports Unicode characters ≘ ≙ ≚ ≛ ≝ ≞ ≟

* Fix lint error

* Delete unnecessary braces
2018-05-03 16:58:04 -04:00
Ron Kok
7fec5ae5dc Fix \underset (#1277)
* Fix \underset

This PR modifies `\underset` and `\overset` to align with LaTeX behavior when a superscript is applied after the `\underset`.  Fixes issue #1275.

I also changed the spacing from KaTeX `mop` to KaTeX `rmel`. The result seems to be a closer visual match to LaTeX.

* Update screenshots
2018-05-03 16:50:18 -04:00
Erik Demaine
98b85097eb Alternate approach to capital Greek letters (#1285)
Alternative to #1283 and #1284 implementing Latin-looking capital Greek
letters via symbols instead of macros, which interacts with fonts more
correctly.
2018-05-03 16:21:44 -04:00
Ethan Luis McDonough
2554f68297 Add version to katex object (#1279)
* Add version to katex object

Address khan/KaTeX#1190

* Update package.json before building
2018-05-02 17:45:49 -04:00
Ron Kok
5535d720dc Greek caps (#1283)
* Support Greek capital letters

Supports Greek letters ΑΒΕΖΗΙΚΜΝΟΡΤΧ.

Resolves issue #1282.
2018-05-02 14:29:57 -04:00
Barry B
4687aa9ec3 Fix typo in release.sh (#1280) 2018-05-01 15:28:59 -04:00
Hossein Saniei
bd7a977404 [plugin system] Add defineSymbol to the main katex object (#1263)
* Expose defineSymbol in the main KaTeX object

* More Unicode letters (#1260)

This PR serves as a complement to PR #1232 by supporting some letters that are omitted from the Unicode range 1D400–1D7FF.

* Include Bold-Italic fonts for \boldsymbol (#1257)

* Include Bold-Italic fonts for \boldsymbol

Fix #1228

* Update screenshots

* README: Add size badge (#1253)

* README: Add size badge

Add a size badge showing size of gzipped katex.min.js

* update-sri: Add code to replace size badge in readme

* Change to use badge from shields.io instead

My bad for assuming that badgesize.io supports https. Change to use the
badge from shields.io which supports https.

* More Unicode letters (#1260)

This PR serves as a complement to PR #1232 by supporting some letters that are omitted from the Unicode range 1D400–1D7FF.

* Include Bold-Italic fonts for \boldsymbol (#1257)

* Include Bold-Italic fonts for \boldsymbol

Fix #1228

* Update screenshots

* README: Add size badge

Add a size badge showing size of gzipped katex.min.js

* update-sri: Add code to replace size badge in readme

* Change to use badge from shields.io instead

My bad for assuming that badgesize.io supports https. Change to use the
badge from shields.io which supports https.

* Use badgesize.io with https

* Fix space width in \texttt (#1261)

* Fix space width in \texttt

Fix #1255 via https://github.com/KaTeX/katex-fonts/pull/41.
Also fix width metrics via https://github.com/KaTeX/katex-fonts/pull/42.

* Improve test

* Update screenshots
2018-04-28 16:36:30 -04:00
Ron Kok
b4b57cbc2b Support Unicode \ll and \lll (#1273)
* Support Unicode \ll and \lll

Fixes #1272. Consistent with `unicode-math`

* Rearranged test strings
2018-04-24 21:01:05 -04:00
Erik Demaine
812b350a5d Fix space width in \texttt (#1261)
* Fix space width in \texttt

Fix #1255 via https://github.com/KaTeX/katex-fonts/pull/41.
Also fix width metrics via https://github.com/KaTeX/katex-fonts/pull/42.

* Improve test

* Update screenshots
2018-04-21 19:52:18 -04:00
Daniel Lim Wee Soong
fe2dc1bedf README: Add size badge (#1253)
* README: Add size badge

Add a size badge showing size of gzipped katex.min.js

* update-sri: Add code to replace size badge in readme

* Change to use badge from shields.io instead

My bad for assuming that badgesize.io supports https. Change to use the
badge from shields.io which supports https.

* More Unicode letters (#1260)

This PR serves as a complement to PR #1232 by supporting some letters that are omitted from the Unicode range 1D400–1D7FF.

* Include Bold-Italic fonts for \boldsymbol (#1257)

* Include Bold-Italic fonts for \boldsymbol

Fix #1228

* Update screenshots

* README: Add size badge

Add a size badge showing size of gzipped katex.min.js

* update-sri: Add code to replace size badge in readme

* Change to use badge from shields.io instead

My bad for assuming that badgesize.io supports https. Change to use the
badge from shields.io which supports https.

* Use badgesize.io with https
2018-04-21 19:22:14 -04:00
Erik Demaine
933a0ee5b5 Include Bold-Italic fonts for \boldsymbol (#1257)
* Include Bold-Italic fonts for \boldsymbol

Fix #1228

* Update screenshots
2018-04-12 22:24:06 -04:00
Ron Kok
00538f674a More Unicode letters (#1260)
This PR serves as a complement to PR #1232 by supporting some letters that are omitted from the Unicode range 1D400–1D7FF.
2018-04-12 22:15:00 -04:00
Ian Rose
0a2bd8878d Specify height for SVG elements (#1252)
* Specify height for SVG elements

I ran into an issue where a low-specificity CSS rule elsewhere on the page was overriding the KaTeX SVG height, rendering fraction lines invisible. Does this seem like a reasonable addition to the style sheet?

* Inherit instead of 100%.
2018-04-06 08:09:56 -04:00
Ashish Myles
cbfcd57162 Type correction to allow documentFragment to be children of span. (#1247)
* Type correction to allow documentFragment to be children of span.

This is necessary because documentFragments are put in spans in some cases --
e.g. src/functions/sqrt.js. Not sure why this wasn't caught by the type system.
It's possible that it might be happening in buildHTML as well -- it is not yet
been typed and thus violations of the existing types haven't yet had a change to
be caught.
2018-04-06 00:20:51 -04:00
Lukas Drgon
0f17ac5080 Change CDN links (#1243) 2018-04-04 21:54:00 +09:00
dudko
f35c41883c List react-katex in Libraries (#1236)
* List react-katex in Libraries

* Added react-latex

* Fix capitalization

* Move React libraries above Ruby library
2018-03-31 09:33:01 -04:00
ylemkimon
1c5a7ed232 Fix anchor.toMarkup (#1246)
* Fix anchor.toMarkup

* Add space between `a`(tag name) and `href`(attribute name)
* Remove `this.href` appended to `markup` in the template literal

* Add regression test on #1245
2018-03-31 08:44:27 -04:00
Ashish Myles
850a0713cb Treat svg-wrapping spans differently from DOM-wrapping spans. (#1239)
* Treat svg-wrapping spans differently from DOM-wrapping spans.

In preparation for the conversion of buildHTML to @flow, separate the two
different uses of domTree.span -- one to wrap a single SVG and one to wrap
arbitrary DOM nodes. This separation is to help avoid type issues that pop up
due to buildHTML methods accessing the .children field of spans as if they are
DOM elements and not SVG ones.

* Simplify the domTree DOM definitions based on separation of two span types.
2018-03-27 22:47:15 -04:00
Erik Demaine
e31cceed58 Add metrics for \S and \P (#1224)
Just updating to latest katex-fonts submodule.
2018-03-16 15:52:59 +09:00
Erik Demaine
95ea3e3095 Fix cli.js: add nomnom dependency, add -u option (#1218)
* Fix cli.js: add nomnom dependency, add -u option

* Add `nomnom` dependency (not dev dependency): fix #1216
* Add -u option for new `unicodeTextInMathMode` option

* Reword color option doc

* Fix comments from review
2018-03-15 22:28:23 +09:00
Erik Demaine
4f29c5a942 Support \( and fix instant mode switching for $, \(, \text (#1213)
* Fix #1212 by supporting `\(...\)` in addition to `$...$` inline math nested inside `\text`. This turned out to be harder than one would think because of the way `$` was being handled specially, while `\(` needed to be handled as a function, which immediately consumed the `\(` token, which meant that the first following token got consumed in text mode instead of math mode (unlike `$` where we could switch the mode before consumption).
* Added new `consumeMode` setting for functions which tells the parser to switch modes just for the consumption of the command token.
* Now that we're working with functions, move all the `$` handling code into `functions/math.js`.  Somewhat bizarrely, we can define `$` as a function (nearly identical to `\(`) and it all works (just like we can have single-character macros).  This move removed a lot of messy stuff from `Parser.js`: `ParsedDollar`, `ParsedFuncOrArgOrDollar`, `newDollar`, `assertFuncOrArg`, and at least three explicit checks for `if (... === "$")`.
* Moved the `consume()` for the command token from `parseSymbol` to `parseGivenFunction`.  This ended up not being strictly necessary, but seems conceptually cleaner.
* Partially address #1027 by setting `consumeMode: "text"` for `\text` commands.  As a result, `\text` now instantly switches the mode to `"text"`, so even an unbraced macro argument will properly detect text mode.  I added a test for this, which is a slightly weaker form of #1027.
2018-03-14 10:54:36 -04:00
Ashish Myles
5bcdeec4ad Format buildHTML groupType definitions in preparation for adding types. (#1206)
* Format buildHTML groupType definitions in preparation for adding types.

1) Collapse groupType definitions (a bunch of functions all of the same type
   defined on the groupType object) into a single object in preparation for
   putting types only on the base object.
2) Do minor reformatting to account for the +4 indent above which pushes some
   lines past 80 characters.
3) Do other minor formatting changes for readability, taking advantage of ES6.

* Review fixes.
2018-03-14 23:38:35 +09:00
Ron Kok
65b47430b5 Support Unicode delimiters (#1207)
* Support Unicode delimiters

This PR adds support for the Unicode versions of \lfloor, \rfloor, \lceil, \rceil, \lgroup, \rgroup, \lmoustache, \rmoustache, \ulcorner, \urcorner, \llcorner, and \lrcorner.

All the mappings agree with `unicode math`

* Change tests from Parse to Build
2018-03-13 09:21:19 -03:00
Erik Demaine
0d3cf000d2 Add \yen support to text mode (#1208)
Fix #1204 by adding `\yen` support to text mode.

More generally, I checked all the text+mode symbols supported by
[amsfonts](http://mirrors.ctan.org/fonts/amsfonts/doc/amsfonts.pdf)
(see Section 6), and found that `\yen` is the only one lacking text-mode
support.
2018-03-13 02:22:04 +01:00
Erik Demaine
75b55a63b1 Add display/displayMode toggle on test page (#1193)
* Add display/displayMode toggle on test page

* Fix #1035
* Refactor query parsing code to promote re-use
* Also add support for (unescaped) single-character macros

* Rewrite to use query-string

* Restore modes on package*json
2018-03-12 01:15:09 +01:00
Ron Kok
b148d5da71 Support Unicode ° (#1203)
Oddly, `unicode-math-table.txt` does not contain an entry for U+00B0. But `\degree` is surely the correct mapping.
2018-03-10 13:19:13 -05:00
Erik Demaine
abfb641d7a Fix \nobreakspace, refactor "regular space" checking (#1200)
* Fix \nobreakspace, refactor "regular space" checking

Fix #1199 by adding \nobreakspace to the list of commands/symbols that
behave like a regular space character.  Refactor to put that list in one
place, and use an object so it checks instantly instead of sequentially.

* Copy test from #1201
2018-03-10 00:14:42 +01:00
Ryan Randall
017eb7b91d Implementing analyze script (#1197) 2018-03-09 17:13:02 +01:00
Erik Demaine
20b5a58451 Work around negative space bug in Chrome (#1194)
* Work around negative space bug in Chrome

Fix #984

The screenshot test is still somewhat defective, showing a space before
the "post" text (a period).  This seems limited to the screenshotter, however,
as it works fine in the tester via
http://localhost:7936/?text=%5Cfbox%7B%5C%241%2C%5C!000%2C%5C!000%7D%5CKaTeX&display=0&after=.

* Update screenshots

* Switch to inherited `width: min-content`
2018-03-09 16:38:25 +01:00
ylemkimon
06e0393abc Online screenshot diff/generation using CircleCI (#1187)
* Add CircleCI config for online screenshot verification/generation

* Remove `Checkout unicode fonts` step

Unicode-fonts are now a submodule, which is checked out in `Checkout submodule` step.

* Always generate new screenshots
2018-03-06 00:47:41 -05:00
Ashish Myles
0ce53e7631 Port spacingData and unicodeSymbols to @flow. (#1195)
* Port spacingData and unicodeSymbols to @flow.

* Review fixes.

* Made Measurement an exact object type.
2018-03-05 23:43:01 -05:00
ylemkimon
96ad6e0f4f Add unicode-fonts as submodule (#1182)
* Add unicode-fonts as submodule

Removed checkout process from screenshotter.sh.

* Rename test-fonts submodule and update repo URL
2018-03-05 23:29:19 -05:00
Ashish Myles
9e22012619 Port delimiter.js to @flow. (#1177)
* Port delimiter.js to @flow.

* Responded to comments.
2018-03-01 19:57:10 -08:00
Ron Kok
56cfc7cf86 Fix contenteditable mode (#1179)
`makeVList` sets depth with an empty span for which it defines a height. But Chrome, in contenteditable mode only, treats that span as if it contains some text.  The resulting `min-height` can over ride our desired depth.

So we insert an empty span inside the `depthStrut` span.
2018-02-27 13:06:58 -05:00
Erik Demaine
aed1c1e564 unicodeTextInMathMode setting (#1117)
* unicodeTextInMathMode setting

* When `unicodeTextInMathMode` is `true`, accented letters from
  `unicodeSymbols.js`, and CJK and other supported languages,
  get added support in math mode (as requested in #895).
* When `unicodeTextInMathMode` is `false, all of these stop working in
  math mode, and are only supported in text mode (matching XeTeX behavior).
  Note that this is a backwards incompatibility with some 0.9.0 alpha/betas.

* Fix handling of Unicode characters ð, Å, å

* Fix double handling of ð (math maps to \eth, not special Unicode character)
* Remove Åå special math handling, thanks to #1125

* Forbid extraLatin when unicodeTextInMathMode is false
2018-02-19 21:25:20 -05:00
Ryan Randall
7de91f73eb Nested Math in Non-Default Text Fix (#1111)
* Fixing nested math in non-default text. Added appropriate screenshot tests.

* Adding appropriate logic for buildMathML and resolving tests.

* Addressing Kevin's comment. Adding tests.

* Adding appropriate screenshots.

* Removing unnecessary data, adding consistent naming convention.

* Cleanup

* Handling possible edge cases.

* Updating per PR comments
2018-02-19 17:37:08 -05:00
Erik Demaine
b341034d2b Add tests for __* internal interface (#1170)
Inspired by codecov
2018-02-19 10:39:16 -05:00
Kevin Barabash
298b482c18 Bump master to v0.10.0-pre 2018-02-18 16:55:16 -05:00
Erik Demaine
0854bb9f15 Add a paragraph about injection safety (#1161)
* Add a paragraph about injection safety

* Rewrite into Security and Handling errors

* minor edits to the suggested whitelist
2018-02-17 14:48:33 -05:00
Kevin Barabash
789aabe7a1 add .codecov.yml and disable patch coverage (#1164) 2018-02-17 14:11:06 -05:00
Ron Kok
95ffb4fad4 Padding over \sqrt and Paths for frac-line (#1143)
* Padding over \sqrt and Paths for frac-line

This replaces two earlier PRs.

* Restore reaction arrows

* regenerate screenshots

* Set line padding in a constant

* Update with latest master

* Fix lint error

* update screenshots
2018-02-17 13:56:13 -05:00
Erik Demaine
bceb7bd163 Fix handling of Unicode characters ð, Å, å (#1157)
* Fix double handling of ð (math maps to \eth, not special Unicode character)
* Remove Åå special math handling, thanks to #1125
2018-02-13 23:27:02 -05:00
Erik Demaine
627fc11f1b Support \underline in text mode (#1159)
* Support \underline in text mode

Fix #1158

* Add to LowerAccent test
2018-02-13 20:30:30 -05:00