Skip to content

LaTeX reader: fix spurious paragraph breaks in math environments#11265

Merged
jgm merged 1 commit intojgm:mainfrom
emmanuel-ferdman:main
Nov 4, 2025
Merged

LaTeX reader: fix spurious paragraph breaks in math environments#11265
jgm merged 1 commit intojgm:mainfrom
emmanuel-ferdman:main

Conversation

@emmanuel-ferdman
Copy link
Contributor

PR Summary

When trailing spaces appeared before \end{equation} or \end{align}, pandoc incorrectly inserted blank lines in the output, breaking the math environment. This occurred because mathEnv used stripTrailingNewlines which only removed newlines but left spaces. The fix changes to trimr which removes all trailing whitespace (spaces, tabs, and newlines).

Example input:

\begin{equation}
 a
 \end{equation}

Outpt before (broken):

\begin{equation}
 a

\end{equation}

Spurious blank line creates paragraph break
Output after (fixed):

\begin{equation}
 a
\end{equation}

Note: The added tests may be a bit too specific, but I included them for completeness. Let me know if we should drop them.

Fixes #11257.

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
@jgm
Copy link
Owner

jgm commented Nov 4, 2025

Looks good, thanks!

@jgm jgm merged commit b106dca into jgm:main Nov 4, 2025
11 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extra paragraph break before \end{equation} in LaTeX reader

2 participants