Comments without terminating newlines, \href fixes, \url support (#1529)

* 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
This commit is contained in:
Erik Demaine
2018-07-31 14:13:30 -04:00
committed by GitHub
parent b73e43832b
commit 2202aa774f
9 changed files with 181 additions and 115 deletions

View File

@@ -18,6 +18,9 @@ You can provide an object of options as the last argument to [`katex.render` and
incorrect (especially in terms of vertical heights).
- `"unicodeTextInMathMode"`: Use of Unicode text characters in math mode.
- `"mathVsTextUnits"`: Mismatch of math vs. text commands and units/mode.
- `"commentAtEnd"`: Use of `%` comment without a terminating newline.
LaTeX would thereby comment out the end of math mode (e.g. `$`),
causing an error.
A second category of `errorCode`s never throw errors, but their strictness
affects the behavior of KaTeX:
- `"newLineInDisplayMode"`: Use of `\\` or `\newline` in display mode