summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-06-05 23:23:10 +0000
committerKarl Berry <karl@freefriends.org>2017-06-05 23:23:10 +0000
commitd024b5690e678248a097a1b55231af47c09328e1 (patch)
treea4fd859c9e19baa4bb31438bdbe452951f5fa23e /Master
parent54b6d43a181a1c487ee932cb9eb9d70344ab4b47 (diff)
latexindent (28may17)
git-svn-id: svn://tug.org/texlive/trunk@44492 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/bin/win32/latexindent.exebin6282983 -> 6290991 bytes
-rw-r--r--Master/texmf-dist/doc/support/latexindent/README2
-rw-r--r--Master/texmf-dist/doc/support/latexindent/appendices.tex5
-rw-r--r--Master/texmf-dist/doc/support/latexindent/latexindent.pdfbin524590 -> 565222 bytes
-rw-r--r--Master/texmf-dist/doc/support/latexindent/latexindent.tex127
-rw-r--r--Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex41
-rw-r--r--Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex2
-rw-r--r--Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex280
-rw-r--r--Master/texmf-dist/doc/support/latexindent/subsec-commands-and-their-options.tex2
-rw-r--r--Master/texmf-dist/doc/support/latexindent/subsec-conflicting-poly-switches.tex2
-rw-r--r--Master/texmf-dist/doc/support/latexindent/subsubsec-environments-and-their-arguments.tex4
-rw-r--r--Master/texmf-dist/doc/support/latexindent/subsubsec-no-add-remaining-code-blocks.tex4
-rwxr-xr-xMaster/texmf-dist/scripts/latexindent/LatexIndent/Command.pm2
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm13
-rwxr-xr-xMaster/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm2
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/FileContents.pm2
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm39
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/Heading.pm17
-rwxr-xr-xMaster/texmf-dist/scripts/latexindent/LatexIndent/IfElseFi.pm2
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/Indent.pm3
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/Item.pm4
-rwxr-xr-xMaster/texmf-dist/scripts/latexindent/LatexIndent/KeyEqualsValuesBraces.pm2
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm4
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/MandatoryArgument.pm2
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm97
-rwxr-xr-xMaster/texmf-dist/scripts/latexindent/LatexIndent/NamedGroupingBracesBrackets.pm2
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/OptionalArgument.pm2
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm2
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm29
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm21
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/UnNamedGroupingBracesBrackets.pm2
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm20
-rwxr-xr-xMaster/texmf-dist/scripts/latexindent/defaultSettings.yaml49
-rwxr-xr-xMaster/texmf-dist/scripts/latexindent/latexindent.pl4
34 files changed, 688 insertions, 101 deletions
diff --git a/Master/bin/win32/latexindent.exe b/Master/bin/win32/latexindent.exe
index 004a5bc7980..e5d6035fa0b 100755
--- a/Master/bin/win32/latexindent.exe
+++ b/Master/bin/win32/latexindent.exe
Binary files differ
diff --git a/Master/texmf-dist/doc/support/latexindent/README b/Master/texmf-dist/doc/support/latexindent/README
index bc733d967fc..f3a55f4978e 100644
--- a/Master/texmf-dist/doc/support/latexindent/README
+++ b/Master/texmf-dist/doc/support/latexindent/README
@@ -1,5 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- latexindent.pl, version 3.0.2, 2017-05-12
+ latexindent.pl, version 3.1, 2017-05-27
PERL script to indent code within environments, and align delimited
environments in .tex files.
diff --git a/Master/texmf-dist/doc/support/latexindent/appendices.tex b/Master/texmf-dist/doc/support/latexindent/appendices.tex
index bd011ec388b..63a2b680394 100644
--- a/Master/texmf-dist/doc/support/latexindent/appendices.tex
+++ b/Master/texmf-dist/doc/support/latexindent/appendices.tex
@@ -14,6 +14,7 @@ use utf8;
use PerlIO::encoding;
use Unicode::GCString;
use open ':std', ':encoding(UTF-8)';
+use Text::Wrap;
use FindBin;
use YAML::Tiny;
use File::Copy;
@@ -25,10 +26,6 @@ use Data::Dumper;
print "hello world";
exit;
\end{cmhlistings}
- My default installation on Ubuntu 12.04 did \emph{not} come
- with all of these modules as standard, but Strawberry Perl for Windows \cite{strawberryperl}
- did.
-
Installing the modules given in \cref{lst:helloworld} will vary depending on your
operating system and \texttt{Perl} distribution. For example, Ubuntu users
might visit the software center, or else run
diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent.pdf b/Master/texmf-dist/doc/support/latexindent/latexindent.pdf
index d9b467b658b..3bf881f5e4c 100644
--- a/Master/texmf-dist/doc/support/latexindent/latexindent.pdf
+++ b/Master/texmf-dist/doc/support/latexindent/latexindent.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent.tex b/Master/texmf-dist/doc/support/latexindent/latexindent.tex
index 16a0a5c26ce..7ef945c18ac 100644
--- a/Master/texmf-dist/doc/support/latexindent/latexindent.tex
+++ b/Master/texmf-dist/doc/support/latexindent/latexindent.tex
@@ -3,7 +3,6 @@
% arara: pdflatex: {shell: yes}
% arara: pdflatex: {shell: yes}
% arara: pdflatex: {shell: yes}
-% !arara: indent: {overwrite: yes, trace: yes, localSettings: yes, silent: yes}
\documentclass[10pt]{article}
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
@@ -172,17 +171,11 @@
\lstset{%
basicstyle=\small\ttfamily,language={[LaTeX]TeX},
- % numbers=left,
numberstyle=\ttfamily%\small,
breaklines=true,
- % frame=single,framexleftmargin=8mm, xleftmargin=8mm,
- % prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookrightarrow}},
- % backgroundcolor=\color{green!5},frameround=fttt,
- % rulecolor=\color{blue!70!black},
keywordstyle=\color{blue}, % keywords
commentstyle=\color{purple}, % comments
tabsize=3,
- %xleftmargin=1.5em,
}%
\DeclareTCBListing[use counter=lstlisting]{yaml}{O{} m O{} m}{
yaml-TCB,
@@ -199,7 +192,6 @@
\lstdefinestyle{yaml-LST}{
style=tcblatex,
numbers=none,
- %numbers=left,
numberstyle=\color{red},
}
@@ -209,6 +201,122 @@
columns=fullflexible,
}
+\lstdefinestyle{fileExtensionPreference}{
+ style=yaml-LST,
+ firstnumber=38,linerange={38-42},
+ numbers=left,
+}
+
+\lstdefinestyle{logFilePreferences}{
+ style=yaml-LST,
+ firstnumber=79,linerange={79-83},numbers=left
+}
+
+\lstdefinestyle{verbatimEnvironments}{
+ style=yaml-LST,
+ firstnumber=87,linerange={87-90},numbers=left
+}
+
+\lstdefinestyle{verbatimCommands}{
+ style=yaml-LST,
+ firstnumber=93,linerange={93-95},numbers=left
+}
+
+\lstdefinestyle{noIndentBlock}{
+ style=yaml-LST,
+ firstnumber=101,linerange={101-103},numbers=left
+}
+
+\lstdefinestyle{removeTrailingWhitespace}{
+ style=yaml-LST,
+ firstnumber=106,linerange={106-108},numbers=left
+}
+
+\lstdefinestyle{fileContentsEnvironments}{
+ style=yaml-LST,
+ firstnumber=112,linerange={112-114},numbers=left
+}
+
+\lstdefinestyle{lookForPreamble}{
+ style=yaml-LST,
+ firstnumber=120,linerange={120-124},numbers=left
+}
+
+\lstdefinestyle{indentAfterItems}{
+ style=yaml-LST,
+ firstnumber=172,linerange={172-176},numbers=left
+}
+
+\lstdefinestyle{itemNames}{
+ style=yaml-LST,
+ firstnumber=182,linerange={182-184},numbers=left
+}
+
+\lstdefinestyle{specialBeginEnd}{
+ style=yaml-LST,
+ firstnumber=188,linerange={188-200},numbers=left
+}
+
+\lstdefinestyle{indentAfterHeadings}{
+ style=yaml-LST,
+ firstnumber=210,linerange={210-219},numbers=left
+}
+
+\lstdefinestyle{noAdditionalIndentGlobalEnv}{
+ style=yaml-LST,
+ firstnumber=265,linerange={265-266},numbers=left
+}
+
+\lstdefinestyle{noAdditionalIndentGlobal}{
+ style=yaml-LST,
+ firstnumber=265,linerange={265-277},numbers=left
+}
+
+\lstdefinestyle{indentRulesGlobalEnv}{
+ style=yaml-LST,
+ firstnumber=281,linerange={281-282},numbers=left
+}
+
+\lstdefinestyle{indentRulesGlobal}{
+ style=yaml-LST,
+ firstnumber=281,linerange={281-293},numbers=left
+}
+
+\lstdefinestyle{commandCodeBlocks}{
+ style=yaml-LST,
+ firstnumber=296,linerange={296-304},numbers=left
+}
+
+\lstdefinestyle{modifylinebreaks}{
+ style=yaml-LST,
+ firstnumber=374,linerange={374-376},numbers=left
+}
+
+\lstdefinestyle{textWrapOptions}{
+ style=yaml-LST,
+ firstnumber=377,linerange={377-378},numbers=left
+}
+
+\lstdefinestyle{textWrapOptionsAll}{
+ style=yaml-LST,
+ firstnumber=377,linerange={377-379},numbers=left
+}
+
+\lstdefinestyle{removeParagraphLineBreaks}{
+ style=yaml-LST,
+ firstnumber=380,linerange={380-392},numbers=left
+}
+
+\lstdefinestyle{paragraphsStopAt}{
+ style=yaml-LST,
+ firstnumber=393,linerange={393-401},numbers=left
+}
+
+\lstdefinestyle{modifylinebreaksEnv}{
+ style=yaml-LST,
+ firstnumber=402,linerange={402-411},numbers=left
+}
+
% stars around contributors
\pgfdeclaredecoration{stars}{initial}{
\state{initial}[width=15pt]
@@ -407,7 +515,7 @@
sharp corners,
enhanced,
overlay={\node[anchor=north east,outer sep=2pt] at ([xshift=3cm,yshift=4mm]frame.north east) {\includegraphics[width=3cm]{logo}}; }]
- \centering\ttfamily\bfseries latexindent.pl\\[1cm] Version 3.0.2
+ \centering\ttfamily\bfseries latexindent.pl\\[1cm] Version 3.1
\end{tcolorbox}
}
\author{Chris Hughes \thanks{and contributors! See \vref{sec:contributors}. For
@@ -444,6 +552,7 @@
\input{subsubsec-no-add-remaining-code-blocks}
\stopcontents[noAdditionalIndent]
\input{subsec-commands-and-their-options}
+\clearpage
\input{sec-the-m-switch}
\input{subsec-partnering-poly-switches}
\input{subsec-conflicting-poly-switches}
diff --git a/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex b/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex
index 5dc0e8a77b4..f8bf01b60fb 100644
--- a/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex
+++ b/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex
@@ -22,7 +22,7 @@
latexindent.pl myfile
\end{commandshell}
\begin{wrapfigure}[8]{r}[0pt]{6cm}
- \cmhlistingsfromfile[firstnumber=22,linerange={22-26},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{fileExtensionPreference}}{lst:fileExtensionPreference}
+ \cmhlistingsfromfile[style=fileExtensionPreference]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{fileExtensionPreference}}{lst:fileExtensionPreference}
\end{wrapfigure}
in which case the script will look for \texttt{myfile} with the extensions
@@ -79,10 +79,10 @@ copy myfile.bak4 to myfile.bak3
\yamltitle{logFilePreferences}*{fields}
\begin{wrapfigure}[10]{r}[0pt]{9cm}
- \cmhlistingsfromfile[firstnumber=63,linerange={63-67},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.85\linewidth,before=\centering,yaml-TCB]{\texttt{logFilePreferences}}{lst:logFilePreferences}
+ \cmhlistingsfromfile[style=logFilePreferences,]{../defaultSettings.yaml}[width=.85\linewidth,before=\centering,yaml-TCB]{\texttt{logFilePreferences}}{lst:logFilePreferences}
\end{wrapfigure}
\texttt{latexindent.pl} writes information to \texttt{indent.log}, some
- of which can be customised by changing \texttt{logFilePreferences}; see \cref{lst:logFilePreferences}.
+ of which can be customized by changing \texttt{logFilePreferences}; see \cref{lst:logFilePreferences}.
If you load your own user settings (see \vref{sec:indentconfig}) then \texttt{latexindent.pl} will
detail them in \texttt{indent.log}; you can choose not to have the details logged by switching
\texttt{showEveryYamlRead} to \texttt{0}. Once all of your settings have
@@ -93,19 +93,20 @@ copy myfile.bak4 to myfile.bak3
\yamltitle{verbatimEnvironments}*{fields}
- \begin{wrapfigure}[14]{r}[0pt]{6cm}
- \cmhlistingsfromfile[firstnumber=71,linerange={71-73},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{verbatimEnvironments}}{lst:verbatimEnvironments}
-
- \vspace{.2cm}
- \cmhlistingsfromfile[firstnumber=76,linerange={76-78},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{verbatimCommands}}{lst:verbatimCommands}
- \end{wrapfigure}
A field that contains a list of environments
that you would like left completely alone -- no indentation will be performed
on environments that you have specified in this field, see \cref{lst:verbatimEnvironments}.
- Note that if you put an environment in \\ \texttt{verbatimEnvironments}
+ \begin{minipage}{.45\textwidth}
+ \cmhlistingsfromfile[style=verbatimEnvironments]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{verbatimEnvironments}}{lst:verbatimEnvironments}
+ \end{minipage}%
+ \begin{minipage}{.45\textwidth}
+ \cmhlistingsfromfile[style=verbatimCommands]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{verbatimCommands}}{lst:verbatimCommands}
+ \end{minipage}%
+
+ Note that if you put an environment in \texttt{verbatimEnvironments}
and in other fields such as \texttt{lookForAlignDelims} or \texttt{noAdditionalIndent}
- then \texttt{latexindent.pl} will \emph{always} prioritize \\ \texttt{verbatimEnvironments}.
+ then \texttt{latexindent.pl} will \emph{always} prioritize \texttt{verbatimEnvironments}.
\yamltitle{verbatimCommands}*{fields}
A field that contains a list of commands that are verbatim commands, for example
@@ -115,7 +116,7 @@ copy myfile.bak4 to myfile.bak3
\yamltitle{noIndentBlock}*{fields}
\begin{wrapfigure}[8]{r}[0pt]{6cm}
- \cmhlistingsfromfile[firstnumber=84,linerange={84-86},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{noIndentBlock}}{lst:noIndentBlock}
+ \cmhlistingsfromfile[style=noIndentBlock]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{noIndentBlock}}{lst:noIndentBlock}
\end{wrapfigure}
If you have a block of code that you don't want \texttt{latexindent.pl} to touch (even if it is \emph{not} a verbatim-like
environment) then you can wrap it in an environment from \texttt{noIndentBlock};
@@ -140,10 +141,10 @@ copy myfile.bak4 to myfile.bak3
\yamltitle{removeTrailingWhitespace}*{fields}\label{yaml:removeTrailingWhitespace}
\begin{wrapfigure}[12]{r}[0pt]{6cm}
- \cmhlistingsfromfile[firstnumber=89,linerange={89-91},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{removeTrailingWhitespace}{lst:removeTrailingWhitespace}
+ \cmhlistingsfromfile[style=removeTrailingWhitespace]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{removeTrailingWhitespace}{lst:removeTrailingWhitespace}
\vspace{.2cm}
- \cmhlistingsfromfile[firstnumber=95,linerange={95-98},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{fileContentsEnvironments}}{lst:fileContentsEnvironments}
+ \cmhlistingsfromfile[style=fileContentsEnvironments]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{fileContentsEnvironments}}{lst:fileContentsEnvironments}
\end{wrapfigure}
Trailing white space can be removed both \emph{before} and \emph{after} processing
the document, as detailed in \cref{lst:removeTrailingWhitespace}; each of the fields
@@ -168,7 +169,7 @@ copy myfile.bak4 to myfile.bak3
\yamltitle{lookForPreamble}*{fields}
\begin{wrapfigure}[8]{r}[0pt]{5cm}
- \cmhlistingsfromfile[firstnumber=103,linerange={103-107},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{lookForPreamble}{lst:lookForPreamble}
+ \cmhlistingsfromfile[style=lookForPreamble]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{lookForPreamble}{lst:lookForPreamble}
\end{wrapfigure}
Not all files contain preamble; for example, \texttt{sty}, \texttt{cls} and \texttt{bib} files typically do \emph{not}. Referencing
\cref{lst:lookForPreamble}, if you set, for example, \texttt{.tex} to \texttt{0}, then regardless of the setting of the value of \texttt{indentPreamble}, preamble
@@ -313,7 +314,7 @@ latexindent.pl matrix1.tex
\yamltitle{indentAfterItems}*{fields}
\begin{wrapfigure}[5]{r}[0pt]{7cm}
- \cmhlistingsfromfile[firstnumber=155,linerange={155-158},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{indentAfterItems}}{lst:indentafteritems}
+ \cmhlistingsfromfile[style=indentAfterItems]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{indentAfterItems}}{lst:indentafteritems}
\end{wrapfigure}
The environment names specified in \texttt{indentAfterItems} tell
\texttt{latexindent.pl} to look for \lstinline!\item! commands; if these switches are set to \texttt{1}
@@ -330,7 +331,7 @@ latexindent.pl matrix1.tex
\yamltitle{itemNames}*{fields}
\begin{wrapfigure}[5]{r}[0pt]{5cm}
- \cmhlistingsfromfile[firstnumber=164,linerange={164-166},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{itemNames}}{lst:itemNames}
+ \cmhlistingsfromfile[style=itemNames]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{itemNames}}{lst:itemNames}
\end{wrapfigure}
If you have your own \texttt{item} commands (perhaps you
prefer to use \texttt{myitem}, for example)
@@ -345,12 +346,12 @@ latexindent.pl matrix1.tex
there is no requirement for this to be the case; \cref{lst:specialBeginEnd} shows the
default settings of \texttt{specialBeginEnd}.
- \cmhlistingsfromfile[firstnumber=170,linerange={170-182},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{specialBeginEnd}}{lst:specialBeginEnd}
+ \cmhlistingsfromfile[style=specialBeginEnd]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{specialBeginEnd}}{lst:specialBeginEnd}
The field \texttt{displayMath} represents \lstinline!\[...\]!, \texttt{inlineMath} represents
\lstinline!$...$! and \texttt{displayMathTex} represents \lstinline!$$...$$!. You can, of course,
rename these in your own YAML files (see \vref{sec:localsettings}); indeed, you
- might like to set up your own specil begin and end statements.
+ might like to set up your own special begin and end statements.
A demonstration of the before-and-after results are shown in \cref{lst:specialbefore,lst:specialafter}.
@@ -368,7 +369,7 @@ latexindent.pl matrix1.tex
\yamltitle{indentAfterHeadings}*{fields}
\begin{wrapfigure}[17]{r}[0pt]{8cm}
- \cmhlistingsfromfile[firstnumber=192,linerange={192-201},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{indentAfterHeadings}}{lst:indentAfterHeadings}
+ \cmhlistingsfromfile[style=indentAfterHeadings]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{indentAfterHeadings}}{lst:indentAfterHeadings}
\end{wrapfigure}
This field enables the user to specify
indentation rules that take effect after heading commands such as \lstinline!\part!, \lstinline!\chapter!,
diff --git a/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex b/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex
index 90b6d8222c9..35c0d1fe1a3 100644
--- a/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex
+++ b/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex
@@ -25,7 +25,7 @@
\texttt{latexindent.pl} has a number of different switches/flags/options, which
can be combined in any way that you like, either in short or long form as detailed below.
\texttt{latexindent.pl} produces a \texttt{.log} file, \texttt{indent.log}, every time it
- is run; the name of the log file can be customised, but we will
+ is run; the name of the log file can be customized, but we will
refer to the log file as \texttt{indent.log} throughout this document.
There is a base of information that is written to \texttt{indent.log},
but other additional information will be written depending
diff --git a/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex b/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex
index 541a66572d2..7e8ddcd50fd 100644
--- a/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex
+++ b/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex
@@ -1,8 +1,4 @@
% arara: pdflatex: {shell: yes, files: [latexindent]}
-% the -m switch
-% the -m switch
-% the -m switch
-
\fancyhead[R]{\bfseries\thepage%
\tikz[remember picture,overlay] {
\node at (1,0){\includegraphics{logo}};
@@ -13,12 +9,12 @@
\yamltitle{modifylinebreaks}*{fields}
\begin{wrapfigure}[7]{r}[0pt]{8cm}
- \cmhlistingsfromfile[firstnumber=356,linerange={356-358},style=yaml-LST,numbers=left,]{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{modifyLineBreaks}}{lst:modifylinebreaks}
+ \cmhlistingsfromfile[style=modifylinebreaks]{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{modifyLineBreaks}}{lst:modifylinebreaks}
\end{wrapfigure}
\makebox[0pt][r]{%
\raisebox{-\totalheight}[0pt][0pt]{%
\tikz\node[opacity=1] at (0,0) {\includegraphics[width=4cm]{logo}};}}%
- One of the most exciting features of Version 3.0 is the \texttt{-m} switch, which
+ As of Version 3.0, \texttt{latexindent.pl} has the \texttt{-m} switch, which
permits \texttt{latexindent.pl} to modify line breaks, according to the
specifications in the \texttt{modifyLineBreaks} field. \emph{The settings
in this field will only be considered if the \texttt{-m} switch has been used}.
@@ -60,6 +56,275 @@ latexindent.pl myfile.tex -m
\cmhlistingsfromfile{demonstrations/mlb1-out.tex}{\texttt{mlb1.tex} out output}{lst:mlb-bl-out}
\end{minipage}
+\yamltitle{textWrapOptions}*{fields}
+ When the \texttt{-m} switch is active \texttt{latexindent.pl} has the ability to wrap text using the options
+ specified in the \texttt{textWrapOptions} field, see \cref{lst:textWrapOptions}. The value of
+ \texttt{columns} specifies the column at which the text should be wrapped.
+ By default, the value of \texttt{columns} is \texttt{0}, so \texttt{latexindent.pl}
+ will \emph{not} wrap text; if you change it to a value of \texttt{2} or more, then
+ text will be wrapped after the character in the specified column.
+
+ \cmhlistingsfromfile[style=textWrapOptions]{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{textWrapOptions}}{lst:textWrapOptions}
+
+ For example, consider the file give in \cref{lst:textwrap1}.
+
+ \begin{widepage}
+ \cmhlistingsfromfile{demonstrations/textwrap1.tex}{\texttt{textwrap1.tex}}{lst:textwrap1}
+ \end{widepage}
+
+ Using the file \texttt{textwrap1.yaml} in \cref{lst:textwrap1-yaml}, and running the command
+ \begin{commandshell}
+latexindent.pl -m textwrap1.tex -o textwrap1-mod1.tex -l textwrap1.yaml
+\end{commandshell}
+ we obtain the output in \cref{lst:textwrap1-mod1}.
+
+ \begin{minipage}{.45\linewidth}
+ \cmhlistingsfromfile{demonstrations/textwrap1-mod1.tex}{\texttt{textwrap1-mod1.tex}}{lst:textwrap1-mod1}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.45\linewidth}
+ \cmhlistingsfromfile{demonstrations/textwrap1.yaml}[MLB-TCB]{\texttt{textwrap1.yaml}}{lst:textwrap1-yaml}
+ \end{minipage}
+
+ The text wrapping routine is performed \emph{after} verbatim environments have been stored, so verbatim
+ environments and verbatim commands are exempt from the routine. For example, using the file in
+ \cref{lst:textwrap2},
+ \begin{widepage}
+ \cmhlistingsfromfile{demonstrations/textwrap2.tex}{\texttt{textwrap2.tex}}{lst:textwrap2}
+ \end{widepage}
+ and running the following command and continuing to use \texttt{textwrap1.yaml} from \cref{lst:textwrap1-yaml},
+ \begin{commandshell}
+latexindent.pl -m textwrap2.tex -o textwrap2-mod1.tex -l textwrap1.yaml
+\end{commandshell}
+ then the output is as in \cref{lst:textwrap2-mod1}.
+ \begin{widepage}
+ \cmhlistingsfromfile{demonstrations/textwrap2-mod1.tex}{\texttt{textwrap2-mod1.tex}}{lst:textwrap2-mod1}
+ \end{widepage}
+ Furthermore, the text wrapping routine is performed after the trailing comments have been
+ stored, and they are also exempt from text wrapping. For example, using the file in \cref{lst:textwrap3}
+ \begin{widepage}
+ \cmhlistingsfromfile{demonstrations/textwrap3.tex}{\texttt{textwrap3.tex}}{lst:textwrap3}
+ \end{widepage}
+ and running the following command and continuing to use \texttt{textwrap1.yaml} from \cref{lst:textwrap1-yaml},
+ \begin{commandshell}
+latexindent.pl -m textwrap3.tex -o textwrap3-mod1.tex -l textwrap1.yaml
+\end{commandshell}
+ then the output is as in \cref{lst:textwrap3-mod1}.
+
+ \cmhlistingsfromfile{demonstrations/textwrap3-mod1.tex}{\texttt{textwrap3-mod1.tex}}{lst:textwrap3-mod1}
+
+ \begin{wrapfigure}[6]{r}[0pt]{8cm}
+ \cmhlistingsfromfile[style=textWrapOptionsAll]{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{textWrapOptions}}{lst:textWrapOptionsAll}
+ \end{wrapfigure}
+ The text wrapping routine of \texttt{latexindent.pl} is performed by the \texttt{Text::Wrap} module, which provides a
+ \texttt{separator} feature to separate lines with characters other than a new line (see \cite{textwrap}). By default,
+ the separator is empty (see \cref{lst:textWrapOptionsAll}) which means that a new line token will be used, but you can change it as you see fit.
+
+ For example starting with the file in \cref{lst:textwrap4}
+
+ \cmhlistingsfromfile{demonstrations/textwrap4.tex}{\texttt{textwrap4.tex}}{lst:textwrap4}
+ and using \texttt{textwrap2.yaml} from \cref{lst:textwrap2-yaml} with the following command
+ \begin{commandshell}
+latexindent.pl -m textwrap4.tex -o textwrap4-mod2.tex -l textwrap2.yaml
+\end{commandshell}
+ then we obtain the output in \cref{lst:textwrap4-mod2}.
+
+ \begin{minipage}{.45\linewidth}
+ \cmhlistingsfromfile{demonstrations/textwrap4-mod2.tex}{\texttt{textwrap4-mod2.tex}}{lst:textwrap4-mod2}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.45\linewidth}
+ \cmhlistingsfromfile{demonstrations/textwrap2.yaml}[MLB-TCB]{\texttt{textwrap2.yaml}}{lst:textwrap2-yaml}
+ \end{minipage}
+
+ \paragraph{Summary of text wrapping}
+ It is important to note the following:
+ \begin{itemize}
+ \item Verbatim environments (\vref{lst:verbatimEnvironments}) and verbatim commands (\vref{lst:verbatimCommands}) will \emph{not} be affected by the text wrapping routine (see \vref{lst:textwrap2-mod1});
+ \item comments will \emph{not} be affected by the text wrapping routine (see \vref{lst:textwrap3-mod1});
+ \item indentation is performed \emph{after} the text wrapping routine; as such, indented code
+ will likely exceed any maximum value set in the \texttt{columns} field.
+ \end{itemize}
+
+\yamltitle{removeParagraphLineBreaks}*{fields}
+ When the \texttt{-m} switch is active \texttt{latexindent.pl} has the ability to remove line breaks
+ from within paragraphs; the behaviour is controlled by the \texttt{removeParagraphLineBreaks} field, detailed in
+ \cref{lst:removeParagraphLineBreaks}. Thank you to \cite{jowens} for shaping and assisting with the testing of this feature.
+
+ \cmhlistingsfromfile[style=removeParagraphLineBreaks]{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{removeParagraphLineBreaks}}{lst:removeParagraphLineBreaks}
+
+ This routine can be turned on \emph{globally} for \emph{every} code block type known to \texttt{latexindent.pl}
+ (see \vref{tab:code-blocks}) by using the \texttt{all} switch; by default, this switch is \emph{off}. Assuming
+ that the \texttt{all} switch is off, then the routine can be controlled on a per-code-block-type basis, and
+ within that, on a per-name basis. We will consider examples of each of these in turn, but
+ before we do, let's specify what \texttt{latexindent.pl} considers as a paragraph:
+ \begin{itemize}
+ \item it must begin on its own line with either an alphabetic or numeric character, and not with any of the
+ code-block types detailed in \vref{tab:code-blocks};
+ \item it can include line breaks, but finishes when it meets either a blank line, a \lstinline!\par!
+ command, or any of the user-specified settings in the \texttt{paragraphsStopAt} field,
+ detailed in \vref{lst:paragraphsStopAt}.
+ \end{itemize}
+
+ Let's start with the \texttt{.tex} file in \cref{lst:shortlines}, together with the YAML settings in
+ \cref{lst:remove-para1-yaml}.
+
+ \begin{minipage}{.45\linewidth}
+ \cmhlistingsfromfile{demonstrations/shortlines.tex}{\texttt{shortlines.tex}}{lst:shortlines}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.49\linewidth}
+ \cmhlistingsfromfile{demonstrations/remove-para1.yaml}[MLB-TCB]{\texttt{remove-para1.yaml}}{lst:remove-para1-yaml}
+ \end{minipage}
+
+ Upon running the command
+ \begin{commandshell}
+latexindent.pl -m shortlines.tex -o shortlines1.tex -l remove-para1.yaml
+\end{commandshell}
+ then we obtain the output given in \cref{lst:shortlines1}.
+
+ \cmhlistingsfromfile{demonstrations/shortlines1.tex}{\texttt{shortlines1.tex}}{lst:shortlines1}
+
+ Keen readers may notice that some trailing white space must be present in the file in \cref{lst:shortlines} which
+ has crept in to the output in \cref{lst:shortlines1}. This can be fixed using the YAML file in
+ \vref{lst:removeTWS-before} and running, for example,
+ \begin{commandshell}
+latexindent.pl -m shortlines.tex -o shortlines1-tws.tex -l remove-para1.yaml,removeTWS-before.yaml
+ \end{commandshell}
+ in which case the output is as in \cref{lst:shortlines1-tws}; notice that the double spaces present in \cref{lst:shortlines1}
+ have been addressed.
+
+ \cmhlistingsfromfile{demonstrations/shortlines1-tws.tex}{\texttt{shortlines1-tws.tex}}{lst:shortlines1-tws}
+
+ Keeping with the settings in \cref{lst:remove-para1-yaml}, we note that the \texttt{all} switch applies
+ to \emph{all} code block types. So, for example, let's consider the files in \cref{lst:shortlines-mand,lst:shortlines-opt}
+
+ \begin{minipage}{.45\linewidth}
+ \cmhlistingsfromfile{demonstrations/shortlines-mand.tex}{\texttt{shortlines-mand.tex}}{lst:shortlines-mand}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.45\linewidth}
+ \cmhlistingsfromfile{demonstrations/shortlines-opt.tex}{\texttt{shortlines-opt.tex}}{lst:shortlines-opt}
+ \end{minipage}
+
+ Upon running the commands
+ \begin{widepage}
+ \begin{commandshell}
+latexindent.pl -m shortlines-mand.tex -o shortlines-mand1.tex -l remove-para1.yaml
+latexindent.pl -m shortlines-opt.tex -o shortlines-opt1.tex -l remove-para1.yaml
+\end{commandshell}
+ \end{widepage}
+
+ then we obtain the respective output given in \cref{lst:shortlines-mand1,lst:shortlines-opt1}.
+
+ \cmhlistingsfromfile{demonstrations/shortlines-mand1.tex}{\texttt{shortlines-mand1.tex}}{lst:shortlines-mand1}
+ \cmhlistingsfromfile{demonstrations/shortlines-opt1.tex}{\texttt{shortlines-opt1.tex}}{lst:shortlines-opt1}
+
+ Assuming that we turn \emph{off} the \texttt{all} switch (by setting it to \texttt{0}), then
+ we can control the behaviour of \texttt{removeParagraphLineBreaks} either on a per-code-block-type basis,
+ or on a per-name basis.
+
+ For example, let's use the code in \cref{lst:shortlines-envs}, and consider the settings in \cref{lst:remove-para2-yaml,lst:remove-para3-yaml};
+ note that in \cref{lst:remove-para2-yaml} we specify that \emph{every} environment should receive
+ treatment from the routine, while in \cref{lst:remove-para3-yaml} we specify that \emph{only} the
+ \texttt{one} environment should receive the treatment.
+
+ \begin{minipage}{.45\linewidth}
+ \cmhlistingsfromfile{demonstrations/shortlines-envs.tex}{\texttt{shortlines-envs.tex}}{lst:shortlines-envs}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.49\linewidth}
+ \cmhlistingsfromfile{demonstrations/remove-para2.yaml}[MLB-TCB]{\texttt{remove-para2.yaml}}{lst:remove-para2-yaml}
+ \cmhlistingsfromfile{demonstrations/remove-para3.yaml}[MLB-TCB]{\texttt{remove-para3.yaml}}{lst:remove-para3-yaml}
+ \end{minipage}
+
+ Upon running the commands
+ \begin{widepage}
+ \begin{commandshell}
+latexindent.pl -m shortlines-envs.tex -o shortlines-envs2.tex -l remove-para2.yaml
+latexindent.pl -m shortlines-envs.tex -o shortlines-envs3.tex -l remove-para3.yaml
+\end{commandshell}
+ \end{widepage}
+ then we obtain the respective output given in \cref{lst:shortlines-envs2,lst:shortlines-envs3}.
+
+ \cmhlistingsfromfile{demonstrations/shortlines-envs2.tex}{\texttt{shortlines-envs2.tex}}{lst:shortlines-envs2}
+ \cmhlistingsfromfile{demonstrations/shortlines-envs3.tex}{\texttt{shortlines-envs3.tex}}{lst:shortlines-envs3}
+
+ The remaining code-block types can be customized in analogous ways, although note that \texttt{commands},
+ \texttt{keyEqualsValuesBracesBrackets}, \texttt{namedGroupingBracesBrackets}, \texttt{UnNamedGroupingBracesBrackets}
+ are controlled by the \texttt{optionalArguments} and the \texttt{mandatoryArguments}.
+
+ The only special case is the \texttt{masterDocument} field; this is designed for `chapter'-type files that
+ may contain paragraphs that are not within any other code-blocks. For example, consider the file in
+ \cref{lst:shortlines-md}, with the YAML settings in \cref{lst:remove-para4-yaml}.
+
+ \begin{minipage}{.45\linewidth}
+ \cmhlistingsfromfile{demonstrations/shortlines-md.tex}{\texttt{shortlines-md.tex}}{lst:shortlines-md}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.49\linewidth}
+ \cmhlistingsfromfile{demonstrations/remove-para4.yaml}[MLB-TCB]{\texttt{remove-para4.yaml}}{lst:remove-para4-yaml}
+ \end{minipage}
+
+ Upon running the following command
+ \begin{widepage}
+ \begin{commandshell}
+latexindent.pl -m shortlines-md.tex -o shortlines-md4.tex -l remove-para4.yaml
+\end{commandshell}
+ \end{widepage}
+ then we obtain the output in \cref{lst:shortlines-md4}.
+ \cmhlistingsfromfile{demonstrations/shortlines-md4.tex}{\texttt{shortlines-md4.tex}}{lst:shortlines-md4}
+
+\yamltitle{paragraphsStopAt}*{fields}
+ The paragraph line break routine considers blank lines and the \lstinline|\par| command to be the end of a paragraph;
+ you can fine tune the behaviour of the routine further by using the \texttt{paragraphsStopAt} fields, shown in \cref{lst:paragraphsStopAt}.
+
+ \cmhlistingsfromfile[style=paragraphsStopAt]{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{paragraphsStopAt}}{lst:paragraphsStopAt}
+
+ The fields specified in \texttt{paragraphsStopAt} tell \texttt{latexindent.pl} to stop the current paragraph
+ when it reaches a line that \emph{begins} with any of the code-block types specified as \texttt{1} in \cref{lst:paragraphsStopAt}.
+ By default, you'll see that the paragraph line break routine will stop when it reaches an environment at the
+ beginning of a line. It is \emph{not} possible to specify these fields on a per-name basis.
+
+ Let's use the \texttt{.tex} file in \cref{lst:sl-stop}; we will, in turn, consider the settings in
+ \cref{lst:stop-command-yaml,lst:stop-comment-yaml}.
+
+ \begin{minipage}{.45\linewidth}
+ \cmhlistingsfromfile{demonstrations/sl-stop.tex}{\texttt{sl-stop.tex}}{lst:sl-stop}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.49\linewidth}
+ \cmhlistingsfromfile{demonstrations/stop-command.yaml}[MLB-TCB]{\texttt{stop-command.yaml}}{lst:stop-command-yaml}
+
+ \cmhlistingsfromfile{demonstrations/stop-comment.yaml}[MLB-TCB]{\texttt{stop-comment.yaml}}{lst:stop-comment-yaml}
+ \end{minipage}
+
+ Upon using the settings from \vref{lst:remove-para4-yaml} and running the commands
+ \begin{widepage}
+ \begin{commandshell}
+latexindent.pl -m sl-stop.tex -o sl-stop4.tex -l remove-para4.yaml
+latexindent.pl -m sl-stop.tex -o sl-stop4-command.tex -l=remove-para4.yaml,stop-command.yaml
+latexindent.pl -m sl-stop.tex -o sl-stop4-comment.tex -l=remove-para4.yaml,stop-comment.yaml
+ \end{commandshell}
+ \end{widepage}
+ we obtain the respective outputs in \crefrange{lst:sl-stop4}{lst:sl-stop4-comment}; notice in particular that:
+ \begin{itemize}
+ \item in \cref{lst:sl-stop4} the paragraph line break routine has included commands and comments;
+ \item in \cref{lst:sl-stop4-command} the paragraph line break routine has \emph{stopped} at the
+ \texttt{emph} command, because in \cref{lst:stop-command-yaml} we have specified \texttt{commands}
+ to be \texttt{1}, and \texttt{emph} is at the beginning of a line;
+ \item in \cref{lst:sl-stop4-comment} the paragraph line break routine has \emph{stopped}
+ at the comments, because in \cref{lst:stop-comment-yaml} we have specified \texttt{comments}
+ to be \texttt{1}, and the comment is at the beginning of a line.
+ \end{itemize}
+ In all outputs in \crefrange{lst:sl-stop4}{lst:sl-stop4-comment} we notice that the paragraph line break
+ routine has stopped at \lstinline!\begin{myenv}! because, by default, \texttt{environments}
+ is set to \texttt{1} in \vref{lst:paragraphsStopAt}.
+
+ \cmhlistingsfromfile{demonstrations/sl-stop4.tex}{\texttt{sl-stop4.tex}}{lst:sl-stop4}
+ \cmhlistingsfromfile{demonstrations/sl-stop4-command.tex}{\texttt{sl-stop4-command.tex}}{lst:sl-stop4-command}
+ \cmhlistingsfromfile{demonstrations/sl-stop4-comment.tex}{\texttt{sl-stop4-comment.tex}}{lst:sl-stop4-comment}
+
\subsection{Poly-switches}
Every other field in the \texttt{modifyLineBreaks} field uses poly-switches, and can take
one of four integer values\footnote{You might like to associate one of the four circles in the logo with one of the four given values}:
@@ -78,7 +343,7 @@ latexindent.pl myfile.tex -m
after the \texttt{environments} field) and that \emph{per-name} settings are also allowed -- in the case of \cref{lst:environments-mlb}, settings
for \texttt{equation*} have been specified. Note that all poly-switches are \emph{off} by default.
- \cmhlistingsfromfile[firstnumber=359,linerange={359-368},style=yaml-LST,numbers=left,]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,MLB-TCB]{\texttt{environments}}{lst:environments-mlb}
+ \cmhlistingsfromfile[style=modifylinebreaksEnv]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,MLB-TCB]{\texttt{environments}}{lst:environments-mlb}
\subsubsection{Adding line breaks (poly-switches set to $1$ or $2$)}
Let's begin with the simple example given in \cref{lst:env-mlb1-tex}; note that we have annotated key parts of the file using $\BeginStartsOnOwnLine$,
@@ -351,7 +616,6 @@ latexindent.pl -m env-mlb5.tex -l env-mlb9.yaml,env-mlb10.yaml,env-mlb11.yaml,en
\cmhlistingsfromfile{demonstrations/env-mlb5-modAll-remove-WS.tex}{\texttt{env-mlb5.tex} using \crefrange{lst:env-mlb4-mod9}{lst:env-mlb4-mod12} \emph{and} \cref{lst:removeTWS-before}}{lst:env-mlb5-modAll-remove-WS}
\end{widepage}
-
\paragraph{Blank lines}
Now let's consider the file in \cref{lst:mlb6}, which contains blank lines.
diff --git a/Master/texmf-dist/doc/support/latexindent/subsec-commands-and-their-options.tex b/Master/texmf-dist/doc/support/latexindent/subsec-commands-and-their-options.tex
index 8ef571bc574..be953d1c5db 100644
--- a/Master/texmf-dist/doc/support/latexindent/subsec-commands-and-their-options.tex
+++ b/Master/texmf-dist/doc/support/latexindent/subsec-commands-and-their-options.tex
@@ -9,7 +9,7 @@
The \texttt{commandCodeBlocks} field contains a few switches detailed in \cref{lst:commandCodeBlocks}.
- \cmhlistingsfromfile[firstnumber=278,linerange={278-286},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{commandCodeBlocks}}{lst:commandCodeBlocks}
+ \cmhlistingsfromfile[style=commandCodeBlocks]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{commandCodeBlocks}}{lst:commandCodeBlocks}
\yamltitle{roundParenthesesAllowed}{0|1}
diff --git a/Master/texmf-dist/doc/support/latexindent/subsec-conflicting-poly-switches.tex b/Master/texmf-dist/doc/support/latexindent/subsec-conflicting-poly-switches.tex
index 61216c96c7c..e7a66901f18 100644
--- a/Master/texmf-dist/doc/support/latexindent/subsec-conflicting-poly-switches.tex
+++ b/Master/texmf-dist/doc/support/latexindent/subsec-conflicting-poly-switches.tex
@@ -105,7 +105,7 @@ latexindent.pl -m -l=nested-env-mlb1.yaml nested-env.tex
\item next, the \texttt{one} environment is found; the line break ahead of \lstinline!\end{one}! is removed because \texttt{EndStartsOnOwnLine}
is set to $-1$.
\end{itemize}
- The indentation is done in Phase 2, and then in Phase 3, \emph{there is no option to add a line break after the \lstinline!end! statements}.
+ The indentation is done in Phase 2; in Phase 3 \emph{there is no option to add a line break after the \lstinline!end! statements}.
We can justify this by remembering that during Phase 3, the \texttt{one} environment will be found and processed first, followed
by the \texttt{two} environment. If the \texttt{two} environment were to add a line break after the \lstinline!\end{two}! statement, then
\texttt{latexindent.pl} would have no way of knowing how much indentation to add to the subsequent text (in this case, \lstinline!\end{one}!).
diff --git a/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-and-their-arguments.tex b/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-and-their-arguments.tex
index 908c2607b78..c26e35914f1 100644
--- a/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-and-their-arguments.tex
+++ b/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-and-their-arguments.tex
@@ -148,7 +148,7 @@ latexindent.pl myenv-args.tex -l myenv-rules4.yaml
\yamltitle{noAdditionalIndentGlobal}*{fields}
\begin{wrapfigure}[6]{r}[0pt]{7cm}
- \cmhlistingsfromfile[firstnumber=247,linerange={247-248},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{env-noAdditionalGlobal.yaml}}{lst:noAdditionalIndentGlobal:environments}
+ \cmhlistingsfromfile[style=noAdditionalIndentGlobalEnv]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{noAdditionalIndentGlobal}}{lst:noAdditionalIndentGlobal:environments}
\end{wrapfigure}
Assuming that your environment name is not found within neither \texttt{noAdditionalIndent} nor \texttt{indentRules}, the next
place that \texttt{latexindent.pl} will look is \texttt{noAdditionalIndentGlobal}, and in particular \emph{for the environments} key
@@ -205,7 +205,7 @@ latexindent.pl myenv-args.tex -local mand-args-no-add-glob.yaml
\yamltitle{indentRulesGlobal}*{fields}
\begin{wrapfigure}[4]{r}[0pt]{7cm}
- \cmhlistingsfromfile[firstnumber=263,linerange={263-264},style=yaml-LST]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{env-indentRulesGlobal.yaml}}{lst:indentRulesGlobal:environments}
+ \cmhlistingsfromfile[style=indentRulesGlobalEnv]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{indentRulesGlobal}}{lst:indentRulesGlobal:environments}
\end{wrapfigure}
The final check that \texttt{latexindent.pl} will make is to look for \texttt{indentRulesGlobal} as detailed in \cref{lst:indentRulesGlobal:environments}; if you change the \texttt{environments}
field to anything involving horizontal space, say \lstinline!" "!, and then run the following commands
diff --git a/Master/texmf-dist/doc/support/latexindent/subsubsec-no-add-remaining-code-blocks.tex b/Master/texmf-dist/doc/support/latexindent/subsubsec-no-add-remaining-code-blocks.tex
index 60063fbb2b7..42794f11f71 100644
--- a/Master/texmf-dist/doc/support/latexindent/subsubsec-no-add-remaining-code-blocks.tex
+++ b/Master/texmf-dist/doc/support/latexindent/subsubsec-no-add-remaining-code-blocks.tex
@@ -100,10 +100,10 @@
\begin{widepage}
\begin{minipage}{.47\linewidth}
- \cmhlistingsfromfile[firstnumber=247,linerange={247-259},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[before=\centering,yaml-TCB]{\texttt{noAdditionalIndentGlobal}}{lst:noAdditionalIndentGlobal}
+ \cmhlistingsfromfile[style=noAdditionalIndentGlobal]{../defaultSettings.yaml}[before=\centering,yaml-TCB]{\texttt{noAdditionalIndentGlobal}}{lst:noAdditionalIndentGlobal}
\end{minipage}%
\hfill
\begin{minipage}{.47\linewidth}
- \cmhlistingsfromfile[firstnumber=263,linerange={263-275},style=yaml-LST,numbers=left]{../defaultSettings.yaml}[before=\centering,yaml-TCB]{\texttt{indentRulesGlobal}}{lst:indentRulesGlobal}
+ \cmhlistingsfromfile[style=indentRulesGlobal]{../defaultSettings.yaml}[before=\centering,yaml-TCB]{\texttt{indentRulesGlobal}}{lst:indentRulesGlobal}
\end{minipage}%
\end{widepage}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Command.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Command.pm
index 022064fd1d7..70712a03626 100755
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Command.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Command.pm
@@ -165,7 +165,7 @@ sub create_unique_id{
my $self = shift;
$commandCounter++;
- ${$self}{id} = "$tokens{command}$commandCounter";
+ ${$self}{id} = "$tokens{commands}$commandCounter";
return;
}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm
index 1872f181c86..93d8c404928 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm
@@ -23,11 +23,11 @@ use open ':std', ':encoding(UTF-8)';
# gain access to subroutines in the following modules
use LatexIndent::Switches qw/storeSwitches %switches $is_m_switch_active $is_t_switch_active $is_tt_switch_active/;
use LatexIndent::LogFile qw/logger output_logfile processSwitches/;
-use LatexIndent::GetYamlSettings qw/readSettings modify_line_breaks_settings get_indentation_settings_for_this_object get_every_or_custom_value get_indentation_information get_object_attribute_for_indentation_settings alignment_at_ampersand_settings/;
+use LatexIndent::GetYamlSettings qw/readSettings modify_line_breaks_settings get_indentation_settings_for_this_object get_every_or_custom_value get_indentation_information get_object_attribute_for_indentation_settings alignment_at_ampersand_settings %masterSettings/;
use LatexIndent::FileExtension qw/file_extension_check/;
use LatexIndent::BackUpFileProcedure qw/create_back_up_file/;
use LatexIndent::BlankLines qw/protect_blank_lines unprotect_blank_lines condense_blank_lines/;
-use LatexIndent::ModifyLineBreaks qw/modify_line_breaks_body modify_line_breaks_end remove_line_breaks_begin adjust_line_breaks_end_parent/;
+use LatexIndent::ModifyLineBreaks qw/modify_line_breaks_body modify_line_breaks_end remove_line_breaks_begin adjust_line_breaks_end_parent max_char_per_line paragraphs_on_one_line construct_paragraph_reg_exp/;
use LatexIndent::TrailingComments qw/remove_trailing_comments put_trailing_comments_back_in add_comment_symbol construct_trailing_comment_regexp/;
use LatexIndent::HorizontalWhiteSpace qw/remove_trailing_whitespace remove_leading_space/;
use LatexIndent::Indent qw/indent wrap_up_statement determine_total_indentation indent_begin indent_body indent_end_statement final_indentation_check get_surrounding_indentation indent_children_recursively check_for_blank_lines_at_beginning put_blank_lines_back_in_at_beginning add_surrounding_indentation_to_begin_statement/;
@@ -87,6 +87,7 @@ sub operate_on_file{
$self->find_aligned_block;
$self->remove_trailing_comments;
$self->find_verbatim_environments;
+ $self->max_char_per_line;
$self->protect_blank_lines;
$self->remove_trailing_whitespace(when=>"before");
$self->find_file_contents_environments_and_preamble;
@@ -116,7 +117,7 @@ sub construct_regular_expressions{
$self->construct_key_equals_values_regexp;
$self->construct_grouping_braces_brackets_regexp;
$self->construct_unnamed_grouping_braces_brackets_regexp;
-
+ $self->construct_paragraph_reg_exp if $is_m_switch_active;
}
sub output_indented_text{
@@ -189,6 +190,12 @@ sub find_objects{
$self->logger('looking for SPECIAL begin/end');
$self->find_special;
+ # documents without preamble need a manual call to the paragraph_one_line routine
+ if ($is_m_switch_active and !${$self}{preamblePresent}){
+ ${$self}{removeParagraphLineBreaks} = ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{all}||${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{masterDocument}||0;
+ $self->paragraphs_on_one_line ;
+ }
+
# if there are no children, return
if(${$self}{children}){
$self->logger("Objects have been found.",'heading');
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm
index 1b0ad27d550..2f6afe07e4b 100755
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm
@@ -120,7 +120,7 @@ sub create_unique_id{
my $self = shift;
$environmentCounter++;
- ${$self}{id} = "$tokens{environment}$environmentCounter";
+ ${$self}{id} = "$tokens{environments}$environmentCounter";
return;
}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/FileContents.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/FileContents.pm
index a1b56391f2c..d4d13507a13 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/FileContents.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/FileContents.pm
@@ -158,6 +158,8 @@ sub find_file_contents_environments_and_preamble{
$preamble->unprotect_blank_lines;
${$self}{verbatim}{${$preamble}{id}} = $preamble;
}
+ } else {
+ ${$self}{preamblePresent} = 0;
}
# loop through the fileContents array, check if it's in the preamble
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
index 4c93bc80426..1a9b9c1f9f8 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
@@ -234,6 +234,7 @@ sub get_indentation_settings_for_this_object{
BodyStartsOnOwnLine=>${$self}{BodyStartsOnOwnLine},
EndStartsOnOwnLine=>${$self}{EndStartsOnOwnLine},
EndFinishesWithLineBreak=>${$self}{EndFinishesWithLineBreak},
+ removeParagraphLineBreaks=>${$self}{removeParagraphLineBreaks},
);
# don't forget alignment settings!
@@ -275,12 +276,6 @@ sub alignment_at_ampersand_settings{
# spacesBeforeDoubleBackSlash: 2
return unless ${$masterSettings{lookForAlignDelims}}{$name};
- ## check, for example,
- ## lookForAlignDelims:
- ## tabular:
- ## body: 1
- #return unless $self->get_object_attribute_for_indentation_settings;
-
if(ref ${$masterSettings{lookForAlignDelims}}{$name} eq "HASH"){
${$self}{lookForAlignDelims} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{delims} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{delims} : 1;
${$self}{alignDoubleBackSlash} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{alignDoubleBackSlash} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{alignDoubleBackSlash} : 1;
@@ -308,13 +303,43 @@ sub modify_line_breaks_settings{
# the following will *definitley* be in the array, so let's add them
push(@toBeAssignedTo,("BeginStartsOnOwnLine","BodyStartsOnOwnLine","EndStartsOnOwnLine","EndFinishesWithLineBreak"));
- # we can effeciently loop through the following
+ # we can efficiently loop through the following
foreach (@toBeAssignedTo){
$self->get_every_or_custom_value(
toBeAssignedTo=>$_,
toBeAssignedToAlias=> ${$self}{aliases}{$_} ? ${$self}{aliases}{$_} : $_,
);
}
+
+ # paragraph line break settings
+ ${$self}{removeParagraphLineBreaks} = ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{all};
+
+ return if(${$self}{removeParagraphLineBreaks});
+
+ # the removeParagraphLineBreaks can contain fields that are hashes or scalar, for example:
+ #
+ # removeParagraphLineBreaks:
+ # all: 0
+ # environments: 0
+ # or
+ # removeParagraphLineBreaks:
+ # all: 0
+ # environments:
+ # quotation: 0
+
+ # name of the object in the modifyLineBreaks yaml (e.g environments, ifElseFi, etc)
+ my $YamlName = ${$self}{modifyLineBreaksYamlName};
+
+ # if the YamlName is either optionalArguments or mandatoryArguments, then we'll be looking for information about the *parent*
+ my $name = ($YamlName =~ m/Arguments/) ? ${$self}{parent} : ${$self}{name};
+
+ if(ref ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName} eq "HASH"){
+ $self->logger("$YamlName specified with fields in removeParagraphLineBreaks, looking for $name") if $is_t_switch_active;
+ ${$self}{removeParagraphLineBreaks} = ${${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName}}{$name}||0;
+ } else {
+ $self->logger("$YamlName specified with just a number in removeParagraphLineBreaks ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName}") if $is_t_switch_active;
+ ${$self}{removeParagraphLineBreaks} = ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName};
+ }
return;
}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Heading.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Heading.pm
index be7ea36661d..6cca3c26695 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Heading.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Heading.pm
@@ -34,6 +34,9 @@ sub construct_headings_levels{
# grab the heading levels
my %headingsLevels = %{$masterSettings{indentAfterHeadings}};
+ # output to log file
+ $self->logger("Constructing headings reg exp for example, chapter, section, etc (see indentAfterThisHeading)") if $is_t_switch_active ;
+
# delete the values that have indentAfterThisHeading set to 0
while( my ($headingName,$headingInfo)= each %headingsLevels){
if(!${$headingsLevels{$headingName}}{indentAfterThisHeading}){
@@ -42,10 +45,10 @@ sub construct_headings_levels{
} else {
# *all heading* regexp, remembering put starred headings at the front of the regexp
if($headingName =~ m/\*/){
- $self->logger("Putting $headingName at the beginning of the allHeadings regexp, as it contains a *");
+ $self->logger("Putting $headingName at the beginning of the allHeadings regexp, as it contains a *") if $is_t_switch_active ;
$allHeadingsRegexp = $headingName.($allHeadingsRegexp eq '' ?q():"|$allHeadingsRegexp");
} else {
- $self->logger("Putting $headingName at the END of the allHeadings regexp, as it contains a *");
+ $self->logger("Putting $headingName at the END of the allHeadings regexp, as it contains a *") if $is_t_switch_active ;
$allHeadingsRegexp .= ($allHeadingsRegexp eq '' ?q():"|").$headingName ;
}
}
@@ -60,8 +63,8 @@ sub construct_headings_levels{
# it could be that @sortedByLevels is empty;
return if !@sortedByLevels;
- $self->logger("All headings regexp: $allHeadingsRegexp",'heading');
- $self->logger("Now to construct headings regexp for each level:",'heading');
+ $self->logger("All headings regexp: $allHeadingsRegexp",'heading') if $is_t_switch_active;
+ $self->logger("Now to construct headings regexp for each level:",'heading') if $is_t_switch_active;
# loop through the levels, and create a regexp for each (min and max values are the first and last values respectively from sortedByLevels)
for(my $i = ${$headingsLevels{$sortedByLevels[0]}}{level}; $i <= ${$headingsLevels{$sortedByLevels[-1]}}{level}; $i++ ){
@@ -72,10 +75,10 @@ sub construct_headings_levels{
foreach(@tmp){
# put starred headings at the front of the regexp
if($_ =~ m/\*/){
- $self->logger("Putting $_ at the beginning of this regexp, as it contains a *");
+ $self->logger("Putting $_ at the beginning of this regexp, as it contains a *") if $is_t_switch_active;
$headingsAtThisLevel = $_.($headingsAtThisLevel eq '' ?q():"|$headingsAtThisLevel");
} else {
- $self->logger("Putting $_ at the END of this regexp, as it contains a *");
+ $self->logger("Putting $_ at the END of this regexp, as it contains a *") if $is_t_switch_active;
$headingsAtThisLevel .= ($headingsAtThisLevel eq '' ?q():"|").$_ ;
}
}
@@ -161,7 +164,7 @@ sub create_unique_id{
$headingCounter++;
- ${$self}{id} = "$tokens{heading}$headingCounter";
+ ${$self}{id} = "$tokens{afterHeading}$headingCounter";
return;
}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/IfElseFi.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/IfElseFi.pm
index e1ac17b3613..a98cebf05e2 100755
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/IfElseFi.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/IfElseFi.pm
@@ -182,7 +182,7 @@ sub create_unique_id{
$ifElseFiCounter++;
- ${$self}{id} = "$tokens{ifelsefi}$ifElseFiCounter";
+ ${$self}{id} = "$tokens{ifElseFi}$ifElseFiCounter";
return;
}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Indent.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Indent.pm
index 600aed5040f..f0cf33aa23f 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Indent.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Indent.pm
@@ -120,6 +120,9 @@ sub indent_body{
# some objects can format their body to align at the & character
$self->align_at_ampersand if ${$self}{lookForAlignDelims};
+ # possibly remove paragraph line breaks
+ $self->paragraphs_on_one_line if $is_m_switch_active;
+
# body indendation
if(${$self}{linebreaksAtEnd}{begin}==1){
if(${$self}{body} =~ m/^\h*$/s){
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Item.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Item.pm
index d85f4e24c31..1166282895d 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Item.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Item.pm
@@ -23,7 +23,7 @@ use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
use Data::Dumper;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
-our @EXPORT_OK = qw/find_items construct_list_of_items/;
+our @EXPORT_OK = qw/find_items construct_list_of_items $listOfItems/;
our $itemCounter;
our $listOfItems = q();
our $itemRegExp;
@@ -111,7 +111,7 @@ sub create_unique_id{
$itemCounter++;
- ${$self}{id} = "$tokens{item}$itemCounter";
+ ${$self}{id} = "$tokens{items}$itemCounter";
return;
}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/KeyEqualsValuesBraces.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/KeyEqualsValuesBraces.pm
index 41fcb981a15..974003d3a87 100755
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/KeyEqualsValuesBraces.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/KeyEqualsValuesBraces.pm
@@ -106,7 +106,7 @@ sub create_unique_id{
my $self = shift;
$key_equals_values_braces_Counter++;
- ${$self}{id} = "$tokens{key_equals_values_braces}$key_equals_values_braces_Counter";
+ ${$self}{id} = "$tokens{keyEqualsValuesBracesBrackets}$key_equals_values_braces_Counter";
return;
}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm
index 309d8355bea..eca7ae7aad5 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm
@@ -41,7 +41,7 @@ sub processSwitches{
my $self = shift;
# details of the script to log file
- $self->logger("$FindBin::Script version 3.0.2, a script to indent .tex files",'heading');
+ $self->logger("$FindBin::Script version 3.1, a script to indent .tex files",'heading');
$self->logger("$FindBin::Script lives here: $FindBin::RealBin/");
# time the script is used
@@ -50,7 +50,7 @@ sub processSwitches{
if(scalar(@ARGV) < 1 or $switches{showhelp}) {
print <<ENDQUOTE
-latexindent.pl version 3.0.2
+latexindent.pl version 3.1
usage: latexindent.pl [options] [file][.tex|.sty|.cls|.bib|...]
-h, --help
help (see the documentation for detailed instructions and examples)
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/MandatoryArgument.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/MandatoryArgument.pm
index 172e002eda4..47b538d2ca2 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/MandatoryArgument.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/MandatoryArgument.pm
@@ -78,7 +78,7 @@ sub create_unique_id{
my $self = shift;
$mandatoryArgumentCounter++;
- ${$self}{id} = "$tokens{mandatoryArgument}$mandatoryArgumentCounter";
+ ${$self}{id} = "$tokens{mandatoryArguments}$mandatoryArgumentCounter";
return;
}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm
index bcfb2336264..3f0148d4670 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm
@@ -18,11 +18,15 @@ use strict;
use warnings;
use Data::Dumper;
use Exporter qw/import/;
+use Text::Wrap;
+use LatexIndent::GetYamlSettings qw/%masterSettings/;
use LatexIndent::Tokens qw/%tokens/;
use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
use LatexIndent::Switches qw/$is_m_switch_active $is_t_switch_active $is_tt_switch_active/;
-our @EXPORT_OK = qw/modify_line_breaks_body modify_line_breaks_end adjust_line_breaks_end_parent remove_line_breaks_begin/;
-our @allObjects;
+use LatexIndent::Item qw/$listOfItems/;
+our @EXPORT_OK = qw/modify_line_breaks_body modify_line_breaks_end adjust_line_breaks_end_parent remove_line_breaks_begin max_char_per_line paragraphs_on_one_line construct_paragraph_reg_exp/;
+our $paragraphRegExp = q();
+
sub modify_line_breaks_body{
my $self = shift;
@@ -171,4 +175,93 @@ sub adjust_line_breaks_end_parent{
}
+sub max_char_per_line{
+ return unless $is_m_switch_active;
+
+ my $self = shift;
+ return unless ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1;
+
+ # call the text wrapping routine
+ $Text::Wrap::columns=${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns};
+ if(${$masterSettings{modifyLineBreaks}{textWrapOptions}}{separator} ne ''){
+ $Text::Wrap::separator=${$masterSettings{modifyLineBreaks}{textWrapOptions}}{separator};
+ }
+ ${$self}{body} = wrap('','',${$self}{body});
+}
+
+sub construct_paragraph_reg_exp{
+ my $self = shift;
+
+ my $stopAtRegExp = q();
+ while( my ($paragraphStopAt,$yesNo)= each %{${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{paragraphsStopAt}}){
+ if($yesNo){
+ # the headings (chapter, section, etc) need a slightly special treatment
+ $paragraphStopAt = "afterHeading" if($paragraphStopAt eq "heading");
+
+ # the comment need a slightly special treatment
+ $paragraphStopAt = "trailingComment" if($paragraphStopAt eq "comments");
+
+ # output to log file
+ $self->logger("The paragraph-stop regexp WILL include $tokens{$paragraphStopAt} (see paragraphsStopAt)",'heading') if $is_t_switch_active ;
+
+ # update the regexp
+ if($paragraphStopAt eq "items"){
+ $stopAtRegExp .= "|(?:\\\\(?:".$listOfItems."))";
+ } else {
+ $stopAtRegExp .= "|(?:".($paragraphStopAt eq "trailingComment" ? "%" : q() ).$tokens{$paragraphStopAt}."\\d+)";
+ }
+ } else {
+ $self->logger("The paragraph-stop regexp won't include $tokens{$paragraphStopAt} (see paragraphsStopAt)",'heading') if $is_t_switch_active ;
+ }
+ }
+
+ $paragraphRegExp = qr/
+ ^
+ (?!$tokens{beginOfToken})
+ (\w
+ (?:
+ (?!
+ (?:$tokens{blanklines}|\\par)
+ ).
+ )*?
+ )
+ (
+ (?:
+ ^(?:(\h*\R)|\\par|$tokens{blanklines}$stopAtRegExp)
+ )
+ |
+ \z # end of string
+ )/sxm;
+
+ $self->logger("The paragraph-stop-regexp is:",'heading') if $is_tt_switch_active ;
+ $self->logger($paragraphRegExp) if $is_tt_switch_active ;
+}
+
+sub paragraphs_on_one_line{
+ my $self = shift;
+ return unless ${$self}{removeParagraphLineBreaks};
+
+ # alignment at ampersand can take priority
+ return if(${$self}{lookForAlignDelims} and ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{alignAtAmpersandTakesPriority});
+
+ $self->logger("Checking ${$self}{name} for paragraphs (see removeParagraphLineBreaks)") if $is_t_switch_active;
+
+ my $paragraphCounter;
+ my @paragraphStorage;
+
+ ${$self}{body} =~ s/$paragraphRegExp/
+ $paragraphCounter++;
+ push(@paragraphStorage,{id=>$tokens{paragraph}.$paragraphCounter.$tokens{endOfToken},value=>$1});
+
+ # replace comment with dummy text
+ $tokens{paragraph}.$paragraphCounter.$tokens{endOfToken}.$2;
+ /xsmeg;
+
+ while( my $paragraph = pop @paragraphStorage){
+ # remove all line breaks from paragraph, except for any at the very end
+ ${$paragraph}{value} =~ s/\R(?!\z)/ /sg;
+ ${$self}{body} =~ s/${$paragraph}{id}/${$paragraph}{value}/;
+ }
+}
+
1;
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/NamedGroupingBracesBrackets.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/NamedGroupingBracesBrackets.pm
index ea2c5323cf3..f7469504e10 100755
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/NamedGroupingBracesBrackets.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/NamedGroupingBracesBrackets.pm
@@ -55,7 +55,7 @@ sub create_unique_id{
my $self = shift;
$groupingBracesCounter++;
- ${$self}{id} = "$tokens{groupingBraces}$groupingBracesCounter";
+ ${$self}{id} = "$tokens{namedGroupingBracesBrackets}$groupingBracesCounter";
return;
}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/OptionalArgument.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/OptionalArgument.pm
index b949e9b7e92..a44ca52a51d 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/OptionalArgument.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/OptionalArgument.pm
@@ -97,7 +97,7 @@ sub create_unique_id{
my $self = shift;
$optionalArgumentCounter++;
- ${$self}{id} = "$tokens{optionalArgument}$optionalArgumentCounter";
+ ${$self}{id} = "$tokens{optionalArguments}$optionalArgumentCounter";
return;
}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm
index ba7b905b492..d278d80e75c 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm
@@ -177,7 +177,7 @@ sub create_unique_id{
$specialCounter++;
- ${$self}{id} = "$tokens{special}$specialCounter";
+ ${$self}{id} = "$tokens{specialBeginEnd}$specialCounter";
return;
}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm
index 8a9a100dc26..e50c66d25d0 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm
@@ -26,28 +26,31 @@ my $ifelsefiSpecial = "!-!";
# the %tokens hash is passed around many modules
our %tokens = (
- environment=>$beginningToken."ENVIRONMENT",
- ifelsefiSpecial=>$ifelsefiSpecial,
- ifelsefi=>$ifelsefiSpecial.$beginningToken."IFELSEFI",
- item=>$beginningToken."ITEMS",
+ # user-facing naming convention
+ environments=>$beginningToken."ENVIRONMENT",
+ commands=>$beginningToken."COMMAND",
+ optionalArguments=>$beginningToken."OPTIONAL-ARGUMENT",
+ mandatoryArguments=>$beginningToken."MANDATORY-ARGUMENT",
+ ifElseFi=>$ifelsefiSpecial.$beginningToken."IFELSEFI",
+ items=>$beginningToken."ITEMS",
+ keyEqualsValuesBracesBrackets=>$beginningToken."KEY-VALUE-BRACES",
+ namedGroupingBracesBrackets=>$beginningToken."GROUPING-BRACES",
+ UnNamedGroupingBracesBrackets=>$beginningToken."UN-NAMED-GROUPING-BRACES",
+ specialBeginEnd=>$beginningToken."SPECIAL",
+ afterHeading=>$beginningToken."HEADING",
+ filecontents=>$beginningToken."FILECONTENTS",
+ # internal-facing naming convention
trailingComment=>"latexindenttrailingcomment",
+ ifelsefiSpecial=>$ifelsefiSpecial,
blanklines=>$beginningToken."blank-line",
arguments=>$beginningToken."ARGUMENTS",
- optionalArgument=>$beginningToken."OPTIONAL-ARGUMENT",
- mandatoryArgument=>$beginningToken."MANDATORY-ARGUMENT",
roundBracket=>$beginningToken."ROUND-BRACKET",
verbatim=>$beginningToken."VERBATIM",
- command=>$beginningToken."COMMAND",
- key_equals_values_braces=>$beginningToken."KEY-VALUE-BRACES",
- groupingBraces=>$beginningToken."GROUPING-BRACES",
- unNamedgroupingBraces=>$beginningToken."UN-NAMED-GROUPING-BRACES",
- special=>$beginningToken."SPECIAL",
- heading=>$beginningToken."HEADING",
- filecontents=>$beginningToken."FILECONTENTS",
preamble=>$beginningToken."preamble",
beginOfToken=>$beginningToken,
doubleBackSlash=>$beginningToken."DOUBLEBACKSLASH",
alignmentBlock=>$beginningToken."ALIGNMENTBLOCK",
+ paragraph=>$beginningToken."PARA",
endOfToken=>"-END",
);
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm
index f8987d271f1..cbc35f6eee7 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm
@@ -17,7 +17,8 @@ package LatexIndent::TrailingComments;
use strict;
use warnings;
use LatexIndent::Tokens qw/%tokens/;
-use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
+use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_m_switch_active/;
+use LatexIndent::GetYamlSettings qw/%masterSettings/;
use Data::Dumper;
use Exporter qw/import/;
our @EXPORT_OK = qw/remove_trailing_comments put_trailing_comments_back_in $trailingCommentRegExp add_comment_symbol construct_trailing_comment_regexp/;
@@ -90,6 +91,24 @@ sub put_trailing_comments_back_in{
while( my $comment = pop @trailingComments){
my $trailingcommentID = ${$comment}{id};
my $trailingcommentValue = ${$comment}{value};
+
+ # the -m switch can modify max characters per line, and trailing comment IDs can
+ # be split across lines
+ if($is_m_switch_active and ${$self}{body} !~ m/%$trailingcommentID/m){
+ $self->logger("$trailingcommentID not found in body using /m matching, assuming it has been split across line (see modifyLineBreaks: textWrapOptions)") if($is_t_switch_active);
+ my $trailingcommentIDwithLineBreaks;
+
+ # construct a reg exp that contains possible line breaks in between each character
+ if(${$masterSettings{modifyLineBreaks}{textWrapOptions}}{separator} ne ''){
+ $trailingcommentIDwithLineBreaks = join("\\".${$masterSettings{modifyLineBreaks}{textWrapOptions}}{separator}."?",split(//,$trailingcommentID));
+ } else {
+ $trailingcommentIDwithLineBreaks = join("\\R?",split(//,$trailingcommentID));
+ }
+ my $trailingcommentIDwithLineBreaksRegExp = qr/$trailingcommentIDwithLineBreaks/s;
+
+ # replace the line-broken trailing comment ID with a non-broken trailing comment ID
+ ${$self}{body} =~ s/%$trailingcommentIDwithLineBreaksRegExp/%$trailingcommentID/s;
+ }
if(${$self}{body} =~ m/%$trailingcommentID
(
(?! # not immediately preceeded by
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/UnNamedGroupingBracesBrackets.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/UnNamedGroupingBracesBrackets.pm
index 268f5b5adfa..30c969076c7 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/UnNamedGroupingBracesBrackets.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/UnNamedGroupingBracesBrackets.pm
@@ -68,7 +68,7 @@ sub create_unique_id{
my $self = shift;
$unNamedGroupingBracesCounter++;
- ${$self}{id} = "$tokens{unNamedgroupingBraces}$unNamedGroupingBracesCounter";
+ ${$self}{id} = "$tokens{UnNamedGroupingBracesBrackets}$unNamedGroupingBracesCounter";
return;
}
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm
index f3804aaf94d..ba6b698175e 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm
@@ -18,7 +18,7 @@ use strict;
use warnings;
use LatexIndent::Tokens qw/%tokens/;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
-use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
+use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_m_switch_active/;
use Data::Dumper;
use Exporter qw/import/;
our @EXPORT_OK = qw/put_verbatim_back_in find_verbatim_environments find_noindent_block find_verbatim_commands put_verbatim_commands_back_in/;
@@ -236,6 +236,15 @@ sub put_verbatim_back_in {
# delete the hash so it won't be operated upon again
delete ${$self}{verbatim}{${$child}{id}};
$self->logger("deleted key") if $is_t_switch_active;
+ } elsif ($is_m_switch_active and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1 and ${$self}{body} !~ m/${$child}{id}/){
+ $self->logger("${$child}{id} not found in body using /m matching, it may have been split across line (see modifyLineBreaks: textWrapOptions)") if($is_t_switch_active);
+
+ # search for a version of the verbatim ID that may have line breaks
+ my $verbatimIDwithLineBreaks = join("\\R?",split(//,${$child}{id}));
+ my $verbatimIDwithLineBreaksRegExp = qr/$verbatimIDwithLineBreaks/s;
+
+ # replace the line-broken verbatim ID with a non-broken verbatim ID
+ ${$self}{body} =~ s/$verbatimIDwithLineBreaksRegExp/${$child}{id}/s;
}
}
}
@@ -273,6 +282,15 @@ sub put_verbatim_commands_back_in {
# delete the hash so it won't be operated upon again
delete ${$self}{verbatimCommands}{${$child}{id}};
$self->logger("deleted key") if $is_t_switch_active;
+ } elsif ($is_m_switch_active and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1 and ${$self}{body} !~ m/${$child}{id}/){
+ $self->logger("${$child}{id} not found in body using /m matching, it may have been split across line (see modifyLineBreaks: textWrapOptions)") if($is_t_switch_active);
+
+ # search for a version of the verbatim ID that may have line breaks
+ my $verbatimIDwithLineBreaks = join("\\R?",split(//,${$child}{id}));
+ my $verbatimIDwithLineBreaksRegExp = qr/$verbatimIDwithLineBreaks/s;
+
+ # replace the line-broken verbatim ID with a non-broken verbatim ID
+ ${$self}{body} =~ s/$verbatimIDwithLineBreaksRegExp/${$child}{id}/s;
}
}
}
diff --git a/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml b/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml
index 20040817b12..fbc5401c3e9 100755
--- a/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml
+++ b/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml
@@ -1,17 +1,33 @@
-#
-# defaultSettings.yaml for latexindent.pl, version 3.0
+# defaultSettings.yaml for latexindent.pl, version 3.1, 2017-05-27
# a script that aims to
# beautify .tex, .sty, .cls files
#
# (or latexindent.exe if you're on Windows)
#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# See http://www.gnu.org/licenses/.
+#
+# Chris Hughes, 2017
+#
+# For all communication, please visit: https://github.com/cmhughes/latexindent.pl
+
+
# You're welcome to change anything you like in here, but
# it would probably be better to have your own user settings
# files somewhere else- remember that this file may be overwritten
# anytime that you update your distribution. Please see the manual
# for details of how to setup your own settings files.
#
-# Please read the manual first to understand what each switch does :)
+# Please read the manual first to understand what each switch does.
# latexindent can be called without a file extension,
# e.g, simply
@@ -71,6 +87,7 @@ logFilePreferences:
verbatimEnvironments:
verbatim: 1
lstlisting: 1
+ minted: 1
# verbatim commands such as \verb! body !, \lstinline$something else$
verbatimCommands:
@@ -155,6 +172,7 @@ lookForAlignDelims:
indentAfterItems:
itemize: 1
enumerate: 1
+ description: 1
list: 1
# if you want to use other names for your items (such as, for example, part)
@@ -356,6 +374,31 @@ commandCodeBlocks:
modifyLineBreaks:
preserveBlankLines: 1
condenseMultipleBlankLinesInto: 1
+ textWrapOptions:
+ columns: 0
+ separator: ""
+ removeParagraphLineBreaks:
+ all: 0
+ alignAtAmpersandTakesPriority: 1
+ environments:
+ quotation: 0
+ ifElseFi: 0
+ optionalArguments: 0
+ mandatoryArguments: 0
+ items: 0
+ specialBeginEnd: 0
+ afterHeading: 0
+ filecontents: 0
+ masterDocument: 0
+ paragraphsStopAt:
+ environments: 1
+ commands: 0
+ ifElseFi: 0
+ items: 0
+ specialBeginEnd: 0
+ heading: 0
+ filecontents: 0
+ comments: 0
environments:
BeginStartsOnOwnLine: 0
BodyStartsOnOwnLine: 0
diff --git a/Master/texmf-dist/scripts/latexindent/latexindent.pl b/Master/texmf-dist/scripts/latexindent/latexindent.pl
index 7cfe4a98bbd..b4474a14c49 100755
--- a/Master/texmf-dist/scripts/latexindent/latexindent.pl
+++ b/Master/texmf-dist/scripts/latexindent/latexindent.pl
@@ -1,5 +1,5 @@
#!/usr/bin/env perl
-# latexindent.pl, version 3.0.2, 2017-05-12
+# latexindent.pl, version 3.1, 2017-05-27
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -67,6 +67,6 @@ if(defined($switches{readLocalSettings}) and ($switches{readLocalSettings} eq ''
$switches{readLocalSettings} = 'localSettings.yaml';
}
-my $document = LatexIndent::Document->new(name=>"masterdocument",fileName=>$ARGV[0],switches=>\%switches);
+my $document = LatexIndent::Document->new(name=>"masterDocument",fileName=>$ARGV[0],switches=>\%switches);
$document->latexindent;
exit(0);