texlive[60522] trunk: latexindent (16sep21)

commits+karl at tug.org commits+karl at tug.org
Thu Sep 16 22:17:39 CEST 2021


Revision: 60522
          http://tug.org/svn/texlive?view=revision&revision=60522
Author:   karl
Date:     2021-09-16 22:17:39 +0200 (Thu, 16 Sep 2021)
Log Message:
-----------
latexindent (16sep21)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/latexindent/latexindent.pl
    trunk/Master/bin/win32/latexindent.exe
    trunk/Master/texmf-dist/doc/support/latexindent/README
    trunk/Master/texmf-dist/doc/support/latexindent/appendices.tex
    trunk/Master/texmf-dist/doc/support/latexindent/cmhlistings.tex
    trunk/Master/texmf-dist/doc/support/latexindent/latexindent.pdf
    trunk/Master/texmf-dist/doc/support/latexindent/latexindent.tex
    trunk/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex
    trunk/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex
    trunk/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex
    trunk/Master/texmf-dist/doc/support/latexindent/subsec-combine-text-wrap-para-line-breaks.tex
    trunk/Master/texmf-dist/doc/support/latexindent/subsec-remove-para-line-breaks.tex
    trunk/Master/texmf-dist/doc/support/latexindent/subsec-text-wrap-summary.tex
    trunk/Master/texmf-dist/doc/support/latexindent/subsec-text-wrap.tex
    trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-and-their-arguments.tex
    trunk/Master/texmf-dist/doc/support/latexindent/title.tex
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Arguments.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BlankLines.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Command.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileContents.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileExtension.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Heading.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/HorizontalWhiteSpace.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/IfElseFi.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Indent.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Item.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/KeyEqualsValuesBraces.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Logger.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/NamedGroupingBracesBrackets.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Preamble.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Replacement.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Sentence.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Switches.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/UnNamedGroupingBracesBrackets.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm
    trunk/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml
    trunk/Master/texmf-dist/scripts/latexindent/latexindent.pl

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/support/latexindent/sec-the-line-switch.tex
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Check.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Lines.pm

Modified: trunk/Build/source/texk/texlive/linked_scripts/latexindent/latexindent.pl
===================================================================
(Binary files differ)

Modified: trunk/Master/bin/win32/latexindent.exe
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/latexindent/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/README	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/README	2021-09-16 20:17:39 UTC (rev 60522)
@@ -1,5 +1,5 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-    latexindent.pl, version 3.11, 2021-07-31
+    latexindent.pl, version 3.12, 2021-09-16
 
     PERL script to indent code within environments, and align delimited 
     environments in .tex files.

Modified: trunk/Master/texmf-dist/doc/support/latexindent/appendices.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/appendices.tex	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/appendices.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -46,14 +46,15 @@
 		then, once you have answered \texttt{Y}, the appropriate modules will be installed onto
 		your distribution.
 
-	\subsection{Manually installed modules}\label{sec:manual-module-instal}
+	\subsection{Manually installing modules}\label{sec:manual-module-instal}
 		Manually installing the modules given in \cref{lst:helloworld} will vary depending on
 		your operating system and \texttt{Perl} distribution.
 
 	\subsubsection{Linux}
-		Linux users may be interested in exploring Perlbrew \cite{perlbrew}; an example
-		installation would be:
-		\begin{commandshell}
+		\paragraph{perlbrew}
+			Linux users may be interested in exploring Perlbrew \cite{perlbrew}; an example
+			installation would be:
+			\begin{commandshell}
 sudo apt-get install perlbrew
 perlbrew init
 perlbrew install perl-5.28.1
@@ -65,8 +66,9 @@
 cpanm Unicode::GCString
 \end{commandshell}
 
-		For other distributions, the Ubuntu/Debian approach may work as follows
-		\begin{commandshell}
+		\paragraph{Ubuntu/Debian}
+			For other distributions, the Ubuntu/Debian approach may work as follows
+			\begin{commandshell}
 sudo apt install perl
 sudo cpan -i App::cpanminus
 sudo cpanm YAML::Tiny
@@ -73,17 +75,29 @@
 sudo cpanm File::HomeDir
 sudo cpanm Unicode::GCString
 \end{commandshell}
-		or else by running, for example,
-		\begin{commandshell}
+			or else by running, for example,
+			\begin{commandshell}
 sudo perl -MCPAN -e'install "File::HomeDir"'
 \end{commandshell}
 
-		If you are using Alpine, some \texttt{Perl} modules are not build-compatible with Alpine,
-		but replacements are available through \texttt{apk}. For example, you might use the
-		commands given in \cref{lst:alpine-install}; thanks to \cite{jun-sheaf} for providing
-		these details.
+		\paragraph{Ubuntu: using the texlive from apt-get}
+			Ubuntu users that install texlive using \texttt{apt-get} as in the following
+			\begin{commandshell}
+sudo apt install texlive
+sudo apt install texlive-latex-recommended
+\end{commandshell}
+			may need the following additional command to work with \texttt{latexindent.pl}
+			\begin{commandshell}
+sudo apt install texlive-extra-utils 
+\end{commandshell}
 
-		\begin{cmhlistings}[style=tcblatex,language=Bash]{\texttt{alpine-install.sh}}{lst:alpine-install}
+		\paragraph{Alpine}
+			If you are using Alpine, some \texttt{Perl} modules are not build-compatible with Alpine,
+			but replacements are available through \texttt{apk}. For example, you might use the
+			commands given in \cref{lst:alpine-install}; thanks to \cite{jun-sheaf} for providing
+			these details.
+
+			\begin{cmhlistings}[style=tcblatex,language=Bash]{\texttt{alpine-install.sh}}{lst:alpine-install}
 # Installing perl
 apk --no-cache add miniperl perl-utils
 
@@ -107,9 +121,9 @@
 cpanm -n Unicode::GCString
 \end{cmhlistings}
 
-		Users of NixOS might like to see
-		\href{https://github.com/cmhughes/latexindent.pl/issues/222}{https://github.com/cmhughes/latexindent.pl/issues/222}
-		for tips.
+			Users of NixOS might like to see
+			\href{https://github.com/cmhughes/latexindent.pl/issues/222}{https://github.com/cmhughes/latexindent.pl/issues/222}
+			for tips.
 	\subsubsection{Mac}
 		Users of the Macintosh operating system might like to explore the following commands, for
 		example:

Modified: trunk/Master/texmf-dist/doc/support/latexindent/cmhlistings.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/cmhlistings.tex	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/cmhlistings.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -4,6 +4,13 @@
 ^^I:caption: #2^^J
 ^^I:name: #3^^J
 }
+\newcommand{\cmhlistingsfromfilelines}[4]{
+.. literalinclude:: #1^^J
+^^I:class: .#4^^J
+^^I:caption: #2^^J
+^^I:name: #3^^J
+^^I:linenos:^^J
+}
 \newcommand{\cmhlistingsfromfilefour}[6]{
 .. literalinclude:: #3^^J
 ^^I:class: .#6^^J
@@ -14,7 +21,7 @@
 ^^I:lineno-start: #1^^J
 }
 \newcommand{\cmhlabel}[1]{
-.. _#1:^^J
+.. \_#1:^^J
 }
 \newcommand{\warning}[1]{
 .. warning::^^J

Modified: trunk/Master/texmf-dist/doc/support/latexindent/latexindent.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/latexindent/latexindent.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/latexindent.tex	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/latexindent.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -27,7 +27,6 @@
 \usepackage{multicol}
 \usepackage{changepage}                              % adjust width of page
 \usepackage{fancyhdr}                                % headers & footers
-\usepackage{wrapfig}
 \usepackage{fontawesome}
 \usepackage[sc,format=hang,font=small]{caption}      % captions
 \usepackage[backend=bibtex]{biblatex}                % bibliography
@@ -42,7 +41,7 @@
 \usepackage{totalcount}
 \usepackage{standalone}
 % setup gitinfo2, as in the manual, details just above begin{document}
-\usepackage[mark,grumpy]{gitinfo2}
+\usepackage[mark]{gitinfo2}
 % tikz, tcolorbox libraries
 \usetikzlibrary{positioning}
 \usetikzlibrary{decorations.pathmorphing}
@@ -163,6 +162,21 @@
 			sharp corners,
 			colbacktitle=white!75!black
 		},
+	tex-TCB/.style={
+			listing only,
+			listing engine=listings,
+			left=0cm,
+			boxrule=0pt,
+			sharp corners,
+			center title,
+			colframe=white!40!black,
+			colback=white,
+			sharp corners,
+			colbacktitle=white!75!black,
+			toprule=1pt,
+			bottomrule=1pt,
+			titlerule=1pt,
+		},
 	yaml-TCB/.style={
 			listing only,
 			listing engine=listings,
@@ -326,6 +340,11 @@
 	columns=fullflexible,
 }
 
+\lstdefinestyle{lineNumbersTeX}{
+	numbers=left,
+	numberstyle=\color{blue},
+}
+
 \lstdefinestyle{fileExtensionPreference}{
 	style=yaml-LST,
 	firstnumber=44,linerange={44-48},
@@ -767,9 +786,14 @@
   {}% <numberless-entry-format>
   {\titlerule*[0.5em]{$\cdot$}\contentspage}
 
+% to explore in the future: 
+%   partial toc customisation
+%   https://tex.stackexchange.com/questions/66345/how-to-remove-section-indentation-in-partial-toc-using-titletoc
+
 \setcounter{secnumdepth}{6}
 \setcounter{tocdepth}{4}
 \makeindex
+
 \begin{document}
 \renewcommand*{\thefootnote}{\arabic{footnote}}
 \input{title.tex}
@@ -801,6 +825,7 @@
  \input{subsec-poly-switches}
  \stopcontents[the-m-switch]
  \input{sec-replacements}
+ \input{sec-the-line-switch}
  \input{sec-fine-tuning}
  \input{sec-conclusions-know-limitations}
  \input{references}

Modified: trunk/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -375,7 +375,7 @@
 		      0);
 		\item \announce{2020-03-21}{delimiter RegEx feature}{delimiterRegEx} optionally specifies the
 		      pattern matching to be used for the alignment delimeter (default:
-		      \lstinline3 '(?<!\\)(&)'3);
+		      \lstinline* '(?<!\\)(&)'*);
 		\item \announce{2020-03-21}{delimiter justification}{delimiterJustification} optionally
 		      specifies the justification for the alignment delimeters (default: left); note that this
 		      feature is only useful if you have delimiters of different lengths in the same column,
@@ -749,7 +749,7 @@
 	\announce{2020-03-21}{delimiterRegEx feature} will, by default, align code blocks at the
 	ampersand character. The behaviour is controlled by the \texttt{delimiterRegEx} field
 	within \texttt{lookForAlignDelims}; the default value is
-	\lstinline3'(?<!\\)(&)'3, which can be read as: \emph{an ampersand, as long as it is not
+	\lstinline*'(?<!\\)(&)'*, which can be read as: \emph{an ampersand, as long as it is not
 		immediately preceeded by a backslash}.
 	\index{warning!capturing parenthesis for lookForAlignDelims}
 	\index{capturing parenthesis (regex)}
@@ -1098,7 +1098,7 @@
 	\texttt{indentRules} (see \vref{sec:noadd-indent-rules}); you will find the default
 	\texttt{indentRules} contains
 	\lstinline!chapter: " "! which tells \texttt{latexindent.pl} simply to use a space
-	character after \texttt{\chapter} headings (once \texttt{indent} is set to \texttt{1} for
+	character after \texttt{chapter} headings (once \texttt{indent} is set to \texttt{1} for
 	\texttt{chapter}).
 
 	For example, assuming that you have the code in \cref{lst:headings1yaml} saved into
@@ -1185,10 +1185,11 @@
 	\begin{table}[!htp]
 		\begin{widepage}
 			\centering
-			\caption{Code blocks known to \texttt{latexindent.pl}}\label{tab:code-blocks}
+			\caption{Code blocks known to \texttt{latexindent.pl}}
+			\label{tab:code-blocks}
 			\begin{tabular}{m{.3\linewidth}@{\hspace{.25cm}}m{.4\linewidth}@{\hspace{.25cm}}m{.2\linewidth}}
 				\toprule
-				Code block                    & characters allowed in name                                                                  & example                                                                                                                                                               \\
+				Code block                    & characters allowed in name                                                                  & example                                                                                                                                                                \\
 				\midrule
 				environments                  & \lstinline!a-zA-Z@\*0-9_\\!                                                                 &
 				\begin{lstlisting}[,nolol=true,]
@@ -1211,10 +1212,10 @@
 }
   \end{lstlisting}
 				\\\cmidrule{2-3}
-				commands                      & \lstinline!+a-zA-Z@\*0-9_\:!                                                                & \lstinline!\mycommand!$\langle$\itshape{arguments}$\rangle$                                                                                                           \\\cmidrule{2-3}
-				keyEqualsValuesBracesBrackets & \lstinline!a-zA-Z@\*0-9_\/.\h\{\}:\#-!                                                      & \lstinline!my key/.style=!$\langle$\itshape{arguments}$\rangle$                                                                                                       \\\cmidrule{2-3}
-				namedGroupingBracesBrackets   & \lstinline!0-9\.a-zA-Z@\*><!                                                                & \lstinline!in!$\langle$\itshape{arguments}$\rangle$                                                                                                                   \\\cmidrule{2-3}
-				UnNamedGroupingBracesBrackets & \centering\emph{No name!}                                                                   & \lstinline!{! or \lstinline![! or \lstinline!,! or \lstinline!&! or \lstinline!)! or \lstinline!(! or \lstinline!$! followed by $\langle$\itshape{arguments}$\rangle$ \\\cmidrule{2-3}
+				commands                      & \lstinline!+a-zA-Z@\*0-9_\:!                                                                & \lstinline!\mycommand!$\langle$\itshape{arguments}$\rangle$                                                                                                            \\\cmidrule{2-3}
+				keyEqualsValuesBracesBrackets & \lstinline!a-zA-Z@\*0-9_\/.\h\{\}:\#-!                                                      & \lstinline!my key/.style=!$\langle$\itshape{arguments}$\rangle$                                                                                                        \\\cmidrule{2-3}
+				namedGroupingBracesBrackets   & \lstinline!0-9\.a-zA-Z@\*><!                                                                & \lstinline!in!$\langle$\itshape{arguments}$\rangle$                                                                                                                    \\\cmidrule{2-3}
+				UnNamedGroupingBracesBrackets & \centering\emph{No name!}                                                                   & \lstinline!{! or \lstinline![! or \lstinline!,! or \lstinline!\&! or \lstinline!)! or \lstinline!(! or \lstinline!$! followed by $\langle$\itshape{arguments}$\rangle$ \\\cmidrule{2-3}
 				ifElseFi                      & \lstinline!@a-zA-Z! but must begin with either \newline \lstinline!\if! of \lstinline!\@if! &
 				\begin{lstlisting}[,nolol=true,]
 \ifnum...
@@ -1222,31 +1223,31 @@
 \else
 ...
 \fi
-  \end{lstlisting}                                                                                                                                                                                                                                                                     \\\cmidrule{2-3}
+  \end{lstlisting}                                                                                                                                                                                                                                                                      \\\cmidrule{2-3}
 				items                         & User specified, see \vref{lst:indentafteritems,lst:itemNames}                               &
 				\begin{lstlisting}[,nolol=true,]
 \begin{enumerate}
   \item ...
 \end{enumerate}
-  \end{lstlisting}                                                                                                                                                                                                                                                                     \\\cmidrule{2-3}
+  \end{lstlisting}                                                                                                                                                                                                                                                                      \\\cmidrule{2-3}
 				specialBeginEnd               & User specified, see \vref{lst:specialBeginEnd}                                              &
 				\begin{lstlisting}[,nolol=true,]
 \[
   ...
 \]
-  \end{lstlisting}                                                                                                                                                                                                                                                                     \\\cmidrule{2-3}
+  \end{lstlisting}                                                                                                                                                                                                                                                                      \\\cmidrule{2-3}
 				afterHeading                  & User specified, see \vref{lst:indentAfterHeadings}                                          &
 				\begin{lstlisting}[,morekeywords={chapter},nolol=true,]
 \chapter{title}
   ...
 \section{title}
-  \end{lstlisting}                                                                                                                                                                                                                                              \\\cmidrule{2-3}
+  \end{lstlisting}                                                                                                                                                                                                                                               \\\cmidrule{2-3}
 				filecontents                  & User specified, see \vref{lst:fileContentsEnvironments}                                     &
 				\begin{lstlisting}[,nolol=true,]
 \begin{filecontents}
 ...
 \end{filecontents}
-  \end{lstlisting}                                                                                                                                                                                                                                                                     \\
+  \end{lstlisting}                                                                                                                                                                                                                                                                      \\
 				\bottomrule
 			\end{tabular}
 		\end{widepage}

Modified: trunk/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -415,7 +415,84 @@
 	and \emph{only} perform replacements/substitutions by using the \texttt{-rr} switch; full
 	details and examples are given in \vref{sec:replacements}.
 
+\flagbox{-k, --check}
+	\index{switches!-k, --check definition and details}
+	\begin{commandshell}
+latexindent.pl -k myfile.tex
+latexindent.pl -check myfile.tex
+\end{commandshell}
+	You can%
+	\announce*{2021-09-16}{-k,-check switch} instruct
+	\texttt{latexindent.pl} to check if the text after indentation matches that given in the
+	original file.
+
+	The \texttt{exit} code
+	\index{exit code} of \texttt{latexindent.pl} is 0 by default. If
+	you use the \texttt{-k} switch then
+	\begin{itemize}
+		\item if the text after indentation matches that given in the original file, then the exit code
+		      is 0;
+		\item if the text after indentation does \emph{not} match that given in the original file, then
+		      the exit code is 1.
+	\end{itemize}
+
+	The value of the exit code may be important to those wishing to, for example, check the
+	status of the indentation in continuous integration tools such as GitHub Actions. Full
+	details of the exit codes of \texttt{latexindent.pl} are given in \cref{tab:exit-codes}.
+
+	A simple \texttt{diff} will be given in \texttt{indent.log}.
+
+\flagbox{-kv, --checkv}
+	\index{switches!-kv, --checkv definition and details}
+	\begin{commandshell}
+latexindent.pl -kv myfile.tex
+latexindent.pl -checkv myfile.tex
+\end{commandshell}
+	\announce*{2021-09-16}{-kv, -checkv: check verbose switch} The \texttt{check verbose} switch is
+	exactly the same as the \texttt{-k} switch, except that it is \emph{verbose}, and it will
+	output the (simple) diff to the terminal, as well as to \texttt{indent.log}.
+
+\flagbox{-n, --lines=MIN-MAX}
+	\index{switches!-n, --lines definition and details}
+	\begin{commandshell}
+latexindent.pl -n 5-8 myfile.tex
+latexindent.pl -lines 5-8 myfile.tex
+\end{commandshell}
+	\announce*{2021-09-16}{-n, -lines switch} The \texttt{lines} switch instructs
+	\texttt{latexindent.pl} to operate only on specific line ranges within
+	\texttt{myfile.tex}.
+
+	Complete demonstrations are given in \cref{sec:line-switch}.
+
 \subsection{From arara}\label{sec:arara}
 	Using \texttt{latexindent.pl} from the command line is fine for some folks, but others
 	may find it easier to use from \texttt{arara}; you can find the arara rule for
 	\texttt{latexindent.pl} and its associated documentation at \cite{paulo}.
+
+\subsection{Summary of exit codes}
+	\index{exit code!summary}
+	Assuming that you call \texttt{latexindent.pl} on \texttt{myfile.tex}
+	\begin{commandshell}
+latexindent.pl myfile.tex
+\end{commandshell}
+	then \texttt{latexindent.pl} can exit with the exit codes given in \cref{tab:exit-codes}.
+
+	\begin{table}[!htb]
+		\caption{Exit codes for \texttt{latexindent.pl}}
+		\label{tab:exit-codes}
+		\begin{tabular}{ccl}
+			\toprule
+			exit code & indentation & status                                                                                        \\
+			\midrule
+			0         & \faCheck    & success; if \texttt{-k} or \texttt{-kv} active, indented text matches original                \\
+			0         & \faClose    & success; if \texttt{-version} or \texttt{-help}, no indentation performed                     \\
+			1         & \faCheck    & success, and \texttt{-k} or \texttt{-kv} active; indented text \emph{different} from original \\
+			\midrule
+			2         & \faClose    & failure, \texttt{defaultSettings.yaml} could not be read                                      \\
+			3         & \faClose    & failure, myfile.tex not found                                                                 \\
+			4         & \faClose    & failure, myfile.tex exists but cannot be read                                                 \\
+			5         & \faClose    & failure, \texttt{-w} active, and back-up file cannot be written                               \\
+			6         & \faClose    & failure, \texttt{-c} active, and cruft directory does not exist                               \\
+			\bottomrule
+		\end{tabular}
+	\end{table}

Added: trunk/Master/texmf-dist/doc/support/latexindent/sec-the-line-switch.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/sec-the-line-switch.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/latexindent/sec-the-line-switch.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -0,0 +1,187 @@
+% arara: pdflatex: {shell: yes, files: [latexindent]}
+\section{The --lines switch}\label{sec:line-switch}
+ \texttt{latexindent.pl}
+ \announce*{2021-09-16}{line switch demonstration} can
+ operate on a \emph{selection} of lines of the file using the \texttt{--lines} or
+ \texttt{-n} switch.
+
+ \index{switches!-lines demonstration}
+
+ The basic syntax is \texttt{--lines MIN-MAX}, so for example
+ \begin{commandshell}
+latexindent.pl --lines 3-7 myfile.tex
+latexindent.pl -n 3-7 myfile.tex
+\end{commandshell}
+ will only operate upon lines 3 to 7 in \texttt{myfile.tex}. All of the other lines will
+ \emph{not} be operated upon by \texttt{latexindent.pl}.
+
+ The options for the \texttt{lines} switch are:
+ \begin{itemize}
+	 \item line range, as in \texttt{--lines 3-7}
+	 \item single line, as in \texttt{--lines 5}
+	 \item multiple line ranges separated by commas, as in \texttt{--lines 3-5,8-10}
+	 \item negated line ranges, as in \texttt{--lines !3-5} which translates to \texttt{--lines
+		       1-2,6-N}, where N is the number of lines in your file.
+ \end{itemize}
+
+ We demonstrate this feature, and the available variations in what follows. We will use
+ the file in \cref{lst:myfile}.
+
+ \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile.tex}[tex-TCB]{\texttt{myfile.tex}}{lst:myfile}
+
+ \begin{example}
+	 We demonstrate the basic usage using the command
+	 \begin{commandshell}
+latexindent.pl --lines 3-7 myfile.tex -o=+-mod1
+\end{commandshell}
+	 which instructs \texttt{latexindent.pl} to only operate on lines 3 to 7; the output is given in \cref{lst:myfile-mod1}.
+
+	 \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile-mod1.tex}[tex-TCB]{\texttt{myfile-mod1.tex}}{lst:myfile-mod1}
+
+	 The following two calls to \texttt{latexindent.pl} are equivalent
+	 \begin{commandshell}
+latexindent.pl --lines 3-7 myfile.tex -o=+-mod1
+latexindent.pl --lines 7-3 myfile.tex -o=+-mod1
+\end{commandshell}
+	 as \texttt{latexindent.pl} performs a check to put the lowest number first.
+ \end{example}
+
+ \begin{example}
+	 You can call the \texttt{lines} switch with only \emph{one number} and
+	 in which case only that line will be operated upon. For example
+	 \begin{commandshell}
+latexindent.pl --lines 5 myfile.tex -o=+-mod2
+\end{commandshell}
+	 instructs \texttt{latexindent.pl} to only operate on line 5; the output is given in \cref{lst:myfile-mod2}.
+
+	 \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile-mod2.tex}[tex-TCB]{\texttt{myfile-mod2.tex}}{lst:myfile-mod2}
+
+	 The following two calls are equivalent:
+	 \begin{commandshell}
+latexindent.pl --lines 5 myfile.tex
+latexindent.pl --lines 5-5 myfile.tex
+\end{commandshell}
+ \end{example}
+
+ \begin{example}
+	 If you specify a value outside of the line range of the file then \texttt{latexindent.pl} will ignore the
+	 \texttt{lines} argument, detail as such in the log file, and proceed to operate on the entire file.
+
+	 For example, in the following call
+	 \begin{commandshell}
+latexindent.pl --lines 11-13 myfile.tex
+  \end{commandshell}
+	 \texttt{latexindent.pl} will ignore the \texttt{lines} argument, and \emph{operate on the entire file} because \cref{lst:myfile} only has 12 lines.
+
+	 Similarly, in the call
+	 \begin{commandshell}
+latexindent.pl --lines -1-3 myfile.tex
+  \end{commandshell}
+	 \texttt{latexindent.pl} will ignore the \texttt{lines} argument, and \emph{operate on the entire file} because we assume that negatively numbered
+	 lines in a file do not exist.
+ \end{example}
+
+ \begin{example}
+	 You can specify \emph{multiple line ranges} as in the following
+	 \begin{commandshell}
+latexindent.pl --lines 3-5,8-10 myfile.tex -o=+-mod3
+\end{commandshell}
+	 which instructs \texttt{latexindent.pl} to operate upon lines 3 to 5 and lines 8 to 10; the output is given in \cref{lst:myfile-mod3}.
+
+	 \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile-mod3.tex}[tex-TCB]{\texttt{myfile-mod3.tex}}{lst:myfile-mod3}
+
+	 The following calls to \texttt{latexindent.pl} are all equivalent
+	 \begin{commandshell}
+latexindent.pl --lines 3-5,8-10 myfile.tex
+latexindent.pl --lines 8-10,3-5 myfile.tex
+latexindent.pl --lines 10-8,3-5 myfile.tex
+latexindent.pl --lines 10-8,5-3 myfile.tex
+\end{commandshell}
+	 as \texttt{latexindent.pl} performs a check to put the lowest line ranges first, and within each line range, it puts
+	 the lowest number first.
+ \end{example}
+
+ \begin{example}
+	 There's no limit to the number of line ranges that you can specify, they just need to be separated by commas. For example
+	 \begin{commandshell}
+latexindent.pl --lines 1-2,4-5,9-10,12 myfile.tex -o=+-mod4
+\end{commandshell}
+	 has four line ranges: lines 1 to 2, lines 4 to 5, lines 9 to 10 and line 12. The output is given in \cref{lst:myfile-mod4}.
+
+	 \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile-mod4.tex}[tex-TCB]{\texttt{myfile-mod4.tex}}{lst:myfile-mod4}
+
+	 As previously, the ordering does not matter, and the following calls to \texttt{latexindent.pl} are all equivalent
+	 \begin{commandshell}
+latexindent.pl --lines 1-2,4-5,9-10,12 myfile.tex
+latexindent.pl --lines 2-1,4-5,9-10,12 myfile.tex
+latexindent.pl --lines 4-5,1-2,9-10,12 myfile.tex
+latexindent.pl --lines 12,4-5,1-2,9-10 myfile.tex
+\end{commandshell}
+	 as \texttt{latexindent.pl} performs a check to put the lowest line ranges first, and within each line range, it puts
+	 the lowest number first.
+ \end{example}
+
+ \begin{example}
+	 \index{switches!-lines demonstration, negation}
+	 You can specify \emph{negated line ranges} by using \texttt{!} as in
+	 \begin{commandshell}
+latexindent.pl --lines !5-7 myfile.tex -o=+-mod5
+\end{commandshell}
+	 which instructs \texttt{latexindent.pl} to operate upon all of the lines \emph{except} lines 5 to 7.
+
+	 In other words, \texttt{latexindent.pl} \emph{will} operate on lines 1 to 4, and 8 to 12, so the following
+	 two calls are equivalent:
+	 \begin{commandshell}
+latexindent.pl --lines !5-7 myfile.tex 
+latexindent.pl --lines 1-4,8-12 myfile.tex 
+\end{commandshell}
+	 The output is given in \cref{lst:myfile-mod5}.
+
+	 \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile-mod5.tex}[tex-TCB]{\texttt{myfile-mod5.tex}}{lst:myfile-mod5}
+
+ \end{example}
+
+ \begin{example}
+	 \index{switches!-lines demonstration, negation}
+	 You can specify \emph{multiple negated line ranges} such as
+	 \begin{commandshell}
+latexindent.pl --lines !5-7,!9-10 myfile.tex -o=+-mod6
+   \end{commandshell}
+	 which is equivalent to:
+	 \begin{commandshell}
+latexindent.pl --lines 1-4,8,11-12 myfile.tex -o=+-mod6
+   \end{commandshell}
+	 The output is given in \cref{lst:myfile-mod6}.
+
+	 \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile-mod6.tex}[tex-TCB]{\texttt{myfile-mod6.tex}}{lst:myfile-mod6}
+ \end{example}
+
+ \begin{example}
+	 If you specify a line range with anything other than an integer, then
+	 \texttt{latexindent.pl} will ignore the \texttt{lines} argument, and \emph{operate on the entire file}.
+
+	 Sample calls that result in the \texttt{lines} argument being ignored include the following:
+	 \begin{commandshell}
+latexindent.pl --lines 1-x myfile.tex 
+latexindent.pl --lines !y-3 myfile.tex 
+     \end{commandshell}
+ \end{example}
+
+ \begin{example}
+	 We can, of course, use the \texttt{lines} switch in combination with other switches.
+
+	 For example, let's use with the file in \cref{lst:myfile1}.
+
+	 \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile1.tex}[tex-TCB]{\texttt{myfile1.tex}}{lst:myfile1}
+
+	 We can demonstrate interaction with the \texttt{-m} switch (see \vref{sec:modifylinebreaks}); in particular,
+	 if we use \vref{lst:mlb2}, \vref{lst:env-mlb7} and \vref{lst:env-mlb8} and run
+	 \begin{widepage}
+		 \begin{commandshell}
+latexindent.pl --lines 6 myfile1.tex -o=+-mod1 -m -l env-mlb2,env-mlb7,env-mlb8 -o=+-mod1
+     \end{commandshell}
+	 \end{widepage}
+	 then we receive the output in \cref{lst:myfile1-mod1}.
+
+	 \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile1-mod1.tex}[tex-TCB]{\texttt{myfile1-mod1.tex}}{lst:myfile1-mod1}
+ \end{example}


