* feat: Allow text-mode accents in math mode, except in strict mode
LaTeX only issues a warning when using e.g. `\r` in math mode.
KaTeX will now do the same with the default `strict` setting of `warn`.
Fixes#2983
* Fix accent mode
Co-authored-by: ylemkimon <y@ylem.kim>
* Bump flow version
* Bump jest version
* Bump eslint version
* Bump rollup version
* Bump webpack version
* Bump misc dependencies and update lockfile
* Update lockfile
* Bump commander version
* Bump misc dependencies
* Bump istanbul version
* Bump docusaurus version
* Update lockfile
* Explicitly declare dependencies
* Bump caniuse-lite version
* Update lockfile
* Bump commander version
* Bump webpack and css-loader version
* Bump flow version
* Remove double encoding in MathML via Unicode MathML spaces
We used to have a complex mechanic for escaping strings, marking them as
`needsEscape = false`, and then not escaping those strings (for
combining strings in `\operatorname`). But this doesn't really work
with `render`ing directly to a node, as `document.createTextNode` can't
be stopped from escaping.
I've thus removed this mechanic, which required the following changes:
* Switch MathML "smart space" encoding to use Unicode instead of
`&LongNames;` (which weren't working with `render` for the same reason).
* Hack our HTML/MathML serializer to not use `String.trim`, which wrecks
havoc with emitted Unicode spaces.
Now `toText()` doesn't escape, so strings concatenate in unescaped form,
and `toHTML()` only does the necessary escaping. Thus fix#1782.
* Fix src/utils.js
Co-Authored-By: edemaine <edemaine@mit.edu>
* Fix src/mathMLTree.js documentation
Co-Authored-By: edemaine <edemaine@mit.edu>
* Remove trim hack thanks to diffable-html@4.0.0
* Switch back to jest-serializer-html
* Update mathMLTree.js
* Comments without terminating newlines in nonstrict mode
Fix#1506 by allowing single-line comments (`%` without terminating newline)
in nonstrict mode. `Lexer` and `MacroExpander` now store the `Settings`
object, so the `Lexer` can complain about missing newline according to the
`strict` setting. I filtered this out from the snapshot tests with a slightly
different `replacer`.
* Reimplement \href like \verb, add \url
Major restructuring to lex URL arguments differently, e.g. to support
`\href%{hello}` and `\href{http://foo.com/#test%}{hello}`. The new URL
parsing code is simpler, but involves a special case in `parseSymbol`
like `\verb`.
Also add support for `\url` while we're here.
* Cleanup
* Fix flow errors and improve error messages
* Add \url to documentation
* Improve doc formatting
* Refactor test helpers
* Combine common codes from `parse` and `build`, and dispatch using
`Mode`
* Remove `toNotBuild` and `toNotParse` and use `expect.not`
* Remove `Warning` and instead mock `console.warn`
* Add `expect.toHavePassed` and check whether parse/build succeeded
lazily
* Improve failed test `message`:
- Use color
- Print stack traces(excluding internals)
- Print diff
- Follow jest matcher output style
* Update helpers.js
* Remove toBeTruthy checks
getParsed throws an error if parsing fails.
* Used tagged literals
* Use .toHaveLength
* Use tagged literals
* Use to{Build,Parse}Like where possible
* Remove compareParseTree
* Use snapshot where possible
* Join into one line where <88 chars
* Revert console.warn() to throw an error
Merge `expectToWarn` to `expectKaTeX`, like
`expect.toFailWithParseError`
* Remove call to console.warn from stack traces
* Fix merge errors
* Remove `getTree`
* Move `_getBuilt` into `getBuilt`
* Move default settings and tagging literal support in to `getParsed`
and `getBuilt`
* Remove stack traces clean-up
* Remove `toHavePassed` matcher
* Extract `expected` string construction into `printExpectedResult`
* \newcommand, \renewcommand, \providecommand
* Tests
* Add comment
* Add symbols to the set of already defined things
* Add implicitCommands, catch \hline outside array
* Add \relax
* Move isDefined to be a method of MacroExpander
* Namespace.has
* Reword error messages
* Add \hdashline given #1407
* 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
* 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