Skip to content

Commit

Permalink
LaTeX reader: improve mathEnvWith.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jgm committed Jun 14, 2022
1 parent 54b20e5 commit b263f38
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Text/Pandoc/Readers/LaTeX/Math.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/command/3113.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
]
]
```
Expand Down
3 changes: 2 additions & 1 deletion test/command/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ x &= y\\
\(5-67\)
\[\begin{aligned}
x &= y\\\end{aligned}\]
x &= y\\
\end{aligned}\]
\emph{hi}
Expand Down

0 comments on commit b263f38

Please sign in to comment.