Property changes on: trunk/Master/texmf-dist/doc/support/latexindent/sec-the-line-switch.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -12,9 +12,6 @@
  \printcontents[the-m-switch]{}{0}{}
 
 \yamltitle{modifylinebreaks}*{fields}
-	\begin{wrapfigure}[7]{r}[0pt]{8cm}
-		\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)
@@ -25,6 +22,8 @@
 		if the \texttt{-m} switch has been used}. A snippet of the default settings of this field
 	is shown in \cref{lst:modifylinebreaks}.
 
+	\cmhlistingsfromfile[style=modifylinebreaks]*{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{modifyLineBreaks}}{lst:modifylinebreaks}
+
 	Having read the previous paragraph, it should sound reasonable that, if you call
 	\texttt{latexindent.pl} using the \texttt{-m} switch, then you give it permission to
 	modify line breaks in your file, but let's be clear:

Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsec-combine-text-wrap-para-line-breaks.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsec-combine-text-wrap-para-line-breaks.tex	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsec-combine-text-wrap-para-line-breaks.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -42,12 +42,12 @@
 	\index{text wrap!recommended starting point}
 
 	I%
-	\announce*{2021-07-31}{textWrapOptions new feature: beforeFindingChildCodeBlocks} think it likely that most users will wish to employ the
+	\announce{2021-07-31}{textWrapOptions new feature: beforeFindingChildCodeBlocks} think it likely that most users will wish to employ the
 	\texttt{beforeFindingChildCodeBlocks} option for the text wrap routine.
 
 	To motivate its use, we begin with the file in \cref{lst:textwrap-bfccb}.
 
-	\cmhlistingsfromfile*{demonstrations/textwrap-bfccb.tex}{\texttt{textwrap-bfccb.tex}}{lst:textwrap-bfccb}
+	\cmhlistingsfromfile{demonstrations/textwrap-bfccb.tex}{\texttt{textwrap-bfccb.tex}}{lst:textwrap-bfccb}
 
 	Using the settings in \cref{lst:textwrap12-yaml} and running
 	\begin{commandshell}
@@ -55,7 +55,7 @@
 \end{commandshell}
 	gives the output in \cref{lst:textwrap-bfccb-mod12}
 
-	\cmhlistingsfromfile*{demonstrations/textwrap-bfccb-mod12.tex}{\texttt{textwrap-bfccb-mod12.tex}}{lst:textwrap-bfccb-mod12}
+	\cmhlistingsfromfile{demonstrations/textwrap-bfccb-mod12.tex}{\texttt{textwrap-bfccb-mod12.tex}}{lst:textwrap-bfccb-mod12}
 
 	Note that we have added a `ruler' to \cref{lst:textwrap-bfccb-mod12} to assist with
 	measuring.
@@ -83,9 +83,9 @@
 \end{commandshell}
 	we receive the output in \cref{lst:textwrap-bfccb-mod13}.
 
-	\cmhlistingsfromfile*{demonstrations/textwrap13.yaml}[MLB-TCB,width=\linewidth]{\texttt{textwrap13.yaml} (tweaked quick start)}{lst:textwrap13-yaml}
+	\cmhlistingsfromfile{demonstrations/textwrap13.yaml}[MLB-TCB,width=\linewidth]{\texttt{textwrap13.yaml} (tweaked quick start)}{lst:textwrap13-yaml}
 
-	\cmhlistingsfromfile*{demonstrations/textwrap-bfccb-mod13.tex}{\texttt{textwrap-bfccb-mod13.tex}}{lst:textwrap-bfccb-mod13}
+	\cmhlistingsfromfile{demonstrations/textwrap-bfccb-mod13.tex}{\texttt{textwrap-bfccb-mod13.tex}}{lst:textwrap-bfccb-mod13}
 
 	This output is different from \cref{lst:textwrap-bfccb-mod12}, but is still not ideal, as
 	the \texttt{test} command has indented its mandatory argument. We can employ
@@ -98,8 +98,8 @@
 
 	\begin{widepage}
 		\begin{cmhtcbraster}
-			\cmhlistingsfromfile*{demonstrations/textwrap-bfccb-mod14.tex}{\texttt{textwrap-bfccb-mod14.tex}}{lst:textwrap-bfccb-mod14}
-			\cmhlistingsfromfile*{demonstrations/textwrap14.yaml}[MLB-TCB]{\texttt{textwrap14.yaml}}{lst:textwrap14-yaml}
+			\cmhlistingsfromfile{demonstrations/textwrap-bfccb-mod14.tex}{\texttt{textwrap-bfccb-mod14.tex}}{lst:textwrap-bfccb-mod14}
+			\cmhlistingsfromfile{demonstrations/textwrap14.yaml}[MLB-TCB]{\texttt{textwrap14.yaml}}{lst:textwrap14-yaml}
 		\end{cmhtcbraster}
 	\end{widepage}
 
@@ -109,4 +109,4 @@
 	output in \cref{lst:textwrap-bfccb-mod14}, then we would need to employ an exception,
 	which we demonstrate in \cref{lst:textwrap15-yaml}.
 
-	\cmhlistingsfromfile*{demonstrations/textwrap15.yaml}[MLB-TCB]{\texttt{textwrap15.yaml}}{lst:textwrap15-yaml}
+	\cmhlistingsfromfile{demonstrations/textwrap15.yaml}[MLB-TCB]{\texttt{textwrap15.yaml}}{lst:textwrap15-yaml}

Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsec-remove-para-line-breaks.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsec-remove-para-line-breaks.tex	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsec-remove-para-line-breaks.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -127,11 +127,18 @@
 	\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
+	The only special case is the \texttt{mainDocument} 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}.
 
+	Note:
+	\announce*{2021-09-16}*{removeParagraphLineBreaks: masterDocument now mainDocument}
+	\texttt{mainDocument} replaces \texttt{masterDocument} which was used in previous verions
+	of \texttt{latexindent.pl}. The field \texttt{masterDocument} is still supported, but it
+	is anticipated to be removed in a future version, so I recommend using
+	\texttt{mainDocument} instead.
+
 	\begin{cmhtcbraster}
 		\cmhlistingsfromfile{demonstrations/shortlines-md.tex}{\texttt{shortlines-md.tex}}{lst:shortlines-md}
 		\cmhlistingsfromfile{demonstrations/remove-para4.yaml}[MLB-TCB]{\texttt{remove-para4.yaml}}{lst:remove-para4-yaml}

Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsec-text-wrap-summary.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsec-text-wrap-summary.tex	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsec-text-wrap-summary.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -1,7 +1,7 @@
 % arara: pdflatex: {shell: yes, files: [latexindent]}
 \subsection{Summary of text wrapping}
 	I consider%
-	\announce*{2021-07-31}{text wrap quick start}
+	\announce{2021-07-31}{text wrap quick start}
 	the most useful starting point for text wrapping to be given in
 	\cref{subsec:textwrapping-quick-start} and \cref{subsubsec:text-wrap-remove-para-bfccb}.
 

Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsec-text-wrap.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsec-text-wrap.tex	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsec-text-wrap.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -10,7 +10,7 @@
 	Of all the available text wrapping options, I consider \cref{lst:textwrap-qs-yaml} to be
 	among the most helpful starting points.
 
-	\cmhlistingsfromfile*{demonstrations/textwrap-qs.yaml}[MLB-TCB,width=1\linewidth]{\texttt{textwrap-qs.yaml}}{lst:textwrap-qs-yaml}
+	\cmhlistingsfromfile{demonstrations/textwrap-qs.yaml}[MLB-TCB,width=1\linewidth]{\texttt{textwrap-qs.yaml}}{lst:textwrap-qs-yaml}
 
 	\index{text wrap!quick start}
 
@@ -182,7 +182,7 @@
 	The code blocks detailed in \cref{lst:textWrapOptionsAll} are with direct reference to
 	those detailed in \vref{tab:code-blocks}.
 
-	The only special case is the \texttt{masterDocument} field; this is designed for
+	The only special case is the \texttt{mainDocument} field; this is designed for
 	`chapter'-type files that may contain paragraphs that are not within any other
 	code-blocks. The same notation is used between this feature and the
 	\texttt{removeParagraphLineBreaks} described in \vref{lst:removeParagraphLineBreaks}; in
@@ -189,8 +189,15 @@
 	fact, the two features can even be combined (this is detailed in
 	\vref{subsec:removeparagraphlinebreaks:and:textwrap}).
 
+	Note:
+	\announce*{2021-09-16}*{textWrapOptions: masterDocument now mainDocument}
+	\texttt{mainDocument} replaces \texttt{masterDocument} which was used in previous verions
+	of \texttt{latexindent.pl}. The field \texttt{masterDocument} is still supported, but it
+	is anticipated to be removed in a future version, so I recommend using
+	\texttt{mainDocument} instead.
+
 	Let's explore these switches with reference to the code given in \cref{lst:textwrap5};
-	the text outside of the environment is considered part of the \texttt{masterDocument}.
+	the text outside of the environment is considered part of the \texttt{mainDocument}.
 
 	\begin{widepage}
 		\cmhlistingsfromfile{demonstrations/textwrap5.tex}{\texttt{textwrap5.tex}}{lst:textwrap5}
@@ -221,8 +228,8 @@
 		      will operate upon \emph{all} code blocks;
 		\item in \cref{lst:textwrap4-yaml} we have \emph{not} specified \texttt{all}, and instead, have
 		      specified that text wrapping should be applied to each of \texttt{environments} and
-		      \texttt{masterDocument};
-		\item in \cref{lst:textwrap5-yaml} we have specified text wrapping for \texttt{masterDocument}
+		      \texttt{mainDocument};
+		\item in \cref{lst:textwrap5-yaml} we have specified text wrapping for \texttt{mainDocument}
 		      and on a \emph{per-name} basis for \texttt{environments} code blocks.
 	\end{itemize}
 
@@ -303,7 +310,7 @@
 		\item in \cref{lst:textwrap6-mod7} the text wrapping routine has not been applied to
 		      \texttt{myenv} because it has been switched off (per-name) in \cref{lst:textwrap7-yaml};
 		\item in \cref{lst:textwrap6-mod8} the text wrapping routine has not been applied to
-		      \texttt{masterDocument} because of the settings in \cref{lst:textwrap8-yaml}.
+		      \texttt{mainDocument} because of the settings in \cref{lst:textwrap8-yaml}.
 	\end{itemize}
 
 	The \texttt{columns} field has a variety of different ways that it can be specified;
@@ -338,12 +345,12 @@
 
 	Notice that:
 	\begin{itemize}
-		\item in \cref{lst:textwrap6-mod9} the text for the \texttt{masterDocument} has been wrapped
+		\item in \cref{lst:textwrap6-mod9} the text for the \texttt{mainDocument} has been wrapped
 		      using \texttt{30} columns, while \texttt{environments} has been wrapped using \texttt{50}
 		      columns;
 		\item in \cref{lst:textwrap6-mod11} the text for \texttt{myenv} has been wrapped using
 		      \texttt{50} columns, the text for \texttt{another} has been wrapped using \texttt{15}
-		      columns, and \texttt{masterDocument} has been wrapped using \texttt{30} columns.
+		      columns, and \texttt{mainDocument} has been wrapped using \texttt{30} columns.
 	\end{itemize}
 	If you don't specify a \texttt{default} value on per-code-block basis, then the
 	\texttt{default} value from \texttt{columns} will be inherited; if you don't specify a

Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-and-their-arguments.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-and-their-arguments.tex	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-and-their-arguments.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -172,13 +172,13 @@
 	has received three spaces of indentation.
 
 \yamltitle{noAdditionalIndentGlobal}*{fields}
-	\begin{wrapfigure}[6]{r}[0pt]{7cm}
-		\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 (see \cref{lst:noAdditionalIndentGlobal:environments}).
+
+	\cmhlistingsfromfile[style=noAdditionalIndentGlobalEnv]*{../defaultSettings.yaml}[width=.5\linewidth,before=\centering,yaml-TCB]{\texttt{noAdditionalIndentGlobal}}{lst:noAdditionalIndentGlobal:environments}
+
 	Let's say that you change the value of \texttt{environments} to \texttt{1} in
 	\cref{lst:noAdditionalIndentGlobal:environments}, and that you run
 	\index{switches!-l demonstration}
@@ -240,12 +240,12 @@
 	\end{minipage}
 
 \yamltitle{indentRulesGlobal}*{fields}
-	\begin{wrapfigure}[4]{r}[0pt]{7cm}
-		\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
+	\texttt{indentRulesGlobal} as detailed in \cref{lst:indentRulesGlobal:environments}.
+
+	\cmhlistingsfromfile[style=indentRulesGlobalEnv]*{../defaultSettings.yaml}[width=.5\linewidth,before=\centering,yaml-TCB]{\texttt{indentRulesGlobal}}{lst:indentRulesGlobal:environments}
+
+	If you change the \texttt{environments} field to anything involving horizontal space, say
 	\lstinline!" "!, and then run the following commands
 	\index{switches!-l demonstration}
 

