豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
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
Copy Markdown
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
Copy Markdown
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