WGUNDERWOOD / tex-fmt

An extremely fast LaTeX formatter written in Rust
MIT License
272 stars 20 forks source link

Add more test cases #13

Open WGUNDERWOOD opened 3 months ago

WGUNDERWOOD commented 3 months ago

More test cases are always appreciated, to ensure that tex-fmt is behaving correctly, to understand the performance on different documents, and to prevent regressions.

cdesaintguilhem commented 1 month ago

Hi, I noticed that the current version doesn't look at sectioning commands.

For example, the following snippet:

\section{Introduction}

If a sectioning command is on the first line, it should remain there.
\subsection{Related Works}
However, a sectioning command in the middle of the file should have an empty line before it.
Also, these commands should be on their own line.\subsection{Our Contributions}And another.\subsection{Outline}

\section{Preliminaries}
However a well-formatted sectioning command should not move.

only gets line-wrapped into:

\section{Introduction}

If a sectioning command is on the first line, it should remain there.
\subsection{Related Works}
However, a sectioning command in the middle of the file should have
an empty line before it.
Also, these commands should be on their own line.\subsection{Our
Contributions}And another.\subsection{Outline}

\section{Preliminaries}
However a well-formatted sectioning command should not move.

Whereas it should perhaps be formatted to:

\section{Introduction}

If a sectioning command is on the first line, it should remain there.

\subsection{Related Works}
However, a sectioning command in the middle of the file should have
an empty line before it.
Also, these commands should be on their own line.

\subsection{Our Contributions}
And another.

\subsection{Outline}

\section{Preliminaries}
However a well-formatted sectioning command should not move.

If this would be a useful test to include, I could make a PR into develop with the corresponding .tex documents.

WGUNDERWOOD commented 1 month ago

Thanks for this! I agree that commands such as \section{} should go on their own line, so I would be happy to look into an implementation of this. However I think we should not insert extra blank lines, as this may disturb other formatting in the document. For example, sometimes such blank lines may contain a single comment symbol %.