cmhughes / latexindent.pl

Perl script to add indentation (leading horizontal space) to LaTeX files. It can modify line breaks before, during and after code blocks; it can perform text wrapping and paragraph line break removal. It can also perform string-based and regex-based substitutions/replacements. The script is customisable through its YAML interface.
GNU General Public License v3.0
894 stars 84 forks source link

Double backslash regex does not match decimals #564

Open danrr opened 1 month ago

danrr commented 1 month ago

Please provide the following when posting an issue:

original .tex code

\begin{pmatrix}
1 & 2 \\[0.2cm] 3 & 4
\end{pmatrix}

yaml settings

modifyLineBreaks:
    environments:
        DBSFinishesWithLineBreak: 1

actual/given output

\begin{pmatrix}
    1         & 2 \\
    [0.2cm] 3 & 4
\end{pmatrix}

desired or expected output

\begin{pmatrix}
    1         & 2 \\[0.2cm]
        3 & 4
\end{pmatrix}

anything else

The regex for doubleBackSlash does not pick up decimals https://github.com/cmhughes/latexindent.pl/blob/78d452f8fc359d828e2c8a4cac0d2c6fc92d2967/defaultSettings.yaml#L655. See https://regex101.com/r/KkFe4h/1.

Something like \\\\(?:\h*\[\h*(?:\d+\.)?\d+\h*[a-zA-Z]+\h*\]) seems to work better. See https://regex101.com/r/Wq1fZw/1.

cmhughes commented 1 month ago

Great, thanks! You can adjust fine tuning in your local yaml.

If you'd like to submit a pull request, feel free!