From ebf6bf5b50a98ac6c5aca1896c0a6ba985c1c91c Mon Sep 17 00:00:00 2001 From: Ron Kok Date: Sat, 22 Oct 2022 09:08:34 -0700 Subject: [PATCH] fix: \hline after \cr (#3735) Support `\hline` when it occurs after a `\cr` within an environment Fixes #3734 --- src/environments/array.js | 5 +++++ test/katex-spec.js | 1 + 2 files changed, 6 insertions(+) diff --git a/src/environments/array.js b/src/environments/array.js index f39a7352c8..bd726f516b 100644 --- a/src/environments/array.js +++ b/src/environments/array.js @@ -39,6 +39,11 @@ function getHLines(parser: Parser): boolean[] { const hlineInfo = []; parser.consumeSpaces(); let nxt = parser.fetch().text; + if (nxt === "\\relax") { // \relax is an artifact of the \cr macro below + parser.consume(); + parser.consumeSpaces(); + nxt = parser.fetch().text; + } while (nxt === "\\hline" || nxt === "\\hdashline") { parser.consume(); hlineInfo.push(nxt === "\\hdashline"); diff --git a/test/katex-spec.js b/test/katex-spec.js index 5dcb069b2d..985bf64734 100644 --- a/test/katex-spec.js +++ b/test/katex-spec.js @@ -1266,6 +1266,7 @@ describe("A begin/end parser", function() { it("should parse an environment with hlines", function() { expect`\begin{matrix}\hline a&b\\ \hline c&d\end{matrix}`.toParse(); + expect`\begin{matrix}\hline a&b\cr \hline c&d\end{matrix}`.toParse(); expect`\begin{matrix}\hdashline a&b\\ \hdashline c&d\end{matrix}`.toParse(); });