Skip to content

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

@hanwenzhu

Description

@hanwenzhu

Explain the problem.

In the LaTeX reader, if an \end{equation} (or \end{align}, etc.) is preceded by a space, then a spurious paragraph break \n \n is inserted in the display math environment, which completely breaks the output.

This is likely caused by a combination of b263f38, and this line

return $ stripTrailingNewlines $ untokenize res
not actually stripping the final whitespace because the inner math content ends in a space and not a newline.

To reproduce:

Command: pandoc -f latex -t latex

Input:

\begin{equation}
  a
 \end{equation}

(Note the space before \end{equation})

Output:

\begin{equation}
  a
 
\end{equation}

Expected output: no paragraph break.

Pandoc version?
I can reproduce it on https://pandoc.org/try/.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions