* 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
* 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
* 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
* Tag sketch
* Drop objectAssign; already using Object.assign elsewhere
* Basic \gdef support
* Bug fix
* Finish \tag
* MathML numbers equations with <mlabeledtr>
* Fix flow bugs
* \gdef tests
* Add basic \tag tests
* Screenshot test for \tag
* \tag* test
* Add missing file
* Bug fix screenshot
* Major refactor
* Represent tag at top level of parse tree, requiring less hackery
* No more \@tag function; it was essentially just doing \text
* Wrap tag in group so e.g. ( and ) are formatted the same
* Add `feed` method to MacroExpander for multiple inputs (for tag)
* Bug fixes in buildHTML, makeTextRow, _getBuilt (for display mode)
* Remove excess <mrow> wrapper when unnecessary
* Update screenshot from tag being wrapped in group
* Add maxExpand limit
* Move test helpers into common modules
* helpers.js gets all the helper functions
* setup.js gets the common Jest setup (serializer, expect extensions)
* Exclude test from coverage testing
* @ylemkimon's comments: parsing -> building, settings || defaultSettings
* Default argument for settings
* Fix lint errors
* @ylemklemon's comment: use buildAndSetResult
* Use template literals
Change symbol parsing to allow all Unicode symbols when the appropriate strict setting allows it. By default, this allows all symbols, but the user will get (probably two) warnings about them.
* Strict setting controls \newline display-mode behavior
* Bug-fix space handling in macros
Whitespace after a \controlWord is now handled within the lexer, not by the
MacroExpander. This way, \\ expanding to \newline doesn't accidentally
cause spaces to get consumed.
* Rename nonstrict -> reportNonstrict; strictBehavior -> useStrictBehavior
* Second category of errorCodes
* Implement strict mode (replacing unicodeTextInMathMode)
Add new "strict" setting (default value false) that can take a boolean
(whether to throw an error or silently ignore), string ("ignore",
"warn", or "error"), or a function possibly returning such a value.
This enables a variety of ways of handling or ignoring transgressions
from "true" LaTeX behavior, making KaTeX easier to use while still
providing the ability for strict LaTeX adherance.
Resolve#1226, implementing that spec, for two existing
transgressions from regular LaTeX:
* src/functions/kern.js had some errors and warnings about use of
(units in) math vs. text mode commands.
* The former setting unicodeTextInMathMode (not in any released version)
needed to be set to true to enable Unicode text symbols in math mode.
Now these are controlled by the strict setting. By default, KaTeX is now
very permissive, but if desired, the user can request warnings or errors.
* Rewrite strict description
* Add tests for strict functions
* Stricter type for strict
* Switch default strict setting to "warn"
* Fix new flow error
* Fix another flow bug
* Support for top-level \newline and \\ in inline math
This was a little tricky because `\\` was defined as an endOfExpression.
Instead made `\\` a termination specific to an array environment.
Outside an array environment, buildHTML handles the `cr` object,
resulting in a `.newline` class. Currently this turns into a
`display: block` (with appropriate vertical spacing) only in inline math,
matching LaTeX.
* Simplify code
* Fix Jest errors
* NewLine screenshot test
* Bug fix: \\ only works at top level of inline
* Add \newline and \cr to test
* Switch test to pmatrix
* Add vertical space test
* Add \\ vs. \newline tests
* Fix flow errors
* Add \cr test
* Add documentation for \\ at top level
* Comment out newRow
* Fix commenting out
* Line breaks for inline formulas
* Basic support for \allowbreak and \nobreak
* Fix spacing around \nobreak, and add documentation
* Backwards-compatibility _getBuilt to fix tests
* Put operator spacing on same line as operator
* One approach to ~
* Simplify \allowbreak/\nobreak, make ~/\nobreakspace prevent line breaks
* Adapt to #1295
* Prevent wrapping within a .base
* Implement \hspace* properly
* Fix flow error
* Update comment for regularSpace
* Update screenshots
* Move `width: min-content` from .katex into .base
* Fix screenshot
* Add min-width rule to .vlist-s
* Factor out hasClass method
* Cleanup nobreak test
* Pull out buildHTMLUnbreakable
* Fix \hspace* test (no longer the same as \hspace)
* Fix \nobreak handling
* Add screenshot test
* Fix \underbrace
Fix the vertical alignment so that it correctly takes into account the descender of the lower element.
Fixes issue 1303.
* Update screenshots
* Revert frac-lines to borders
This PR reverts the rendering of frac-lines from SVG paths back to span borders. This solves the thick grey bar reported by @mbourne in issue #1173.
The result is a frac-line similar to KaTeX v0.9.0-alpha1. The frac-lines are span borders and the CSS contains a `min-width: 1px;` rule to keep those borders visible.
There is one difference between this PR and v0.9.0-alpha1. The earlier work contained a second CSS rule:
```
@media screen and (-webkit-min-device-pixel-ratio: 2), screen and (min-resolution: 192dpi) {
.katex.mfra.fracline {
min-height:0.5px;
}
}
That second CSS rule did not help much. Instead, it caused some lines to disappear. In the thread to issue 1173, people tested the rendering from the proposed approach and reported that frac-lines disappeared only at sized that were already too small to read.
* Fix lint errors
* Remove superfluous SVG paths.
* Remove superfluous CSS
* Removed `rulespan` from `stretchy.js`
* Support Unicode \ll and \lll
Fixes issue #1271
* Fix indent
* update screenshots for fracLineBorder
* Update Arrays-chrome screenshot for fracLineBorder
* Support Unicode \ll and \lll
Fixes issue #1271
* Adjust \underset alignment and spacing
Fixes issue #1288.
1. Fixes vertical alignment by keeping the base element on the baseline.
2. Assigns horizontal spacing to \underset in a manner that aligns with LaTeX `\binrel`
* Fix flow error
* Add comment
* Allow for shift of mathops
* Update screenshots
* Test for nested ordgroups
* Set \stackrel spacing class to mrel
* Fix lint error
* Better determination of atom type
* Add comment.
* Add `suppressBaseShift` to ParseNodeTypes
* Make ParseNode `value` payload type-safe.
* Make defineFunction handlers aware of ParseNode data types.
* Add `type` to all function definitions to help determine handler return type.
* Added unit test for case caught only in screenshot test and fixed issue.
* Rename some symbol `Group`s to avoid conflicts with `ParseNode` groups.
Symbol `Group`s are also used as `ParseNode` types. However, `ParseNode`s of
these types always contain a raw text token as opposed to any structured
content. These `ParseNode`s are passed as arguments into function handlers to
create more semantical `ParseNode`s with more structure.
Before this change, "accent" and "op" were both symbol `Group`s and `ParseNode`
types. With this change, these two types (the raw accent token `ParseNode`, and
the structured semantical `ParseNode` are separated for better type-safety on
the `ParseNode` payload).
* stretchy: Remove FlowFixMe for a forced typecast that's no longer needed.
* 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
* \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
* 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
* 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
* 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
* 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.
* 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
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.
* 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
* 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`
* 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
* 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
* Support Reaction Arrows
This PR is written to supply reaction arrows for a future `mhchem` extension. `mhchem` uses seven reaction arrows. Four of them correspond to extensible arrows already available in KaTeX. This PR creates the other three.
These arrows will also be useful to chemists writing about reactions when `mhchem` is unavailable.
Three new extensible arrows are introduced: `\xrightleftarrows`, `\xrightequilibrium`, and `\xleftequilibrium`.
These names are not `mhchem`’s user-facing function names. In `mhchem`, users would call these arrows with syntax such as: `\ce{A<-->B}`, or `\ce{A<=>>B}`, or `\ce{A<<=>B}`. I’ve provided names that look more like the other extensible arrow names. That’s probably worth some discussion.
* generate screenshots for ReactionArrows
* Increase overlap in arrow shaft
To prevent a small gap when rendering in very large font sizes.
* Adjust upper text vert alignment. Add warning.
* Limit alignment adjustment to \xleftequilibrium
* generate screenshots for reaction arrows
* Enable spacing functions in text mode
Spacing functions such as `\;` or `\quad` should be accepted in either math mode or text mode
* Add tests
* Fix tests
* Fix lint error