* fix: Support `\let` via `macros` option
Issue #3737 turned out to be how we handled the return value of `expandOnce`.
We assumed that, if the return value isn't an `Array`, it's an
`instanceof Token`. This isn't necessary true with a user's `macros`
object, and given that we don't currently export `Token`, it's pretty
difficult to bypass.
Given that we never actually use the array return values from
`expandOnce`, I changed the return value for `expandOnce` to either a
`number` (to indicate the number of expanded tokens, so you could still
look up the tokens in the stack if you wanted to) or `false`
(to indicate no expansion happened). We can't use `0` for the latter
because an actual expansion might result in zero tokens.
The resulting code is arguably cleaner.
I also documented that `macros` can have object expansions, and
specified how to simulate `\let`.
Fixes#3737
* Revise macros documentation according to comments
* `\bar` examples weren't rendering correctly because of `\gdef\bar`
example when illustrating `\gdef` and `\xdef`.
* Improve `\bar` name to `\sqr` when defining squaring
(not necessary for fix, but improved naming).
* Fix `\def` scoping test that originally seemed related.
Fixes#3803
* feat: Support \Braket, \set, and \Set
* Update screenshots.
* Rewrite to redefine | via macros
* Update screenshot after merge
* Rename \bra@ket@one -> \bra@set
* Fix spacing in \set and \Set to match braket.sty
* Add || and \| support
* Update tests
* Update screenshots
Co-authored-by: Ron Kok <ronkok@comcast.net>
* feat: Support Unicode (sub|super)script characters
* Acquire tokens via repeated fetch()
* Match more Unicode (sub|super)script characters
* Update docs with new characters
* Add Greek characters to RegEx
* Pick up review comments
Co-authored-by: Erik Demaine <edemaine@mit.edu>
* Apply operator spacing to Unicode ∙ ∘ ∖
* Appease Semantic Versioning.
* Fix website build issue
* Tweak docs to space final bin correctly
Co-authored-by: Erik Demaine <edemaine@mit.edu>
* Better doc for `globalGroup`
* Mention `globalGroup` in `macros`
* Example uses `macros` argument passed to multiple examples
* Include `renderToString` example that sets `macros`
Co-authored-by: Erik Demaine <edemaine@mit.edu>
* feat: \nonumber and \notag support
Support `\nonumber` (and equivalent `\notag`) using a global macro
`\@eqnsw` to track whether one occurs in each row, similar to how
amsmath uses global `\@eqnswtrue`/`\@eqnswfalse`.
Fix#2950
* Remove duplicate mention of align*
* Working version of \tag within {align}
* Simpler subparse mechanism
* Fix flow errors, clarifying set-to-undefined
* Document that \tag works in rows
* Add screenshot tests
* Add Jest tests
* Add Safari screenshot
* Commit message about fixing \tag
Fixes#2379
* Apply suggestions from code review
Co-authored-by: ylemkimon <y@ylem.kim>
* Revise and move getAutoTag
* Fix handling of split
* Remove unnecessary feedTokens
Co-authored-by: ylemkimon <y@ylem.kim>
Co-authored-by: ylemkimon <y@ylem.kim>
* feat: implement \relax as no-op function
BREAKING CHANGE: `\relax` is now implemented as a function. It'll stop
expansions and parsing, so the behavior around `\relax` may change.
For example, `\kern2\relax em` will no longer work.
# [0.14.0](https://github.com/KaTeX/KaTeX/compare/v0.13.24...v0.14.0) (2021-10-30)
### Features
* conditionally export ECMAScript modules ([#3377](https://github.com/KaTeX/KaTeX/issues/3377)) ([15ee9b4](15ee9b4a5a))
### BREAKING CHANGES
* With module loaders that support conditional exports
and ECMAScript modules, `import katex from 'katex';` will import the
ECMAScript module.
You can now use:
|Before |After |
|------------------------------------------|----------------------------------|
|`require('katex/dist/contrib/[name].js')` | `require('katex/contrib/[name]')`|
|`import katex from 'katex/dist/katex.mjs'`| `import katex from 'katex'` |
|`import 'katex/dist/contrib/[name].mjs'` | `import 'katex/contrib/[name]'` |
* feat: conditionally export ECMAScript modules
BREAKING CHANGE: With module loaders that support conditional exports
and ECMAScript modules, `import katex from 'katex';` will import the
ECMAScript module.
You can now use:
|Before |After |
|------------------------------------------|----------------------------------|
|`require('katex/dist/contrib/[name].js')` | `require('katex/contrib/[name]')`|
|`import katex from 'katex/dist/katex.mjs'`| `import katex from 'katex'` |
|`import 'katex/dist/contrib/[name].mjs'` | `import 'katex/contrib/[name]'` |