Post-process the list of atoms after they are created, changing
binary operators to ordinary atoms according to the TeXbook's
rules. This makes the `prev` argument redundant, so drop it.
This commit assumes that the math class (mop/mbin/mrel/etc.) comes
first in the `classes` list, if present. Add a TODO to change the
signature of `makeSpan/makeSymbol` to enforce this invariant.
* Internal: Pass full `options` objects to makeSpan/makeSymbol.
Not just the current color. This will facilitate applying options
to built nodes in a standardized way, rather than changing all
callsites.
* Add style switching test: text and scriptstyle in the same group.
* Apply style-specific spacing using different CSS coding.
Specifically, infer style from a class on the *current* element,
rather than the parent element. Use "mtight" class to denote elements
with tight spacing (scriptstyle or scriptscriptstyle). Apply that
class automatically based on options.
* Fix#533, #534, #541.
- #534: Implement getTypeOfGroup for font groups.
- #533, #541: Improve the ways spaces are applied to lists. Since
CSS adjacency implements mathematical spacing, it's incorrect to
introduce "convenience spans" for spaces and display changes into
the generated HTML -- those spans break adjacency. Apply display
changes directly, and shift space spans into adjacent atoms.
Requires updates to two screenshotter tests, LimitControls and
SupSubLeftAlignReset. The new results for these tests are closer
to TeX output than the old results.
Also requires updates to Jasmine tests, since those assumed output
structures that have changed.
* Fix#136: Size commands generate fragments, not spans.
This is so the size commands don't hide the types of their enclosed
atoms. Addresses #136.
This slightly changes the vertical position of the Sizing test. Not
sure the vertical position matters, so change the test.
* Exit cleanly after invalid screenshot test name
This avoids waiting forever.
* Auto-detect host IP in Docker for Mac environment
This checks all available network addresses to find one which the Selenium
container can connect to. That way we don't have to analyze network
settings or similar to figure out the main public IP address of the machine.
* Make server less sensitive to current working directory
That way it becomes possible to run screenshotter.js from within the
Screenshotter directory, and still server all files as intended.
This ensures that running screenshots as indicated by the screenshotter
readme will correctly render the Unicode examples, even if not run on
Travis. It also fixes the commit ID of the unicode fonts.
One alternative would have been using a git submodule. But as many tools
will initialize submodules automatically, that would mean big downloads for
anyone using such a tool to clone KaTeX.
Another alternative would be tweaking the server to fetch the files on
demand if the local copy is unavailable. But that would cause additional
network overhead, so grabbing the files just once should be simpler.
Summary:
FONTDIM metrics include metrics like sup2, sup3, etc. which are used for
position sub/super-scripts, fractions, delimiters, etc. TeX uses three
different font styles: textfont2 (DISPLAY & TEXT), scriptfont2 (SCRIPT), and
scriptscriptfont2 (SCRIPTSCRIPT) and has different sets of metrics for each.
This diff adds style specific metrics for better TeX compliance.
Notable squashed commits:
- Recreated screenshots (martin)
- fix getEmPerEx to use getXHeight
- regularize how we access options.style, remove unnecessary newlines
- use var style = options.style in more places in buildHTML
* Let git ignore .npm-install.stamp and dist
The former is created for most makefile targets after dependencies have been
retrieved. The latter is created by typical operations like “make” without
arguments or “npm install”. Having these around is to be expected.
Adding this to .gitignore should NOT affect npm packaging, since that is
based on a whitelist in package.json which does mention dist.
* Allow installing dependencies without actually building KaTeX
We have been using “npm install” to install dependencies, but since that
also does build KaTeX itself, it may fail if e.g. there are any style guide
violations. Now we only fetch dependencies but do not build KaTeX itself.
The make conditionals used here are not part of POSIX make but a GNU
extension. But we already use functionality not mandated by POSIX (namely
many of the functions like “wildcard”), so this should not make portability
any worse than it already is.
* Ensure bit depth 8
* Print affected file if PNG failed to read (e.g. due to wrong bit depth)
* Disable running Kern test case through TeX as doing so fails
Since boot2docker has been superseded by docker-machine, we need this to
support developers on OS X. The changes to the bash script ensure that we
clean up our containers even if taking screenshots gets hung and requires a
keyboard interrupt, as happens if the IP addresses were guessed incorrectly.
* Added check for type of expressions passed to parseTree function
* Added tests for bad input raising exception
* Added test for supported types NOT throwing exception
* Added test case for parser taking String objects
This adds a stamp file which is used to detect whether the `package.json`
file got updated since the last `npm install`. If so, `npm install` is run
again to update all modules to the version described in `package.json`.
This happens as a dependency of only those modules which actually need some
npm-installed module.
Setting the corresponding make variable to the empty string disables the
feature, which is used by the `make` invocation in the `prepublish` script
inside `package.json` to avoid infinite loops. It can also be used by
developers working in an environment with reduced connectivity, as long as
they know what they are doing.
Summary:
This diff provides support for Latin-1, Cyrillic, and CJK characters
inside \text{} groups. For Latin-1 and Cyrillic characters we use
glyph metrics from a glyph from Basic Latin that has roughly the same
bounding box. We use the metrics for a capital 'M' to approximate the
full-width CJK characters. Half-width characters are not supported yet.
Test Plan:
- make test
- make screenshots
Reviewers: emily
Sometimes a page might not be ready when the screenshot is taken, due to
fonts still being loaded or some such. In --verify mode this is taken care
of by repeated attempts. But when creating a screenshot for the first time,
it might be desirable to wait a given number of seconds for things to settle
down. So this commit introduces a --wait option to the screenshotter.
Summary:
I've been experimenting with delivering a TrueType-only KaTeX build for our mobile apps. I couldn't
get anything to render properly until I flipped the `format` specifier from `ttf` to `truetype`.
Though I can't find a definitive source on this, all the examples I've seen online use `truetype`
over `ttf`, and flipping from `ttf` to `truetype` fixed my own issues.
It's unlikely that this has been much of a problem in practice, since so many browsers now support
WOFF (I'm considering a TrueType-only build since it's the least common denominator across Android
4.3+ and mobile Safari).
Test Plan:
- To force TrueType rendering, comment out the `.use-eot`, `.use-woff2`, and `.use-woff` lines in `fonts.less`.
- Run `make serve`.
- Open up the demo page.
- Verify that the demo text is rendered as before (only the parens are noticeably different in the demo?).
Reviewers: kevinb, emily
Reviewed By: emily
Subscribers: benkomalo
Differential Revision: https://phabricator.khanacademy.org/D29274
This adds support for the following input sequences:
-- --- ` ' `` '' \degree \pounds \maltese
resulting in – — ‘ ’ “ ” ° £ ✠ symbols already present in our fonts.
As part of this modification, the recognition of multiple dashes was moved
from the lexer to the parser.
This is neccessary since in math mode a sequence of hyphens is just a
sequence of minus signs. Just like a pair of apostrophes in math mode is a
double prime not a right double quotation mark.
To make this easier, parseGroup and parseOptionalGroup have been merged.
This fixes a problem where the graceful-js dependency of the old less
version is incompatible with node 7, and will cause warnings on node 6.
The resulting katex.min.css is exactly the same as with the previous
version, so the major version upgrade does not seem to affect the outcome.
The less.Parser has been deprecated, and less.render is the supported
approach now, so we have to switch the development server to that.
* Introduce MacroExpander
The job of the MacroExpander is turning a stream of possibly expandable
tokens, as obtained from the Lexer, into a stream of non-expandable tokens
(in KaTeX, even though they may well be expandable in TeX) which can be
processed by the Parser. The challenge here is that we don't have
mode-specific lexer implementations any more, so we need to do everything on
the token level, including reassembly of sizes and colors.
* Make macros available in development server
Now one can specify macro definitions like \foo=bar as part of the query
string and use these macros in the formula being typeset.
* Add tests for macro expansions
* Handle end of input in special groups
This avoids an infinite loop if input ends prematurely.
* Simplify parseSpecialGroup
The parseSpecialGroup methos now returns a single token spanning the whole
special group, and leaves matching that string against a suitable regular
expression to whoever is calling the method. Suggested by @cbreeden.
* Incorporate review suggestions
Add improvements suggested by Kevin Barabash during review.
* Input range sanity checks
Ensure that both tokens of a token range come from the same lexer,
and that the range has a non-negative length.
* Improved wording of two comments
Summary: The KaTex renderer used to use old Khan Academy colors when displaying colored text. The configuration is now updated to have the new colors.
Test Plan:
- verified that colored text now uses the new colors in a browser
- running commands such as `\blueA{blueA}` will style the text in the blueA color from the configuration
Reviewers: emily, kevinb
Reviewed By: kevinb
Differential Revision: https://phabricator.khanacademy.org/D27963
Summary: We didn't have a rule for ignoring .sh files in the bower.json,
so it got included in the 0.6.0 release. Oops! This adds it to the
ignore file.
Test Plan:
- ???
Auditors: kevinb
Summary:
We prevent any precommit checks so that we don't have to include
a "Test Plan" etc. in the release commit message.
Test Plan:
- ./release.sh 0.6.0 0.7.0
Auditors: emily
Summary: Make the release script that's been floating around in my gists
for a while into a real script.
Test Plan:
- Comment out all the scary bits (the two pushes, and `npm
publish`), and run:
- `./release.sh 0.6.0`
- Checkout the `v0.6.0` tag, see that it successfully modified
package.json and bower.json to version 0.6.0, and built and committed
the rest of the files.
- `git tag -d v0.6.0`
- `./release.sh 0.6.0 0.7.0`
- Checkout master, see that it successfully made a commit bumping
package.json and bower.json to 0.7.0-pre.
Reviewers: @kevinbarabash
Summary: Looks like there was lint, but `make lint` wasn't failing on it
because it would just automatically fix it! This removes the `--fix`
from `eslint` and fixes the lint.
Test Plan:
- `make lint`
Auditors: kevinb
It looks like the `text-align: center` is affecting the text in sub and
superscripts. Fixes#447
Test Plan:
- Visit [this
example](http://localhost:7936/?text=x%5El_%7Bi%5E%7Bl%2B1%7D%2Bi%2C%20j%5E%7Bl%2B1%7D%2Bj%2C%20d%7D)
- Edit the HTML to add `<span class="katex-display">...</span>` around the
`<span class="katex">` node.
- See that the sub and superscripts are left-aligned, not centered
(It looks like we don't have a way to test this in the screenshotter for now)
@kevinb
Summary:
This only supports em and ex units and doesn't handle vertical layouts.
Negative kerning works.
Test Plan:
- make test
- make screenshots (verify that d is slightly overlapping c in the screenshots)
Reviewers: emily
Summary:
Alpert alerted me to the fact that \centerdot and \cdot are
not the same despite what MathJax thinks.
Test Plan:
- make serve
- load http://localhost:7936/
- see the `a \centerdot b` produces a small, bottom-aligned square
Auditors: alpert emily
Summary:
Update the symbol definition for \centerdot so that it does
the same thing as \cdot.
Fixes https://github.com/Khan/KaTeX/issues/421.
Test Plan:
- make serve
- open http://localhost:7936/
- verify that `a \centerdot b` looks the same as `a \cdot b`
Auditors: emily