Modified: trunk/Master/texmf-dist/doc/support/latexindent/title.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/title.tex	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/doc/support/latexindent/title.tex	2021-09-16 20:17:39 UTC (rev 60522)
@@ -8,7 +8,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.11
+		\centering\ttfamily\bfseries latexindent.pl\\[1cm] Version 3.12
 	\end{tcolorbox}
 }
 \author{Chris Hughes \thanks{and contributors!
@@ -15,7 +15,7 @@
 		See \vref{sec:contributors}.
 		For
 		all communication, please visit \cite{latexindent-home}.}}
-\date{2021-07-31}
+\date{2021-09-16}
 \maketitle
 \begin{adjustwidth}{1cm}{1cm}
 	\small

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -23,7 +23,7 @@
 use List::Util qw/max min sum/;
 use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::Tokens qw/%tokens/;
 use LatexIndent::LogFile qw/$logger/;
 use LatexIndent::HiddenChildren qw/%familyTree/;
@@ -48,8 +48,8 @@
 	#         5 &   & 6 &   \\
 	#        %* \end{tabular}
     $logger->trace('*Searching for ALIGNED blocks marked by comments')if($is_t_switch_active);
-    $logger->trace(Dumper(\%{$masterSettings{lookForAlignDelims}})) if($is_tt_switch_active);
-    while( my ($alignmentBlock,$yesno)= each %{$masterSettings{lookForAlignDelims}}){
+    $logger->trace(Dumper(\%{$mainSettings{lookForAlignDelims}})) if($is_tt_switch_active);
+    while( my ($alignmentBlock,$yesno)= each %{$mainSettings{lookForAlignDelims}}){
         if(ref $yesno eq "HASH"){
               $yesno = (defined ${$yesno}{delims} ) ? ${$yesno}{delims} : 1;
             }
@@ -1362,7 +1362,7 @@
     # check for existence of \\ statement, and associated line break information
     $self->check_for_else_statement(
               # else name regexp
-              elseNameRegExp=>qr/${${$masterSettings{fineTuning}}{modifyLineBreaks}}{doubleBackSlash}/,
+              elseNameRegExp=>qr/${${$mainSettings{fineTuning}}{modifyLineBreaks}}{doubleBackSlash}/,
               # else statements name: note that DBS stands for 'Double Back Slash'
               ElseStartsOnOwnLine=>"DBSStartsOnOwnLine",
               # end statements

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Arguments.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Arguments.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Arguments.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -19,7 +19,7 @@
 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/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::LogFile qw/$logger/;
 use Data::Dumper;
 use Exporter qw/import/;
@@ -56,7 +56,7 @@
     my $objectDependentOptAndMandRegExp = (defined ${$self}{optAndMandArgsRegExp} ? ${$self}{optAndMandArgsRegExp} : $optAndMandRegExpWithLineBreaks);
 
     if(${$self}{body} =~ m/^$objectDependentOptAndMandRegExp\h*($trailingCommentRegExp)?/){
-        $logger->trace("Optional/Mandatory arguments".(${$masterSettings{commandCodeBlocks}}{roundParenthesesAllowed}?" (possibly round Parentheses)":q())." found in ${$self}{name}: $1") if $is_t_switch_active;
+        $logger->trace("Optional/Mandatory arguments".(${$mainSettings{commandCodeBlocks}}{roundParenthesesAllowed}?" (possibly round Parentheses)":q())." found in ${$self}{name}: $1") if $is_t_switch_active;
 
         # create a new Arguments object
         # The arguments object is a little different to most
@@ -179,7 +179,7 @@
                     ${$self}{begin} =~ s/\h*$//s;
                 } elsif (${${${$arguments}{children}}[0]}{BeginStartsOnOwnLine}==3) {
                   $logger->trace("Adding a blank line immediately ${$self}{begin} ($BeginStringLogFile==3)") if $is_t_switch_active;
-                  $trailingCharacterToken = "\n".(${$masterSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:q());
+                  $trailingCharacterToken = "\n".(${$mainSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:q());
                 }
 
                 # modification
@@ -243,16 +243,16 @@
     my $lineBreaksAtEnd = (defined ${input}{mode} and ${input}{mode} eq 'lineBreaksAtEnd')?'\R*':q();
 
     # arguments Before, by default, includes beamer special and numbered arguments, for example #1 #2, etc
-    my  $argumentsBefore = qr/${${$masterSettings{fineTuning}}{arguments}}{before}/;
-    my  $argumentsBetween = qr/${${$masterSettings{fineTuning}}{arguments}}{between}/;
+    my  $argumentsBefore = qr/${${$mainSettings{fineTuning}}{arguments}}{before}/;
+    my  $argumentsBetween = qr/${${$mainSettings{fineTuning}}{arguments}}{between}/;
 
     # commands are allowed strings between arguments, e.g node, decoration, etc, specified in stringsAllowedBetweenArguments
     my $stringsBetweenArguments = q();
 
     if(defined ${input}{stringBetweenArguments} and ${input}{stringBetweenArguments}==1
-       and ref(${$masterSettings{commandCodeBlocks}}{stringsAllowedBetweenArguments}) eq "ARRAY"){
+       and ref(${$mainSettings{commandCodeBlocks}}{stringsAllowedBetweenArguments}) eq "ARRAY"){
         # grab the strings allowed between arguments
-        my @stringsAllowedBetweenArguments = @{${$masterSettings{commandCodeBlocks}}{stringsAllowedBetweenArguments}};
+        my @stringsAllowedBetweenArguments = @{${$mainSettings{commandCodeBlocks}}{stringsAllowedBetweenArguments}};
 
         $logger->trace("*Looping through array for commandCodeBlocks->stringsAllowedBetweenArguments") if $is_t_switch_active ;
 
@@ -404,7 +404,7 @@
     # check for existence of \\ statement, and associated line break information
     $self->check_for_else_statement(
               # else name regexp
-              elseNameRegExp=>qr/${${$masterSettings{fineTuning}}{modifyLineBreaks}}{comma}/,
+              elseNameRegExp=>qr/${${$mainSettings{fineTuning}}{modifyLineBreaks}}{comma}/,
               # else statements name
               ElseStartsOnOwnLine=>"CommaStartsOnOwnLine",
               # end statements

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -16,7 +16,7 @@
 #	For all communication, please visit: https://github.com/cmhughes/latexindent.pl
 use strict;
 use warnings;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::Switches qw/%switches/;
 use LatexIndent::LogFile qw/$logger/;
 use File::Basename;             # to get the filename and directory path
@@ -37,7 +37,7 @@
     my $fileName = ${$self}{fileName};
 
     # grab the file extension preferences
-    my %fileExtensionPreference= %{$masterSettings{fileExtensionPreference}};
+    my %fileExtensionPreference= %{$mainSettings{fileExtensionPreference}};
 
     # sort the file extensions by preference 
     my @fileExtensions = sort { $fileExtensionPreference{$a} <=> $fileExtensionPreference{$b} } keys(%fileExtensionPreference);
@@ -49,10 +49,10 @@
     $backupFile = "${$self}{cruftDirectory}/$backupFile";
 
     # local variables, determined from the YAML settings
-    my $onlyOneBackUp = $masterSettings{onlyOneBackUp};
-    my $maxNumberOfBackUps = $masterSettings{maxNumberOfBackUps};
-    my $cycleThroughBackUps= $masterSettings{cycleThroughBackUps};
-    my $backupExtension= $masterSettings{backupExtension};
+    my $onlyOneBackUp = $mainSettings{onlyOneBackUp};
+    my $maxNumberOfBackUps = $mainSettings{maxNumberOfBackUps};
+    my $cycleThroughBackUps= $mainSettings{cycleThroughBackUps};
+    my $backupExtension= $mainSettings{backupExtension};
     
     # if both ($onlyOneBackUp and $maxNumberOfBackUps) then we have
     # a conflict- er on the side of caution and turn off onlyOneBackUp
@@ -109,7 +109,14 @@
                         # check that the oldBackupFile exists
                         if(-e $oldBackupFile){
                         $logger->info(" copying $oldBackupFile to $newBackupFile ");
-                            copy($oldBackupFile,$newBackupFile) or die "Could not write to backup file $backupFile. Please check permissions. Exiting.";
+                            my $backUpFilePossible = 1;
+                            copy($oldBackupFile,$newBackupFile) or ($backUpFilePossible = 0);
+                            if ($backUpFilePossible==0){ 
+                                $logger->fatal("*Could not write to backup file $backupFile. Please check permissions. Exiting.");
+                                $logger->fatal("Exiting, no indendation done."); 
+                                $self->output_logfile();
+                                exit(5);
+                            }
                         }
                     }
                 }
@@ -131,6 +138,13 @@
     # output these lines to the log file
     $logger->info("Backup file: $backupFile");
     $logger->info("$fileName will be overwritten after indentation");
-    copy($fileName,$backupFile) or die "Could not write to backup file $backupFile. Please check permissions. Exiting.";
+    my $backUpFilePossible = 1;
+    copy($fileName,$backupFile) or ($backUpFilePossible = 0);
+    if ($backUpFilePossible==0){ 
+        $logger->fatal("*Could not write to backup file $backupFile. Please check permissions.");
+        $logger->fatal("Exiting, no indendation done."); 
+        $self->output_logfile();
+        exit(5);
+    }
 }
 1;

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BlankLines.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BlankLines.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BlankLines.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -17,7 +17,7 @@
 use strict;
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::Switches qw/$is_m_switch_active $is_t_switch_active $is_tt_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
 use Exporter qw/import/;
@@ -24,10 +24,9 @@
 our @EXPORT_OK = qw/protect_blank_lines unprotect_blank_lines condense_blank_lines/;
 
 sub protect_blank_lines{
-    return unless $is_m_switch_active;
     my $self = shift;
     
-    unless(${$masterSettings{modifyLineBreaks}}{preserveBlankLines}){
+    unless(${$mainSettings{modifyLineBreaks}}{preserveBlankLines}){
         $logger->trace("*Blank lines will not be protected (preserveBlankLines=0)") if $is_t_switch_active;
         return
     }
@@ -38,18 +37,15 @@
 }
 
 sub condense_blank_lines{
-    return unless $is_m_switch_active;
 
-    return unless ${$masterSettings{modifyLineBreaks}}{condenseMultipleBlankLinesInto}>0;
-
     my $self = shift;
     
     $logger->trace("*condense blank lines routine") if $is_t_switch_active;
     # if preserveBlankLines is set to 0, then the blank-line-token will not be present
     # in the document -- we change that here
-    if(${$masterSettings{modifyLineBreaks}}{preserveBlankLines}==0){
+    if(${$mainSettings{modifyLineBreaks}}{preserveBlankLines}==0){
         # turn the switch on
-        ${$masterSettings{modifyLineBreaks}}{preserveBlankLines}=1;
+        ${$mainSettings{modifyLineBreaks}}{preserveBlankLines}=1;
 
         # log file information
         $logger->trace("Updating body to include blank line token, this requires preserveBlankLines = 1") if($is_tt_switch_active);
@@ -61,7 +57,7 @@
      }
 
     # grab the value from the settings
-    my $condenseMultipleBlankLinesInto = ${$masterSettings{modifyLineBreaks}}{condenseMultipleBlankLinesInto};
+    my $condenseMultipleBlankLinesInto = ${$mainSettings{modifyLineBreaks}}{condenseMultipleBlankLinesInto};
 
     # grab the blank-line-token
     my $blankLineToken = $tokens{blanklines};
@@ -80,9 +76,6 @@
 }
 
 sub unprotect_blank_lines{
-    return unless $is_m_switch_active;
-
-    return unless ${$masterSettings{modifyLineBreaks}}{preserveBlankLines};
     my $self = shift;
     
     # remove any empty lines that might have been added by the text_wrap routine; see, for example,

Added: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Check.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Check.pm	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Check.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -0,0 +1,130 @@
+package LatexIndent::Check;
+#	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
+use strict;
+use warnings;
+use Exporter qw/import/;
+use LatexIndent::LogFile qw/$logger/;
+use LatexIndent::Switches qw/$is_m_switch_active $is_check_verbose_switch_active/;
+our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
+our @EXPORT_OK = qw/simple_diff/;
+
+sub simple_diff {
+    my $self = shift;
+
+    # simple diff...
+    $logger->info("*simple diff: (check switch active)");
+
+    # check switch work below here
+    if (${$self}{originalBody} eq ${$self}{body}){
+        $logger->info("no differences, no diff to report");
+        return;
+    }
+
+    # otherwise we loop through the old and new body, and make comparisons
+    my @oldBody = split("\n",${$self}{originalBody}); 
+    my @newBody = split("\n",${$self}{body}); 
+    my @diff = ();
+
+    # this loop stores the differences ...
+    if($is_m_switch_active){
+        # if -m *is* active, then the number of lines in old and new may not be the same
+        # so we need to go through the options
+        my $maxLines = ($#oldBody >= $#newBody ? $#oldBody : $#newBody);
+
+        # loop through to maxLines, accounting for the three scenarios:
+        #
+        #   oldBody[lineCount] and newBody[lineCount] both defined
+        #   oldBody[lineCount] defined and newBody[lineCount] not defined
+        #   oldBody[lineCount] not defined and newBody[lineCount] defined
+        #
+        for (my $lineCount=0;$lineCount<=$maxLines;$lineCount++){
+           if ($lineCount<=$#oldBody and $lineCount<=$#newBody ){
+              if ($oldBody[$lineCount] ne $newBody[$lineCount]){
+                 push(@diff,{old=>$oldBody[$lineCount],new=>$newBody[$lineCount],lineNumber=>$lineCount+1});
+              }
+           } elsif ($lineCount<=$#oldBody) {
+             push(@diff,{old=>$oldBody[$lineCount],lineNumber=>$lineCount+1});
+           } else {
+             push(@diff,{new=>$newBody[$lineCount],lineNumber=>$lineCount+1});
+           }
+        }
+    } else {
+        # if -m is not active, then the number of lines in old and new will be the same
+        for (my $lineCount=0;$lineCount<=$#oldBody;$lineCount++){
+           if ($oldBody[$lineCount] ne $newBody[$lineCount]){
+              push(@diff,{old=>$oldBody[$lineCount],new=>$newBody[$lineCount],lineNumber=>$lineCount+1});
+           }
+        }
+    }
+
+    # initialise the old and new tmp body for storage
+    my $tmpOldBody = '-';
+    my $tmpNewBody = '+';
+    my $previousLineNumber = -1;
+
+    # and the 'diff chunk' storage array
+    my @diffChunks = ();
+    my $diffChunkFirstLineNumber = ${$diff[0]}{lineNumber};
+
+    # ... and this loop combines the diffs into chunks
+    for my $i (0..$#diff) {
+
+        my $currentLineNumber = ${$diff[$i]}{lineNumber};
+
+        if ($i == $#diff 
+            or ( $previousLineNumber>=0 and $currentLineNumber>($previousLineNumber+1) )){
+
+            my $lastLine = ${$diff[$i-1]}{lineNumber};
+
+            if ($i == $#diff){
+                $lastLine = $currentLineNumber;
+                $tmpOldBody .= ($tmpOldBody eq '-' ? q() : "\n-").${$diff[$i]}{old};
+                $tmpNewBody .= ($tmpNewBody eq '+' ? q() : "\n+").${$diff[$i]}{new};
+            }
+
+            push(@diffChunks, {old=>$tmpOldBody, 
+                               new=>$tmpNewBody, 
+                               firstLine=>$diffChunkFirstLineNumber,
+                               lastLine=>$lastLine } );
+
+            $tmpOldBody = '-'.${$diff[$i]}{old} if defined ${$diff[$i]}{old};
+            $tmpNewBody = '+'.${$diff[$i]}{new} if defined ${$diff[$i]}{new};
+            $diffChunkFirstLineNumber = $currentLineNumber; 
+        } else {
+            $tmpOldBody .= ($tmpOldBody eq '-' ? q() : "\n-").${$diff[$i]}{old} if defined ${$diff[$i]}{old};
+            $tmpNewBody .= ($tmpNewBody eq '+' ? q() : "\n+").${$diff[$i]}{new} if defined ${$diff[$i]}{new};
+        }
+
+        $previousLineNumber = ${$diff[$i]}{lineNumber};
+    }
+
+    # finally, output the diff chunks
+    foreach (@diffChunks){
+        $logger->info("@@ ${$_}{firstLine} -- ${$_}{lastLine} @@");
+        $logger->info(${$_}{old});
+        $logger->info(${$_}{new});
+
+        # possibly output to terminal
+        if($is_check_verbose_switch_active){
+            print "\n@@ ${$_}{firstLine} -- ${$_}{lastLine} @@\n";
+            print ${$_}{old},"\n";
+            print ${$_}{new},"\n";
+        }
+    }
+}
+
+1;


Property changes on: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Check.pm
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Command.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Command.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Command.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -19,7 +19,7 @@
 use LatexIndent::Tokens qw/%tokens/;
 use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::LogFile qw/$logger/;
 use Data::Dumper;
 use Exporter qw/import/;
@@ -36,19 +36,19 @@
     my $self = shift;
 
     $optAndMandAndRoundBracketsRegExp = $self->get_arguments_regexp(
-                                                                    roundBrackets=>${$masterSettings{commandCodeBlocks}}{roundParenthesesAllowed},
+                                                                    roundBrackets=>${$mainSettings{commandCodeBlocks}}{roundParenthesesAllowed},
                                                                     stringBetweenArguments=>1);
 
     $optAndMandAndRoundBracketsRegExpLineBreaks = $self->get_arguments_regexp(
-                                                                    roundBrackets=>${$masterSettings{commandCodeBlocks}}{roundParenthesesAllowed},
+                                                                    roundBrackets=>${$mainSettings{commandCodeBlocks}}{roundParenthesesAllowed},
                                                                     mode=>"lineBreaksAtEnd",
                                                                     stringBetweenArguments=>1);
 
     # put together a list of the special command names (this was mostly motivated by the \@ifnextchar[ issue)
     my $commandNameSpecialRegExp = q();
-    if(ref(${$masterSettings{commandCodeBlocks}}{commandNameSpecial}) eq "ARRAY"){
+    if(ref(${$mainSettings{commandCodeBlocks}}{commandNameSpecial}) eq "ARRAY"){
 
-        my @commandNameSpecial = @{${$masterSettings{commandCodeBlocks}}{commandNameSpecial}};
+        my @commandNameSpecial = @{${$mainSettings{commandCodeBlocks}}{commandNameSpecial}};
         $logger->trace("*Looping through array for commandCodeBlocks->commandNameSpecial") if $is_t_switch_active ;
 
         # note that the zero'th element in this array contains the amalgamate switch, which we don't want!
@@ -65,7 +65,7 @@
     $logger->trace("*The special command names regexp is: $commandNameSpecialRegExp (see commandNameSpecial)") if $is_t_switch_active;
 
     # read from fine tuning
-    my  $commandNameRegExp = qr/${${$masterSettings{fineTuning}}{commands}}{name}/;
+    my  $commandNameRegExp = qr/${${$mainSettings{fineTuning}}{commands}}{name}/;
 
     # construct the command regexp
     $commandRegExp = qr/
@@ -132,7 +132,7 @@
         if (${${${${$self}{children}}[0]}{children}[-1]}{EndFinishesWithLineBreak} == 3 ){
               my $EndStringLogFile = ${${${${$self}{children}}[0]}{children}[-1]}{aliases}{EndFinishesWithLineBreak}||"EndFinishesWithLineBreak";
               $logger->trace("Adding another blank line to replacement text for ${$self}{name} as last argument has $EndStringLogFile == 3 ") if $is_t_switch_active;
-              ${$self}{replacementText} .= (${$masterSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:"\n")."\n";
+              ${$self}{replacementText} .= (${$mainSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:"\n")."\n";
         }
 
         # update the argument object

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -21,11 +21,13 @@
 use open ':std', ':encoding(UTF-8)';
 
 # gain access to subroutines in the following modules
-use LatexIndent::Switches qw/store_switches %switches $is_m_switch_active $is_t_switch_active $is_tt_switch_active $is_r_switch_active $is_rr_switch_active $is_rv_switch_active/;
+use LatexIndent::Switches qw/store_switches %switches $is_m_switch_active $is_t_switch_active $is_tt_switch_active $is_r_switch_active $is_rr_switch_active $is_rv_switch_active $is_check_switch_active/;
 use LatexIndent::LogFile qw/process_switches $logger/;
 use LatexIndent::Logger qw/@logFileLines/;
+use LatexIndent::Check qw/simple_diff/;
+use LatexIndent::Lines qw/lines_body_selected_lines lines_verbatim_create_line_block/;
 use LatexIndent::Replacement qw/make_replacements/;
-use LatexIndent::GetYamlSettings qw/yaml_read_settings yaml_modify_line_breaks_settings yaml_get_indentation_settings_for_this_object yaml_poly_switch_get_every_or_custom_value yaml_get_indentation_information yaml_get_object_attribute_for_indentation_settings yaml_alignment_at_ampersand_settings yaml_get_textwrap_removeparagraphline_breaks %masterSettings yaml_get_columns/;
+use LatexIndent::GetYamlSettings qw/yaml_read_settings yaml_modify_line_breaks_settings yaml_get_indentation_settings_for_this_object yaml_poly_switch_get_every_or_custom_value yaml_get_indentation_information yaml_get_object_attribute_for_indentation_settings yaml_alignment_at_ampersand_settings yaml_get_textwrap_removeparagraphline_breaks %mainSettings yaml_get_columns/;
 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/;
@@ -67,7 +69,7 @@
     my $invocant = shift;
     my $class = ref($invocant) || $invocant;
     my $self = {@_};
-    $logger->trace(${$masterSettings{logFilePreferences}}{showDecorationStartCodeBlockTrace}) if ${$masterSettings{logFilePreferences}}{showDecorationStartCodeBlockTrace};
+    $logger->trace(${$mainSettings{logFilePreferences}}{showDecorationStartCodeBlockTrace}) if ${$mainSettings{logFilePreferences}}{showDecorationStartCodeBlockTrace};
     bless ($self,$class);
     return $self;
 }
@@ -79,6 +81,11 @@
     $self->yaml_read_settings;
     $self->file_extension_check;
     $self->operate_on_file;
+
+    # check switch active, and file changed, gives different exit code
+    if ($is_check_switch_active and ${$self}{originalBody} ne ${$self}{body}){
+        exit(1);
+    }
 }
 
 sub operate_on_file{
@@ -85,7 +92,7 @@
     my $self = shift;
 
     $self->create_back_up_file;
-    $self->token_check;
+    $self->token_check unless ($switches{lines}) ;
     $self->make_replacements(when=>"before") if ($is_r_switch_active and !$is_rv_switch_active);
     unless ($is_rr_switch_active){
         $self->construct_regular_expressions;
@@ -99,17 +106,17 @@
         $logger->trace(Dumper(\%verbatimStorage)) if $is_tt_switch_active;
         $self->verbatim_modify_line_breaks if $is_m_switch_active; 
         $self->make_replacements(when=>"before") if $is_rv_switch_active;
-        $self->text_wrap if ($is_m_switch_active and !${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1);
-        $self->protect_blank_lines;
+        $self->text_wrap if ($is_m_switch_active and !${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1);
+        $self->protect_blank_lines if $is_m_switch_active;
         $self->remove_trailing_whitespace(when=>"before");
         $self->find_file_contents_environments_and_preamble;
         $self->dodge_double_backslash;
         $self->remove_leading_space;
         $self->process_body_of_text;
-        ${$self}{body} =~ s/\r\n/\n/sg if $masterSettings{dos2unixlinebreaks};
+        ${$self}{body} =~ s/\r\n/\n/sg if $mainSettings{dos2unixlinebreaks};
         $self->remove_trailing_whitespace(when=>"after");
-        $self->condense_blank_lines;
-        $self->unprotect_blank_lines;
+        $self->condense_blank_lines  if( $is_m_switch_active and ${$mainSettings{modifyLineBreaks}}{condenseMultipleBlankLinesInto} );
+        $self->unprotect_blank_lines if( $is_m_switch_active and ${$mainSettings{modifyLineBreaks}}{preserveBlankLines} );
         $self->un_dodge_double_backslash;
         $self->make_replacements(when=>"after") if $is_rv_switch_active;
         $self->put_verbatim_back_in (match=>"everything-except-commands");
@@ -116,7 +123,7 @@
         $self->put_trailing_comments_back_in;
         $self->put_verbatim_back_in (match=>"just-commands");
         $self->make_replacements(when=>"after") if ($is_r_switch_active and !$is_rv_switch_active);
-        ${$self}{body} =~ s/\r\n/\n/sg if $masterSettings{dos2unixlinebreaks};
+        ${$self}{body} =~ s/\r\n/\n/sg if $mainSettings{dos2unixlinebreaks};
     }
     $self->output_indented_text;
     return
@@ -141,6 +148,8 @@
 sub output_indented_text{
     my $self = shift;
 
+    $self->simple_diff() if $is_check_switch_active;
+
     $logger->info("*Output routine:");
 
     # if -overwrite is active then output to original fileName
@@ -172,10 +181,10 @@
     my $self = shift;
     #
     # put the final line in the logfile
-    $logger->info("${$masterSettings{logFilePreferences}}{endLogFileWith}") if ${$masterSettings{logFilePreferences}}{endLogFileWith};
+    $logger->info("${$mainSettings{logFilePreferences}}{endLogFileWith}") if ${$mainSettings{logFilePreferences}}{endLogFileWith};
     
     # github info line
-    $logger->info("*Please direct all communication/issues to:\nhttps://github.com/cmhughes/latexindent.pl") if ${$masterSettings{logFilePreferences}}{showGitHubInfoFooter};
+    $logger->info("*Please direct all communication/issues to:\nhttps://github.com/cmhughes/latexindent.pl") if ${$mainSettings{logFilePreferences}}{showGitHubInfoFooter};
 
     # open log file
     my $logfileName = $switches{logFileName}||"indent.log";
@@ -220,19 +229,19 @@
     my $self = shift;
 
     # one sentence per line: sentences are objects, as of V3.5.1
-    $self->one_sentence_per_line if ($is_m_switch_active and ${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{manipulateSentences});
+    $self->one_sentence_per_line if ($is_m_switch_active and ${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{manipulateSentences});
 
     if ($is_m_switch_active and !${$self}{preamblePresent}){
         $self->yaml_get_textwrap_removeparagraphline_breaks;
     }
 
-    if( $is_m_switch_active and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} == 1){ 
+    if( $is_m_switch_active and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} == 1){ 
         # call the remove_paragraph_line_breaks and text_wrap routines
-        if(${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap}){
+        if(${$mainSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap}){
             $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
-            $self->text_wrap if (${$self}{textWrapOptions} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+            $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
         } else {
-            $self->text_wrap if (${$self}{textWrapOptions} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+            $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
             $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
         }
     }
@@ -253,13 +262,13 @@
     $self->find_commands_or_key_equals_values_braces_and_special if ${$self}{body} =~ m/$specialBeginAndBracesBracketsBasicRegExp/s;
     
     # documents without preamble need a manual call to the paragraph_one_line routine
-    if ($is_m_switch_active and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} == 0 ){ 
+    if ($is_m_switch_active and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} == 0 ){ 
        # call the remove_paragraph_line_breaks and text_wrap routines
-       if(${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap}){
+       if(${$mainSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap}){
            $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
-           $self->text_wrap if (${$self}{textWrapOptions} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+           $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
        } else {
-           $self->text_wrap if (${$self}{textWrapOptions} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+           $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
            $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
        }
     }
@@ -283,7 +292,7 @@
 
     # the order in which we search for specialBeginEnd and commands/key/braces
     # can change depending upon specialBeforeCommand
-    if(${$masterSettings{specialBeginEnd}}{specialBeforeCommand}){
+    if(${$mainSettings{specialBeginEnd}}{specialBeforeCommand}){
         # search for special begin/end
         $logger->trace('looking for SPECIAL begin/end *before* looking for commands (see specialBeforeCommand)') if $is_t_switch_active;
         $self->find_special if ${$self}{body} =~ m/$specialBeginBasicRegExp/s;
@@ -318,13 +327,13 @@
     $latexIndentObject->tasks_common_to_each_object(%{$self});
     
     # removeParagraphLineBreaks and textWrapping fun!
-    $latexIndentObject->text_wrap_remove_paragraph_line_breaks if( $is_m_switch_active and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} );
+    $latexIndentObject->text_wrap_remove_paragraph_line_breaks if( $is_m_switch_active and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} );
       
     # tasks particular to each object
     $latexIndentObject->tasks_particular_to_each_object;
     
     # removeParagraphLineBreaks and textWrapping fun!
-    $latexIndentObject->text_wrap_remove_paragraph_line_breaks if($is_m_switch_active and !${$masterSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} );
+    $latexIndentObject->text_wrap_remove_paragraph_line_breaks if($is_m_switch_active and !${$mainSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} );
 
     # store children in special hash
     push(@{${$self}{children}},$latexIndentObject);
@@ -333,7 +342,7 @@
     $self->hidden_children_preparation_for_alignment($latexIndentObject) if(${$latexIndentObject}{lookForAlignDelims} and ${$latexIndentObject}{measureHiddenChildren});
 
     # possible decoration in log file 
-    $logger->trace(${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
+    $logger->trace(${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
 }
 
 
@@ -381,7 +390,7 @@
     ${$self}{idRegExp} = ${$self}{id};
 
     if($is_m_switch_active
-        and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{huge} ne "overflow"){
+        and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{huge} ne "overflow"){
         my $IDwithLineBreaks = join("\\R?\\h*",split(//,${$self}{id}));
         ${$self}{idRegExp} = qr/$IDwithLineBreaks/s;  
     }

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -18,7 +18,7 @@
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
 use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_m_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
 use LatexIndent::Braces qw/$braceBracketRegExpBasic/;
@@ -36,7 +36,7 @@
 sub construct_environments_regexp{
   
     # read from fine tuning
-    my  $environmentNameRegExp = qr/${${$masterSettings{fineTuning}}{environments}}{name}/;
+    my  $environmentNameRegExp = qr/${${$mainSettings{fineTuning}}{environments}}{name}/;
     $environmentRegExp = qr/
                 (
                     \\begin\{
@@ -110,7 +110,7 @@
     }
 
     # search for items as the first order of business
-    $self->find_items if ${$masterSettings{indentAfterItems}}{${$self}{name}};
+    $self->find_items if ${$mainSettings{indentAfterItems}}{${$self}{name}};
 
     # search for headings (important to do this before looking for commands!)
     $self->find_heading if ${$self}{body} =~ m/$allHeadingsRegexp/s;

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileContents.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileContents.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileContents.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -17,7 +17,7 @@
 use strict;
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_m_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
 use LatexIndent::Environment qw/$environmentBasicRegExp/;
@@ -41,8 +41,8 @@
 
     # fileContents environments
     $logger->trace('*Searching for FILE CONTENTS environments (see fileContentsEnvironments)') if $is_t_switch_active;
-    $logger->trace(Dumper(\%{$masterSettings{fileContentsEnvironments}})) if($is_tt_switch_active);
-    while( my ($fileContentsEnv,$yesno)= each %{$masterSettings{fileContentsEnvironments}}){
+    $logger->trace(Dumper(\%{$mainSettings{fileContentsEnvironments}})) if($is_tt_switch_active);
+    while( my ($fileContentsEnv,$yesno)= each %{$mainSettings{fileContentsEnvironments}}){
 
         if(!$yesno){
             $logger->trace(" *not* looking for $fileContentsEnv as $fileContentsEnv:$yesno");
@@ -133,7 +133,7 @@
     my $needToStorePreamble = 0;
 
     # try and find the preamble
-    if( ${$self}{body} =~ m/$preambleRegExp/sx and ${$masterSettings{lookForPreamble}}{${$self}{fileExtension}}){
+    if( ${$self}{body} =~ m/$preambleRegExp/sx and ${$mainSettings{lookForPreamble}}{${$self}{fileExtension}}){
 
         $logger->trace("\\begin{document} found in body (after searching for filecontents)-- assuming that a preamble exists") if $is_t_switch_active ;
 
@@ -173,13 +173,13 @@
 
         $logger->trace("replaced with ID: ${$preamble}{replacementText}") if $is_tt_switch_active;
         # indentPreamble set to 1
-        if($masterSettings{indentPreamble}){
+        if($mainSettings{indentPreamble}){
             $logger->trace("storing ${$preamble}{id} for indentation (see indentPreamble)") if $is_tt_switch_active;
             $needToStorePreamble = 1;
         } else {
             # indentPreamble set to 0
             $logger->trace("NOT storing ${$preamble}{id} for indentation -- will store as VERBATIM object (because indentPreamble:0)") if $is_t_switch_active;
-            $preamble->unprotect_blank_lines;
+            $preamble->unprotect_blank_lines if( $is_m_switch_active and ${$mainSettings{modifyLineBreaks}}{preserveBlankLines} );
             $verbatimStorage{${$preamble}{id}} = $preamble;
         }
     } else {
@@ -193,7 +193,7 @@
               if($preamble ne '' and ${$preamble}{body} =~ m/${$_}{id}/){
                 $logger->trace("filecontents (${$_}{id}) is within preamble") if $is_t_switch_active;
                 # indentPreamble set to 1
-                if($masterSettings{indentPreamble}){
+                if($mainSettings{indentPreamble}){
                     $logger->trace("storing ${$_}{id} for indentation (indentPreamble is 1)") if $is_t_switch_active;
                     $indentThisChild = 1;
                 } else {
@@ -213,7 +213,7 @@
                     push(@{${$self}{children}},$_);
               
                     # possible decoration in log file 
-                    $logger->trace(${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
+                    $logger->trace(${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
               }
     }
 
@@ -220,7 +220,7 @@
     if($needToStorePreamble){
         $preamble->dodge_double_backslash;
         $preamble->remove_leading_space;
-        $preamble->find_commands_or_key_equals_values_braces if($masterSettings{preambleCommandsBeforeEnvironments});
+        $preamble->find_commands_or_key_equals_values_braces if($mainSettings{preambleCommandsBeforeEnvironments});
         $preamble->tasks_particular_to_each_object;
         push(@{${$self}{children}},$preamble);
     }
@@ -238,6 +238,23 @@
 sub tasks_particular_to_each_object{
     my $self = shift;
 
+    # text wrapping, remove paragraph line breaks
+    if ($is_m_switch_active){
+        $self->yaml_get_textwrap_removeparagraphline_breaks;
+    }
+
+    # option to textWrap beforeFindingChildCodeBlocks
+    if( $is_m_switch_active and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} == 1){ 
+        # call the remove_paragraph_line_breaks and text_wrap routines
+        if(${$mainSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap}){
+            $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
+            $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+        } else {
+            $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+            $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
+        }
+    }
+
     # search for environments
     $self->find_environments if ${$self}{body} =~ m/$environmentBasicRegExp/s;
 
@@ -251,15 +268,13 @@
     $self->find_commands_or_key_equals_values_braces_and_special if ${$self}{body} =~ m/$specialBeginAndBracesBracketsBasicRegExp/s;
     
     # text wrapping, remove paragraph line breaks
-    if ($is_m_switch_active){
-        $self->yaml_get_textwrap_removeparagraphline_breaks;
-
+    if ($is_m_switch_active and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} == 0){
         # call the remove_paragraph_line_breaks and text_wrap routines
-        if(${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap}){
+        if(${$mainSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap}){
             $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
-            $self->text_wrap if (${$self}{textWrapOptions} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+            $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
         } else {
-            $self->text_wrap if (${$self}{textWrapOptions} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+            $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
             $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
         }
     }

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileExtension.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileExtension.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileExtension.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -21,8 +21,8 @@
 use open ':std', ':encoding(UTF-8)';
 use File::Basename; # to get the filename and directory path
 use Exporter qw/import/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
-use LatexIndent::Switches qw/%switches/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
+use LatexIndent::Switches qw/%switches $is_check_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
 our @EXPORT_OK = qw/file_extension_check/;
 
@@ -36,7 +36,7 @@
     my ($name,$dir,$ext) = fileparse($fileName,qr/\..[^.]*$/);
     
     # grab the file extension preferences
-    my %fileExtensionPreference= %{$masterSettings{fileExtensionPreference}};
+    my %fileExtensionPreference= %{$mainSettings{fileExtensionPreference}};
 
     # sort the file extensions by preference 
     my @fileExtensions = sort { $fileExtensionPreference{$a} <=> $fileExtensionPreference{$b} } keys(%fileExtensionPreference);
@@ -69,17 +69,18 @@
               foreach (@fileExtensions ){
                 $logger->fatal("I searched for $fileName$_");
               }
-              $logger->fatal("but couldn't find any of them.\nConsider updating fileExtensionPreference.\nExiting, no indendation done.");
+              $logger->fatal("but couldn't find any of them.\nConsider updating fileExtensionPreference.");
+              $logger->fatal("*Exiting, no indendation done."); 
               $self->output_logfile();
-              die "ERROR: I couldn't find any of the following files: ".$fileName.join(", $fileName", at fileExtensions)." (see fileExtensionPreference)\nExiting, no indendation done."; 
+              exit(3);
             }
           } else {
             # if the file has a recognised extension, check that the file exists
             unless( -e $fileName ){
-              my $message = "ERROR: I couldn't find $fileName, are you sure it exists?\nNo indentation done.\nExiting.";
-              $logger->fatal("*$message");
+              $logger->fatal("*I couldn't find $fileName, are you sure it exists?");
+              $logger->fatal("Exiting, no indendation done."); 
               $self->output_logfile();
-              die $message;
+              exit(3);
             }
           }
      }
@@ -140,7 +141,14 @@
     # read the file into the Document body
     my @lines;
     if($fileName ne "-"){
-        open(MAINFILE, $fileName) or die "Could not open input file, $fileName";
+        my $openFilePossible=1;
+        open(MAINFILE, $fileName) or ($openFilePossible=0);
+        if($openFilePossible==0){
+            $logger->fatal("*$fileName exists, but could not open it");
+            $logger->fatal("Exiting, no indendation done."); 
+            $self->output_logfile();
+            exit(4);
+        }
         push(@lines,$_) while(<MAINFILE>);
         close(MAINFILE);
     } else {
@@ -147,7 +155,17 @@
             push(@lines,$_) while (<>)
     }
 
-    # the all-important step: update the body
-    ${$self}{body} = join("", at lines);
+    # -n, --lines mode active
+    if($switches{lines}){
+      $self->lines_body_selected_lines(\@lines); 
+    } else {
+      # the all-important step: update the body
+      ${$self}{body} = join("", at lines);
+    }
+
+    # necessary extra storage if check switch is active
+    if ($is_check_switch_active){
+        ${$self}{originalBody} = ${$self}{body};
+    }
 }
 1;

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -24,13 +24,13 @@
 use Cwd;
 use Exporter qw/import/;
 use LatexIndent::LogFile qw/$logger/;
-our @EXPORT_OK = qw/yaml_read_settings yaml_modify_line_breaks_settings yaml_get_indentation_settings_for_this_object yaml_poly_switch_get_every_or_custom_value yaml_get_indentation_information yaml_get_object_attribute_for_indentation_settings yaml_alignment_at_ampersand_settings yaml_get_textwrap_removeparagraphline_breaks %masterSettings yaml_get_columns/;
+our @EXPORT_OK = qw/yaml_read_settings yaml_modify_line_breaks_settings yaml_get_indentation_settings_for_this_object yaml_poly_switch_get_every_or_custom_value yaml_get_indentation_information yaml_get_object_attribute_for_indentation_settings yaml_alignment_at_ampersand_settings yaml_get_textwrap_removeparagraphline_breaks %mainSettings yaml_get_columns/;
 
 # Read in defaultSettings.YAML file
 our $defaultSettings;
 
 # master yaml settings is a hash, global to this module
-our %masterSettings;
+our %mainSettings;
 
 # previously found settings is a hash, global to this module
 our %previouslyFoundSettings;
@@ -64,15 +64,25 @@
   # if latexindent.exe is invoked from TeXLive, then defaultSettings.yaml won't be in 
   # the same directory as it; we need to navigate to it
   if(!$defaultSettings) {
-    $defaultSettings = YAML::Tiny->read( "$FindBin::RealBin/../../texmf-dist/scripts/latexindent/defaultSettings.yaml");
     $logger->info("Reading defaultSettings.yaml (2nd attempt, TeXLive, Windows) from $FindBin::RealBin/../../texmf-dist/scripts/latexindent/defaultSettings.yaml");
+    if ( -e "$FindBin::RealBin/../../texmf-dist/scripts/latexindent/defaultSettings.yaml" ){
+        $defaultSettings = YAML::Tiny->read( "$FindBin::RealBin/../../texmf-dist/scripts/latexindent/defaultSettings.yaml");
+    } else {
+        $logger->fatal("*Could not open defaultSettings.yaml");
+        $self->output_logfile();
+        exit(2);
+    }
   }
 
   # need to exit if we can't get defaultSettings.yaml
-  die "Could not open defaultSettings.yaml" if(!$defaultSettings);
+  if(!$defaultSettings){
+    $logger->fatal("*Could not open defaultSettings.yaml");
+    $self->output_logfile();
+    exit(2);
+  }
    
   # master yaml settings is a hash, global to this module
-  our %masterSettings = %{$defaultSettings->[0]};
+  our %mainSettings = %{$defaultSettings->[0]};
 
   &yaml_update_dumper_settings();
 
@@ -270,26 +280,26 @@
                       if (ref($firstLevelValue) eq "HASH") {
                           while(my ($secondLevelKey,$secondLevelValue) = each %{$userSettings->[0]{$firstLevelKey}}) {
                             if (ref $secondLevelValue eq "HASH"){
-                                # if masterSettings already contains a *scalar* value in secondLevelKey
+                                # if mainSettings already contains a *scalar* value in secondLevelKey
                                 # then we need to delete it (test-cases/headings-first.tex with indentRules1.yaml first demonstrated this)
-                                if(defined $masterSettings{$firstLevelKey}{$secondLevelKey} 
-                                    and ref $masterSettings{$firstLevelKey}{$secondLevelKey} ne "HASH"){
-                                    $logger->trace("*masterSettings{$firstLevelKey}{$secondLevelKey} currently contains a *scalar* value, but it needs to be updated with a hash (see $settings); deleting the scalar") if($is_t_switch_active);
-                                    delete $masterSettings{$firstLevelKey}{$secondLevelKey} ;
+                                if(defined $mainSettings{$firstLevelKey}{$secondLevelKey} 
+                                    and ref $mainSettings{$firstLevelKey}{$secondLevelKey} ne "HASH"){
+                                    $logger->trace("*mainSettings{$firstLevelKey}{$secondLevelKey} currently contains a *scalar* value, but it needs to be updated with a hash (see $settings); deleting the scalar") if($is_t_switch_active);
+                                    delete $mainSettings{$firstLevelKey}{$secondLevelKey} ;
                                 }
                                 while(my ($thirdLevelKey,$thirdLevelValue) = each %{$secondLevelValue}) {
                                     if (ref $thirdLevelValue eq "HASH"){
                                         # similarly for third level
-                                        if (defined $masterSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} 
-                                            and ref $masterSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} ne "HASH"){
-                                            $logger->trace("*masterSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} currently contains a *scalar* value, but it needs to be updated with a hash (see $settings); deleting the scalar") if($is_t_switch_active);
-                                            delete $masterSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} ;
+                                        if (defined $mainSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} 
+                                            and ref $mainSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} ne "HASH"){
+                                            $logger->trace("*mainSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} currently contains a *scalar* value, but it needs to be updated with a hash (see $settings); deleting the scalar") if($is_t_switch_active);
+                                            delete $mainSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} ;
                                         }
                                         while(my ($fourthLevelKey,$fourthLevelValue) = each %{$thirdLevelValue}) {
-                                            $masterSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey}{$fourthLevelKey} = $fourthLevelValue;
+                                            $mainSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey}{$fourthLevelKey} = $fourthLevelValue;
                                         }
                                     } else {
-                                        $masterSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} = $thirdLevelValue;
+                                        $mainSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} = $thirdLevelValue;
                                     }
                                 }
                             } else {
@@ -297,7 +307,7 @@
                                 # to be amalgamated, rather than overwritten
                                 if(ref($secondLevelValue) eq "ARRAY" 
                                     and 
-                                   ${${$masterSettings{$firstLevelKey}{$secondLevelKey}}[0]}{amalgamate}
+                                   ${${$mainSettings{$firstLevelKey}{$secondLevelKey}}[0]}{amalgamate}
                                     and
                                    !(ref(${$secondLevelValue}[0]) eq "HASH" and defined ${$secondLevelValue}[0]{amalgamate} and !${$secondLevelValue}[0]{amalgamate}) 
                                  ){
@@ -304,20 +314,20 @@
                                     $logger->trace("*$firstLevelKey -> $secondLevelKey, amalgamate: 1") if($is_t_switch_active);
                                     foreach (@{$secondLevelValue}){
                                         $logger->trace("$_") if($is_t_switch_active);
-                                        push (@{$masterSettings{$firstLevelKey}{$secondLevelKey}},$_) unless(ref($_) eq "HASH");
+                                        push (@{$mainSettings{$firstLevelKey}{$secondLevelKey}},$_) unless(ref($_) eq "HASH");
                                     }
 
                                     # remove duplicated entries, https://stackoverflow.com/questions/7651/how-do-i-remove-duplicate-items-from-an-array-in-perl
                                     my %seen = ();
-                                    my @unique = grep { ! $seen{ $_ }++ } @{$masterSettings{$firstLevelKey}{$secondLevelKey}};
-                                    @{$masterSettings{$firstLevelKey}{$secondLevelKey}} = @unique; 
+                                    my @unique = grep { ! $seen{ $_ }++ } @{$mainSettings{$firstLevelKey}{$secondLevelKey}};
+                                    @{$mainSettings{$firstLevelKey}{$secondLevelKey}} = @unique; 
 
                                     $logger->trace("*master settings for $firstLevelKey -> $secondLevelKey now look like:") if $is_t_switch_active;
-                                    foreach (@{$masterSettings{$firstLevelKey}{$secondLevelKey}}){
+                                    foreach (@{$mainSettings{$firstLevelKey}{$secondLevelKey}}){
                                         $logger->trace("$_") if($is_t_switch_active);
                                     }
                                 } else {
-                                    $masterSettings{$firstLevelKey}{$secondLevelKey} = $secondLevelValue;
+                                    $mainSettings{$firstLevelKey}{$secondLevelKey} = $secondLevelValue;
                                 }
                             }
                           }
@@ -324,27 +334,27 @@
                       } elsif (ref($firstLevelValue) eq "ARRAY") {
                             # update amalgamate in master settings
                             if(ref(${$firstLevelValue}[0]) eq "HASH" and defined ${$firstLevelValue}[0]{amalgamate}){
-                               ${$masterSettings{$firstLevelKey}[0]}{amalgamate} = ${$firstLevelValue}[0]{amalgamate};
-                               shift @{$firstLevelValue} if ${$masterSettings{$firstLevelKey}[0]}{amalgamate};
+                               ${$mainSettings{$firstLevelKey}[0]}{amalgamate} = ${$firstLevelValue}[0]{amalgamate};
+                               shift @{$firstLevelValue} if ${$mainSettings{$firstLevelKey}[0]}{amalgamate};
                             }
 
                             # if amalgamate is set to 1, then append
-                            if(${$masterSettings{$firstLevelKey}[0]}{amalgamate}){
+                            if(${$mainSettings{$firstLevelKey}[0]}{amalgamate}){
                                 # loop through the other settings
                                 foreach (@{$firstLevelValue}){
-                                    push (@{$masterSettings{$firstLevelKey}},$_);
+                                    push (@{$mainSettings{$firstLevelKey}},$_);
                                 }
                             } else {
                                 # otherwise overwrite
-                                $masterSettings{$firstLevelKey} = $firstLevelValue;
+                                $mainSettings{$firstLevelKey} = $firstLevelValue;
                             }
                       } else {
-                            $masterSettings{$firstLevelKey} = $firstLevelValue;
+                            $mainSettings{$firstLevelKey} = $firstLevelValue;
                       }
               }
 
               # output settings to $logfile
-              if($masterSettings{logFilePreferences}{showEveryYamlRead}){
+              if($mainSettings{logFilePreferences}{showEveryYamlRead}){
                   $logger->info(Dump \%{$userSettings->[0]});
               } else {
                   $logger->info("Not showing settings in the log file (see showEveryYamlRead and showAmalgamatedSettings).");
@@ -532,21 +542,21 @@
             if(scalar(@keysValues) == 2){
                 # for example, -y="defaultIndent: ' '"
                 my $key = $keysValues[0];
-                $logger->info("Updating masterSettings with $key: $value");
-                $masterSettings{$key} = $value;
+                $logger->info("Updating mainSettings with $key: $value");
+                $mainSettings{$key} = $value;
             } elsif(scalar(@keysValues) == 3){
                 # for example, -y="indentRules: one: '\t\t\t\t'"
                 my $parent = $keysValues[0];
                 my $child = $keysValues[1];
-                $logger->info("Updating masterSettings with $parent: $child: $value");
-                $masterSettings{$parent}{$child} = $value;
+                $logger->info("Updating mainSettings with $parent: $child: $value");
+                $mainSettings{$parent}{$child} = $value;
             } elsif(scalar(@keysValues) == 4){
                 # for example, -y='modifyLineBreaks  :  environments: EndStartsOnOwnLine:3' -m
                 my $parent = $keysValues[0];
                 my $child = $keysValues[1];
                 my $grandchild = $keysValues[2];
-                $logger->info("Updating masterSettings with $parent: $child: $grandchild: $value");
-                $masterSettings{$parent}{$child}{$grandchild} = $value;
+                $logger->info("Updating mainSettings with $parent: $child: $grandchild: $value");
+                $mainSettings{$parent}{$child}{$grandchild} = $value;
             } elsif(scalar(@keysValues) == 5){
                 # for example, -y='modifyLineBreaks  :  environments: one: EndStartsOnOwnLine:3' -m
                 my $parent = $keysValues[0];
@@ -553,8 +563,8 @@
                 my $child = $keysValues[1];
                 my $grandchild = $keysValues[2];
                 my $greatgrandchild = $keysValues[3];
-                $logger->info("Updating masterSettings with $parent: $child: $grandchild: $greatgrandchild: $value");
-                $masterSettings{$parent}{$child}{$grandchild}{$greatgrandchild} = $value;
+                $logger->info("Updating mainSettings with $parent: $child: $grandchild: $greatgrandchild: $value");
+                $mainSettings{$parent}{$child}{$grandchild}{$greatgrandchild} = $value;
             }
           
             &yaml_update_dumper_settings();
@@ -562,17 +572,9 @@
 
   }
 
-  # some users may wish to see showAmalgamatedSettings
-  # which details the overall state of the settings modified
-  # from the default in various user files
-  if($masterSettings{logFilePreferences}{showAmalgamatedSettings}){
-      $logger->info("Amalgamated/overall settings to be used:");
-      $logger->info(Dumper(\%masterSettings));
-  }
-
   if( $is_m_switch_active 
-      and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks}
-      and !${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis} ){
+      and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks}
+      and !${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis} ){
 
       # the following settings don't make sense, so we change
       #
@@ -589,8 +591,89 @@
       $logger->warn("*textWrapOptions:beforeFindingChildCodeBlocks:1 with textWrapOptions:perCodeBlockBasis:0");
       $logger->warn("turning off beforeFindingChildCodeBlocks by changing textWrapOptions:beforeFindingOtherCodeBlocks to be 0");
       $logger->warn("you need to set *both* values to be 1 to use the beforeFindingChildCodeBlocks feature");
-      ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} = 0;
+      ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} = 0;
   }
+
+  # modifyLineBreaks:
+  #     textWrapOptions:
+  #         columns: 80
+  #         perCodeBlockBasis: 1
+  #         masterDocument: 1
+  #
+  # needs to be interpretted as
+  #
+  # modifyLineBreaks:
+  #     textWrapOptions:
+  #         columns: 80
+  #         perCodeBlockBasis: 1
+  #         mainDocument: 1
+  #
+  if( $is_m_switch_active 
+      and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis} 
+      and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{masterDocument} ){
+      $logger->warn("*textWrapOptions:masterDocument specified when textWrapOptions:mainDocument preferred");
+      $logger->warn("setting textWrapOptions:mainDocument: 1, but note that future versions of latexindent.pl may not support this");
+      $logger->warn("recommendation to use textWrapOptions:mainDocument: 1 in place of textWrapOptions:masterDocument:1");
+      ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{mainDocument} = 1;
+  }
+  
+  # modifyLineBreaks:
+  #     removeParagraphLineBreaks:
+  #         masterDocument: 1
+  #
+  # needs to be interpretted as
+  #
+  # modifyLineBreaks:
+  #     removeParagraphLineBreaks:
+  #         mainDocument: 1
+  #
+  if( $is_m_switch_active and ${$mainSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{masterDocument} ){
+      $logger->warn("*removeParagraphLineBreaks:masterDocument specified when removeParagraphLineBreaks:mainDocument preferred");
+      $logger->warn("setting removeParagraphLineBreaks:mainDocument: 1, but note that future versions of latexindent.pl may not support this");
+      $logger->warn("recommendation to use removeParagraphLineBreaks:mainDocument: 1 in place of removeParagraphLineBreaks:masterDocument:1");
+      ${$mainSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{mainDocument} = 1;
+  }
+
+  # modifyLineBreaks:
+  #     textWrapOptions/removeParagraphLineBreaks:
+  #         all:
+  #             except:
+  #                 - 'masterDocument'
+  #
+  # need to be interpretted as
+  #
+  # modifyLineBreaks:
+  #     textWrapOptions/removeParagraphLineBreaks:
+  #         all:
+  #             except:
+  #                 - 'mainDocument'
+  #
+  if( $is_m_switch_active ){
+    foreach ("textWrapOptions","removeParagraphLineBreaks"){
+      if ( ref ${$mainSettings{modifyLineBreaks}{$_}}{all} eq "HASH" 
+                and
+           defined ${${$mainSettings{modifyLineBreaks}{$_}}{all}}{except} 
+                and 
+           ref ${${$mainSettings{modifyLineBreaks}{$_}}{all}}{except} eq "ARRAY") {
+            my %except = map { $_ => 1 } @{${${$mainSettings{modifyLineBreaks}}{$_}}{all}{except}};
+            if($except{masterDocument}){
+                $logger->warn("*$_:all:except:masterDocument specified when mainDocument preferred");
+                $logger->warn("setting $_:all:except:mainDocument:1, but note that future versions of latexindent.pl may not support this");
+                $logger->warn("recommendation to use $_:all:except:mainDocument:1 in place of $_:all:except:masterDocument:1");
+                push( @{${${$mainSettings{modifyLineBreaks}}{$_}}{all}{except}}, "mainDocument" );
+            }
+         }
+    }
+  }
+  
+  # some users may wish to see showAmalgamatedSettings
+  # which details the overall state of the settings modified
+  # from the default in various user files
+  if($mainSettings{logFilePreferences}{showAmalgamatedSettings}){
+      $logger->info("Amalgamated/overall settings to be used:");
+      $logger->info(Dumper(\%mainSettings));
+  }
+
   return;
 }
 
@@ -670,11 +753,11 @@
     #         delims: 1
     #         alignDoubleBackSlash: 1
     #         spacesBeforeDoubleBackSlash: 2
-    return unless ${$masterSettings{lookForAlignDelims}}{$name}; 
+    return unless ${$mainSettings{lookForAlignDelims}}{$name}; 
 
     $logger->trace("alignAtAmpersand settings for $name (see lookForAlignDelims)") if($is_t_switch_active);
 
-    if(ref ${$masterSettings{lookForAlignDelims}}{$name} eq "HASH"){
+    if(ref ${$mainSettings{lookForAlignDelims}}{$name} eq "HASH"){
       # specified as a hash, e.g
       #
       #   lookForAlignDelims:
@@ -704,11 +787,11 @@
           #           default: 0
           #
           # approach:
-          #     - update masterSettings to have the relevant information: leadingBlankColumn and/or default
+          #     - update mainSettings to have the relevant information: leadingBlankColumn and/or default
           #     - delete the spacesBeforeAmpersand hash
           #
           if ($yamlname eq "spacesBeforeAmpersand" 
-              and ref(${${$masterSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand}) eq "HASH"){
+              and ref(${${$mainSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand}) eq "HASH"){
             $logger->trace("spacesBeforeAmpersand settings for $name") if $is_t_switch_active;
             
             #   lookForAlignDelims:
@@ -715,10 +798,10 @@
             #      aligned: 
             #         spacesBeforeAmpersand: 
             #           leadingBlankColumn: 0
-            if(defined ${${${$masterSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand}}{leadingBlankColumn}){
+            if(defined ${${${$mainSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand}}{leadingBlankColumn}){
                 $logger->trace("spacesBeforeAmpersand: leadingBlankColumn specified for $name") if $is_t_switch_active;
-                ${${$masterSettings{lookForAlignDelims}}{$name}}{leadingBlankColumn} 
-                    =  ${${${$masterSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand}}{leadingBlankColumn};
+                ${${$mainSettings{lookForAlignDelims}}{$name}}{leadingBlankColumn} 
+                    =  ${${${$mainSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand}}{leadingBlankColumn};
             }
 
             #   lookForAlignDelims:
@@ -725,16 +808,16 @@
             #      aligned: 
             #         spacesBeforeAmpersand: 
             #           default: 0
-            if(defined ${${${$masterSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand}}{default}){
-                ${${$masterSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand} 
-                    = ${${${$masterSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand}}{default};
+            if(defined ${${${$mainSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand}}{default}){
+                ${${$mainSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand} 
+                    = ${${${$mainSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand}}{default};
             } else {
                 # deleting spacesBeforeAmpersand hash allows spacesBeforeAmpersand
                 # to pull from the default values @alignAtAmpersandInformation
-                delete ${${$masterSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand};
+                delete ${${$mainSettings{lookForAlignDelims}}{$name}}{spacesBeforeAmpersand};
             }
           }
-          ${$self}{ ${$_}{name} } = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{$yamlname} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{$yamlname} : ${$_}{default};
+          ${$self}{ ${$_}{name} } = (defined ${${$mainSettings{lookForAlignDelims}}{$name}}{$yamlname} ) ? ${${$mainSettings{lookForAlignDelims}}{$name}}{$yamlname} : ${$_}{default};
       } 
     } else {
       # specified as a scalar, e.g
@@ -815,10 +898,10 @@
         #   will disable textWrapOptions for itemize
         
         # if 'all' is set as a hash, then the default value is 1, to be turned  off (possibly) later
-        ${$self}{$_} = ( ref ${$masterSettings{modifyLineBreaks}{$_}}{all} eq "HASH" ? 1 : ${$masterSettings{modifyLineBreaks}{$_}}{all});
+        ${$self}{$_} = ( ref ${$mainSettings{modifyLineBreaks}{$_}}{all} eq "HASH" ? 1 : ${$mainSettings{modifyLineBreaks}{$_}}{all});
 
         # get the columns
-        if($_ eq "textWrapOptions" and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis}){
+        if($_ eq "textWrapOptions" and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis}){
             $self->yaml_get_columns;
         }
         
@@ -835,9 +918,9 @@
         #
         if(${$self}{$_} 
                     and 
-                ref ${$masterSettings{modifyLineBreaks}{$_}}{all} ne "HASH" 
+                ref ${$mainSettings{modifyLineBreaks}{$_}}{all} ne "HASH" 
                     and 
-                ${$masterSettings{modifyLineBreaks}{$_}}{all}){
+                ${$mainSettings{modifyLineBreaks}{$_}}{all}){
                $logger->trace("$_ for $name is ${$self}{$_}") if $is_t_switch_active;
                next;  
         };
@@ -865,11 +948,11 @@
         #
         if(${$self}{$_} 
                 and 
-           defined ${${$masterSettings{modifyLineBreaks}{$_}}{all}}{except} 
+           defined ${${$mainSettings{modifyLineBreaks}{$_}}{all}}{except} 
                 and 
-           ref ${${$masterSettings{modifyLineBreaks}{$_}}{all}}{except} eq "ARRAY"
+           ref ${${$mainSettings{modifyLineBreaks}{$_}}{all}}{except} eq "ARRAY"
          ){
-              my %except = map { $_ => 1 } @{${${$masterSettings{modifyLineBreaks}}{$_}}{all}{except}};
+              my %except = map { $_ => 1 } @{${${$mainSettings{modifyLineBreaks}}{$_}}{all}{except}};
               if( $except{$name} or $except{$YamlName}){
                 ${$self}{$_} = 0;
                 my $detail = ($except{$name} ? "per-name" : "per-code-block-type");
@@ -884,19 +967,19 @@
             #
             # the textWrapOptions/removeParagraphLineBreaks can contain fields that are hashes or scalar
             # 
-            if(ref ${$masterSettings{modifyLineBreaks}{$_}}{$YamlName} eq "HASH"){
+            if(ref ${$mainSettings{modifyLineBreaks}{$_}}{$YamlName} eq "HASH"){
                 # textWrapOptions/removeParagraphLineBreaks:
                 #     all: 0
                 #     environments: 
                 #         quotation: 0
                 $logger->trace("*$YamlName specified with fields in $_, looking for $name") if $is_t_switch_active;
-                ${$self}{$_} = ${${$masterSettings{modifyLineBreaks}{$_}}{$YamlName}}{$name} if (defined ${${$masterSettings{modifyLineBreaks}{$_}}{$YamlName}}{$name});
-            } elsif(defined ${$masterSettings{modifyLineBreaks}{$_}}{$YamlName}){
+                ${$self}{$_} = ${${$mainSettings{modifyLineBreaks}{$_}}{$YamlName}}{$name} if (defined ${${$mainSettings{modifyLineBreaks}{$_}}{$YamlName}}{$name});
+            } elsif(defined ${$mainSettings{modifyLineBreaks}{$_}}{$YamlName}){
                 # textWrapOptions/removeParagraphLineBreaks:
                 #     all: 0
                 #     environments: 0
-                $logger->trace("*$YamlName specified with just a number in $_ ${$masterSettings{modifyLineBreaks}{$_}}{$YamlName}") if $is_t_switch_active;
-                ${$self}{$_} = ${$masterSettings{modifyLineBreaks}{$_}}{$YamlName} if (defined ${$masterSettings{modifyLineBreaks}{$_}}{$YamlName});
+                $logger->trace("*$YamlName specified with just a number in $_ ${$mainSettings{modifyLineBreaks}{$_}}{$YamlName}") if $is_t_switch_active;
+                ${$self}{$_} = ${$mainSettings{modifyLineBreaks}{$_}}{$YamlName} if (defined ${$mainSettings{modifyLineBreaks}{$_}}{$YamlName});
             }
         }
 
@@ -913,17 +996,17 @@
     my $YamlName = ${$self}{modifyLineBreaksYamlName};
 
     # the columns settings can have a variety of different ways of being specified
-    if(ref ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns} eq "HASH"){
+    if(ref ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns} eq "HASH"){
         # assign default value of $columns
         my $columns;
-        if(defined ${${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{default}){
-            $columns = ${${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{default};
+        if(defined ${${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{default}){
+            $columns = ${${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{default};
         } else {
             $columns = 80;
         }
 
         # possibly specify object wrapping on a per-name basis
-        if(ref ${${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{$YamlName} eq "HASH"){
+        if(ref ${${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{$YamlName} eq "HASH"){
             # for example:
             #   modifyLineBreaks:
             #       textWrapOptions:
@@ -933,10 +1016,10 @@
             #                   default: 80
             #                   something: 10
             #                   another: 20
-            if(defined ${${${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{$YamlName}}{${$self}{name}}){
-                $columns = ${${${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{$YamlName}}{${$self}{name}};
-            } elsif (${${${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{$YamlName}}{default}){
-                $columns = ${${${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{$YamlName}}{default};
+            if(defined ${${${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{$YamlName}}{${$self}{name}}){
+                $columns = ${${${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{$YamlName}}{${$self}{name}};
+            } elsif (${${${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{$YamlName}}{default}){
+                $columns = ${${${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{$YamlName}}{default};
             }
         } else {
             # for example:
@@ -945,11 +1028,11 @@
             #           columns: 
             #               default: 80
             #               environments: 10
-            $columns = ${${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{$YamlName};
+            $columns = ${${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{$YamlName};
         }
         ${$self}{columns} = $columns;
     } else {
-        ${$self}{columns} = ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns};
+        ${$self}{columns} = ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns};
     }
     return;
 }
@@ -973,8 +1056,8 @@
   my $name = ($YamlName =~ m/Arguments/) ? ${$self}{parent} : ${$self}{name};
 
   # these variables just ease the notation what follows
-  my $everyValue = ${${$masterSettings{modifyLineBreaks}}{$YamlName}}{$toBeAssignedToAlias};
-  my $customValue = ${${${$masterSettings{modifyLineBreaks}}{$YamlName}}{$name}}{$toBeAssignedToAlias};
+  my $everyValue = ${${$mainSettings{modifyLineBreaks}}{$YamlName}}{$toBeAssignedToAlias};
+  my $customValue = ${${${$mainSettings{modifyLineBreaks}}{$YamlName}}{$name}}{$toBeAssignedToAlias};
 
   # check for the *custom* value
   if (defined $customValue){
@@ -1043,12 +1126,12 @@
     my $indentationInformation;
     foreach my $indentationAbout ("noAdditionalIndent","indentRules"){
         # check that the 'thing' is defined
-        if(defined ${$masterSettings{$indentationAbout}}{$name}){
-            if(ref ${$masterSettings{$indentationAbout}}{$name} eq "HASH"){
+        if(defined ${$mainSettings{$indentationAbout}}{$name}){
+            if(ref ${$mainSettings{$indentationAbout}}{$name} eq "HASH"){
                 $logger->trace("$indentationAbout indentation specified with multiple fields for $name, searching for $name: $YamlName (see $indentationAbout)") if $is_t_switch_active ;
-                $indentationInformation = ${${$masterSettings{$indentationAbout}}{$name}}{$YamlName};
+                $indentationInformation = ${${$mainSettings{$indentationAbout}}{$name}}{$YamlName};
             } else {
-                $indentationInformation = ${$masterSettings{$indentationAbout}}{$name};
+                $indentationInformation = ${$mainSettings{$indentationAbout}}{$name};
                 $logger->trace("$indentationAbout indentation specified for $name (for *all* fields, body, optionalArguments, mandatoryArguments, afterHeading), using '$indentationInformation' (see $indentationAbout)") if $is_t_switch_active ;
             }
             # return, after performing an integrity check
@@ -1070,16 +1153,16 @@
     foreach my $indentationAbout ("noAdditionalIndent","indentRules"){
         # global assignments in noAdditionalIndentGlobal and/or indentRulesGlobal
         my $globalInformation = $indentationAbout."Global";
-        next if(!(defined ${$masterSettings{$globalInformation}}{$YamlName})); 
-        if( ($globalInformation eq "noAdditionalIndentGlobal") and ${$masterSettings{$globalInformation}}{$YamlName}==1){
+        next if(!(defined ${$mainSettings{$globalInformation}}{$YamlName})); 
+        if( ($globalInformation eq "noAdditionalIndentGlobal") and ${$mainSettings{$globalInformation}}{$YamlName}==1){
             $logger->trace("$globalInformation specified for $YamlName (see $globalInformation)") if $is_t_switch_active;
             return q();
         } elsif($globalInformation eq "indentRulesGlobal") {
-            if(${$masterSettings{$globalInformation}}{$YamlName}=~m/^\h*$/){
+            if(${$mainSettings{$globalInformation}}{$YamlName}=~m/^\h*$/){
                 $logger->trace("$globalInformation specified for $YamlName (see $globalInformation)") if $is_t_switch_active;
-                return ${$masterSettings{$globalInformation}}{$YamlName};
-            } elsif (${$masterSettings{$globalInformation}}{$YamlName} ne '0') {
-                $logger->warn("$globalInformation specified (${$masterSettings{$globalInformation}}{$YamlName}) for $YamlName, but it needs to only contain horizontal space -- I'm ignoring this one");
+                return ${$mainSettings{$globalInformation}}{$YamlName};
+            } elsif (${$mainSettings{$globalInformation}}{$YamlName} ne '0') {
+                $logger->warn("$globalInformation specified (${$mainSettings{$globalInformation}}{$YamlName}) for $YamlName, but it needs to only contain horizontal space -- I'm ignoring this one");
           }
         }
     }
@@ -1086,7 +1169,7 @@
 
     # return defaultIndent, by default
     $logger->trace("Using defaultIndent for $name") if $is_t_switch_active;
-    return $masterSettings{defaultIndent};
+    return $mainSettings{defaultIndent};
 }
 
 sub yaml_get_object_attribute_for_indentation_settings{
@@ -1107,13 +1190,13 @@
 sub yaml_update_dumper_settings{
 
   # log file preferences
-  $Data::Dumper::Terse  = ${$masterSettings{logFilePreferences}{Dumper}}{Terse};
-  $Data::Dumper::Indent = ${$masterSettings{logFilePreferences}{Dumper}}{Indent};
-  $Data::Dumper::Useqq = ${$masterSettings{logFilePreferences}{Dumper}}{Useqq};
-  $Data::Dumper::Deparse = ${$masterSettings{logFilePreferences}{Dumper}}{Deparse};
-  $Data::Dumper::Quotekeys = ${$masterSettings{logFilePreferences}{Dumper}}{Quotekeys};
-  $Data::Dumper::Sortkeys = ${$masterSettings{logFilePreferences}{Dumper}}{Sortkeys};
-  $Data::Dumper::Pair = ${$masterSettings{logFilePreferences}{Dumper}}{Pair};
+  $Data::Dumper::Terse  = ${$mainSettings{logFilePreferences}{Dumper}}{Terse};
+  $Data::Dumper::Indent = ${$mainSettings{logFilePreferences}{Dumper}}{Indent};
+  $Data::Dumper::Useqq = ${$mainSettings{logFilePreferences}{Dumper}}{Useqq};
+  $Data::Dumper::Deparse = ${$mainSettings{logFilePreferences}{Dumper}}{Deparse};
+  $Data::Dumper::Quotekeys = ${$mainSettings{logFilePreferences}{Dumper}}{Quotekeys};
+  $Data::Dumper::Sortkeys = ${$mainSettings{logFilePreferences}{Dumper}}{Sortkeys};
+  $Data::Dumper::Pair = ${$mainSettings{logFilePreferences}{Dumper}}{Pair};
 
 }
 1;

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Heading.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Heading.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Heading.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -19,7 +19,7 @@
 use LatexIndent::Tokens qw/%tokens/;
 use LatexIndent::Switches qw/$is_m_switch_active $is_t_switch_active $is_tt_switch_active/;
 use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::LogFile qw/$logger/;
 use LatexIndent::Special qw/$specialBeginBasicRegExp/;
 use Exporter qw/import/;
@@ -33,7 +33,7 @@
     my $self = shift;
 
     # grab the heading levels
-    my %headingsLevels = %{$masterSettings{indentAfterHeadings}};
+    my %headingsLevels = %{$mainSettings{indentAfterHeadings}};
 
     # output to log file
     $logger->trace("*Constructing headings reg exp for example, chapter, section, etc (see indentAfterThisHeading)") if $is_t_switch_active ;

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/HorizontalWhiteSpace.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/HorizontalWhiteSpace.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/HorizontalWhiteSpace.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -16,7 +16,7 @@
 #	For all communication, please visit: https://github.com/cmhughes/latexindent.pl
 use strict;
 use warnings;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
 use Exporter qw/import/;
@@ -30,17 +30,17 @@
 
     # removeTrailingWhitespace can be either a hash or a scalar, but if
     # it's a scalar, we need to fix it
-    if(ref($masterSettings{removeTrailingWhitespace}) ne 'HASH'){
+    if(ref($mainSettings{removeTrailingWhitespace}) ne 'HASH'){
         $logger->trace("removeTrailingWhitespace specified as scalar, will update it to be a hash") if $is_t_switch_active;
         # grab the value
-        my $removeTWS = $masterSettings{removeTrailingWhitespace};
+        my $removeTWS = $mainSettings{removeTrailingWhitespace};
 
         # delete the scalar
-        delete $masterSettings{removeTrailingWhitespace};
+        delete $mainSettings{removeTrailingWhitespace};
 
         # redefine it as a hash
-        ${$masterSettings{removeTrailingWhitespace}}{beforeProcessing} = $removeTWS; 
-        ${$masterSettings{removeTrailingWhitespace}}{afterProcessing} = $removeTWS; 
+        ${$mainSettings{removeTrailingWhitespace}}{beforeProcessing} = $removeTWS; 
+        ${$mainSettings{removeTrailingWhitespace}}{afterProcessing} = $removeTWS; 
         $logger->trace("removeTrailingWhitespace: beforeProcessing is now $removeTWS") if $is_t_switch_active;
         $logger->trace("removeTrailingWhitespace: afterProcessing is now $removeTWS") if $is_t_switch_active;
     }
@@ -47,10 +47,10 @@
 
     # this method can be called before the indendation, and after, depending upon the input
     if($input{when} eq "before"){
-        return unless(${$masterSettings{removeTrailingWhitespace}}{beforeProcessing});
+        return unless(${$mainSettings{removeTrailingWhitespace}}{beforeProcessing});
         $logger->trace("Removing trailing white space *before* the document is processed (see removeTrailingWhitespace: beforeProcessing)") if $is_t_switch_active;
     } elsif($input{when} eq "after"){
-        return unless(${$masterSettings{removeTrailingWhitespace}}{afterProcessing});
+        return unless(${$mainSettings{removeTrailingWhitespace}}{afterProcessing});
         $logger->trace("Removing trailing white space *after* the document is processed (see removeTrailingWhitespace: afterProcessing)") if $is_t_switch_active;
     } else {
         return;

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/IfElseFi.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/IfElseFi.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/IfElseFi.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -17,7 +17,7 @@
 use strict;
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
 use LatexIndent::Switches qw/$is_m_switch_active $is_t_switch_active $is_tt_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
@@ -33,7 +33,7 @@
 # note: we search for \else separately in an attempt to keep this regexp a little more managable
 
 sub construct_ifelsefi_regexp{
-    my $ifElseFiNameRegExp = qr/${${$masterSettings{fineTuning}}{ifElseFi}}{name}/;
+    my $ifElseFiNameRegExp = qr/${${$mainSettings{fineTuning}}{ifElseFi}}{name}/;
     $ifElseFiRegExp = qr/
                 (
                     \\

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Indent.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Indent.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Indent.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -19,7 +19,7 @@
 use LatexIndent::Tokens qw/%tokens/;
 use LatexIndent::Switches qw/$is_m_switch_active $is_t_switch_active $is_tt_switch_active/;
 use LatexIndent::HiddenChildren qw/%familyTree/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::LogFile qw/$logger/;
 use Text::Tabs;
 use Data::Dumper;
@@ -126,7 +126,7 @@
     my $indentation = ${$self}{indentation};
 
     # possibly remove paragraph line breaks
-    $self->remove_paragraph_line_breaks if ($is_m_switch_active and ${$self}{removeParagraphLineBreaks} and !${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap});
+    $self->remove_paragraph_line_breaks if ($is_m_switch_active and ${$self}{removeParagraphLineBreaks} and !${$mainSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap});
 
     # body indendation
     if(${$self}{linebreaksAtEnd}{begin}==1){
@@ -236,7 +236,7 @@
                         $indentation;
                        /xsmeg;
 
-    return unless($masterSettings{maximumIndentation} =~ m/^\h+$/);
+    return unless($mainSettings{maximumIndentation} =~ m/^\h+$/);
 
     # maximum indentation check
     $logger->trace("*Maximum indentation check") if($is_t_switch_active);
@@ -246,7 +246,7 @@
     ${$self}{body} = join("", at expanded_lines);
 
     # grab the maximum indentation
-    my $maximumIndentation = $masterSettings{maximumIndentation};
+    my $maximumIndentation = $mainSettings{maximumIndentation};
     my $maximumIndentationLength = length($maximumIndentation)+1;
 
     # replace any leading space that is greater than the 
@@ -355,7 +355,7 @@
                                 $trailingCharacterToken = "%".$self->add_comment_symbol;
                             } elsif ($_==3){
                                 $logger->trace("Adding a blank line at the end of the line that ${$child}{begin} is on, then a linebreak ($BeginStringLogFile == 3)") if $is_t_switch_active;
-                                $trailingCharacterToken = "\n".(${$masterSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:q());
+                                $trailingCharacterToken = "\n".(${$mainSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:q());
                             } else {
                                 $logger->trace("Adding a linebreak at the beginning of ${$child}{begin} (see $BeginStringLogFile)") if $is_t_switch_active;
                             }

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Item.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Item.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Item.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -18,7 +18,7 @@
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
 use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
 use LatexIndent::IfElseFi qw/$ifElseFiBasicRegExp/;
@@ -36,7 +36,7 @@
     my $self = shift;
 
     # put together a list of the items
-    while( my ($item,$lookForThisItem)= each %{$masterSettings{itemNames}}){
+    while( my ($item,$lookForThisItem)= each %{$mainSettings{itemNames}}){
         $listOfItems .= ($listOfItems eq "")?"$item":"|$item" if($lookForThisItem);
     }
 
@@ -71,7 +71,7 @@
 
     # otherwise loop through the item names
     $logger->trace("Searching for items (see itemNames) in ${$self}{name} (see indentAfterItems)") if $is_t_switch_active;
-    $logger->trace(Dumper(\%{$masterSettings{itemNames}})) if $is_tt_switch_active;
+    $logger->trace(Dumper(\%{$mainSettings{itemNames}})) if $is_tt_switch_active;
 
     while(${$self}{body} =~ m/$itemRegExp\h*($trailingCommentRegExp)?/){
 

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/KeyEqualsValuesBraces.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/KeyEqualsValuesBraces.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/KeyEqualsValuesBraces.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -17,7 +17,7 @@
 use strict;
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
 use LatexIndent::Switches qw/$is_m_switch_active $is_t_switch_active $is_tt_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
@@ -38,8 +38,8 @@
     my $blankLineToken = $tokens{blanklines};
 
     # read from fine tuning
-    my  $keyEqualsValuesBracesBrackets = qr/${${$masterSettings{fineTuning}}{keyEqualsValuesBracesBrackets}}{name}/;
-    my  $keyEqualsValuesBracesBracketsFollow = qr/${${$masterSettings{fineTuning}}{keyEqualsValuesBracesBrackets}}{follow}/;
+    my  $keyEqualsValuesBracesBrackets = qr/${${$mainSettings{fineTuning}}{keyEqualsValuesBracesBrackets}}{name}/;
+    my  $keyEqualsValuesBracesBracketsFollow = qr/${${$mainSettings{fineTuning}}{keyEqualsValuesBracesBrackets}}{follow}/;
 
     # store the regular expresssion for matching and replacing 
     $key_equals_values_bracesRegExp = qr/

Added: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Lines.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Lines.pm	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Lines.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -0,0 +1,266 @@
+package LatexIndent::Lines;
+#	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
+use strict;
+use warnings;
+use Exporter qw/import/;
+use LatexIndent::LogFile qw/$logger/;
+use LatexIndent::Switches qw/%switches/;
+use LatexIndent::Verbatim qw/%verbatimStorage/;
+our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
+our @EXPORT_OK = qw/lines_body_selected_lines lines_verbatim_create_line_block/;
+
+sub lines_body_selected_lines {
+    my $self = shift;
+    my @lines = @{$_[0]};
+
+    # strip all space from lines switch
+    $switches{lines} =~ s/\h//sg;
+
+    $logger->info("*-n,--lines switch is active, operating on lines $switches{lines}"); 
+    $logger->info("number of lines in file: ".($#lines+1));
+    $logger->info("*interpretting $switches{lines}"); 
+    
+    my @lineRanges = split(/,/,$switches{lines});
+    my @indentLineRange;
+    my @NOTindentLineRange;
+
+    my %minMaxStorage;
+    my %negationMinMaxStorage;
+
+    # loop through line ranges, which are separated by commas
+    #
+    #       --lines 3-15,17-19
+    #
+    foreach(@lineRanges){
+      my $minLine = 0;
+      my $maxLine = 0;
+      my $negationMode = 0;
+
+      #
+      #  --lines !3-15
+      #
+      if($_ =~ m/!/s){
+        $negationMode = 1;
+        $_ =~ s/!//s;
+        $logger->info("negation mode active as $_");
+      }
+
+      #  --lines min-max
+      if($_ =~ m/-/s){
+          ($minLine,$maxLine) = split(/-/,$_);
+      } else {
+          $minLine = $_;
+          $maxLine = $_;
+      }
+
+      # both minLine and maxLine need to be INTEGERS
+      if ($minLine !~ m/^\d+$/ or $maxLine !~ m/^\d+$/){
+        $logger->warn("*$_ not a valid line specification; I'm ignoring this entry");
+        next;
+      }
+
+      # swap minLine and maxLine if necessary
+      if($minLine > $maxLine){
+          ($minLine,$maxLine) = ($maxLine, $minLine);
+      }
+      
+      # minline > number of lines needs addressing
+      if ($minLine-1 > $#lines){
+           $logger->warn("*--lines specified with min line $minLine which is *greater than* the number of lines in file: ".($#lines+1));
+           $logger->warn("adjusting this value to be ".($#lines+1));
+           $minLine = $#lines+1;
+      }
+
+      # maxline > number of lines needs addressing
+      if ($maxLine-1 > $#lines){
+           $logger->warn("*--lines specified with max line $maxLine which is *greater than* the number of lines in file: ".($#lines+1));
+           $logger->warn("adjusting this value to be ".($#lines+1));
+           $maxLine = $#lines+1;
+      }
+
+      # either store the negation, or not
+      if($negationMode){
+        $negationMinMaxStorage{$minLine} = $maxLine;
+      } else {
+        $minMaxStorage{$minLine} = $maxLine;
+      }
+      $logger->info("min line: $minLine, max line: $maxLine");
+    } 
+    
+    # only proceed if we have a valid line range
+    if ( (keys %minMaxStorage) < 1 and (keys %negationMinMaxStorage) < 1){
+      $logger->warn("*--lines not specified with valid range: $switches{lines}");
+      $logger->warn("entire body will be indented, and ignoring $switches{lines}");
+      $switches{lines} = 0;
+      ${$self}{body} = join("", at lines);
+      return;
+    } 
+    
+    # we need to perform the token check here
+    ${$self}{body} = join("", at lines);
+    $self->token_check;
+    ${$self}{body} = q();
+
+    # negated line ranges
+    if (keys %negationMinMaxStorage >= 1){
+        @NOTindentLineRange = &lines_sort_and_combine_line_range(\%negationMinMaxStorage);
+
+        $logger->info("*negation line range summary: ");
+        $logger->info("the number of NEGATION line ranges: ".(($#NOTindentLineRange+1)/2));
+        $logger->info("the *sorted* NEGATION line ranges are in the form MIN-MAX: ");
+        for (my $index=0; $index<(($#NOTindentLineRange+1)/2); $index++){
+            $logger->info(join("-", at NOTindentLineRange[2*$index..2*$index+1]));
+
+            if($index==0 and $NOTindentLineRange[2*$index]>1){
+                $minMaxStorage{1} = $NOTindentLineRange[2*$index]-1;
+            } elsif($index>0){
+                $minMaxStorage{$NOTindentLineRange[2*$index-1]+1} = $NOTindentLineRange[2*$index]-1;
+            }
+        }
+
+        # final range
+        if($NOTindentLineRange[-1]<$#lines){
+          $minMaxStorage{$NOTindentLineRange[-1]+1} = $#lines+1;
+        }
+    }
+
+    @indentLineRange = &lines_sort_and_combine_line_range(\%minMaxStorage) if (keys %minMaxStorage >= 1) ;
+
+    $logger->info("*line range summary: ");
+    $logger->info("the number of indent line ranges: ".(($#indentLineRange+1)/2));
+    $logger->info("the *sorted* line ranges are in the form MIN-MAX: ");
+    for (my $index=0; $index<(($#indentLineRange+1)/2); $index++){
+        $logger->info(join("-", at indentLineRange[2*$index..2*$index+1]));
+    }
+
+    my $startLine = 0;
+
+    # now that we have the line range, we can sort arrange the body 
+    while ($#indentLineRange>0){
+        my $minLine = shift(@indentLineRange);
+        my $maxLine = shift(@indentLineRange);
+
+        # perl arrays start at 0
+        $minLine--;
+        $maxLine--;
+
+        $self->lines_verbatim_create_line_block(\@lines,$startLine,$minLine-1) unless ($minLine == 0);
+
+        ${$self}{body} .= join("", at lines[$minLine..$maxLine]);
+
+        $startLine = $maxLine+1;
+    }
+
+    # final line range
+    $self->lines_verbatim_create_line_block(\@lines,$startLine,$#lines) if($startLine<=$#lines);
+    return;
+}
+
+sub lines_sort_and_combine_line_range{
+
+    my %minMaxStorage = %{$_[0]};
+    #
+    #     --lines 8-10,4-5,1-2
+    #
+    # needs to be interpretted as 
+    #
+    #     --lines 1-2,4-5,8-10, 
+    #
+    # sort the line ranges by the *minimum* value, the associated 
+    # maximum values will be arranged after this
+    my @indentLineRange = sort { $a <=> $b } keys(%minMaxStorage);
+
+    my @justMinimumValues = @indentLineRange; 
+    for (my $index=0;$index<=$#justMinimumValues;$index++){
+        splice(@indentLineRange,2*$index+1,0,$minMaxStorage{$justMinimumValues[$index]});
+    }
+
+    for (my $index=1;$index<(($#indentLineRange+1)/2);$index++){
+        my $currentMin  = $indentLineRange[2*$index];
+        my $currentMax  = $indentLineRange[2*$index+1];
+        my $previousMax = $indentLineRange[2*$index-1];
+        my $previousMin = $indentLineRange[2*$index-2];
+
+        if ( ($currentMin - 1) <= $previousMax and ( $currentMax > $previousMax ) ){
+            # overlapping line ranges, for example
+            #
+            #     --lines 3-5,4-10 
+            #
+            # needs to be interpretted as 
+            #
+            #     --lines 3-10 
+            #
+            $logger->info("overlapping line range found");
+            $logger->info("line ranges (before): ".join(", ", at indentLineRange));
+            splice(@indentLineRange,2*$index-1,2);
+            $logger->info("line ranges (after): ".join(", ", at indentLineRange));
+
+            # reset index so that loop starts again
+            $index = 0;
+        } elsif ( ($currentMin - 1) <= $previousMax and ( $currentMax <= $previousMax ) ){
+            # overlapping line ranges, for example
+            #
+            #     --lines 3-7,4-6
+            #
+            # needs to be interpretted as 
+            #
+            #     --lines 3-7
+            #
+            $logger->info("overlapping line range found");
+            $logger->info("line ranges (before): ".join(", ", at indentLineRange));
+            splice(@indentLineRange,2*$index,2);
+            $logger->info("line ranges (after): ".join(", ", at indentLineRange));
+
+            # reset index so that loop starts again
+            $index = 0;
+        }
+    }
+
+    return @indentLineRange;
+}
+
+sub lines_verbatim_create_line_block{
+    my $self = shift;
+    my @lines = @{$_[0]};
+    my $startLine = $_[1];
+    my $finishLine = $_[2];
+
+    my $verbBody = join("", at lines[$startLine..$finishLine]);
+    $verbBody =~ s/\R?$//s;
+
+    # create a new Verbatim object
+    my $noIndentBlockObj = LatexIndent::Verbatim->new( begin=>q(),
+                                          body=>$verbBody,
+                                          end=>q(),
+                                          name=>"line-switch-verbatim-protection",
+                                          type=>"linesprotect", 
+                                          modifyLineBreaksYamlName=>"lines-not-to-be-indented",
+                                          );
+    
+    # give unique id
+    $noIndentBlockObj->create_unique_id;
+
+    # verbatim children go in special hash
+    $verbatimStorage{${$noIndentBlockObj}{id}}=$noIndentBlockObj;
+
+    # remove the environment block, and replace with unique ID
+    ${$self}{body} .= ${$noIndentBlockObj}{id}."\n";
+
+    return;
+}
+
+1;


Property changes on: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Lines.pm
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -28,7 +28,7 @@
     # -v switch is just to show the version number
     if($switches{version}) {
         print $versionNumber,", ",$versionDate,"\n";
-        exit(2);
+        exit(0);
     }
 
     if(scalar(@ARGV) < 1 or $switches{showhelp}) {
@@ -81,9 +81,17 @@
       -rr, --onlyreplacement
           *only* replacement mode, no indentation;
           verbatim blocks not respected
+      -k, --check mode
+          will exit with 0 if document body unchanged, 1 if changed
+      -kv, --check mode verbose
+          as in check mode, but outputs diff to screen as well as to logfile
+      -n, --lines=<MIN-MAX>
+          only operate on selected lines; sample usage:
+                latexindent.pl --lines 3-5 myfile.tex
+                latexindent.pl --lines 3-5,7-10 myfile.tex
 ENDQUOTE
     ;
-    exit(2);
+    exit(0);
 }
 
     # if we've made it this far, the processing of switches and logging begins
@@ -93,8 +101,15 @@
     
     # cruft directory
     ${$self}{cruftDirectory} = $switches{cruftDirectory}||(dirname ${$self}{fileName});
-    die "Could not find directory ${$self}{cruftDirectory}\nExiting, no indentation done." if(!(-d ${$self}{cruftDirectory}));
 
+    # if cruft directory does not exist
+    if(!(-d ${$self}{cruftDirectory})){
+        $logger->fatal("*Could not find directory ${$self}{cruftDirectory}");
+        $logger->fatal("Exiting, no indendation done."); 
+        $self->output_logfile();
+        exit(6);
+    }
+
     my $logfileName = ($switches{cruftDirectory} ? ${$self}{cruftDirectory}."/" : '').($switches{logFileName}||"indent.log");
     
     # details of the script to log file
@@ -135,6 +150,9 @@
     $logger->info("-c|--cruft: cruft directory") if($switches{cruftDirectory});
     $logger->info("-r|--replacement: replacement mode") if($switches{replacement});
     $logger->info("-rr|--onlyreplacement: *only* replacement mode, no indentation") if($switches{onlyreplacement});
+    $logger->info("-k|--check mode: will exit with 0 if document body unchanged, 1 if changed") if($switches{check});
+    $logger->info("-kv|--check mode verbose: as in check mode, but outputs diff to screen") if($switches{checkverbose});
+    $logger->info("-n|--lines mode: will only operate on specific lines $switches{lines}") if($switches{lines});
 
     # check if overwrite and outputfile are active similtaneously
     if($switches{overwrite} and $switches{outputToFile}){

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Logger.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Logger.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Logger.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -60,7 +60,7 @@
         $logfileline =~ s/^/      /mg;
     }
     push(@logFileLines,$logfileline);
-    print $logfileline,"\n" if $switches{screenlog};
+    print $logfileline,"\n";
 }
 
 sub trace{

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -18,7 +18,7 @@
 use warnings;
 use Exporter qw/import/;
 use Text::Wrap;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 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/;
@@ -74,7 +74,7 @@
             my $trailingCharacterToken = q();
             $logger->trace("Adding a blank line at the end of begin ${$self}{begin} followed by a linebreak ($BodyStringLogFile == 3)") if $is_t_switch_active;
             ${$self}{begin} =~ s/\h*$//;       
-            ${$self}{begin} .= (${$masterSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:"\n")."\n";       
+            ${$self}{begin} .= (${$mainSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:"\n")."\n";       
             ${$self}{linebreaksAtEnd}{begin} = 1;
             $logger->trace("Removing leading space from body of ${$self}{name} (see $BodyStringLogFile)") if $is_t_switch_active;
             ${$self}{body} =~ s/^\h*//;       
@@ -127,7 +127,7 @@
                     ${$self}{body} =~ s/\h*$//s;
                   } elsif ($_==3) {
                     $logger->trace("Adding a blank line immediately after body of ${$self}{name} ($EndStringLogFile==3)") if $is_t_switch_active;
-                    $trailingCharacterToken = "\n".(${$masterSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:q());
+                    $trailingCharacterToken = "\n".(${$mainSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:q());
                     ${$self}{body} =~ s/\h*$//s;
                   }
                   
@@ -203,7 +203,7 @@
                     ${$self}{linebreaksAtEnd}{end} = 1;
 
                     # modified end statement
-                    ${$self}{replacementText} .= (${$masterSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:"\n")."\n";
+                    ${$self}{replacementText} .= (${$mainSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:"\n")."\n";
                   } 
         }
     }
@@ -278,11 +278,11 @@
 sub text_wrap_remove_paragraph_line_breaks{
     my $self = shift;
 
-    if(${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap}){
+    if(${$mainSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap}){
         $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
-        $self->text_wrap if (${$self}{textWrapOptions} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+        $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
     } else {
-        $self->text_wrap if (${$self}{textWrapOptions} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+        $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
     }
 
 }
@@ -292,7 +292,7 @@
     my $self = shift;
     
     # alignment at ampersand can take priority
-    return if(${$self}{lookForAlignDelims} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{alignAtAmpersandTakesPriority});
+    return if(${$self}{lookForAlignDelims} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{alignAtAmpersandTakesPriority});
 
     # goal: get an accurate measurement of verbatim objects;
     # 
@@ -316,7 +316,7 @@
     my @putVerbatimBackIn;
 
     # check body for verbatim and get measurements
-    if (${$self}{body} =~ m/$tokens{verbatim}/s and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{huge} eq "overflow"){
+    if (${$self}{body} =~ m/$tokens{verbatim}/s and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{huge} eq "overflow"){
 
       # reference: https://stackoverflow.com/questions/10336660/in-perl-how-can-i-generate-random-strings-consisting-of-eight-hex-digits
       my @set = ('0' ..'9', 'A' .. 'Z', 'a' .. 'z');
@@ -354,14 +354,14 @@
     # columns might have been defined by the user
     if(defined ${$self}{columns}){
         $columns = ${$self}{columns};
-    } elsif(ref ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns} eq "HASH"){
-        if(defined ${${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{default}){
-            $columns = ${${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{default};
+    } elsif(ref ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns} eq "HASH"){
+        if(defined ${${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{default}){
+            $columns = ${${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}}{default};
         } else {
             $columns = 80;
         }
-    } elsif (defined ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}){
-        $columns = ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns} ;
+    } elsif (defined ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}){
+        $columns = ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns} ;
     } else {
         $columns = 80;
     }
@@ -368,13 +368,13 @@
 
     # vital Text::Wrap options
     $Text::Wrap::columns=$columns;
-    $Text::Wrap::huge = ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{huge};
+    $Text::Wrap::huge = ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{huge};
 
     # all other Text::Wrap options not usually needed/helpful, but available
-    $Text::Wrap::separator=${$masterSettings{modifyLineBreaks}{textWrapOptions}}{separator} if(${$masterSettings{modifyLineBreaks}{textWrapOptions}}{separator} ne '');
-    $Text::Wrap::break = ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{break} if ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{break};
-    $Text::Wrap::unexpand = ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{unexpand} if ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{unexpand};
-    $Text::Wrap::tabstop = ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{tabstop} if ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{tabstop};
+    $Text::Wrap::separator=${$mainSettings{modifyLineBreaks}{textWrapOptions}}{separator} if(${$mainSettings{modifyLineBreaks}{textWrapOptions}}{separator} ne '');
+    $Text::Wrap::break = ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{break} if ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{break};
+    $Text::Wrap::unexpand = ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{unexpand} if ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{unexpand};
+    $Text::Wrap::tabstop = ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{tabstop} if ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{tabstop};
 
     # perform the text wrapping
     ${$self}{body} = wrap('','',${$self}{body});
@@ -387,7 +387,7 @@
 
     $logger->trace("*Constructing the paragraph-stop regexp (see paragraphsStopAt)") if $is_t_switch_active ;
     my $stopAtRegExp = q();
-    while( my ($paragraphStopAt,$yesNo)= each %{${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{paragraphsStopAt}}){
+    while( my ($paragraphStopAt,$yesNo)= each %{${$mainSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{paragraphsStopAt}}){
         if($yesNo){
             # the headings (chapter, section, etc) need a slightly special treatment
             $paragraphStopAt = "afterHeading" if($paragraphStopAt eq "heading");
@@ -436,7 +436,7 @@
     return unless ${$self}{removeParagraphLineBreaks};
 
     # alignment at ampersand can take priority
-    return if(${$self}{lookForAlignDelims} and ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{alignAtAmpersandTakesPriority});
+    return if(${$self}{lookForAlignDelims} and ${$mainSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{alignAtAmpersandTakesPriority});
 
     $logger->trace("Checking ${$self}{name} for paragraphs (see removeParagraphLineBreaks)") if $is_t_switch_active;
 

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/NamedGroupingBracesBrackets.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/NamedGroupingBracesBrackets.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/NamedGroupingBracesBrackets.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -17,7 +17,7 @@
 use strict;
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
@@ -35,8 +35,8 @@
     my $optAndMandRegExp = $self->get_arguments_regexp;
 
     # read from fine tuning
-    my $NamedGroupingBracesBracketsRegExp = qr/${${$masterSettings{fineTuning}}{namedGroupingBracesBrackets}}{name}/;
-    my $NamedGroupingFollowRegExp = qr/${${$masterSettings{fineTuning}}{namedGroupingBracesBrackets}}{follow}/;
+    my $NamedGroupingBracesBracketsRegExp = qr/${${$mainSettings{fineTuning}}{namedGroupingBracesBrackets}}{name}/;
+    my $NamedGroupingFollowRegExp = qr/${${$mainSettings{fineTuning}}{namedGroupingBracesBrackets}}{follow}/;
 
     # defaultSettings.yaml mistakenly had 
     #
@@ -50,13 +50,13 @@
     #
     # the mistake was mine, so I feel that the following is necessary; if we 
     # get to V4, then this will be removed and only namedGroupingBracesBrackets will be supported
-    if(${${$masterSettings{fineTuning}}{NamedGroupingBracesBrackets}}{name}){
+    if(${${$mainSettings{fineTuning}}{NamedGroupingBracesBrackets}}{name}){
         $logger->warn("*fineTuning:NamedGroupingBracesBrackets is ok for now, but in future versions, fineTuning:namedGroupingBracesBrackets will be used");
-        $NamedGroupingBracesBracketsRegExp = qr/${${$masterSettings{fineTuning}}{NamedGroupingBracesBrackets}}{name}/;
+        $NamedGroupingBracesBracketsRegExp = qr/${${$mainSettings{fineTuning}}{NamedGroupingBracesBrackets}}{name}/;
     } 
-    if(${${$masterSettings{fineTuning}}{NamedGroupingBracesBrackets}}{follow}){
+    if(${${$mainSettings{fineTuning}}{NamedGroupingBracesBrackets}}{follow}){
         $logger->warn("*fineTuning:NamedGroupingBracesBrackets is ok for now, but in future versions, fineTuning:namedGroupingBracesBrackets will be used");
-        $NamedGroupingFollowRegExp = qr/${${$masterSettings{fineTuning}}{NamedGroupingBracesBrackets}}{follow}/;
+        $NamedGroupingFollowRegExp = qr/${${$mainSettings{fineTuning}}{NamedGroupingBracesBrackets}}{follow}/;
     }
 
     # store the regular expresssion for matching and replacing 

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Preamble.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Preamble.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Preamble.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -18,7 +18,7 @@
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_m_switch_active/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::LogFile qw/$logger/;
 use LatexIndent::Environment qw/$environmentBasicRegExp/;
 use LatexIndent::IfElseFi qw/$ifElseFiBasicRegExp/;
@@ -51,6 +51,23 @@
 sub tasks_particular_to_each_object{
     my $self = shift;
 
+    # text wrapping, remove paragraph line breaks
+    if ($is_m_switch_active){
+        $self->yaml_get_textwrap_removeparagraphline_breaks;
+    }
+
+    # option to textWrap beforeFindingChildCodeBlocks
+    if( $is_m_switch_active and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} == 1){ 
+        # call the remove_paragraph_line_breaks and text_wrap routines
+        if(${$mainSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap}){
+            $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
+            $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+        } else {
+            $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+            $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
+        }
+    }
+
     # search for environments
     $self->find_environments if ${$self}{body} =~ m/$environmentBasicRegExp/;
 
@@ -57,15 +74,15 @@
     # search for ifElseFi blocks
     $self->find_ifelsefi if ${$self}{body} =~ m/$ifElseFiBasicRegExp/s;
 
-    if(${$masterSettings{specialBeginEnd}}{specialBeforeCommand}){
+    if(${$mainSettings{specialBeginEnd}}{specialBeforeCommand}){
         # search for special begin/end
         $self->find_special if ${$self}{body} =~ m/$specialBeginBasicRegExp/s;
 
         # search for commands with arguments
-        $self->find_commands_or_key_equals_values_braces if(!$masterSettings{preambleCommandsBeforeEnvironments});
+        $self->find_commands_or_key_equals_values_braces if(!$mainSettings{preambleCommandsBeforeEnvironments});
     } else {
         # search for commands with arguments
-        $self->find_commands_or_key_equals_values_braces if(!$masterSettings{preambleCommandsBeforeEnvironments});
+        $self->find_commands_or_key_equals_values_braces if(!$mainSettings{preambleCommandsBeforeEnvironments});
 
         # search for special begin/end
         $self->find_special if ${$self}{body} =~ m/$specialBeginBasicRegExp/s;
@@ -72,15 +89,13 @@
     }
 
     # text wrapping, remove paragraph line breaks
-    if ($is_m_switch_active){
-        $self->yaml_get_textwrap_removeparagraphline_breaks;
-
+    if ($is_m_switch_active and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{beforeFindingChildCodeBlocks} == 0){
         # call the remove_paragraph_line_breaks and text_wrap routines
-        if(${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap}){
+        if(${$mainSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{beforeTextWrap}){
             $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
-            $self->text_wrap if (${$self}{textWrapOptions} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+            $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
         } else {
-            $self->text_wrap if (${$self}{textWrapOptions} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
+            $self->text_wrap if (${$self}{textWrapOptions} and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis});
             $self->remove_paragraph_line_breaks if ${$self}{removeParagraphLineBreaks};
         }
     }

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Replacement.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Replacement.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Replacement.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -18,7 +18,7 @@
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
 use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_rr_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
 use Exporter qw/import/;
@@ -34,7 +34,7 @@
       $logger->trace("*Replacement mode, -rr switch is active") if $is_t_switch_active ;
     }
 
-	my @replacements = @{$masterSettings{replacements}};
+	my @replacements = @{$mainSettings{replacements}};
 
 	foreach ( @replacements ){
         next if !(${$_}{this} or ${$_}{substitution});

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Sentence.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Sentence.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Sentence.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -18,7 +18,7 @@
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
 use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_m_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
 use LatexIndent::Environment qw/$environmentBasicRegExp/;
@@ -40,7 +40,7 @@
     # sentences FOLLOW
     my $sentencesFollow = q();
 
-    while( my ($sentencesFollowEachPart,$yesNo)= each %{${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}){
+    while( my ($sentencesFollowEachPart,$yesNo)= each %{${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}){
         if($yesNo){
             if($sentencesFollowEachPart eq "par"){
                 $sentencesFollowEachPart = qr/\R?\\par/s;
@@ -75,7 +75,7 @@
     # if blankLine is not active from sentencesFollow then we need to set up the 
     # beginning of the string, but make sure that it is *not* followed by a 
     # blank line token, or a blank line
-    if(!${${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}{blankLine}){
+    if(!${${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}{blankLine}){
             $sentencesFollow .= ($sentencesFollow eq '' ? q() : "|").
                                     qr/
                                         \G
@@ -83,7 +83,7 @@
                                     /sx;
     }
 
-    if(${${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}{blankLine}){
+    if(${${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}{blankLine}){
         $sentencesFollow = ($sentencesFollow eq '' ? q() : qr/(?:$sentencesFollow)(?:\h|\R)*/sx );
     } else {
         $sentencesFollow = ($sentencesFollow eq '' ? q() : qr/(?:$sentencesFollow)(?:\h*\R?)/sx );
@@ -98,7 +98,7 @@
     # sentences BEGIN with
     my $sentencesBeginWith = q();
 
-    while( my ($sentencesBeginWithEachPart,$yesNo)= each %{${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesBeginWith}}){
+    while( my ($sentencesBeginWithEachPart,$yesNo)= each %{${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesBeginWith}}){
         if($yesNo){
             if($sentencesBeginWithEachPart eq "A-Z"){
                 $logger->trace("sentence BEGINS with capital letters (see oneSentencePerLine:sentencesBeginWith:A-Z)") if $is_t_switch_active;
@@ -118,10 +118,10 @@
     # sentences END with
     # sentences END with
     # sentences END with
-    ${${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesEndWith}}{basicFullStop} = 0 if ${${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesEndWith}}{betterFullStop};
+    ${${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesEndWith}}{basicFullStop} = 0 if ${${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesEndWith}}{betterFullStop};
     my $sentencesEndWith = q();
 
-    while( my ($sentencesEndWithEachPart,$yesNo)= each %{${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesEndWith}}){
+    while( my ($sentencesEndWithEachPart,$yesNo)= each %{${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesEndWith}}){
         if($yesNo){
             if($sentencesEndWithEachPart eq "basicFullStop"){
                 $logger->trace("sentence ENDS with full stop (see oneSentencePerLine:sentencesEndWith:basicFullStop") if $is_t_switch_active;
@@ -128,7 +128,7 @@
                 $sentencesEndWithEachPart = qr/\./;
             } elsif($sentencesEndWithEachPart eq "betterFullStop"){
                 $logger->trace("sentence ENDS with *better* full stop (see oneSentencePerLine:sentencesEndWith:betterFullStop") if $is_t_switch_active;
-                $sentencesEndWithEachPart = qr/${${$masterSettings{fineTuning}}{modifyLineBreaks}}{betterFullStop}/;
+                $sentencesEndWithEachPart = qr/${${$mainSettings{fineTuning}}{modifyLineBreaks}}{betterFullStop}/;
             } elsif ($sentencesEndWithEachPart eq "exclamationMark"){
                 $logger->trace("sentence ENDS with exclamation mark (see oneSentencePerLine:sentencesEndWith:exclamationMark)") if $is_t_switch_active;
                 $sentencesEndWithEachPart = qr/!/;
@@ -163,12 +163,12 @@
     #
     # is set to 0 then we need to *exclude* the $tokens{blanklines} from the sentence routine,
     # otherwise we could begin a sentence with $tokens{blanklines}.
-    if(!${${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}{blankLine}){
+    if(!${${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}{blankLine}){
         $notWithinSentence .= "|".qr/(?:\h*\R?$tokens{blanklines})/s;
     }
 
     # similarly for \par
-    if(${${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}{par}){
+    if(${${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}{par}){
         $notWithinSentence .= "|".qr/(?:\R?\\par)/s;
     }
 
@@ -193,7 +193,7 @@
                             my $lineBreaksAtEnd = ($6? 1 : ($7?1:0) );
                             my $trailingComments = q();
                             # remove trailing comments from within the body of the sentence
-                            if (${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{removeSentenceLineBreaks}){
+                            if (${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{removeSentenceLineBreaks}){
                                 while($middle =~ m|$trailingCommentRegExp|){
                                     $middle =~ s|\h*($trailingCommentRegExp)||s;
                                     $trailingComments .= $1;
@@ -203,7 +203,7 @@
                             $middle =~ s|
                                             (?!\A)      # not at the *beginning* of a match
                                             (\h*)\R     # possible horizontal space, then line break
-                                        |$1?$1:" ";|esgx if ${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{removeSentenceLineBreaks};
+                                        |$1?$1:" ";|esgx if ${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{removeSentenceLineBreaks};
                             $middle =~ s|$tokens{blanklines}\h*\R?|$tokens{blanklines}\n|sg;
                             $logger->trace("follows: $beginning") if $is_tt_switch_active;
                             $logger->trace("sentence: $middle") if $is_tt_switch_active;
@@ -211,13 +211,13 @@
                             # if indentation is specified for sentences, then we treat
                             # them as objects; otherwise we don't
                             my $replacementText = q();
-                            if(${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentenceIndent} =~ m|\h+|){
+                            if(${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentenceIndent} =~ m|\h+|){
                                 my $sentenceObj = LatexIndent::Sentence->new(
                                                             name=>"sentence",
                                                             begin=>q(),
                                                             body=>$middle.$end,
                                                             end=>q(),
-                                                            indentation=>${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentenceIndent},
+                                                            indentation=>${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentenceIndent},
                                                             modifyLineBreaksYamlName=>"sentence",
                                                             BeginStartsOnOwnLine=>1,
                                                           );
@@ -236,7 +236,7 @@
                             $replacementText;
                             /xsge;
 
-       if(${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentenceIndent} !~ m/\h+/){
+       if(${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentenceIndent} !~ m/\h+/){
              # loop back through the sentenceStorage and replace with the sentence, adjusting line breaks
              # before and after appropriately
              while( my $sentence = pop @sentenceStorage){
@@ -244,7 +244,7 @@
                my $sentenceStorageValue = ${$sentence}{value};
 
                # option to text wrap (and option to indent) sentences
-               if(${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{textWrapSentences}){
+               if(${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{textWrapSentences}){
                        my $sentenceObj = LatexIndent::Document->new(body=>$sentenceStorageValue,
                                                              name=>"sentence",
                                                              modifyLineBreaksYamlName=>"sentence",
@@ -257,7 +257,7 @@
                            $logger->info("You have specified oneSentencePerLine:textWrapSentences, but columns is set to 0");
                            $logger->info("You might wish to specify, for example: modifyLineBreaks: textWrapOptions: columns: 80");
                            $logger->info("The value of oneSentencePerLine:textWrapSentences will now be set to 0, so you won't see this message again");
-                           ${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{textWrapSentences} = 0;
+                           ${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{textWrapSentences} = 0;
                        } else {
                            $sentenceObj->text_wrap;
                        }
@@ -270,7 +270,7 @@
                                            /sx){
                            my $bodyFirstLine = $1;
                            my $remainingBody = $2;
-                           my $indentation = ${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentenceIndent};
+                           my $indentation = ${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentenceIndent};
                            $logger->trace("first line of sencent:  $bodyFirstLine") if $is_tt_switch_active;
                            $logger->trace("remaining body (before indentation):\n'$remainingBody'") if($is_tt_switch_active);
              
@@ -305,7 +305,7 @@
       my $self = shift;
 
       # option to text wrap (and option to indent) sentences
-      if(${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{textWrapSentences}){
+      if(${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{textWrapSentences}){
         $self->yaml_get_columns;
         $self->text_wrap;
       }
@@ -327,7 +327,7 @@
 }
 
 sub indent_body{
-      return unless ${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentenceIndent} =~ m/\h+/;
+      return unless ${$mainSettings{modifyLineBreaks}{oneSentencePerLine}}{sentenceIndent} =~ m/\h+/;
 
       my $self = shift;
 

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -18,7 +18,7 @@
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
 use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
 use LatexIndent::IfElseFi qw/$ifElseFiBasicRegExp/;
@@ -39,11 +39,11 @@
     $logger->trace("*Constructing specialBeginEnd regex (see specialBeginEnd)") if $is_t_switch_active;
 
     # put together a list of the begin terms in special
-    while( my ($specialName,$BeginEnd)= each %{$masterSettings{specialBeginEnd}}){
+    while( my ($specialName,$BeginEnd)= each %{$mainSettings{specialBeginEnd}}){
       if(ref($BeginEnd) eq "HASH"){
         if (not defined ${$BeginEnd}{lookForThis}){
             ${$BeginEnd}{lookForThis} = 1;
-            ${${$masterSettings{specialBeginEnd}}{$specialName}}{lookForThis} = 1;
+            ${${$mainSettings{specialBeginEnd}}{$specialName}}{lookForThis} = 1;
             $logger->trace("setting lookForThis:1 for $specialName (lookForThis not specified)") if $is_t_switch_active;
         }
 
@@ -53,7 +53,7 @@
     }
 
     # put together a list of the begin terms in special
-    while( my ($specialName,$BeginEnd)= each %{$masterSettings{specialBeginEnd}}){
+    while( my ($specialName,$BeginEnd)= each %{$mainSettings{specialBeginEnd}}){
 
       # only append the regexps if lookForThis is 1
       if( ref($BeginEnd) eq "HASH" ){
@@ -129,13 +129,13 @@
 
     # otherwise loop through the special begin/end
     $logger->trace("*Searching ${$self}{name} for special begin/end (see specialBeginEnd)") if $is_t_switch_active ;
-    $logger->trace(Dumper(\%{$masterSettings{specialBeginEnd}})) if $is_tt_switch_active;
+    $logger->trace(Dumper(\%{$mainSettings{specialBeginEnd}})) if $is_tt_switch_active;
 
     # keep looping as long as there is a special match of some kind
     while(${$self}{body} =~ m/$specialAllMatchesRegExp/sx){
 
         # loop through each special match
-        while( my ($specialName,$BeginEnd)= each %{$masterSettings{specialBeginEnd}}){
+        while( my ($specialName,$BeginEnd)= each %{$mainSettings{specialBeginEnd}}){
 
             # log file
             if((ref($BeginEnd) eq "HASH") and ${$BeginEnd}{lookForThis}=~m/\d/s and ${$BeginEnd}{lookForThis} == 1){
@@ -197,7 +197,7 @@
 sub tasks_particular_to_each_object{
     my $self = shift;
 
-    if( defined ${${$masterSettings{specialBeginEnd}}{${$self}{name}}}{middle}){
+    if( defined ${${$mainSettings{specialBeginEnd}}{${$self}{name}}}{middle}){
             $logger->trace("middle specified for ${$self}{name} (see specialBeginEnd -> ${$self}{name} -> middle)") if $is_t_switch_active ;
 
             # initiate the middle regexp
@@ -204,14 +204,14 @@
             my $specialMiddle = q();
 
             # we can specify middle as either an array or a hash
-            if(ref(${${$masterSettings{specialBeginEnd}}{${$self}{name}}}{middle}) eq "ARRAY"){
+            if(ref(${${$mainSettings{specialBeginEnd}}{${$self}{name}}}{middle}) eq "ARRAY"){
                 $logger->trace("looping through middle array for ${$self}{name}") if $is_t_switch_active ;
-                foreach(@{${${$masterSettings{specialBeginEnd}}{${$self}{name}}}{middle}}){
+                foreach(@{${${$mainSettings{specialBeginEnd}}{${$self}{name}}}{middle}}){
                     $specialMiddle .= ($specialMiddle eq ""?q():"|").$_;
                 }
                 $specialMiddle = qr/$specialMiddle/; 
             } else {
-                $specialMiddle = qr/${${$masterSettings{specialBeginEnd}}{${$self}{name}}}{middle}/;
+                $specialMiddle = qr/${${$mainSettings{specialBeginEnd}}{${$self}{name}}}{middle}/;
             }
 
             $logger->trace("overall middle regexp for ${$self}{name}: $specialMiddle") if $is_t_switch_active ;
@@ -236,7 +236,7 @@
     
     }
 
-    return unless(${$masterSettings{specialBeginEnd}}{specialBeforeCommand});
+    return unless(${$mainSettings{specialBeginEnd}}{specialBeforeCommand});
 
     # search for commands with arguments
     $self->find_commands_or_key_equals_values_braces;
@@ -253,7 +253,7 @@
     # needed to remove leading horizontal space before \else
     my $self = shift;
 
-    return unless ( defined ${${$masterSettings{specialBeginEnd}}{${$self}{name}}}{middle});
+    return unless ( defined ${${$mainSettings{specialBeginEnd}}{${$self}{name}}}{middle});
 
     $logger->trace("post indentation check for ${$self}{name} to account for middle") if $is_t_switch_active ;
 

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Switches.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Switches.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Switches.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -17,7 +17,7 @@
 use strict;
 use warnings;
 use Exporter qw/import/;
-our @EXPORT_OK = qw/%switches store_switches $is_m_switch_active $is_t_switch_active $is_tt_switch_active $is_r_switch_active $is_rr_switch_active $is_rv_switch_active/;
+our @EXPORT_OK = qw/%switches store_switches $is_m_switch_active $is_t_switch_active $is_tt_switch_active $is_r_switch_active $is_rr_switch_active $is_rv_switch_active $is_check_switch_active $is_check_verbose_switch_active/;
 our %switches;
 our $is_m_switch_active;
 our $is_t_switch_active;
@@ -25,6 +25,8 @@
 our $is_r_switch_active;
 our $is_rr_switch_active;
 our $is_rv_switch_active;
+our $is_check_switch_active;
+our $is_check_verbose_switch_active;
 
 sub store_switches{
     my $self = shift;
@@ -39,6 +41,9 @@
     $is_rr_switch_active = defined $switches{onlyreplacement}?$switches{onlyreplacement}: 0;
     $is_rv_switch_active = defined $switches{replacementRespectVerb}?$switches{replacementRespectVerb}: 0;
     $is_r_switch_active = ($is_rr_switch_active|$is_rv_switch_active) ? ($is_rr_switch_active|$is_rv_switch_active) : $is_r_switch_active;
+    $is_check_switch_active = defined $switches{check}?$switches{check}: 0;
+    $is_check_verbose_switch_active = defined $switches{checkverbose}?$switches{checkverbose}: 0;
+    $is_check_switch_active = $is_check_verbose_switch_active ? $is_check_verbose_switch_active : $is_check_switch_active; 
     delete ${$self}{switches};
   }
 1;

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -18,7 +18,7 @@
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_m_switch_active/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::LogFile qw/$logger/;
 use Data::Dumper;
 use Exporter qw/import/;
@@ -28,7 +28,7 @@
 our $trailingCommentRegExp;
 
 sub construct_trailing_comment_regexp{
-    my  $notPreceededBy = qr/${${$masterSettings{fineTuning}}{trailingComments}}{notPreceededBy}/;
+    my  $notPreceededBy = qr/${${$mainSettings{fineTuning}}{trailingComments}}{notPreceededBy}/;
 
     $trailingCommentRegExp = qr/$notPreceededBy%$tokens{trailingComment}\d+$tokens{endOfToken}/;
 }
@@ -56,7 +56,7 @@
     my $self = shift;
     $logger->trace("*Storing trailing comments")if $is_t_switch_active;
 
-    my  $notPreceededBy = qr/${${$masterSettings{fineTuning}}{trailingComments}}{notPreceededBy}/;
+    my  $notPreceededBy = qr/${${$mainSettings{fineTuning}}{trailingComments}}{notPreceededBy}/;
 
     # perform the substitution
     ${$self}{body} =~ s/
@@ -104,8 +104,8 @@
             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));
+            if(${$mainSettings{modifyLineBreaks}{textWrapOptions}}{separator} ne ''){
+                $trailingcommentIDwithLineBreaks = join("\\".${$mainSettings{modifyLineBreaks}{textWrapOptions}}{separator}."?",split(//,$trailingcommentID));
             } else {
                 $trailingcommentIDwithLineBreaks = join("(?:\\h|\\R)*",split(//,$trailingcommentID));
             }
@@ -114,7 +114,7 @@
             # replace the line-broken trailing comment ID with a non-broken trailing comment ID
             ${$self}{body} =~ s/%\R?$trailingcommentIDwithLineBreaksRegExp/%$trailingcommentID/s;
       }
-      my  $notPreceededBy = qr/${${$masterSettings{fineTuning}}{trailingComments}}{notPreceededBy}/;
+      my  $notPreceededBy = qr/${${$mainSettings{fineTuning}}{trailingComments}}{notPreceededBy}/;
       if(${$self}{body} =~ m/%$trailingcommentID
                               (
                                   (?!                  # not immediately preceeded by 

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/UnNamedGroupingBracesBrackets.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/UnNamedGroupingBracesBrackets.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/UnNamedGroupingBracesBrackets.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -17,7 +17,7 @@
 use strict;
 use warnings;
 use LatexIndent::Tokens qw/%tokens/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
@@ -38,8 +38,8 @@
     my $blankLineToken = $tokens{blanklines};
 
     # arguments Before, by default, includes beamer special and numbered arguments, for example #1 #2, etc
-    my $argumentsBefore = qr/${${$masterSettings{fineTuning}}{arguments}}{before}/;
-    my $UnNamedGroupingFollowRegExp = qr/${${$masterSettings{fineTuning}}{UnNamedGroupingBracesBrackets}}{follow}/;
+    my $argumentsBefore = qr/${${$mainSettings{fineTuning}}{arguments}}{before}/;
+    my $UnNamedGroupingFollowRegExp = qr/${${$mainSettings{fineTuning}}{UnNamedGroupingBracesBrackets}}{follow}/;
 
     # store the regular expresssion for matching and replacing 
     $un_named_grouping_braces_RegExp = qr/

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -19,7 +19,7 @@
 use Data::Dumper;
 use Exporter qw/import/;
 use LatexIndent::Tokens qw/%tokens/;
-use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings/;
 use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_m_switch_active/;
 use LatexIndent::LogFile qw/$logger/;
 our @EXPORT_OK = qw/put_verbatim_back_in find_verbatim_environments find_noindent_block find_verbatim_commands find_verbatim_special verbatim_common_tasks %verbatimStorage/;
@@ -32,8 +32,8 @@
 
     # noindent block
     $logger->trace('*Searching for NOINDENTBLOCk (see noIndentBlock)') if $is_t_switch_active;
-    $logger->trace(Dumper(\%{$masterSettings{noIndentBlock}})) if($is_tt_switch_active);
-    while( my ($noIndentBlock,$yesno)= each %{$masterSettings{noIndentBlock}}){
+    $logger->trace(Dumper(\%{$mainSettings{noIndentBlock}})) if($is_tt_switch_active);
+    while( my ($noIndentBlock,$yesno)= each %{$mainSettings{noIndentBlock}}){
 
         # integrity check on the field for noIndentBlock
         if ( ref($yesno) eq "HASH" ){
@@ -123,7 +123,7 @@
           $logger->trace("replaced with ID: ${$noIndentBlockObj}{id}") if $is_t_switch_active;
           
           # possible decoration in log file 
-          $logger->trace(${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
+          $logger->trace(${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
         } 
     }
     return;
@@ -134,8 +134,8 @@
 
     # verbatim environments
     $logger->trace('*Searching for VERBATIM environments (see verbatimEnvironments)') if $is_t_switch_active;
-    $logger->trace(Dumper(\%{$masterSettings{verbatimEnvironments}})) if($is_tt_switch_active);
-    while( my ($verbEnv,$yesno)= each %{$masterSettings{verbatimEnvironments}}){
+    $logger->trace(Dumper(\%{$mainSettings{verbatimEnvironments}})) if($is_tt_switch_active);
+    while( my ($verbEnv,$yesno)= each %{$mainSettings{verbatimEnvironments}}){
         if($yesno){
             $logger->trace("looking for $verbEnv:$yesno environments") if $is_t_switch_active;
 
@@ -192,7 +192,7 @@
               $logger->trace("replaced with ID: ${$verbatimBlock}{id}") if $is_t_switch_active;
               
               # possible decoration in log file 
-              $logger->trace(${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
+              $logger->trace(${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
             } 
       } else {
             $logger->trace("*not* looking for $verbEnv as $verbEnv:$yesno") if $is_t_switch_active;
@@ -210,8 +210,8 @@
     # verbatim commands need to be put back in *after* trailing comments have been put 
     # back in
     $logger->trace('*Searching for VERBATIM commands (see verbatimCommands)') if $is_t_switch_active;
-    $logger->trace(Dumper(\%{$masterSettings{verbatimCommands}})) if($is_tt_switch_active);
-    while( my ($verbCommand,$yesno)= each %{$masterSettings{verbatimCommands}}){
+    $logger->trace(Dumper(\%{$mainSettings{verbatimCommands}})) if($is_tt_switch_active);
+    while( my ($verbCommand,$yesno)= each %{$mainSettings{verbatimCommands}}){
         if($yesno){
             $logger->trace("looking for $verbCommand:$yesno Commands") if $is_t_switch_active;
 
@@ -281,7 +281,7 @@
               $logger->trace("replaced with ID: ${$verbatimCommand}{id}") if $is_t_switch_active;
               
               # possible decoration in log file 
-              $logger->trace(${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
+              $logger->trace(${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
             } 
       } else {
             $logger->trace("*not* looking for $verbCommand as $verbCommand:$yesno") if $is_t_switch_active;
@@ -295,7 +295,7 @@
     my $self = shift;
 
     # loop through specialBeginEnd
-    while( my ($specialName,$BeginEnd)= each %{$masterSettings{specialBeginEnd}}){
+    while( my ($specialName,$BeginEnd)= each %{$mainSettings{specialBeginEnd}}){
 
       # only classify special Verbatim if lookForThis is 'verbatim'
       if( (ref($BeginEnd) eq "HASH") and ${$BeginEnd}{lookForThis}=~m/v/s and ${$BeginEnd}{lookForThis} eq 'verbatim'){
@@ -350,7 +350,7 @@
               $logger->trace("replaced with ID: ${$verbatimBlock}{id}") if $is_t_switch_active;
               
               # possible decoration in log file 
-              $logger->trace(${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
+              $logger->trace(${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
             } 
     }
   }
@@ -363,7 +363,7 @@
     my $verbatimCount=0;
     my $toMatch = q();
     if($input{match} eq "everything-except-commands"){
-        $toMatch = "noindentblockenvironmentspecial";
+        $toMatch = "noindentblockenvironmentspeciallinesprotect";
     } else {
         $toMatch = "command";
     }
@@ -386,14 +386,32 @@
     while($verbatimFound < $verbatimCount){
         while( my ($verbatimID,$child)= each %verbatimStorage){
           if($toMatch =~ m/${$child}{type}/){
-            if(${$self}{body} =~ m/$verbatimID/mx){
+            if(${$self}{body} =~ m/$verbatimID/m){
                 # possibly remove trailing line break
-                if(defined ${$child}{EndFinishesWithLineBreak} 
+                if($is_m_switch_active 
+                    and defined ${$child}{EndFinishesWithLineBreak} 
                     and ${$child}{EndFinishesWithLineBreak}==-1
                     and ${$self}{body} =~ m/$verbatimID\h*\R/s){
                     $logger->trace("m-switch active, removing trailing line breaks from ${$child}{name}") if $is_t_switch_active;
                     ${$self}{body} =~ s/$verbatimID(\h*)?(\R|\h)*/$verbatimID /s;
                 }
+
+                # line protection mode can allow line breaks to be removed 
+                # at end of verbatim; these need to be added back in
+                #
+                # see 
+                #
+                #   test-cases/line-switch-test-cases/environments-simple-nested-mod13.tex 
+                #
+                if(${$child}{type} eq "linesprotect"){
+                    # remove leading space ahead of verbatim ID
+                    ${$self}{body} =~ s/^\h*$verbatimID/$verbatimID/m;
+
+                    if($is_m_switch_active and ${$self}{body}=~ m/$verbatimID\h*\S/s){
+                        ${$self}{body} =~ s/$verbatimID\h*(\S)/$verbatimID\n$1/s;
+                    }
+                }
+
                 # replace ids with body
                 ${$self}{body} =~ s/$verbatimID/${$child}{begin}${$child}{body}${$child}{end}/s;
 
@@ -405,8 +423,8 @@
                 delete $verbatimStorage{$verbatimID};
                 $verbatimFound++;
               } elsif ($is_m_switch_active 
-                  and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1 
-                  and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{huge} ne "overflow" 
+                  and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1 
+                  and ${$mainSettings{modifyLineBreaks}{textWrapOptions}}{huge} ne "overflow" 
                   and ${$self}{body} !~ m/${$child}{id}/){
                 $logger->trace("$verbatimID not found in body using /m matching, it may have been split across line (see modifyLineBreaks: textWrapOptions)") if($is_t_switch_active);
 
@@ -462,7 +480,7 @@
 
 sub yaml_get_textwrap_removeparagraphline_breaks{
     my $self = shift;
-    $logger->trace("No text wrap or remove paragraph line breaks for verbatim code blocks, ${$self}{name}") if ${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
+    $logger->trace("No text wrap or remove paragraph line breaks for verbatim code blocks, ${$self}{name}") if ${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
 }
 
 1;

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm	2021-09-16 20:17:39 UTC (rev 60522)
@@ -19,6 +19,6 @@
 use Exporter qw/import/;
 our @EXPORT_OK = qw/$versionNumber $versionDate/;
 
-our $versionNumber = '3.11';
-our $versionDate = '2021-07-31';
+our $versionNumber = '3.12';
+our $versionDate = '2021-09-16';
 1

Modified: trunk/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml	2021-09-16 20:17:02 UTC (rev 60521)
+++ trunk/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml	2021-09-16 20:17:39 UTC (rev 60522)
@@ -1,4 +1,4 @@
-# defaultSettings.yaml for latexindent.pl, version 3.11, 2021-07-31
+# defaultSettings.yaml for latexindent.pl, version 3.12, 2021-09-16
 #                      a script that aims to
 #                      beautify .tex, .sty, .cls files
 #
@@ -528,7 +528,7 @@
         afterHeading: 0
         preamble: 0
         filecontents: 0
-        masterDocument: 0
+        mainDocument: 0
     removeParagraphLineBreaks:
         all: 0
         beforeTextWrap: 0
@@ -543,7 +543,7 @@
         afterHeading: 0
         preamble: 0
         filecontents: 0
-        masterDocument: 0
+        mainDocument: 0
         paragraphsStopAt:
             environments: 1
             verbatim: 1

Modified: trunk/Master/texmf-dist/scripts/latexindent/latexindent.pl
===================================================================
(Binary files differ)



More information about the tex-live-commits mailing list.