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
884 stars 84 forks source link

textwrap not working correctly #487

Closed RitschAlex closed 1 year ago

RitschAlex commented 1 year ago

Please provide the following when posting an issue:

original .tex code

\section{Einleitung}
Seit 2010 hat sich die Anzahl der psychischen Erkrankungen und die damit verbundenen Fehltage um 56\% erhöht. Laut dem Fehlzeiten-Report 2022 des wissenschaftlicehn Instituts der AOK (WIdO) stellen dars
\subsection{Problemstellung}
\subsection{Zielsetzung}
\subsection{Aufbau der Arbeit}

yaml settings

textWrapOptions:
    columns: 20
    multipleSpacesToSingle: 1              
    removeBlockLineBreaks: 1
    when: before                        # before/after
    comments: 
       wrap: 0                          # 0/1
       inheritLeadingSpace: 0           # 0/1
    blocksFollow:
       headings: 1                      # 0/1
       commentOnPreviousLine: 1         # 0/1
       par: 1                           # 0/1
       blankLine: 1                     # 0/1
       verbatim: 1                      # 0/1
       filecontents: 1                  # 0/1
       other: \\\]|\\item(?:\h|\[)      # regex
    blocksBeginWith:
       A-Z: 1                           # 0/1
       a-z: 1                           # 0/1
       0-9: 0                           # 0/1
       other: 0                         # regex
    blocksEndBefore:
       commentOnOwnLine: 1              # 0/1
       verbatim: 1                      # 0/1
       filecontents: 1                  # 0/1
       other: \\begin\{|\\\[|\\end\{    # regex
    huge: overflow                      # forbid mid-word line breaks
    separator: ""

actual/given output

INFO: latexindent.pl version 3.23.2, 2023-09-23, a script to indent .tex files latexindent.pl lives here: C:/Users/ritsc/AppData/Local/Programs/MiKTeX/scripts/latexindent/ Sun Oct 8 01:44:15 2023 Filename: .\Datenanalyse\Chapters\Einleitung.tex INFO: Processing switches: -m|--modifylinebreaks: modify line breaks INFO: Directory for backup files and indent.log: .\Datenanalyse\Chapters INFO: Perl modules are being loaded from the following directories: C:/Strawberry/perl/lib/FindBin.pm C:/Strawberry/perl/vendor/lib/YAML/Tiny.pm C:/Strawberry/perl/lib/File/Copy.pm C:/Strawberry/perl/lib/File/Basename.pm C:/Strawberry/perl/lib/Getopt/Long.pm C:/Strawberry/perl/vendor/lib/File/HomeDir.pm INFO: LatexIndent perl modules are being loaded from, for example: C:/Users/ritsc/AppData/Local/Programs/MiKTeX/scripts/latexindent/LatexIndent/Document.pm INFO: YAML settings read: defaultSettings.yaml Reading defaultSettings.yaml from C:/Users/ritsc/AppData/Local/Programs/MiKTeX/scripts/latexindent/defaultSettings.yaml INFO: YAML reading settings Home directory is C:\Users\ritsc latexindent.pl didn't find indentconfig.yaml or .indentconfig.yaml see all possible locations: https://latexindentpl.readthedocs.io/en/latest/sec-appendices.html#indentconfig-options) INFO: Phase 1: searching for objects INFO: Phase 2: finding surrounding indentation INFO: Phase 3: indenting objects INFO: Phase 4: final indentation check INFO: Output routine: Not outputting to file; see -w and -o switches for more options.

INFO: Please direct all communication/issues to: https://github.com/cmhughes/latexindent.pl

\section{Einleitung}
Seit 2010
hat sich
die
Anzahl
der
psychischen
Erkrankungen
und die
damit
verbundenen
Fehltage
um 56\%
erhöht.
Laut dem
Fehlzeiten-Report
2022 des
wissenschaftlicehn
Instituts
der AOK
(WIdO)
stellen
\subsection{Problemstellung}
\subsection{Zielsetzung}
\subsection{Aufbau der Arbeit}

desired or expected output

\section{Einleitung}
Seit 2010 hat sich die Anzahl der psychischen Erkrankungen und 
die damit verbundenen Fehltage um 56\% erhöht. 
Laut dem Fehlzeiten Report 2022 des wissenschaftlicehn Instituts der AOK (WIdO) stellen
\subsection{Problemstellung}
\subsection{Zielsetzung}
\subsection{Aufbau der Arbeit}

anything else

I would like the text wrapping behave like the Example 78 in the documentation. I'm using neovim with null-ls and with the standard defaultSettings.yaml the text gets always formatted like shown above.

cmhughes commented 1 year ago

Can you show the actual output? (not the log file)

RitschAlex commented 1 year ago

The actual output is the original .tex code above. My original .tex code is just one long sentence without text wrapping in Windows Terminal:

\section{Einleitung}
Seit 2010 hat sich die Anzahl der psychischen Erkrankungen und die damit verbundenen Fehltage um 56\% erhöht. Laut dem Fehlzeiten-Report 2022 des wissenschaftlicehn Instituts der AOK (WIdO) stellen dars
\subsection{Problemstellung}
\subsection{Zielsetzung}
\subsection{Aufbau der Arbeit}
cmhughes commented 1 year ago

Using the settings

modifyLineBreaks:
   textWrapOptions:
       columns: 20

gives the following

\section{Einleitung}
Seit 2010 hat sich
die Anzahl der
psychischen
Erkrankungen und
die damit
verbundenen
Fehltage um 56\%
erhöht. Laut dem
Fehlzeiten-Report
2022 des
wissenschaftlicehn
Instituts der AOK
(WIdO) stellen dars
\subsection{Problemstellung}
\subsection{Zielsetzung}
\subsection{Aufbau der Arbeit}
cmhughes commented 1 year ago

The above YAML settings are given in https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html#lst-textwrap1-yaml