From b263f383040618ff991912512ccd396b83d43da5 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 13 Jun 2022 23:14:51 -0600 Subject: [PATCH] LaTeX reader: improve mathEnvWith. When converting e.g. an align environment to an aligned environment inside a Math element, we need to include a newline before the `\end{aligned}`, since the previous line might end in a comment. Closes #8122. --- src/Text/Pandoc/Readers/LaTeX/Math.hs | 2 +- test/command/3113.md | 2 +- test/command/macros.md | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Text/Pandoc/Readers/LaTeX/Math.hs b/src/Text/Pandoc/Readers/LaTeX/Math.hs index 9f3d6fe53..92f41910b 100644 --- a/src/Text/Pandoc/Readers/LaTeX/Math.hs +++ b/src/Text/Pandoc/Readers/LaTeX/Math.hs @@ -65,7 +65,7 @@ mathEnvWith f innerEnv name = f . mathDisplay . inner <$> mathEnv name where inner x = case innerEnv of Nothing -> x Just y -> "\\begin{" <> y <> "}\n" <> x <> - "\\end{" <> y <> "}" + "\n\\end{" <> y <> "}" mathEnv :: PandocMonad m => Text -> LP m Text mathEnv name = do diff --git a/test/command/3113.md b/test/command/3113.md index 7452995b5..7746ec14f 100644 --- a/test/command/3113.md +++ b/test/command/3113.md @@ -11,7 +11,7 @@ E&=&F [ Para [ Math DisplayMath - "\\begin{aligned}\nA&=&B,\\\\\nC&=&D,\\\\\n%\\end{eqnarray}\n%\\begin{eqnarray}\nE&=&F\\end{aligned}" + "\\begin{aligned}\nA&=&B,\\\\\nC&=&D,\\\\\n%\\end{eqnarray}\n%\\begin{eqnarray}\nE&=&F\n\\end{aligned}" ] ] ``` diff --git a/test/command/macros.md b/test/command/macros.md index 9f7a0f9d3..86f10ea1b 100644 --- a/test/command/macros.md +++ b/test/command/macros.md @@ -62,7 +62,8 @@ x &= y\\ \(5-67\) \[\begin{aligned} -x &= y\\\end{aligned}\] +x &= y\\ +\end{aligned}\] \emph{hi}