Add length and rawError as public parameters of ParseError to allow for richer error UIs in editors. This information was already there, but only encoded into the errors message. This change is purely additional, the existing parameters have not changed.
* 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
Fix `src/functions/cr.js`'s definition of `\\` to manually look for an
optional argument via `future()` instead of `numOptionalArgs`, so that
it does *not* skip over spaces. This matches the existing behavior of
`\\` in `src/environments/array.js` and AMSMath's behavior of `\math@cr`
via `\new@ifnextchar`.
Fixes#3745
Co-authored-by: Ron Kok <ronkok@comcast.net>
* Update quoted error message
This page didn't appear for me when searching for "No character metrics". I then stumbled onto it, and it's quite useful
* Update broken link
metrics/extract_ttfs.py does not exist, and it's not the "root" of the metric-generation stuff
* fix(auto-render): concatenate text nodes
Concatenate successive text nodes to prevent auto-render from skipping
math input when browsers split text nodes with long textContent.
* Remove siblings only when math found
Only remove siblings when math expressions were found to prevent removal
of nodes that do not contain math.
* Skip siblings if they do not contain math
* Fixed typo in comments
* Added first tests for large test nodes
* Expanded testing to compare renderMathInElement with renderMathInText
* Simplified text node test
* Change description of test
* Update contrib/auto-render/auto-render.js
Co-authored-by: marcoesters <marco.esters@duke.edu>
Co-authored-by: ylemkimon <y@ylem.kim>
The previous link is deprecated, I'm pretty sure the new link directs to what is intended, but I was not here before that link broke.
Co-authored-by: ylemkimon <y@ylem.kim>
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
Co-authored-by: ylemkimon <y@ylem.kim>
* Upgrade to yarn 4.0.0-rc.14
Adds support for Node 18
* Upgrade CI to Node 16
* Update website/yarn.lock
* pnpIgnorePatterns for subproject
* Switch to stable Yarn 3.2.2
* copy-tex: Use JS to select full equation instead of CSS
* remove CSS
* Update webpack.common.js
* more build tweaks
* Update contrib/copy-tex/copy-tex.js
Co-authored-by: Erik Demaine <edemaine@mit.edu>
* Document new behavior
BREAKING CHANGE: copy-tex extension no longer has (or requires) a CSS file.
* Code cleanup, lint fixes, port to Flow
* Rewrite to extend both start and end of range
* Remove contrib/**/*.css linting
Co-authored-by: Erik Demaine <edemaine@mit.edu>
* 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>