Support for top-level \newline and \\ in inline math (#1298)

* 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
This commit is contained in:
Erik Demaine
2018-05-13 09:58:24 -04:00
committed by GitHub
parent bb1dc0c431
commit 4801ab875a
15 changed files with 116 additions and 23 deletions

View File

@@ -207,6 +207,14 @@ NegativeSpace:
NestedFractions: |
\dfrac{\frac{a}{b}}{\frac{c}{d}}\dfrac{\dfrac{a}{b}}
{\dfrac{c}{d}}\frac{\frac{a}{b}}{\frac{c}{d}}
NewLine: |
\frac{a^2+b^2}{c^2} \newline
\frac{a^2+b^2}{c^2} \\[1ex]
\begin{pmatrix}
a & b \\
c & d \cr
\end{pmatrix} \\
a+b+c+{d+\\e}+f+g
Not: |
\begin{array}{l}
\not=\not>\not\geq\not\in\not<\not\leq\not{abc} \\