Fix #337 - Array/Matrix trim trailing empty line (#479)

This commit is contained in:
Christopher
2017-09-16 19:44:26 -05:00
committed by Kevin Barabash
parent db1cccdeab
commit 6e75ebdc2d
5 changed files with 13 additions and 0 deletions

View File

@@ -96,6 +96,14 @@ function parseArray(
if (next === "&") { if (next === "&") {
parser.consume(); parser.consume();
} else if (next === "\\end") { } else if (next === "\\end") {
// Arrays terminate newlines with `\crcr` which consumes a `\cr` if
// the last line is empty.
const lastRow = body[body.length - 1][0].value;
if (body.length > 1
&& lastRow.value.length === 1
&& lastRow.value[0].value.length === 0) {
body.pop();
}
break; break;
} else if (next === "\\\\" || next === "\\cr") { } else if (next === "\\\\" || next === "\\cr") {
const cr = parser.parseFunction(); const cr = parser.parseFunction();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@@ -38,6 +38,11 @@ ArrayMode:
\end{matrix} \end{matrix}
display: 1 display: 1
ArrayType: 1\begin{array}{c}2\\3\end{array}4 ArrayType: 1\begin{array}{c}2\\3\end{array}4
ArrayRemoveEmptyLine: |
\begin{pmatrix}
1 \\
2 \\
\end{pmatrix}
Baseline: a+b-c\cdot d/e Baseline: a+b-c\cdot d/e
BasicTest: a BasicTest: a
BinCancellation: | BinCancellation: |