texlive[46303] trunk: latexindent (13jan18)
commits+karl at tug.org
commits+karl at tug.org
Sat Jan 13 23:26:57 CET 2018
Revision: 46303
http://tug.org/svn/texlive?view=revision&revision=46303
Author: karl
Date: 2018-01-13 23:26:56 +0100 (Sat, 13 Jan 2018)
Log Message:
-----------
latexindent (13jan18)
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/latexindent.pdf
trunk/Master/texmf-dist/doc/support/latexindent/latexindent.tex
trunk/Master/texmf-dist/doc/support/latexindent/sec-conclusions-know-limitations.tex
trunk/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex
trunk/Master/texmf-dist/doc/support/latexindent/sec-demonstration.tex
trunk/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex
trunk/Master/texmf-dist/doc/support/latexindent/sec-indent-config-and-settings.tex
trunk/Master/texmf-dist/doc/support/latexindent/sec-introduction.tex
trunk/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex
trunk/Master/texmf-dist/doc/support/latexindent/subsec-commands-and-their-options.tex
trunk/Master/texmf-dist/doc/support/latexindent/subsec-conflicting-poly-switches.tex
trunk/Master/texmf-dist/doc/support/latexindent/subsec-partnering-poly-switches.tex
trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-commands-with-arguments.tex
trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-and-their-arguments.tex
trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-with-items.tex
trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-headings.tex
trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-ifelsefi.tex
trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-no-add-remaining-code-blocks.tex
trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-special.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/Braces.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/Else.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/HiddenChildren.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/MandatoryArgument.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/OptionalArgument.pm
trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Preamble.pm
trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm
trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.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/latexindent-module-installer.pl
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 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/README 2018-01-13 22:26:56 UTC (rev 46303)
@@ -1,5 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- latexindent.pl, version 3.3, 2017-08-21
+ latexindent.pl, version 3.4, 2018-01-13
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 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/appendices.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -3,9 +3,9 @@
\section{Required \texttt{Perl} modules}\label{sec:requiredmodules}
If you intend to use \texttt{latexindent.pl} and \emph{not} one of the supplied standalone executable files, then you will need a few standard Perl modules -- if you can run the
minimum code in \cref{lst:helloworld} (\texttt{perl helloworld.pl}) then you will be able to run \texttt{latexindent.pl}, otherwise you may
- need to install the missing modules.
+ need to install the missing modules -- see \cref{sec:module-installer,sec:manual-module-instal}.
- \begin{cmhlistings}[language=Perl]{\texttt{helloworld.pl}}{lst:helloworld}
+ \begin{cmhlistings}[style=tcblatex,language=Perl]{\texttt{helloworld.pl}}{lst:helloworld}
#!/usr/bin/perl
use strict;
@@ -23,42 +23,62 @@
use File::HomeDir;
use Getopt::Long;
use Data::Dumper;
+use List::Util qw(max);
+use Log::Log4perl qw(get_logger :levels);
print "hello world";
exit;
\end{cmhlistings}
- Installing the modules given in \cref{lst:helloworld} will vary depending on your
- operating system and \texttt{Perl} distribution. For example, Ubuntu users
- might visit the software center, or else run
- \begin{commandshell}
+
+ \subsection{Module installer script}\label{sec:module-installer}
+ \announce*{2018-01-13}{perl module helper script} \texttt{latexindent.pl} ships with a helper script that will install any missing \texttt{perl} modules
+ on your system; if you run
+ \begin{commandshell}
+perl latexindent-module-installer.pl
+ \end{commandshell}
+ or
+ \begin{dosprompt}
+perl latexindent-module-installer.pl
+ \end{dosprompt}
+ 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}
+ Manually installing the modules given in \cref{lst:helloworld} will vary depending on your
+ operating system and \texttt{Perl} distribution. For example, Ubuntu users
+ might visit the software center, or else run
+ \begin{commandshell}
sudo perl -MCPAN -e 'install "File::HomeDir"'
\end{commandshell}
- Linux users may be interested in exploring Perlbrew \cite{perlbrew}; possible installation and setup
- options follow for Ubuntu (other distributions will need slightly different commands).
- \begin{commandshell}
+ Linux users may be interested in exploring Perlbrew \cite{perlbrew}; possible installation and setup
+ options follow for Ubuntu (other distributions will need slightly different commands).
+ \begin{commandshell}
sudo apt-get install perlbrew
-perlbrew install perl-5.20.1
-perlbrew switch perl-5.20.1
+perlbrew install perl-5.22.1
+perlbrew switch perl-5.22.1
sudo apt-get install curl
curl -L http://cpanmin.us | perl - App::cpanminus
cpanm YAML::Tiny
cpanm File::HomeDir
+cpanm Unicode::GCString
+cpanm Log::Log4perl
+cpanm Log::Dispatch
\end{commandshell}
- Strawberry Perl users on Windows might use
- \texttt{CPAN client}. All of the modules are readily available on CPAN \cite{cpan}.
+ Strawberry Perl users on Windows might use
+ \texttt{CPAN client}. All of the modules are readily available on CPAN \cite{cpan}.
- \texttt{indent.log} will contain details of the location
- of the Perl modules on your system. \texttt{latexindent.exe} is a standalone
- executable for Windows (and therefore does not require a Perl distribution) and caches copies of the Perl modules onto your system; if you
- wish to see where they are cached, use the \texttt{trace} option, e.g
- \begin{dosprompt}
+ \texttt{indent.log} will contain details of the location
+ of the Perl modules on your system. \texttt{latexindent.exe} is a standalone
+ executable for Windows (and therefore does not require a Perl distribution) and caches copies of the Perl modules onto your system; if you
+ wish to see where they are cached, use the \texttt{trace} option, e.g
+ \begin{dosprompt}
latexindent.exe -t myfile.tex
\end{dosprompt}
\section{Updating the \texttt{path} variable}\label{sec:updating-path}
- \texttt{latexindent.pl} has a few scripts (available at \cite{latexindent-home}) that can update the \texttt{path} variables\footnote{Thanks to \cite{jasjuang} for this feature!}. If you're
+ \texttt{latexindent.pl} has a few scripts (available at \cite{latexindent-home}) that can update the \texttt{path} variables.
+ Thank you to \cite{jasjuang} for this feature. If you're
on a Linux or Mac machine, then you'll want \texttt{CMakeLists.txt} from \cite{latexindent-home}.
\subsection{Add to path for Linux}
To add \texttt{latexindent.pl} to the path for Linux, follow these steps:
@@ -110,6 +130,42 @@
\end{enumerate}
To \emph{remove} the directory from your \lstinline!%path%!, run \texttt{remove-from-path.bat} as administrator.
+ \section{\texttt{logFilePreferences}}\label{app:logfile-demo}
+ \Vref{lst:logFilePreferences} describes the options for customising the information given
+ to the log file, and we provide a few demonstrations here. Let's say that we start with the code
+ given in \cref{lst:simple}, and the settings specified in \cref{lst:logfile-prefs1-yaml}.
+
+ \begin{minipage}{.35\linewidth}
+ \cmhlistingsfromfile*{demonstrations/simple.tex}{\texttt{simple.tex}}{lst:simple}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.6\linewidth}
+ \cmhlistingsfromfile*{demonstrations/logfile-prefs1.yaml}[yaml-TCB]{\texttt{logfile-prefs1.yaml}}{lst:logfile-prefs1-yaml}
+ \end{minipage}
+
+ If we run the following command (noting that \texttt{-t} is active)
+ \begin{commandshell}
+latexindent.pl -t -l=logfile-prefs1.yaml simple.tex
+ \end{commandshell}
+ then on inspection of \texttt{indent.log} we will find the snippet given in \cref{lst:indentlog}.
+ \begin{cmhlistings}[style=tcblatex,morekeywords={TRACE}]{\texttt{indent.log}}{lst:indentlog}
+ +++++
+TRACE: environment found: myenv
+ No ancestors found for myenv
+ Storing settings for myenvenvironments
+ indentRulesGlobal specified (0) for environments, ...
+ Using defaultIndent for myenv
+ Putting linebreak after replacementText for myenv
+ looking for COMMANDS and key = {value}
+TRACE: Searching for commands with optional and/or mandatory arguments AND key = {value}
+ looking for SPECIAL begin/end
+TRACE: Searching myenv for special begin/end (see specialBeginEnd)
+TRACE: Searching myenv for optional and mandatory arguments
+ ... no arguments found
+ -----
+ \end{cmhlistings}
+ Notice that the information given about \texttt{myenv} is `framed' using \texttt{+++++} and \lstinline!-----! respectively.
+
\section{Differences from Version 2.2 to 3.0}\label{app:differences}
There are a few (small) changes to the interface when comparing Version 2.2 to Version 3.0.
Explicitly, in previous versions you might have run, for example,
@@ -189,6 +245,6 @@
\mbox{}\hfill \begin{minipage}{.25\textwidth}
\hrule
- \hfill\itshape End
+ \hfill\itshape End\\\mbox{}\hfill\mbox{}\rlap{\hfill\includegraphics{logo}}
\end{minipage}
Added: trunk/Master/texmf-dist/doc/support/latexindent/latexindent-module-installer.pl
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/latexindent-module-installer.pl (rev 0)
+++ trunk/Master/texmf-dist/doc/support/latexindent/latexindent-module-installer.pl 2018-01-13 22:26:56 UTC (rev 46303)
@@ -0,0 +1,51 @@
+#!/usr/bin/env perl
+# latexindent.pl, version 3.3, 2017-08-21
+#
+# 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;
+
+print ("============\nlatexindent.pl module installer\n============\n");
+print ("Would you like to run the following commands?\n");
+my @modulesToInstall = ("cpanm YAML::Tiny","cpanm File::HomeDir","cpanm Unicode::GCString","cpanm Log::Log4perl","cpanm Log::Dispatch");
+foreach (@modulesToInstall) {
+ print $_,"\n";
+}
+if (prompt_yn("Press Y to run the above commands")){
+ foreach (@modulesToInstall) {
+ system($_);
+ }
+} else {
+ print "Not installing modules\n";
+}
+exit;
+
+# reference: https://stackoverflow.com/questions/18103501/prompting-multiple-questions-to-user-yes-no-file-name-input
+sub prompt {
+ my ($query) = @_; # take a prompt string as argument
+ local $| = 1; # activate autoflush to immediately show the prompt
+ print $query;
+ chomp(my $answer = <STDIN>);
+ return $answer;
+}
+
+sub prompt_yn {
+ my ($query) = @_;
+ my $answer = prompt("$query (Y/N): ");
+ return lc($answer) eq 'y';
+}
Property changes on: trunk/Master/texmf-dist/doc/support/latexindent/latexindent-module-installer.pl
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
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 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/latexindent.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -193,7 +193,7 @@
% \cmhlistingsfromfile
% * no star: not new, star: new
% [ listing/minted options ]
-% * no star: uses listings library star: uses minted library
+% * no star: uses minted library, star: uses listings library star:
% {<name of listing file>}
% [<options for tcolorbox>]
% {<title>}
@@ -207,7 +207,7 @@
\DeclareTCBInputListing[use counter=lstlisting]{\cmhlistingsfromfile}{s O{} s m O{} m m}{%
cmhlistings,
listing file={#4},
- IfBooleanTF={#3}{minted options={obeytabs=true,showtabs=true,tabsize=4,showspaces=false,#2}}{listing options={#2}},
+ IfBooleanTF={#3}{listing options={style=tcblatex,showspaces=false,#2}}{minted options={obeytabs=true,showtabs=false,tabsize=4,showspaces=false,#2}},
title={\color{black}{\scshape Listing \thetcbcounter}: ~#6},label={#7},
#5,
IfBooleanTF={#1}{new-to-this-version}{addtolol},
@@ -289,133 +289,157 @@
\lstdefinestyle{logFilePreferences}{
style=yaml-LST,
- firstnumber=79,linerange={79-83},
+ firstnumber=79,linerange={79-89},
numbers=left,
}
\lstdefinestyle{verbatimEnvironments}{
style=yaml-LST,
- firstnumber=87,linerange={87-90},
+ firstnumber=93,linerange={93-96},
numbers=left,
}
\lstdefinestyle{verbatimCommands}{
style=yaml-LST,
- firstnumber=93,linerange={93-95},
+ firstnumber=99,linerange={99-101},
numbers=left,
}
\lstdefinestyle{noIndentBlock}{
style=yaml-LST,
- firstnumber=101,linerange={101-103},
+ firstnumber=107,linerange={107-109},
numbers=left,
}
\lstdefinestyle{removeTrailingWhitespace}{
style=yaml-LST,
- firstnumber=106,linerange={106-108},
+ firstnumber=112,linerange={112-114},
numbers=left,
}
\lstdefinestyle{fileContentsEnvironments}{
style=yaml-LST,
- firstnumber=112,linerange={112-114},
+ firstnumber=118,linerange={118-120},
numbers=left,
}
\lstdefinestyle{lookForPreamble}{
style=yaml-LST,
- firstnumber=120,linerange={120-124},
+ firstnumber=126,linerange={126-130},
numbers=left,
}
\lstdefinestyle{indentAfterItems}{
style=yaml-LST,
- firstnumber=174,linerange={174-178},
+ firstnumber=183,linerange={183-187},
numbers=left,
}
\lstdefinestyle{itemNames}{
style=yaml-LST,
- firstnumber=184,linerange={184-186},
+ firstnumber=193,linerange={193-195},
numbers=left,
}
\lstdefinestyle{specialBeginEnd}{
style=yaml-LST,
- firstnumber=190,linerange={190-203},
+ firstnumber=199,linerange={199-212},
numbers=left,
}
\lstdefinestyle{indentAfterHeadings}{
style=yaml-LST,
- firstnumber=213,linerange={213-222},
+ firstnumber=222,linerange={222-231},
numbers=left,
}
\lstdefinestyle{noAdditionalIndentGlobalEnv}{
style=yaml-LST,
- firstnumber=271,linerange={271-272},
+ firstnumber=280,linerange={280-281},
numbers=left,
}
\lstdefinestyle{noAdditionalIndentGlobal}{
style=yaml-LST,
- firstnumber=271,linerange={271-283},
+ firstnumber=280,linerange={280-292},
numbers=left,
}
\lstdefinestyle{indentRulesGlobalEnv}{
style=yaml-LST,
- firstnumber=287,linerange={287-288},
+ firstnumber=296,linerange={296-297},
numbers=left,
}
\lstdefinestyle{indentRulesGlobal}{
style=yaml-LST,
- firstnumber=287,linerange={287-299},
+ firstnumber=296,linerange={296-308},
numbers=left,
}
\lstdefinestyle{commandCodeBlocks}{
style=yaml-LST,
- firstnumber=302,linerange={302-312},
+ firstnumber=311,linerange={311-321},
numbers=left,
}
\lstdefinestyle{modifylinebreaks}{
style=yaml-LST,
- firstnumber=382,linerange={382-384},
+ firstnumber=391,linerange={391-393},
numbers=left,
}
\lstdefinestyle{textWrapOptions}{
style=yaml-LST,
- firstnumber=385,linerange={385-386},
+ firstnumber=394,linerange={394-395},
numbers=left,
}
\lstdefinestyle{textWrapOptionsAll}{
style=yaml-LST,
- firstnumber=385,linerange={385-387},
+ firstnumber=394,linerange={394-396},
numbers=left,
}
\lstdefinestyle{removeParagraphLineBreaks}{
style=yaml-LST,
- firstnumber=388,linerange={388-400},
+ firstnumber=419,linerange={419-431},
numbers=left,
}
\lstdefinestyle{paragraphsStopAt}{
style=yaml-LST,
- firstnumber=401,linerange={401-409},
+ firstnumber=432,linerange={432-440},
numbers=left,
}
+\lstdefinestyle{oneSentencePerLine}{
+ style=yaml-LST,
+ firstnumber=397,linerange={397-418},
+ numbers=left,
+}
+
+\lstdefinestyle{sentencesFollow}{
+ style=yaml-LST,
+ firstnumber=400,linerange={400-408},
+ numbers=left,
+}
+
+\lstdefinestyle{sentencesBeginWith}{
+ style=yaml-LST,
+ firstnumber=409,linerange={409-412},
+ numbers=left,
+}
+
+\lstdefinestyle{sentencesEndWith}{
+ style=yaml-LST,
+ firstnumber=413,linerange={413-418},
+ numbers=left,
+}
+
\lstdefinestyle{modifylinebreaksEnv}{
style=yaml-LST,
- firstnumber=410,linerange={410-419},
+ firstnumber=441,linerange={441-450},
numbers=left,
}
@@ -619,19 +643,19 @@
% toc settings
\titleclass{\cmhtitle}{straight}[\subsection]
\titleformat{\cmhtitle}{}{}{}{}
-\titlecontents*{cmhtitle}% <paragaph>
-[3cm]% <left>
-{\small\itshape}% <above-code>
-{}% <numbered-entry-format>; you could also use {\thecontentslabel. } to show the numbers
-{}% <numberless-entry-format>
-{\ \thecontentspage}% <filler-page-format>
-[,\ ]% <separator>
-[]% <end>
+\titlecontents{cmhtitle}% <paragaph>
+ [2cm]% <left>
+ {\small\itshape}% <above-code>
+ {}% <numbered-entry-format>; you could also use {\thecontentslabel. } to show the numbers
+ {}% <numberless-entry-format>
+ {\titlerule*[0.5em]{$\cdot$}\contentspage}
\setcounter{secnumdepth}{5}
\begin{document}
\renewcommand*{\thefootnote}{\arabic{footnote}}
\input{title.tex}
+\tableofcontents
+{\small\lstlistoflistings}
\input{sec-introduction}
\input{sec-demonstration}
\input{sec-how-to-use}
@@ -648,6 +672,7 @@
\stopcontents[noAdditionalIndent]
\input{subsec-commands-and-their-options}
\input{sec-the-m-switch}
+\stopcontents[the-m-switch]
\input{subsec-partnering-poly-switches}
\input{subsec-conflicting-poly-switches}
\input{sec-conclusions-know-limitations}
@@ -707,3 +732,23 @@
Version 3.2.2
Users can specify removeTrailingWhitespace as a scalar, for example, removeTrailingWhitespace: 0
https://github.com/cmhughes/latexindent.pl/pull/72
+
+Version 3.3
+- maximum indentation: https://github.com/cmhughes/latexindent.pl/issues/50
+- blank line poly-switch: https://github.com/cmhughes/latexindent.pl/issues/57
+- ifnextchar issue: https://github.com/cmhughes/latexindent.pl/issues/73
+- the -y/yaml switch: https://github.com/cmhughes/latexindent.pl/issues/79
+- absolute paths for the -l switch: https://github.com/cmhughes/latexindent.pl/issues/82
+bug fixes:
+- an ifelsefi bug: https://github.com/cmhughes/latexindent.pl/issues/76
+- empty environment bug: https://github.com/cmhughes/latexindent.pl/issues/78
+- a command/special bug: https://github.com/cmhughes/latexindent.pl/issues/80
+https://github.com/cmhughes/latexindent.pl/releases/tag/V3.3
+
+Version 3.4
+- enhancements to alignment at ampersand routine: https://github.com/cmhughes/latexindent.pl/issues/74
+- log4Perl module: https://github.com/cmhughes/latexindent.pl/issues/75
+- one sentence per line: https://github.com/cmhughes/latexindent.pl/issues/81
+- STDIN allowed: https://github.com/cmhughes/latexindent.pl/issues/88
+- textwrap bug fix: https://github.com/cmhughes/latexindent.pl/issues/90
+- polyswitch bug fix: https://github.com/cmhughes/latexindent.pl/issues/94
Modified: trunk/Master/texmf-dist/doc/support/latexindent/sec-conclusions-know-limitations.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/sec-conclusions-know-limitations.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/sec-conclusions-know-limitations.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -3,7 +3,23 @@
There are a number of known limitations of the script, and almost certainly quite a
few that are \emph{unknown}!
- The main limitation is to do with efficiency, particularly when the \texttt{-m}
+ The main limitation is to do with the alignment routine discussed on \cpageref{yaml:lookforaligndelims}; for example,
+ consider the file given in \cref{lst:matrix2}.
+
+ \cmhlistingsfromfile*{demonstrations/matrix2.tex}{\texttt{matrix2.tex}}{lst:matrix2}
+
+ The default output is given in \cref{lst:matrix2-default}, and it is clear that the alignment routine
+ has not worked as hoped, but it is \emph{expected}.
+ \cmhlistingsfromfile*{demonstrations/matrix2-default.tex}{\texttt{matrix2.tex} default output}{lst:matrix2-default}
+
+ The reason for the problem is that when \texttt{latexindent.pl} stores its code blocks (see \vref{tab:code-blocks})
+ it uses replacement tokens. The alignment routine is using the \emph{length of the replacement token} in its measuring -- I hope
+ to be able to address this in the future.
+
+ There are other limitations to do with the multicolumn alignment routine (see \vref{lst:tabular2-mod2}); in particular,
+ when working with codeblocks in which multicolumn commands overlap, the algorithm can fail.
+
+ Another limitation is to do with efficiency, particularly when the \texttt{-m}
switch is active, as this adds many checks and processes. The current implementation
relies upon finding and storing \emph{every} code block (see the discussion on \cpageref{page:phases});
it is hoped that, in a future version, only \emph{nested} code blocks will need
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 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -22,7 +22,7 @@
latexindent.pl myfile
\end{commandshell}
\begin{wrapfigure}[8]{r}[0pt]{6cm}
- \cmhlistingsfromfile[style=fileExtensionPreference]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{fileExtensionPreference}}{lst:fileExtensionPreference}
+ \cmhlistingsfromfile[style=fileExtensionPreference]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{fileExtensionPreference}}{lst:fileExtensionPreference}
\end{wrapfigure}
in which case the script will look for \texttt{myfile} with the extensions
@@ -78,9 +78,6 @@
The default value of \texttt{cycleThroughBackUps} is \texttt{0}.
\yamltitle{logFilePreferences}*{fields}
- \begin{wrapfigure}[10]{r}[0pt]{9cm}
- \cmhlistingsfromfile[style=logFilePreferences,]{../defaultSettings.yaml}[width=.85\linewidth,before=\centering,yaml-TCB]{\texttt{logFilePreferences}}{lst:logFilePreferences}
- \end{wrapfigure}
\texttt{latexindent.pl} writes information to \texttt{indent.log}, some
of which can be customized by changing \texttt{logFilePreferences}; see \cref{lst:logFilePreferences}.
If you load your own user settings (see \vref{sec:indentconfig}) then \texttt{latexindent.pl} will
@@ -87,10 +84,25 @@
detail them in \texttt{indent.log}; you can choose not to have the details logged by switching
\texttt{showEveryYamlRead} to \texttt{0}. Once all of your settings have
been loaded, you can see the amalgamated settings in the log file by switching \texttt{showAmalgamatedSettings}
- to \texttt{1}, if you wish. The log file will end with the characters
+ to \texttt{1}, if you wish.
+
+ \cmhlistingsfromfile*[style=logFilePreferences,]*{../defaultSettings.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{logFilePreferences}}{lst:logFilePreferences}
+
+ When%
+ \announce*{2018-01-13}{showDecorationStartCodeBlockTrace feature for log file} either of the \texttt{trace} modes (see \cpageref{page:traceswitch})
+ are active, you will receive detailed information in \texttt{indent.log}. You can specify character strings
+ to appear before and after the notification of a found code block using, respectively, \texttt{showDecorationStartCodeBlockTrace}
+ and \texttt{showDecorationFinishCodeBlockTrace}. A demonstration is given in \vref{app:logfile-demo}.
+
+ The log file will end with the characters
given in \texttt{endLogFileWith}, and will report the \texttt{GitHub} address
of \texttt{latexindent.pl} to the log file if \texttt{showGitHubInfoFooter} is set to \texttt{1}.
+ \texttt{latexindent.pl}%
+ \announce*{2018-01-13}{log file pattern layout for log file} uses the \texttt{log4perl} module \cite{log4perl}
+ to handle the creation of the logfile. You can specify the layout of the information given in the logfile
+ using any of the \texttt{Log Layouts} detailed at \cite{log4perl}.
+
\yamltitle{verbatimEnvironments}*{fields}
A field that contains a list of environments
@@ -98,11 +110,11 @@
on environments that you have specified in this field, see \cref{lst:verbatimEnvironments}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=verbatimEnvironments]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{verbatimEnvironments}}{lst:verbatimEnvironments}
+ \cmhlistingsfromfile[style=verbatimEnvironments]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{verbatimEnvironments}}{lst:verbatimEnvironments}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=verbatimCommands]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{verbatimCommands}}{lst:verbatimCommands}
+ \cmhlistingsfromfile[style=verbatimCommands]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{verbatimCommands}}{lst:verbatimCommands}
\end{minipage}%
Note that if you put an environment in \texttt{verbatimEnvironments}
@@ -117,7 +129,7 @@
\yamltitle{noIndentBlock}*{fields}
\begin{wrapfigure}[8]{r}[0pt]{6cm}
- \cmhlistingsfromfile[style=noIndentBlock]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{noIndentBlock}}{lst:noIndentBlock}
+ \cmhlistingsfromfile[style=noIndentBlock]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{noIndentBlock}}{lst:noIndentBlock}
\end{wrapfigure}
If you have a block of code that you don't want \texttt{latexindent.pl} to touch (even if it is \emph{not} a verbatim-like
environment) then you can wrap it in an environment from \texttt{noIndentBlock};
@@ -142,7 +154,7 @@
\yamltitle{removeTrailingWhitespace}*{fields}\label{yaml:removeTrailingWhitespace}
\begin{wrapfigure}[10]{r}[0pt]{7cm}
- \cmhlistingsfromfile[style=removeTrailingWhitespace]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{removeTrailingWhitespace}{lst:removeTrailingWhitespace}
+ \cmhlistingsfromfile[style=removeTrailingWhitespace]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{removeTrailingWhitespace}{lst:removeTrailingWhitespace}
\vspace{.1cm}
\begin{yaml}[numbers=none]{removeTrailingWhitespace (alt)}[width=.8\linewidth,before=\centering]{lst:removeTrailingWhitespace-alt}
@@ -161,7 +173,7 @@
\yamltitle{fileContentsEnvironments}*{field}
\begin{wrapfigure}[6]{r}[0pt]{6cm}
- \cmhlistingsfromfile[style=fileContentsEnvironments]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{fileContentsEnvironments}}{lst:fileContentsEnvironments}
+ \cmhlistingsfromfile[style=fileContentsEnvironments]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{fileContentsEnvironments}}{lst:fileContentsEnvironments}
\end{wrapfigure}
Before \texttt{latexindent.pl} determines the difference between preamble (if any) and the main document,
it first searches for any of the environments specified in \texttt{fileContentsEnvironments}, see
@@ -179,7 +191,7 @@
\yamltitle{lookForPreamble}*{fields}
\begin{wrapfigure}[8]{r}[0pt]{5cm}
- \cmhlistingsfromfile[style=lookForPreamble]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{lookForPreamble}{lst:lookForPreamble}
+ \cmhlistingsfromfile[style=lookForPreamble]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{lookForPreamble}{lst:lookForPreamble}
\end{wrapfigure}
Not all files contain preamble; for example, \texttt{sty}, \texttt{cls} and \texttt{bib} files typically do \emph{not}. Referencing
\cref{lst:lookForPreamble}, if you set, for example, \texttt{.tex} to \texttt{0}, then regardless of the setting of the value of \texttt{indentPreamble}, preamble
@@ -205,7 +217,7 @@
If you're interested in experimenting with \texttt{latexindent.pl} then you
can \emph{remove} all indentation by setting \texttt{defaultIndent: ""}.
-\yamltitle{lookForAlignDelims}*{fields}
+\yamltitle{lookForAlignDelims}*{fields}\label{yaml:lookforaligndelims}
\begin{wrapfigure}[12]{r}[0pt]{5cm}
\begin{yaml}[numbers=none]{\texttt{lookForAlignDelims} (basic)}[width=.8\linewidth,before=\centering]{lst:aligndelims:basic}
lookForAlignDelims:
@@ -232,101 +244,119 @@
instances of the environment, you could wrap them in something from \texttt{noIndentBlock} (see \vref{lst:noIndentBlock}).
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[showspaces=false,showtabs=false]*{demonstrations/tabular1.tex}{\texttt{tabular1.tex}}{lst:tabularbefore:basic}
+ \cmhlistingsfromfile{demonstrations/tabular1.tex}{\texttt{tabular1.tex}}{lst:tabularbefore:basic}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[showspaces=false,showtabs=false]*{demonstrations/tabular1-default.tex}{\texttt{tabular1.tex} default output}{lst:tabularafter:basic}
+ \cmhlistingsfromfile{demonstrations/tabular1-default.tex}{\texttt{tabular1.tex} default output}{lst:tabularafter:basic}
\end{minipage}%
- If you wish to remove the alignment of the \lstinline!\\! within a delimiter-aligned block, then the
+ If, for example, you wish to remove the alignment of the \lstinline!\\! within a delimiter-aligned block, then the
advanced form of \texttt{lookForAlignDelims} shown in \cref{lst:aligndelims:advanced} is for you.
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/tabular.yaml}[yaml-TCB]{\texttt{tabular.yaml}}{lst:aligndelims:advanced}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/tabular.yaml}[yaml-TCB]{\texttt{tabular.yaml}}{lst:aligndelims:advanced}
Note that you can use a mixture of the basic and advanced form: in \cref{lst:aligndelims:advanced} \texttt{tabular} and \texttt{tabularx}
are advanced and \texttt{longtable} is basic. When using the advanced form, each field should receive at least 1 sub-field, and \emph{can}
(but does not have to) receive any of the following fields:
\begin{itemize}
- \item \texttt{delims}: switch equivalent to simply specifying, for example, \texttt{tabular: 1} in
- the basic version shown in \cref{lst:aligndelims:basic} (default: 1);
- \item \texttt{alignDoubleBackSlash}: switch to determine if \lstinline!\\! should be aligned (default: 1);
- \item \texttt{spacesBeforeDoubleBackSlash}: optionally, specifies the number of spaces to be inserted
- before (non-aligned) \lstinline!\\!. In order to use this field, \texttt{alignDoubleBackSlash} needs
- to be set to 0 (default: 0).
- \item \announce{2017-06-19}{multiColumnGrouping} \texttt{multiColumnGrouping}: details if \texttt{latexindent.pl} should group columns
- underneath a \lstinline!\multicolumn! command (default: 0);
- \item \announce{2017-06-19}{alignRowsWithoutMaxDelims} \texttt{alignRowsWithoutMaxDelims}: details if rows that do not contain the
- maximum number of delimeters should be formatted so as to have the ampersands aligned (default: 1).
+ \item \texttt{delims}: binary switch (0 or 1) equivalent to simply specifying, for example, \texttt{tabular: 1} in
+ the basic version shown in \cref{lst:aligndelims:basic}. If \texttt{delims} is set to \texttt{0} then the align at ampersand routine
+ will not be called for this code block (default: 1);
+ \item \texttt{alignDoubleBackSlash}: binary switch (0 or 1) to determine if \lstinline!\\! should be aligned (default: 1);
+ \item \texttt{spacesBeforeDoubleBackSlash}: optionally,%
+ \announce*{2018-01-13}*{update to spacesBeforeDoubleBackSlash in ampersand alignment} specifies the number (integer $\geq$ 0) of spaces to be inserted
+ before \lstinline!\\! (default: 1). \footnote{Previously this only activated if \texttt{alignDoubleBackSlash} was set to \texttt{0}.}
+ \item \announce{2017-06-19}{multiColumnGrouping} \texttt{multiColumnGrouping}: binary switch (0 or 1) that details if \texttt{latexindent.pl} should group columns
+ above and below a \lstinline!\multicolumn! command (default: 0);
+ \item \announce{2017-06-19}{alignRowsWithoutMaxDelims} \texttt{alignRowsWithoutMaxDelims}: binary switch (0 or 1) that details if rows that do not contain the
+ maximum number of delimeters should be formatted so as to have the ampersands aligned (default: 1);
+ \item \announce*{2018-01-13}{spacesBeforeAmpersand in ampersand alignment}\texttt{spacesBeforeAmpersand}: optionally specifies the number (integer $\geq$ 0) of
+ spaces to be placed \emph{before} ampersands (default: 1);
+ \item \announce*{2018-01-13}{spacesAfterAmpersand in ampersand alignment}\texttt{spacesAfterAmpersand}: optionally specifies the number (integer $\geq$ 0) of
+ spaces to be placed \emph{After} ampersands (default: 1);
+ \item \announce*{2018-01-13}{justification of cells in ampersand alignment}\texttt{justification}: optionally specifies the justification of each cell as either \emph{left}
+ or \emph{right} (default: left).
\end{itemize}
- Assuming that you have the settings in \cref{lst:aligndelims:advanced} saved in \texttt{tabular.yaml}, and the code
- from \cref{lst:tabularbefore:basic} in \texttt{tabular1.tex} and you run
- \begin{commandshell}
-latexindent.pl -l tabular.yaml tabular1.tex
-\end{commandshell}
- then you should receive the before-and-after results shown in
- \cref{lst:tabularbefore:advanced,lst:tabularafter:advanced}; note that the ampersands have been aligned, but
- the \lstinline!\\! have not (compare the alignment of \lstinline!\\! in \cref{lst:tabularafter:basic,lst:tabularafter:advanced}).
+ We will explore each of these features using the file \texttt{tabular2.tex} in \cref{lst:tabular2} (which contains a \lstinline!\multicolumn! command),
+ and the YAML files in \crefrange{lst:tabular2YAML}{lst:tabular8YAML}.
+ \cmhlistingsfromfile{demonstrations/tabular2.tex}{\texttt{tabular2.tex}}{lst:tabular2}
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[showspaces=false,showtabs=false]*{demonstrations/tabular1.tex}{\texttt{tabular1.tex}}{lst:tabularbefore:advanced}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/tabular2.yaml}[yaml-TCB]{\texttt{tabular2.yaml}}{lst:tabular2YAML}
\end{minipage}%
\hfill
- \begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[showspaces=false,showtabs=false]*{demonstrations/tabular1-advanced.tex}{\texttt{tabular1.tex} using \cref{lst:aligndelims:advanced}}{lst:tabularafter:advanced}
+ \begin{minipage}{.48\textwidth}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/tabular3.yaml}[yaml-TCB]{\texttt{tabular3.yaml}}{lst:tabular3YAML}
\end{minipage}%
- Saving \cref{lst:aligndelims:advanced} into \texttt{tabular1.yaml} as in \cref{lst:tabular1YAML}, and running the command
- \begin{commandshell}
-latexindent.pl -l tabular1.yaml tabular1.tex
-\end{commandshell}
- gives \cref{lst:tabularafter:spacing}; note the spacing before the \lstinline!\\!.
-
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[showspaces=false,showtabs=false]*{demonstrations/tabular1-advanced-3spaces.tex}{\texttt{tabular1.tex} using \cref{lst:tabular1YAML}}{lst:tabularafter:spacing}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/tabular4.yaml}[yaml-TCB]{\texttt{tabular4.yaml}}{lst:tabular4YAML}
\end{minipage}%
\hfill
- \begin{minipage}{.54\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/tabular1.yaml}[yaml-TCB]{\texttt{tabular1.yaml}}{lst:tabular1YAML}
+ \begin{minipage}{.48\textwidth}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/tabular5.yaml}[yaml-TCB]{\texttt{tabular5.yaml}}{lst:tabular5YAML}
\end{minipage}%
- Now consider the file \texttt{tabular2.tex} in \cref{lst:tabular2}, which contains a \lstinline!\multicolumn! command, and
- the YAML files in \cref{lst:tabular2YAML,lst:tabular3YAML}.
-
- \cmhlistingsfromfile[showspaces=false,showtabs=false]*{demonstrations/tabular2.tex}{\texttt{tabular2.tex}}{lst:tabular2}
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/tabular2.yaml}[yaml-TCB]{\texttt{tabular2.yaml}}{lst:tabular2YAML}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/tabular6.yaml}[yaml-TCB]{\texttt{tabular6.yaml}}{lst:tabular6YAML}
\end{minipage}%
\hfill
- \begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/tabular3.yaml}[yaml-TCB]{\texttt{tabular3.yaml}}{lst:tabular3YAML}
+ \begin{minipage}{.48\textwidth}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/tabular7.yaml}[yaml-TCB]{\texttt{tabular7.yaml}}{lst:tabular7YAML}
\end{minipage}%
+ \begin{minipage}{.48\textwidth}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/tabular8.yaml}[yaml-TCB]{\texttt{tabular8.yaml}}{lst:tabular8YAML}
+ \end{minipage}%
+
On running the commands
\begin{commandshell}
latexindent.pl tabular2.tex
-latexindent.pl -s tabular2.tex -l tabular2.yaml
-latexindent.pl -s tabular2.tex -l tabular3.yaml
+latexindent.pl tabular2.tex -l tabular2.yaml
+latexindent.pl tabular2.tex -l tabular3.yaml
+latexindent.pl tabular2.tex -l tabular2.yaml,tabular4.yaml
+latexindent.pl tabular2.tex -l tabular2.yaml,tabular5.yaml
+latexindent.pl tabular2.tex -l tabular2.yaml,tabular6.yaml
+latexindent.pl tabular2.tex -l tabular2.yaml,tabular7.yaml
+latexindent.pl tabular2.tex -l tabular2.yaml,tabular8.yaml
\end{commandshell}
- we obtain the respective outputs given in \cref{lst:tabular2-default,lst:tabular2-mc,lst:tabular2-no-max}.
+ we obtain the respective outputs given in \crefrange{lst:tabular2-default}{lst:tabular2-mod8}.
\begin{widepage}
- \cmhlistingsfromfile[showspaces=false,showtabs=false]*{demonstrations/tabular2-default.tex}{\texttt{tabular2-default.tex}}{lst:tabular2-default}
- \cmhlistingsfromfile[showspaces=false,showtabs=false]*{demonstrations/tabular2-mc.tex}{\texttt{tabular2-mc.tex}}{lst:tabular2-mc}
- \cmhlistingsfromfile[showspaces=false,showtabs=false]*{demonstrations/tabular2-no-max.tex}{\texttt{tabular2-no-max.tex}}{lst:tabular2-no-max}
+ \cmhlistingsfromfile*{demonstrations/tabular2-default.tex}{\texttt{tabular2.tex} default output}{lst:tabular2-default}
+ \cmhlistingsfromfile*{demonstrations/tabular2-mod2.tex}{\texttt{tabular2.tex} using \cref{lst:tabular2YAML}}{lst:tabular2-mod2}
+ \cmhlistingsfromfile*{demonstrations/tabular2-mod3.tex}{\texttt{tabular2.tex} using \cref{lst:tabular3YAML}}{lst:tabular2-mod3}
+ \cmhlistingsfromfile*{demonstrations/tabular2-mod4.tex}{\texttt{tabular2.tex} using \cref{lst:tabular2YAML,lst:tabular4YAML}}{lst:tabular2-mod4}
+ \cmhlistingsfromfile*{demonstrations/tabular2-mod5.tex}{\texttt{tabular2.tex} using \cref{lst:tabular2YAML,lst:tabular5YAML}}{lst:tabular2-mod5}
+ \cmhlistingsfromfile*{demonstrations/tabular2-mod6.tex}{\texttt{tabular2.tex} using \cref{lst:tabular2YAML,lst:tabular6YAML}}{lst:tabular2-mod6}
+ \cmhlistingsfromfile*{demonstrations/tabular2-mod7.tex}{\texttt{tabular2.tex} using \cref{lst:tabular2YAML,lst:tabular7YAML}}{lst:tabular2-mod7}
+ \cmhlistingsfromfile*{demonstrations/tabular2-mod8.tex}{\texttt{tabular2.tex} using \cref{lst:tabular2YAML,lst:tabular8YAML}}{lst:tabular2-mod8}
\end{widepage}
Notice in particular:
\begin{itemize}
- \item in both \cref{lst:tabular2-default,lst:tabular2-mc} all rows have been aligned at the ampersand, even
+ \item in both \cref{lst:tabular2-default,lst:tabular2-mod2} all rows have been aligned at the ampersand, even
those that do not contain the maximum number of ampersands (3 ampersands, in this case);
\item in \cref{lst:tabular2-default} the columns have been aligned at the ampersand;
- \item in \cref{lst:tabular2-mc} the \lstinline!\multicolumn! command has grouped the $2$ columns beneath \emph{and} above it,
+ \item in \cref{lst:tabular2-mod2} the \lstinline!\multicolumn! command has grouped the $2$ columns beneath \emph{and} above it,
because \texttt{multiColumnGrouping} is set to $1$ in \cref{lst:tabular2YAML};
- \item in \cref{lst:tabular2-no-max} rows~3 and~6 have \emph{not} been aligned at the ampersand, because
+ \item in \cref{lst:tabular2-mod3} rows~3 and~6 have \emph{not} been aligned at the ampersand, because
\texttt{alignRowsWithoutMaxDelims} has been to set to $0$ in \cref{lst:tabular3YAML}; however,
- the \lstinline!\\! \emph{have} still been aligned.
+ the \lstinline!\\! \emph{have} still been aligned;
+ \item in \cref{lst:tabular2-mod4} the columns beneath and above the \lstinline!\multicolumn! commands have been
+ grouped (because \texttt{multiColumnGrouping} is set to $1$), and there are at least $4$ spaces \emph{before}
+ each aligned ampersand because \texttt{spacesBeforeAmpersand} is set to $4$;
+ \item in \cref{lst:tabular2-mod5} the columns beneath and above the \lstinline!\multicolumn! commands have been
+ grouped (because \texttt{multiColumnGrouping} is set to $1$), and there are at least $4$ spaces \emph{after}
+ each aligned ampersand because \texttt{spacesAfterAmpersand} is set to $4$;
+ \item in \cref{lst:tabular2-mod6} the \lstinline!\\! have \emph{not} been aligned, because \texttt{alignDoubleBackSlash}
+ is set to \texttt{0}, otherwise the output is the same as \cref{lst:tabular2-mod2};
+ \item in \cref{lst:tabular2-mod7} the \lstinline!\\! \emph{have} been aligned, and because \texttt{spacesBeforeDoubleBackSlash}
+ is set to \texttt{0}, there are no spaces ahead of them; the output is otherwise the same as \cref{lst:tabular2-mod2}.
+ \item in \cref{lst:tabular2-mod8} the cells have been \emph{right}-justified; note that cells above and below the \lstinline!\multicol!
+ statements have still been group correctly, because of the settings in \cref{lst:tabular2YAML}.
\end{itemize}
As of Version 3.0, the alignment routine works on mandatory and optional arguments within commands, and also within `special' code blocks
@@ -340,11 +370,11 @@
shown in \cref{lst:matrixbefore,lst:matrixafter} are achievable by default.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[columns=fixed]{demonstrations/matrix1.tex}{\texttt{matrix1.tex}}{lst:matrixbefore}
+ \cmhlistingsfromfile{demonstrations/matrix1.tex}{\texttt{matrix1.tex}}{lst:matrixbefore}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[columns=fixed]{demonstrations/matrix1-default.tex}{\texttt{matrix1.tex} default output}{lst:matrixafter}
+ \cmhlistingsfromfile{demonstrations/matrix1-default.tex}{\texttt{matrix1.tex} default output}{lst:matrixafter}
\end{minipage}%
If you have blocks of code that you wish to align at the \& character that
@@ -355,11 +385,11 @@
environment name that you have specified in \texttt{lookForAlignDelims}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[columns=fixed]{demonstrations/align-block.tex}{\texttt{align-block.tex}}{lst:alignmentmarkup}
+ \cmhlistingsfromfile{demonstrations/align-block.tex}{\texttt{align-block.tex}}{lst:alignmentmarkup}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[columns=fixed]{demonstrations/align-block-default.tex}{\texttt{align-block.tex} default output}{lst:alignmentmarkup-default}
+ \cmhlistingsfromfile{demonstrations/align-block-default.tex}{\texttt{align-block.tex} default output}{lst:alignmentmarkup-default}
\end{minipage}%
With reference to \vref{tab:code-blocks} and the, yet undiscussed, fields of \texttt{noAdditionalIndent} and \texttt{indentRules}
@@ -367,7 +397,7 @@
\yamltitle{indentAfterItems}*{fields}
\begin{wrapfigure}[5]{r}[0pt]{7cm}
- \cmhlistingsfromfile[style=indentAfterItems]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{indentAfterItems}}{lst:indentafteritems}
+ \cmhlistingsfromfile[style=indentAfterItems]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{indentAfterItems}}{lst:indentafteritems}
\end{wrapfigure}
The environment names specified in \texttt{indentAfterItems} tell
\texttt{latexindent.pl} to look for \lstinline!\item! commands; if these switches are set to \texttt{1}
@@ -384,7 +414,7 @@
\yamltitle{itemNames}*{fields}
\begin{wrapfigure}[5]{r}[0pt]{5cm}
- \cmhlistingsfromfile[style=itemNames]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{itemNames}}{lst:itemNames}
+ \cmhlistingsfromfile[style=itemNames]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{itemNames}}{lst:itemNames}
\end{wrapfigure}
If you have your own \texttt{item} commands (perhaps you
prefer to use \texttt{myitem}, for example)
@@ -396,11 +426,11 @@
\yamltitle{specialBeginEnd}*{fields}\label{yaml:specialBeginEnd}
The fields specified%
- \announce*{2017-08-21}*{specialBeginEnd} in \texttt{specialBeginEnd} are, in their default state, focused on math mode begin and end statements, but
+ \announce{2017-08-21}*{specialBeginEnd} in \texttt{specialBeginEnd} are, in their default state, focused on math mode begin and end statements, but
there is no requirement for this to be the case; \cref{lst:specialBeginEnd} shows the
default settings of \texttt{specialBeginEnd}.
- \cmhlistingsfromfile*[style=specialBeginEnd]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{specialBeginEnd}}{lst:specialBeginEnd}
+ \cmhlistingsfromfile[style=specialBeginEnd]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{specialBeginEnd}}{lst:specialBeginEnd}
The field \texttt{displayMath} represents \lstinline!\[...\]!, \texttt{inlineMath} represents
\lstinline!$...$! and \texttt{displayMathTex} represents \lstinline!$$...$$!. You can, of course,
@@ -422,20 +452,20 @@
\texttt{lookForThis} to \texttt{0}.
There are%
- \announce*{2017-08-21}{specialBeforeCommand} examples in which it is advantageous to search for \texttt{specialBeginEnd} fields \emph{before}
+ \announce{2017-08-21}{specialBeforeCommand} examples in which it is advantageous to search for \texttt{specialBeginEnd} fields \emph{before}
searching for commands, and the \texttt{specialBeforeCommand} switch controls this behaviour. For example, consider
the file shown in \cref{lst:specialLRbefore}.
- \cmhlistingsfromfile*{demonstrations/specialLR.tex}{\texttt{specialLR.tex}}{lst:specialLRbefore}
+ \cmhlistingsfromfile{demonstrations/specialLR.tex}{\texttt{specialLR.tex}}{lst:specialLRbefore}
Now consider the YAML files shown in \cref{lst:specialsLeftRight-yaml,lst:specialBeforeCommand-yaml}
\begin{minipage}{.49\linewidth}
- \cmhlistingsfromfile*{demonstrations/specialsLeftRight.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{specialsLeftRight.yaml}}{lst:specialsLeftRight-yaml}
+ \cmhlistingsfromfile[]*{demonstrations/specialsLeftRight.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{specialsLeftRight.yaml}}{lst:specialsLeftRight-yaml}
\end{minipage}
\hfill
\begin{minipage}{.49\linewidth}
- \cmhlistingsfromfile*{demonstrations/specialBeforeCommand.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{specialBeforeCommand.yaml}}{lst:specialBeforeCommand-yaml}
+ \cmhlistingsfromfile[]*{demonstrations/specialBeforeCommand.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{specialBeforeCommand.yaml}}{lst:specialBeforeCommand-yaml}
\end{minipage}
Upon running the following commands
@@ -448,11 +478,11 @@
we receive the respective outputs in \cref{lst:specialLR-comm-first-tex,lst:specialLR-special-first-tex}.
\begin{minipage}{.49\linewidth}
- \cmhlistingsfromfile*{demonstrations/specialLR-comm-first.tex}{\texttt{specialLR.tex} using \cref{lst:specialsLeftRight-yaml}}{lst:specialLR-comm-first-tex}
+ \cmhlistingsfromfile{demonstrations/specialLR-comm-first.tex}{\texttt{specialLR.tex} using \cref{lst:specialsLeftRight-yaml}}{lst:specialLR-comm-first-tex}
\end{minipage}
\hfill
\begin{minipage}{.49\linewidth}
- \cmhlistingsfromfile*{demonstrations/specialLR-special-first.tex}{\texttt{specialLR.tex} using \cref{lst:specialsLeftRight-yaml,lst:specialBeforeCommand-yaml}}{lst:specialLR-special-first-tex}
+ \cmhlistingsfromfile{demonstrations/specialLR-special-first.tex}{\texttt{specialLR.tex} using \cref{lst:specialsLeftRight-yaml,lst:specialBeforeCommand-yaml}}{lst:specialLR-special-first-tex}
\end{minipage}
Notice that in:
@@ -464,7 +494,7 @@
\yamltitle{indentAfterHeadings}*{fields}
\begin{wrapfigure}[17]{r}[0pt]{8cm}
- \cmhlistingsfromfile[style=indentAfterHeadings]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{indentAfterHeadings}}{lst:indentAfterHeadings}
+ \cmhlistingsfromfile[style=indentAfterHeadings]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{indentAfterHeadings}}{lst:indentAfterHeadings}
\end{wrapfigure}
This field enables the user to specify
indentation rules that take effect after heading commands such as \lstinline!\part!, \lstinline!\chapter!,
@@ -487,7 +517,7 @@
and that you have the text from \cref{lst:headings1} saved into \texttt{headings1.tex}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/headings1.yaml}[yaml-TCB]{\texttt{headings1.yaml}}{lst:headings1yaml}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/headings1.yaml}[yaml-TCB]{\texttt{headings1.yaml}}{lst:headings1yaml}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
@@ -501,11 +531,11 @@
then you should receive the output given in \cref{lst:headings1-mod1}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/headings1-mod1.tex}{\texttt{headings1.tex} using \cref{lst:headings1yaml}}{lst:headings1-mod1}
+ \cmhlistingsfromfile[showtabs=true]{demonstrations/headings1-mod1.tex}{\texttt{headings1.tex} using \cref{lst:headings1yaml}}{lst:headings1-mod1}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/headings1-mod2.tex}{\texttt{headings1.tex} second modification}{lst:headings1-mod2}
+ \cmhlistingsfromfile[showtabs=true]{demonstrations/headings1-mod2.tex}{\texttt{headings1.tex} second modification}{lst:headings1-mod2}
\end{minipage}
Now say that you modify the \texttt{YAML} from \cref{lst:headings1yaml} so that the \texttt{paragraph} \texttt{level} is \texttt{1}; after
@@ -518,7 +548,7 @@
\yamltitle{maximumIndentation}*{horizontal space}
You can control the maximum indentation given to your file by%
- \announce*{2017-08-21}{maximumIndentation}
+ \announce{2017-08-21}{maximumIndentation}
specifying the \texttt{maximumIndentation} field as horizontal space (but \emph{not} including tabs).
This feature uses the \texttt{Text::Tabs} module \cite{texttabs}, and is \emph{off}
by default.
@@ -527,11 +557,11 @@
shown in \cref{lst:mult-nested-default}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile*{demonstrations/mult-nested.tex}{\texttt{mult-nested.tex}}{lst:mult-nested}
+ \cmhlistingsfromfile{demonstrations/mult-nested.tex}{\texttt{mult-nested.tex}}{lst:mult-nested}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile*{demonstrations/mult-nested-default.tex}{\texttt{mult-nested.tex} default output}{lst:mult-nested-default}
+ \cmhlistingsfromfile[showtabs=true]{demonstrations/mult-nested-default.tex}{\texttt{mult-nested.tex} default output}{lst:mult-nested-default}
\end{minipage}
Now say that, for example, you have the \texttt{max-indentation1.yaml} from \cref{lst:max-indentation1yaml} and
@@ -542,11 +572,11 @@
You should receive the output shown in \cref{lst:mult-nested-max-ind1}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile*[style=yaml-LST]{demonstrations/max-indentation1.yaml}[yaml-TCB]{\texttt{max-indentation1.yaml}}{lst:max-indentation1yaml}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/max-indentation1.yaml}[yaml-TCB]{\texttt{max-indentation1.yaml}}{lst:max-indentation1yaml}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile*{demonstrations/mult-nested-max-ind1.tex}{\texttt{mult-nested.tex} using \cref{lst:max-indentation1yaml}}{lst:mult-nested-max-ind1}
+ \cmhlistingsfromfile[showspaces=true]{demonstrations/mult-nested-max-ind1.tex}{\texttt{mult-nested.tex} using \cref{lst:max-indentation1yaml}}{lst:mult-nested-max-ind1}
\end{minipage}
Comparing the output in \cref{lst:mult-nested-default,lst:mult-nested-max-ind1} we notice that the (default) tabs
Modified: trunk/Master/texmf-dist/doc/support/latexindent/sec-demonstration.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/sec-demonstration.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/sec-demonstration.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -1,3 +1,4 @@
+% arara: pdflatex: {shell: yes, files: [latexindent]}
\section{Demonstration: before and after}
Let's give a demonstration of some before and after code -- after all, you probably
won't want to try the script if you don't much like the results. You might also
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 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,7 +19,9 @@
\texttt{latexindent.pl} ships with \texttt{latexindent.exe} for Windows
users, so that you can use the script with or without a Perl distribution.
If you plan to use \texttt{latexindent.pl} (i.e, the original Perl script) then you will
- need a few standard Perl modules -- see \vref{sec:requiredmodules} for details.
+ need a few standard Perl modules -- see \vref{sec:requiredmodules} for details;
+ \announce*{2018-01-13}{perl module installer helper script} in particular, note
+ that a module installer helper script is shipped with \texttt{latexindent.pl}.
\subsection{From the command line}\label{sec:commandline}
\texttt{latexindent.pl} has a number of different switches/flags/options, which
@@ -31,13 +33,6 @@
but other additional information will be written depending
on which of the following options are used.
- \begin{commandshell}
-latexindent.pl
- \end{commandshell}
-
- This will output a welcome message to the terminal, including the version number
- and available options.
-
\flagbox{-v, --version}
\announce{2017-06-25}{version}
\begin{commandshell}
@@ -199,7 +194,7 @@
The \texttt{-l} flag can take an \emph{optional} parameter which details the name (or names separated by commas) of a YAML file(s)
that resides in the same directory as \texttt{myfile.tex}; you can use this option if you would
like to load a settings file in the current working directory that is \emph{not} called \texttt{localSettings.yaml}.
- \announce*{2017-08-21}*{-l switch absolute paths} In fact, you can specify both \emph{relative} and \emph{absolute paths} for your YAML files;
+ \announce{2017-08-21}*{-l switch absolute paths} In fact, you can specify both \emph{relative} and \emph{absolute paths} for your YAML files;
for example
\begin{commandshell}
latexindent.pl -l=../../myyaml.yaml myfile.tex
@@ -247,7 +242,7 @@
latexindent.pl myfile.tex -y='modifyLineBreaks:environments:one:EndStartsOnOwnLine:3' -m
\end{commandshell}
\label{page:yamlswitch}You%
- \announce*{2017-08-21}{the -y switch} can specify YAML settings from the command line using the \texttt{-y} or \texttt{--yaml} switch;
+ \announce{2017-08-21}{the -y switch} can specify YAML settings from the command line using the \texttt{-y} or \texttt{--yaml} switch;
sample demonstrations are given above. Note, in particular, that multiple settings can be specified by separating them
via commas. There is a further option to use a \texttt{;} to separate fields, which is demonstrated in \vref{sec:yamlswitch}.
@@ -265,7 +260,7 @@
call the script with the \texttt{-d} switch; note that this will also tell
the script to ignore \texttt{localSettings.yaml} even if it has been called with the
\texttt{-l} switch; \texttt{latexindent.pl}%
- \announce*{2017-08-21}*{updated -d switch} will also ignore any settings specified
+ \announce{2017-08-21}*{updated -d switch} will also ignore any settings specified
from the \texttt{-y} switch.
\flagbox{-c, --cruft=<directory>}
@@ -278,7 +273,7 @@
to another directory.
% this switch was made as a result of http://tex.stackexchange.com/questions/142652/output-latexindent-auxiliary-files-to-a-different-directory
-\flagbox{-g, --logfile}
+\flagbox{-g, --logfile=<name of log file>}
\begin{commandshell}
latexindent.pl -g=other.log myfile.tex
latexindent.pl -g other.log myfile.tex
@@ -289,6 +284,15 @@
By default, \texttt{latexindent.pl} reports information to \texttt{indent.log}, but if you wish to change the
name of this file, simply call the script with your chosen name after the \texttt{-g} switch as demonstrated above.
+\flagbox{-sl, --screenlog}
+ \begin{commandshell}
+latexindent.pl -sl myfile.tex
+latexindent.pl -screenlog myfile.tex
+ \end{commandshell}
+ Using this%
+ \announce*{2018-01-13}{screenlog switch created} option tells \texttt{latexindent.pl} to output the log file to the screen, as well
+ as to your chosen log file.
+
\flagbox{-m, --modifylinebreaks}
\begin{commandshell}
latexindent.pl -m myfile.tex
@@ -306,7 +310,29 @@
and in which case, you can specify
the order in which extensions are searched for; see \vref{lst:fileExtensionPreference}
for full details.
+\flagbox{STDIN}
+ \begin{commandshell}
+cat myfile.tex | latexindent.pl
+ \end{commandshell}
+ \texttt{latexindent.pl} will%
+ \announce*{2018-01-13}{STDIN allowed} allow input from STDIN, which means that you can pipe output from
+ other commands directly into the script. For example assuming that you have content in \texttt{myfile.tex}, then the above
+ command will output the results of operating upon \texttt{myfile.tex}
+ Similarly, if you%
+ \announce*{2018-01-13}*{no options/filename updated} simply type \texttt{latexindent.pl}
+ at the command line, then it will expect (STDIN) input from the command line.
+ \begin{commandshell}
+latexindent.pl
+ \end{commandshell}
+
+ Once you have finished typing your input, you can press
+ \begin{itemize}
+ \item \texttt{CTRL+D} on Linux
+ \item \texttt{CTRL+Z} followed by \texttt{ENTER} on Windows
+ \end{itemize}
+ to signify that your input has finished.
+
\subsection{From \texttt{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 at \cite{paulo}.
Modified: trunk/Master/texmf-dist/doc/support/latexindent/sec-indent-config-and-settings.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/sec-indent-config-and-settings.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/sec-indent-config-and-settings.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -116,7 +116,7 @@
\subsection{The \texttt{-y|yaml} switch}\label{sec:yamlswitch}
You%
- \announce*{2017-08-21}{demonstration of the -y switch} may use the \texttt{-y} switch to load
+ \announce{2017-08-21}{demonstration of the -y switch} may use the \texttt{-y} switch to load
your settings; for example, if you wished to specify the settings from \cref{lst:localSettings}
using the \texttt{-y} switch, then you could use the following command:
\begin{commandshell}
@@ -143,10 +143,10 @@
\item \texttt{localSettings.yaml} but only if found in the same directory as \texttt{myfile.tex} and called
with \texttt{-l} switch; this file can be renamed, provided that the call to \texttt{latexindent.pl} is adjusted
accordingly (see \cref{sec:localsettings}). You may specify both relative and absolute%
- \announce*{2017-08-21}*{-l absolute paths} paths to other
+ \announce{2017-08-21}*{-l absolute paths} paths to other
YAML files using the \texttt{-l} switch, separating multiple files using commas;
\item any settings%
- \announce*{2017-08-21}{-y switch load order} specified in the \texttt{-y} switch.
+ \announce{2017-08-21}{-y switch load order} specified in the \texttt{-y} switch.
\end{enumerate}
A visual representation of this is given in \cref{fig:loadorder}.
Modified: trunk/Master/texmf-dist/doc/support/latexindent/sec-introduction.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/sec-introduction.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/sec-introduction.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -58,7 +58,7 @@
The different listings are presented using different styles:
\begin{minipage}{.4\textwidth}
- \cmhlistingsfromfile*{demonstrations/demo-tex.tex}{\texttt{demo-tex.tex}}{lst:demo-tex}
+ \cmhlistingsfromfile{demonstrations/demo-tex.tex}{\texttt{demo-tex.tex}}{lst:demo-tex}
\end{minipage}%
\hfill
\begin{minipage}{.4\textwidth}
@@ -66,7 +66,7 @@
\end{minipage}%
\begin{minipage}{.4\textwidth}
- \cmhlistingsfromfile*[style=fileExtensionPreference]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{fileExtensionPreference}}{lst:fileExtensionPreference-demo}
+ \cmhlistingsfromfile[style=fileExtensionPreference]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{fileExtensionPreference}}{lst:fileExtensionPreference-demo}
\end{minipage}%
\hfill
\begin{minipage}{.4\textwidth}
@@ -76,7 +76,7 @@
\end{minipage}%
\begin{minipage}{.55\textwidth}
- \cmhlistingsfromfile*[style=modifylinebreaks]{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{modifyLineBreaks}}{lst:modifylinebreaks-demo}
+ \cmhlistingsfromfile[style=modifylinebreaks]*{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{modifyLineBreaks}}{lst:modifylinebreaks-demo}
\end{minipage}%
\hfill
\begin{minipage}{.4\textwidth}
@@ -94,3 +94,21 @@
not read this document before (and even if you have!), then you can ignore every occurrence of the \stardemo;
they are simply there to highlight new and updated features.
The new and updated features in this documentation (\gitRel) are on the following pages: \listOfNewFeatures
+
+\subsection{Quick start}\label{sec:quickstart}
+ If you'd like to get started with \texttt{latexindent.pl} then simply type
+ \begin{commandshell}
+latexindent.pl myfile.tex
+ \end{commandshell}
+ from the command line. If you receive an error message such as that given in \cref{lst:poss-errors},
+ then you need to install the missing perl modules.
+ \begin{cmhlistings}[style=tcblatex,language=Perl]{Possible error messages}{lst:poss-errors}
+Can't locate File/HomeDir.pm in @INC (@INC contains: /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12 /Library/Perl/Updates/5.12.4/darwin-thread-multi-2level /Library/Perl/Updates/5.12.4 /System/Library/Perl/5.12/darwin-thread-multi-2level /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library/Perl/Extras/5.12 .) at helloworld.pl line 10.
+BEGIN failed--compilation aborted at helloworld.pl line 10.
+\end{cmhlistings}
+ \texttt{latexindent.pl} ships with a script to help with this process; if you run the following script, you should be prompted
+ to install the appropriate modules.
+ \begin{commandshell}
+perl latexindent-module-installer.pl
+ \end{commandshell}
+ You might also like to see \href{https://stackoverflow.com/questions/19590042/error-cant-locate-file-homedir-pm-in-inc}{https://stackoverflow.com/questions/19590042/error-cant-locate-file-homedir-pm-in-inc}, for example, as well as \vref{sec:requiredmodules}.
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 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -7,9 +7,12 @@
All features described in this section will only be relevant if the \texttt{-m} switch
is used.
+ \startcontents[the-m-switch]
+ \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}
+ \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]{%
@@ -65,7 +68,7 @@
will \emph{not} wrap text; if you change it to a value of \texttt{2} or more, then
text will be wrapped after the character in the specified column.
- \cmhlistingsfromfile[style=textWrapOptions]{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{textWrapOptions}}{lst:textWrapOptions}
+ \cmhlistingsfromfile[style=textWrapOptions]*{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{textWrapOptions}}{lst:textWrapOptions}
For example, consider the file give in \cref{lst:textwrap1}.
@@ -115,7 +118,7 @@
\cmhlistingsfromfile{demonstrations/textwrap3-mod1.tex}{\texttt{textwrap3-mod1.tex}}{lst:textwrap3-mod1}
\begin{wrapfigure}[6]{r}[0pt]{8cm}
- \cmhlistingsfromfile[style=textWrapOptionsAll]{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{textWrapOptions}}{lst:textWrapOptionsAll}
+ \cmhlistingsfromfile[style=textWrapOptionsAll]*{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{textWrapOptions}}{lst:textWrapOptionsAll}
\end{wrapfigure}
The text wrapping routine of \texttt{latexindent.pl} is performed by the \texttt{Text::Wrap} module, which provides a
\texttt{separator} feature to separate lines with characters other than a new line (see \cite{textwrap}). By default,
@@ -147,13 +150,278 @@
will likely exceed any maximum value set in the \texttt{columns} field.
\end{itemize}
-\yamltitle{removeParagraphLineBreaks}*{fields}
+\subsection{\texttt{oneSentencePerLine}: modifying line breaks for sentences}\label{sec:onesentenceperline}
+ You can instruct \texttt{latexindent.pl} to format%
+ \announce*{2018-01-13}{one sentence per line} your file so that it puts one sentence
+ per line. Thank you to \cite{mlep} for helping to shape and test this feature. The behaviour of this part of the script is controlled by the switches detailed in \cref{lst:oneSentencePerLine},
+ all of which we discuss next.
+
+ \cmhlistingsfromfile*[style=oneSentencePerLine]*{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{oneSentencePerLine}}{lst:oneSentencePerLine}
+
+\yamltitle{manipulateSentences}{0|1}
+ This is a binary switch that details if \texttt{latexindent.pl} should perform the sentence manipulation routine; it
+ is \emph{off} (set to \texttt{0}) by default, and you will need to turn it on (by setting it to \texttt{1}) if you want the script
+ to modify line breaks surrounding and within sentences.
+
+\yamltitle{removeSentenceLineBreaks}{0|1}
+ When operating upon sentences \texttt{latexindent.pl} will, by default, remove internal linebreaks as \texttt{removeSentenceLineBreaks}
+ is set to \texttt{1}. Setting this switch to \texttt{0} instructs \texttt{latexindent.pl} not to do so.
+
+ For example, consider \texttt{multiple-sentences.tex} shown in \cref{lst:multiple-sentences}.
+
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences.tex}{\texttt{multiple-sentences.tex}}{lst:multiple-sentences}
+
+ If we use the YAML files in \cref{lst:manipulate-sentences-yaml,lst:keep-sen-line-breaks-yaml}, and run the commands
+ \begin{widepage}
+ \begin{commandshell}
+latexindent.pl multiple-sentences -m -l=manipulate-sentences.yaml
+latexindent.pl multiple-sentences -m -l=keep-sen-line-breaks.yaml
+ \end{commandshell}
+ \end{widepage}
+ then we obtain the respective output given in \cref{lst:multiple-sentences-mod1,lst:multiple-sentences-mod2}.
+
+ \begin{minipage}{.5\linewidth}
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences-mod1.tex}{\texttt{multiple-sentences.tex} using \cref{lst:manipulate-sentences-yaml}}{lst:multiple-sentences-mod1}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.5\linewidth}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/manipulate-sentences.yaml}[MLB-TCB]{\texttt{manipulate-sentences.yaml}}{lst:manipulate-sentences-yaml}
+ \end{minipage}
+
+ \begin{minipage}{.5\linewidth}
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences-mod2.tex}{\texttt{multiple-sentences.tex} using \cref{lst:keep-sen-line-breaks-yaml}}{lst:multiple-sentences-mod2}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.5\linewidth}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/keep-sen-line-breaks.yaml}[MLB-TCB]{\texttt{keep-sen-line-breaks.yaml}}{lst:keep-sen-line-breaks-yaml}
+ \end{minipage}
+
+ Notice, in particular, that the `internal' sentence line breaks in \cref{lst:multiple-sentences} have
+ been removed in \cref{lst:multiple-sentences-mod1}, but have not been removed in \cref{lst:multiple-sentences-mod2}.
+
+ The remainder of the settings displayed in \vref{lst:oneSentencePerLine} instruct \texttt{latexindent.pl} on how to define
+ a sentence. From the perpesctive of \texttt{latexindent.pl} a sentence must:
+ \begin{itemize}
+ \item \emph{follow} a certain character or set of characters (see \cref{lst:sentencesFollow}); by default, this is either \lstinline!\par!, a blank line,
+ a full stop/period (.), exclamation mark (!), question mark (?) right brace (\}) or a comment
+ on the previous line;
+ \item \emph{begin} with a character type (see \cref{lst:sentencesBeginWith}); by default, this is only capital letters;
+ \item \emph{end} with a character (see \cref{lst:sentencesEndWith}); by default, these are
+ full stop/period (.), exclamation mark (!) and question mark (?).
+ \end{itemize}
+ In each case, you can specify the \texttt{other} field to include any pattern that you would like; you can specify anything in
+ this field using the language of regular expressions.
+
+ \begin{adjustwidth}{-3.5cm}{-2.5cm}
+ \begin{minipage}{.36\linewidth}
+ \cmhlistingsfromfile*[style=sentencesFollow]*{../defaultSettings.yaml}[MLB-TCB,width=.9\linewidth,before=\centering]{\texttt{sentencesFollow}}{lst:sentencesFollow}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.31\linewidth}
+ \cmhlistingsfromfile*[style=sentencesBeginWith]*{../defaultSettings.yaml}[MLB-TCB,width=.9\linewidth,before=\centering]{\texttt{sentencesBeginWith}}{lst:sentencesBeginWith}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.31\linewidth}
+ \cmhlistingsfromfile*[style=sentencesEndWith]*{../defaultSettings.yaml}[MLB-TCB,width=.9\linewidth,before=\centering]{\texttt{sentencesEndWith}}{lst:sentencesEndWith}
+ \end{minipage}
+ \end{adjustwidth}
+
+\subsubsection{\texttt{sentencesFollow}}
+ Let's explore a few of the switches in \texttt{sentencesFollow}; let's start with \vref{lst:multiple-sentences}, and use the YAML
+ settings given in \cref{lst:sentences-follow1-yaml}. Using the command
+ \begin{commandshell}
+latexindent.pl multiple-sentences -m -l=sentences-follow1.yaml
+\end{commandshell}
+ we obtain the output given in \cref{lst:multiple-sentences-mod3}.
+
+ \begin{minipage}{.5\linewidth}
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences-mod3.tex}{\texttt{multiple-sentences.tex} using \cref{lst:sentences-follow1-yaml}}{lst:multiple-sentences-mod3}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.5\linewidth}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/sentences-follow1.yaml}[MLB-TCB]{\texttt{sentences-follow1.yaml}}{lst:sentences-follow1-yaml}
+ \end{minipage}
+
+ Notice that, because \texttt{blankLine} is set to \texttt{0}, \texttt{latexindent.pl} will not seek sentences following a blank line,
+ and so the fourth sentence has not been accounted for.
+
+ We can explore the \texttt{other} field in \cref{lst:sentencesFollow} with the \texttt{.tex} file detailed in \cref{lst:multiple-sentences1}.
+
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences1.tex}{\texttt{multiple-sentences1.tex}}{lst:multiple-sentences1}
+
+ Upon running the following commands
+ \begin{widepage}
+ \begin{commandshell}
+latexindent.pl multiple-sentences1 -m -l=manipulate-sentences.yaml
+latexindent.pl multiple-sentences1 -m -l=manipulate-sentences.yaml,sentences-follow2.yaml
+ \end{commandshell}
+ \end{widepage}
+ then we obtain the respective output given in \cref{lst:multiple-sentences1-mod1,lst:multiple-sentences1-mod2}.
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences1-mod1.tex}{\texttt{multiple-sentences1.tex} using \vref{lst:manipulate-sentences-yaml}}{lst:multiple-sentences1-mod1}
+
+ \begin{minipage}{.55\linewidth}
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences1-mod2.tex}{\texttt{multiple-sentences1.tex} using \cref{lst:sentences-follow2-yaml}}{lst:multiple-sentences1-mod2}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.45\linewidth}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/sentences-follow2.yaml}[MLB-TCB]{\texttt{sentences-follow2.yaml}}{lst:sentences-follow2-yaml}
+ \end{minipage}
+
+ Notice that in \cref{lst:multiple-sentences1-mod1} the first sentence after the \texttt{)} has not been accounted for, but that
+ following the inclusion of \cref{lst:sentences-follow2-yaml}, the output given in \cref{lst:multiple-sentences1-mod2} demonstrates that
+ the sentence \emph{has} been accounted for correctly.
+
+\subsubsection{\texttt{sentencesBeginWith}}
+ By default, \texttt{latexindent.pl} will only assume that sentences begin with the upper case letters \texttt{A-Z}; you can instruct the
+ script to define sentences to begin with lower case letters (see \cref{lst:sentencesBeginWith}), and we can use the \texttt{other} field
+ to define sentences to begin with other characters.
+
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences2.tex}{\texttt{multiple-sentences2.tex}}{lst:multiple-sentences2}
+
+ Upon running the following commands
+ \begin{widepage}
+ \begin{commandshell}
+latexindent.pl multiple-sentences2 -m -l=manipulate-sentences.yaml
+latexindent.pl multiple-sentences2 -m -l=manipulate-sentences.yaml,sentences-begin1.yaml
+ \end{commandshell}
+ \end{widepage}
+ then we obtain the respective output given in \cref{lst:multiple-sentences2-mod1,lst:multiple-sentences2-mod2}.
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences2-mod1.tex}{\texttt{multiple-sentences2.tex} using \vref{lst:manipulate-sentences-yaml}}{lst:multiple-sentences2-mod1}
+
+ \begin{minipage}{.55\linewidth}
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences2-mod2.tex}{\texttt{multiple-sentences2.tex} using \cref{lst:sentences-begin1-yaml}}{lst:multiple-sentences2-mod2}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.45\linewidth}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/sentences-begin1.yaml}[MLB-TCB]{\texttt{sentences-begin1.yaml}}{lst:sentences-begin1-yaml}
+ \end{minipage}
+ Notice that in \cref{lst:multiple-sentences2-mod1}, the first sentence has been accounted for but that the subsequent sentences
+ have not. In \cref{lst:multiple-sentences2-mod2}, all of the sentences have been accounted for, because the \texttt{other} field
+ in \cref{lst:sentences-begin1-yaml} has defined sentences to begin with either \lstinline!$! or any numeric digit, \texttt{0} to \texttt{9}.
+
+\subsubsection{\texttt{sentencesEndWith}}
+ Let's return to \vref{lst:multiple-sentences}; we have already seen the default way in which \texttt{latexindent.pl} will operate on the
+ sentences in this file in \vref{lst:multiple-sentences-mod1}. We can populate the \texttt{other} field with any character that we wish;
+ for example, using the YAML specified in \cref{lst:sentences-end1-yaml} and the command
+ \begin{commandshell}
+latexindent.pl multiple-sentences -m -l=sentences-end1.yaml
+latexindent.pl multiple-sentences -m -l=sentences-end2.yaml
+\end{commandshell}
+ then we obtain the output in \cref{lst:multiple-sentences-mod4}.
+
+ \begin{minipage}{.5\linewidth}
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences-mod4.tex}{\texttt{multiple-sentences.tex} using \cref{lst:sentences-end1-yaml}}{lst:multiple-sentences-mod4}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.5\linewidth}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/sentences-end1.yaml}[MLB-TCB]{\texttt{sentences-end1.yaml}}{lst:sentences-end1-yaml}
+ \end{minipage}
+
+ \begin{minipage}{.5\linewidth}
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences-mod5.tex}{\texttt{multiple-sentences.tex} using \cref{lst:sentences-end2-yaml}}{lst:multiple-sentences-mod5}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.5\linewidth}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/sentences-end2.yaml}[MLB-TCB]{\texttt{sentences-end2.yaml}}{lst:sentences-end2-yaml}
+ \end{minipage}
+
+ There is a subtle difference between the output in \cref{lst:multiple-sentences-mod4,lst:multiple-sentences-mod5}; in particular,
+ in \cref{lst:multiple-sentences-mod4} the word \texttt{sentence} has not been defined as a sentence, because we have not instructed
+ \texttt{latexindent.pl} to begin sentences with lower case letters. We have changed this by using the settings in \cref{lst:sentences-end2-yaml},
+ and the associated output in \cref{lst:multiple-sentences-mod5} reflects this.
+
+ Referencing \vref{lst:sentencesEndWith}, you'll notice that there is a field called \texttt{basicFullStop}, which
+ is set to \texttt{0}, and that the \texttt{betterFullStop} is set to \texttt{1} by default.
+
+ Let's consider the file shown in \cref{lst:url}.
+
+ \cmhlistingsfromfile*{demonstrations/url.tex}{\texttt{url.tex}}{lst:url}
+
+ Upon running the following commands
+ \begin{commandshell}
+latexindent.pl url -m -l=manipulate-sentences.yaml
+\end{commandshell}
+ we obtain the output given in \cref{lst:url-mod1}.
+
+ \cmhlistingsfromfile*{demonstrations/url-mod1.tex}{\texttt{url.tex} using \vref{lst:manipulate-sentences-yaml}}{lst:url-mod1}
+
+ Notice that the full stop within the url has been interpreted correctly. This is because, within the \texttt{betterFullStop},
+ full stops at the end of sentences have the following properties:
+ \begin{itemize}
+ \item they are ignored within \texttt{e.g.} and \texttt{i.e.};
+ \item they can not be immediately followed by a lower case or upper case letter;
+ \item they can not be immediately followed by a hyphen, comma, or number.
+ \end{itemize}
+ If you find that the \texttt{betterFullStop} does not work for your purposes, then you can switch it off by setting
+ it to \texttt{0}, and you can experiment with the \texttt{other} field.
+
+ The \texttt{basicFullStop} routine should probably be avoided in most situations, as it does not accomodate the specifications
+ above. For example, using the YAML in \cref{lst:alt-full-stop1-yaml} gives the output from the following command in \cref{lst:url-mod2}.
+ \begin{commandshell}
+latexindent.pl url -m -l=alt-full-stop1.yaml
+\end{commandshell}
+
+ \begin{adjustwidth}{-3.5cm}{-1.5cm}
+ \begin{minipage}{.6\linewidth}
+ \cmhlistingsfromfile*{demonstrations/url-mod2.tex}{\texttt{url.tex} using \cref{lst:alt-full-stop1-yaml}}{lst:url-mod2}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.4\linewidth}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/alt-full-stop1.yaml}[MLB-TCB]{\texttt{alt-full-stop1.yaml}}{lst:alt-full-stop1-yaml}
+ \end{minipage}
+ \end{adjustwidth}
+
+ Notice that the full stop within the URL has not been accomodated correctly because of the non-default settings in \cref{lst:alt-full-stop1-yaml}.
+
+\subsubsection{Features of the \texttt{oneSentencePerLine} routine}
+ The sentence manipulation routine takes place \emph{after} verbatim environments, preamble and trailing comments have
+ been accounted for; this means that any characters within these types of code blocks will not be part
+ of the sentence manipulation routine.
+
+ For example, if we begin with the \texttt{.tex} file in \cref{lst:multiple-sentences3}, and run the command
+ \begin{commandshell}
+latexindent.pl multiple-sentences3 -m -l=manipulate-sentences.yaml
+ \end{commandshell}
+ then we obtain the output in \cref{lst:multiple-sentences3-mod1}.
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences3.tex}{\texttt{multiple-sentences3.tex}}{lst:multiple-sentences3}
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences3-mod1.tex}{\texttt{multiple-sentences3.tex} using \vref{lst:manipulate-sentences-yaml}}{lst:multiple-sentences3-mod1}
+
+ Furthermore, if sentences run across environments then, by default, the line breaks internal to the sentence will be removed.
+ For example, if we use the \texttt{.tex} file in \cref{lst:multiple-sentences4} and run the commands
+ \begin{commandshell}
+latexindent.pl multiple-sentences4 -m -l=manipulate-sentences.yaml
+latexindent.pl multiple-sentences4 -m -l=keep-sen-line-breaks.yaml
+ \end{commandshell}
+ then we obtain the output in \cref{lst:multiple-sentences4-mod1,lst:multiple-sentences4-mod2}.
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences4.tex}{\texttt{multiple-sentences4.tex}}{lst:multiple-sentences4}
+ \begin{widepage}
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences4-mod1.tex}{\texttt{multiple-sentences4.tex} using \vref{lst:manipulate-sentences-yaml}}{lst:multiple-sentences4-mod1}
+ \end{widepage}
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences4-mod2.tex}{\texttt{multiple-sentences4.tex} using \vref{lst:keep-sen-line-breaks-yaml}}{lst:multiple-sentences4-mod2}
+ Once you've read \cref{sec:poly-switches}, you will know that you can accomodate the removal of internal sentence line breaks
+ by using the YAML in \cref{lst:item-rules2-yaml} and the command
+ \begin{commandshell}
+latexindent.pl multiple-sentences4 -m -l=item-rules2.yaml
+ \end{commandshell}
+ the output of which is shown in \cref{lst:multiple-sentences4-mod3}.
+
+ \begin{minipage}{.5\linewidth}
+ \cmhlistingsfromfile*{demonstrations/multiple-sentences4-mod3.tex}{\texttt{multiple-sentences4.tex} using \cref{lst:item-rules2-yaml}}{lst:multiple-sentences4-mod3}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.5\linewidth}
+ \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/item-rules2.yaml}[MLB-TCB]{\texttt{item-rules2.yaml}}{lst:item-rules2-yaml}
+ \end{minipage}
+
+\subsection{\texttt{removeParagraphLineBreaks}: modifying line breaks for paragraphs}
When the \texttt{-m} switch is active \texttt{latexindent.pl} has the ability to remove line breaks
\announce{2017-05-27}{removeParagraphLineBreaks}
from within paragraphs; the behaviour is controlled by the \texttt{removeParagraphLineBreaks} field, detailed in
\cref{lst:removeParagraphLineBreaks}. Thank you to \cite{jowens} for shaping and assisting with the testing of this feature.
+\yamltitle{removeParagraphLineBreaks}*{fields}
+ This feature is considered complimentary to the \texttt{oneSentencePerLine} feature described in \vref{sec:onesentenceperline}.
- \cmhlistingsfromfile[style=removeParagraphLineBreaks]{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{removeParagraphLineBreaks}}{lst:removeParagraphLineBreaks}
+ \cmhlistingsfromfile[style=removeParagraphLineBreaks]*{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{removeParagraphLineBreaks}}{lst:removeParagraphLineBreaks}
This routine can be turned on \emph{globally} for \emph{every} code block type known to \texttt{latexindent.pl}
(see \vref{tab:code-blocks}) by using the \texttt{all} switch; by default, this switch is \emph{off}. Assuming
@@ -172,7 +440,7 @@
\cref{lst:remove-para1-yaml}.
\begin{minipage}{.45\linewidth}
- \cmhlistingsfromfile{demonstrations/shortlines.tex}{\texttt{shortlines.tex}}{lst:shortlines}
+ \cmhlistingsfromfile[showspaces=true]{demonstrations/shortlines.tex}{\texttt{shortlines.tex}}{lst:shortlines}
\end{minipage}
\hfill
\begin{minipage}{.49\linewidth}
@@ -185,7 +453,7 @@
\end{commandshell}
then we obtain the output given in \cref{lst:shortlines1}.
- \cmhlistingsfromfile{demonstrations/shortlines1.tex}{\texttt{shortlines1.tex}}{lst:shortlines1}
+ \cmhlistingsfromfile[showspaces=true]{demonstrations/shortlines1.tex}{\texttt{shortlines1.tex}}{lst:shortlines1}
Keen readers may notice that some trailing white space must be present in the file in \cref{lst:shortlines} which
has crept in to the output in \cref{lst:shortlines1}. This can be fixed using the YAML file in
@@ -196,7 +464,7 @@
in which case the output is as in \cref{lst:shortlines1-tws}; notice that the double spaces present in \cref{lst:shortlines1}
have been addressed.
- \cmhlistingsfromfile{demonstrations/shortlines1-tws.tex}{\texttt{shortlines1-tws.tex}}{lst:shortlines1-tws}
+ \cmhlistingsfromfile[showspaces=true]{demonstrations/shortlines1-tws.tex}{\texttt{shortlines1-tws.tex}}{lst:shortlines1-tws}
Keeping with the settings in \cref{lst:remove-para1-yaml}, we note that the \texttt{all} switch applies
to \emph{all} code block types. So, for example, let's consider the files in \cref{lst:shortlines-mand,lst:shortlines-opt}
@@ -282,7 +550,7 @@
\announce{2017-05-27}{paragraphsStopAt}
you can fine tune the behaviour of the routine further by using the \texttt{paragraphsStopAt} fields, shown in \cref{lst:paragraphsStopAt}.
- \cmhlistingsfromfile[style=paragraphsStopAt]{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{paragraphsStopAt}}{lst:paragraphsStopAt}
+ \cmhlistingsfromfile[style=paragraphsStopAt]*{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{paragraphsStopAt}}{lst:paragraphsStopAt}
The fields specified in \texttt{paragraphsStopAt} tell \texttt{latexindent.pl} to stop the current paragraph
when it reaches a line that \emph{begins} with any of the code-block types specified as \texttt{1} in \cref{lst:paragraphsStopAt}.
@@ -328,10 +596,10 @@
\cmhlistingsfromfile{demonstrations/sl-stop4-command.tex}{\texttt{sl-stop4-command.tex}}{lst:sl-stop4-command}
\cmhlistingsfromfile{demonstrations/sl-stop4-comment.tex}{\texttt{sl-stop4-comment.tex}}{lst:sl-stop4-comment}
-\subsection{Poly-switches}
+\subsection{Poly-switches}\label{sec:poly-switches}
Every other field in the \texttt{modifyLineBreaks} field uses poly-switches, and can take
one of \emph{five}%
- \announce*{2017-08-21}*{blank line poly-switch} integer values:
+ \announce{2017-08-21}*{blank line poly-switch} integer values:
\begin{itemize}[font=\bfseries]
\item[$-1$] \emph{remove mode}: line breaks before or after the \emph{<part of thing>} can be removed (assuming that \texttt{preserveBlankLines} is set to \texttt{0});
\item[0] \emph{off mode}: line breaks will not be modified for the \emph{<part of thing>} under consideration;
@@ -340,7 +608,7 @@
\item[2] \emph{comment then add mode}: a comment symbol will be added, followed by a line break before or after the \emph{<part of thing>} under consideration, assuming that
there is not already a comment and line break before or after the \emph{<part of thing>};
\item[3] \emph{add then blank line mode}%
- \announce*{2017-08-21}{blank line poly-switch}: a line break will be added before or after the \emph{<part of thing>} under consideration, assuming that
+ \announce{2017-08-21}{blank line poly-switch}: a line break will be added before or after the \emph{<part of thing>} under consideration, assuming that
there is not already a line break before or after the \emph{<part of thing>}, followed by a blank line.
\end{itemize}
In the above, \emph{<part of thing>} refers to either the \emph{begin statement}, \emph{body} or \emph{end statement} of the
@@ -352,25 +620,25 @@
after the \texttt{environments} field) and that \emph{per-name} settings are also allowed -- in the case of \cref{lst:environments-mlb}, settings
for \texttt{equation*} have been specified. Note that all poly-switches are \emph{off} by default.
- \cmhlistingsfromfile[style=modifylinebreaksEnv]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,MLB-TCB]{\texttt{environments}}{lst:environments-mlb}
+ \cmhlistingsfromfile[style=modifylinebreaksEnv]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,MLB-TCB]{\texttt{environments}}{lst:environments-mlb}
Let's begin with the simple example given in \cref{lst:env-mlb1-tex}; note that we have annotated key parts of the file using $\BeginStartsOnOwnLine$,
$\BodyStartsOnOwnLine$, $\EndStartsOnOwnLine$ and $\EndFinishesWithLineBreak$, these will be related to fields specified in \cref{lst:environments-mlb}.
- \begin{cmhlistings}[escapeinside={(*@}{@*)}]{\texttt{env-mlb1.tex}}{lst:env-mlb1-tex}
+ \begin{cmhlistings}[style=tcblatex,escapeinside={(*@}{@*)}]{\texttt{env-mlb1.tex}}{lst:env-mlb1-tex}
before words(*@$\BeginStartsOnOwnLine$@*) \begin{myenv}(*@$\BodyStartsOnOwnLine$@*)body of myenv(*@$\EndStartsOnOwnLine$@*)\end{myenv}(*@$\EndFinishesWithLineBreak$@*) after words
\end{cmhlistings}
-\subsubsection{Adding line breaks using \texttt{BeginStartsOnOwnLine} and \texttt{BodyStartsOnOwnLine}}
+\subsubsection[Adding line breaks: \texttt{BeginStartsOnOwnLine} and \texttt{BodyStartsOnOwnLine}]{Adding line breaks using \texttt{BeginStartsOnOwnLine} and \texttt{BodyStartsOnOwnLine}}
Let's explore \texttt{BeginStartsOnOwnLine} and \texttt{BodyStartsOnOwnLine} in \cref{lst:env-mlb1,lst:env-mlb2}, and in particular,
let's allow each of them in turn to take a value of $1$.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/env-mlb1.yaml}[MLB-TCB]{\texttt{env-mlb1.yaml}}{lst:env-mlb1}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb1.yaml}[MLB-TCB]{\texttt{env-mlb1.yaml}}{lst:env-mlb1}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/env-mlb2.yaml}[MLB-TCB]{\texttt{env-mlb2.yaml}}{lst:env-mlb2}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb2.yaml}[MLB-TCB]{\texttt{env-mlb2.yaml}}{lst:env-mlb2}
\end{minipage}
After running the following commands,
@@ -402,11 +670,11 @@
save them into \texttt{env-mlb3.yaml} and \texttt{env-mlb4.yaml} respectively (see \cref{lst:env-mlb3,lst:env-mlb4}).
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/env-mlb3.yaml}[MLB-TCB]{\texttt{env-mlb3.yaml}}{lst:env-mlb3}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb3.yaml}[MLB-TCB]{\texttt{env-mlb3.yaml}}{lst:env-mlb3}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/env-mlb4.yaml}[MLB-TCB]{\texttt{env-mlb4.yaml}}{lst:env-mlb4}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb4.yaml}[MLB-TCB]{\texttt{env-mlb4.yaml}}{lst:env-mlb4}
\end{minipage}
Upon running commands analogous to the above, we obtain \cref{lst:env-mlb-mod3,lst:env-mlb-mod4}.
@@ -426,15 +694,15 @@
space has been stripped before doing so.
Let's%
- \announce*{2017-08-21}{demonstration of blank line poly-switch (3)} now change each of the \texttt{1} values in \cref{lst:env-mlb1,lst:env-mlb2} so that they are $3$ and
+ \announce{2017-08-21}{demonstration of blank line poly-switch (3)} now change each of the \texttt{1} values in \cref{lst:env-mlb1,lst:env-mlb2} so that they are $3$ and
save them into \texttt{env-mlb5.yaml} and \texttt{env-mlb6.yaml} respectively (see \cref{lst:env-mlb5,lst:env-mlb6}).
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile*[style=yaml-LST]{demonstrations/env-mlb5.yaml}[MLB-TCB]{\texttt{env-mlb5.yaml}}{lst:env-mlb5}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb5.yaml}[MLB-TCB]{\texttt{env-mlb5.yaml}}{lst:env-mlb5}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile*[style=yaml-LST]{demonstrations/env-mlb6.yaml}[MLB-TCB]{\texttt{env-mlb6.yaml}}{lst:env-mlb6}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb6.yaml}[MLB-TCB]{\texttt{env-mlb6.yaml}}{lst:env-mlb6}
\end{minipage}
Upon running commands analogous to the above, we obtain \cref{lst:env-mlb-mod5,lst:env-mlb-mod6}.
@@ -441,11 +709,11 @@
\begin{widepage}
\begin{minipage}{.56\linewidth}
- \cmhlistingsfromfile*{demonstrations/env-mlb-mod5.tex}{\texttt{env-mlb.tex} using \cref{lst:env-mlb5}}{lst:env-mlb-mod5}
+ \cmhlistingsfromfile{demonstrations/env-mlb-mod5.tex}{\texttt{env-mlb.tex} using \cref{lst:env-mlb5}}{lst:env-mlb-mod5}
\end{minipage}
\hfill
\begin{minipage}{.43\linewidth}
- \cmhlistingsfromfile*{demonstrations/env-mlb-mod6.tex}{\texttt{env-mlb.tex} using \cref{lst:env-mlb6}}{lst:env-mlb-mod6}
+ \cmhlistingsfromfile{demonstrations/env-mlb-mod6.tex}{\texttt{env-mlb.tex} using \cref{lst:env-mlb6}}{lst:env-mlb-mod6}
\end{minipage}
\end{widepage}
@@ -452,16 +720,16 @@
Note that line breaks have been added as in \cref{lst:env-mlb-mod1,lst:env-mlb-mod2}, but this time a \emph{blank line}
has been added after adding the line break.
-\subsubsection{Adding line breaks using \texttt{EndStartsOnOwnLine} and \texttt{EndFinishesWithLineBreak}}
+\subsubsection[Adding line breaks: \texttt{EndStartsOnOwnLine} and \texttt{EndFinishesWithLineBreak}]{Adding line breaks using \texttt{EndStartsOnOwnLine} and \texttt{EndFinishesWithLineBreak}}
Let's explore \texttt{EndStartsOnOwnLine} and \texttt{EndFinishesWithLineBreak} in \cref{lst:env-mlb7,lst:env-mlb8},
and in particular, let's allow each of them in turn to take a value of $1$.
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/env-mlb7.yaml}[MLB-TCB]{\texttt{env-mlb7.yaml}}{lst:env-mlb7}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb7.yaml}[MLB-TCB]{\texttt{env-mlb7.yaml}}{lst:env-mlb7}
\end{minipage}
\hfill
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/env-mlb8.yaml}[MLB-TCB]{\texttt{env-mlb8.yaml}}{lst:env-mlb8}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb8.yaml}[MLB-TCB]{\texttt{env-mlb8.yaml}}{lst:env-mlb8}
\end{minipage}
After running the following commands,
@@ -492,11 +760,11 @@
save them into \texttt{env-mlb9.yaml} and \texttt{env-mlb10.yaml} respectively (see \cref{lst:env-mlb9,lst:env-mlb10}).
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/env-mlb9.yaml}[MLB-TCB]{\texttt{env-mlb9.yaml}}{lst:env-mlb9}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb9.yaml}[MLB-TCB]{\texttt{env-mlb9.yaml}}{lst:env-mlb9}
\end{minipage}
\hfill
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/env-mlb10.yaml}[MLB-TCB]{\texttt{env-mlb10.yaml}}{lst:env-mlb10}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb10.yaml}[MLB-TCB]{\texttt{env-mlb10.yaml}}{lst:env-mlb10}
\end{minipage}
Upon running commands analogous to the above, we obtain \cref{lst:env-mlb-mod9,lst:env-mlb-mod10}.
@@ -516,15 +784,15 @@
space has been stripped before doing so.
Let's%
- \announce*{2017-08-21}{demonstration of blank line poly-switch (3)} now change each of the \texttt{1} values in \cref{lst:env-mlb7,lst:env-mlb8} so that they are $3$ and
+ \announce{2017-08-21}{demonstration of blank line poly-switch (3)} now change each of the \texttt{1} values in \cref{lst:env-mlb7,lst:env-mlb8} so that they are $3$ and
save them into \texttt{env-mlb11.yaml} and \texttt{env-mlb12.yaml} respectively (see \cref{lst:env-mlb11,lst:env-mlb12}).
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile*[style=yaml-LST]{demonstrations/env-mlb11.yaml}[MLB-TCB]{\texttt{env-mlb11.yaml}}{lst:env-mlb11}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb11.yaml}[MLB-TCB]{\texttt{env-mlb11.yaml}}{lst:env-mlb11}
\end{minipage}
\hfill
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile*[style=yaml-LST]{demonstrations/env-mlb12.yaml}[MLB-TCB]{\texttt{env-mlb12.yaml}}{lst:env-mlb12}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb12.yaml}[MLB-TCB]{\texttt{env-mlb12.yaml}}{lst:env-mlb12}
\end{minipage}
Upon running commands analogous to the above, we obtain \cref{lst:env-mlb-mod11,lst:env-mlb-mod12}.
@@ -531,11 +799,11 @@
\begin{widepage}
\begin{minipage}{.42\linewidth}
- \cmhlistingsfromfile*{demonstrations/env-mlb-mod11.tex}{\texttt{env-mlb.tex} using \cref{lst:env-mlb11}}{lst:env-mlb-mod11}
+ \cmhlistingsfromfile{demonstrations/env-mlb-mod11.tex}{\texttt{env-mlb.tex} using \cref{lst:env-mlb11}}{lst:env-mlb-mod11}
\end{minipage}
\hfill
\begin{minipage}{.57\linewidth}
- \cmhlistingsfromfile*{demonstrations/env-mlb-mod12.tex}{\texttt{env-mlb.tex} using \cref{lst:env-mlb12}}{lst:env-mlb-mod12}
+ \cmhlistingsfromfile{demonstrations/env-mlb-mod12.tex}{\texttt{env-mlb.tex} using \cref{lst:env-mlb12}}{lst:env-mlb-mod12}
\end{minipage}
\end{widepage}
@@ -582,7 +850,7 @@
and $\EndFinishesWithLineBreak$, together with the associated YAML files in \crefrange{lst:env-mlb13}{lst:env-mlb16}.
\begin{minipage}{.45\linewidth}
- \begin{cmhlistings}[escapeinside={(*@}{@*)}]{\texttt{env-mlb4.tex}}{lst:mlb4}
+ \begin{cmhlistings}[style=tcblatex,escapeinside={(*@}{@*)}]{\texttt{env-mlb4.tex}}{lst:mlb4}
before words(*@$\BeginStartsOnOwnLine$@*)
\begin{myenv}(*@$\BodyStartsOnOwnLine$@*)
body of myenv(*@$\EndStartsOnOwnLine$@*)
@@ -592,13 +860,13 @@
\end{minipage}%
\hfill
\begin{minipage}{.51\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/env-mlb13.yaml}[MLB-TCB]{\texttt{env-mlb13.yaml}}{lst:env-mlb13}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb13.yaml}[MLB-TCB]{\texttt{env-mlb13.yaml}}{lst:env-mlb13}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/env-mlb14.yaml}[MLB-TCB]{\texttt{env-mlb14.yaml}}{lst:env-mlb14}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb14.yaml}[MLB-TCB]{\texttt{env-mlb14.yaml}}{lst:env-mlb14}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/env-mlb15.yaml}[MLB-TCB]{\texttt{env-mlb15.yaml}}{lst:env-mlb15}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb15.yaml}[MLB-TCB]{\texttt{env-mlb15.yaml}}{lst:env-mlb15}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/env-mlb16.yaml}[MLB-TCB]{\texttt{env-mlb16.yaml}}{lst:env-mlb16}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/env-mlb16.yaml}[MLB-TCB]{\texttt{env-mlb16.yaml}}{lst:env-mlb16}
\end{minipage}
After running the commands
@@ -651,7 +919,7 @@
file shown in \cref{lst:mlb5}, which highlights trailing spaces.
\begin{minipage}{.45\linewidth}
- \begin{cmhlistings}[showspaces=true,escapeinside={(*@}{@*)}]{\texttt{env-mlb5.tex}}{lst:mlb5}
+ \begin{cmhlistings}[style=tcblatex,showspaces=true,escapeinside={(*@}{@*)}]{\texttt{env-mlb5.tex}}{lst:mlb5}
before words (*@$\BeginStartsOnOwnLine$@*)
\begin{myenv} (*@$\BodyStartsOnOwnLine$@*)
body of myenv (*@$\EndStartsOnOwnLine$@*)
@@ -661,7 +929,7 @@
\end{minipage}
\hfill
\begin{minipage}{.45\linewidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/removeTWS-before.yaml}[yaml-TCB]{\texttt{removeTWS-before.yaml}}{lst:removeTWS-before}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/removeTWS-before.yaml}[yaml-TCB]{\texttt{removeTWS-before.yaml}}{lst:removeTWS-before}
\end{minipage}
The output from the following commands
@@ -676,9 +944,9 @@
in \cref{lst:env-mlb5-modAll-remove-WS}, it has been removed using the switch specified in \cref{lst:removeTWS-before}.
\begin{widepage}
- \cmhlistingsfromfile{demonstrations/env-mlb5-modAll.tex}{\texttt{env-mlb5.tex} using \crefrange{lst:env-mlb4-mod13}{lst:env-mlb4-mod16}}{lst:env-mlb5-modAll}
+ \cmhlistingsfromfile[showspaces=true]{demonstrations/env-mlb5-modAll.tex}{\texttt{env-mlb5.tex} using \crefrange{lst:env-mlb4-mod13}{lst:env-mlb4-mod16}}{lst:env-mlb5-modAll}
- \cmhlistingsfromfile{demonstrations/env-mlb5-modAll-remove-WS.tex}{\texttt{env-mlb5.tex} using \crefrange{lst:env-mlb4-mod13}{lst:env-mlb4-mod16} \emph{and} \cref{lst:removeTWS-before}}{lst:env-mlb5-modAll-remove-WS}
+ \cmhlistingsfromfile[showspaces=true]{demonstrations/env-mlb5-modAll-remove-WS.tex}{\texttt{env-mlb5.tex} using \crefrange{lst:env-mlb4-mod13}{lst:env-mlb4-mod16} \emph{and} \cref{lst:removeTWS-before}}{lst:env-mlb5-modAll-remove-WS}
\end{widepage}
\subsubsection{poly-switch line break removal and blank lines}
@@ -685,7 +953,7 @@
Now let's consider the file in \cref{lst:mlb6}, which contains blank lines.
\begin{minipage}{.45\linewidth}
- \begin{cmhlistings}[escapeinside={(*@}{@*)}]{\texttt{env-mlb6.tex}}{lst:mlb6}
+ \begin{cmhlistings}[style=tcblatex,escapeinside={(*@}{@*)}]{\texttt{env-mlb6.tex}}{lst:mlb6}
before words(*@$\BeginStartsOnOwnLine$@*)
@@ -702,7 +970,7 @@
\end{minipage}%
\hfill
\begin{minipage}{.45\linewidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/UnpreserveBlankLines.yaml}[MLB-TCB]{\texttt{UnpreserveBlankLines.yaml}}{lst:UnpreserveBlankLines}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/UnpreserveBlankLines.yaml}[MLB-TCB]{\texttt{UnpreserveBlankLines.yaml}}{lst:UnpreserveBlankLines}
\end{minipage}
Upon running the following commands
@@ -731,7 +999,7 @@
We can explore this further using the blank-line poly-switch value of $3$; let's use the file given
in \cref{lst:env-mlb7-tex}.
- \cmhlistingsfromfile*{demonstrations/env-mlb7.tex}{\texttt{env-mlb7.tex}}{lst:env-mlb7-tex}
+ \cmhlistingsfromfile{demonstrations/env-mlb7.tex}{\texttt{env-mlb7.tex}}{lst:env-mlb7-tex}
Upon running the following commands
\begin{commandshell}
@@ -740,8 +1008,8 @@
\end{commandshell}
we receive the outputs given in \cref{lst:env-mlb7-preserve,lst:env-mlb7-no-preserve}.
- \cmhlistingsfromfile*{demonstrations/env-mlb7-preserve.tex}{\texttt{env-mlb7-preserve.tex}}{lst:env-mlb7-preserve}
- \cmhlistingsfromfile*{demonstrations/env-mlb7-no-preserve.tex}{\texttt{env-mlb7-no-preserve.tex}}{lst:env-mlb7-no-preserve}
+ \cmhlistingsfromfile{demonstrations/env-mlb7-preserve.tex}{\texttt{env-mlb7-preserve.tex}}{lst:env-mlb7-preserve}
+ \cmhlistingsfromfile{demonstrations/env-mlb7-no-preserve.tex}{\texttt{env-mlb7-no-preserve.tex}}{lst:env-mlb7-no-preserve}
Notice that in:
\begin{itemize}
@@ -764,7 +1032,7 @@
Code block & Sample & Poly-switch mapping \\
\midrule
environment &
- \begin{lstlisting}[escapeinside={(*@}{@*)},nolol=true]
+ \begin{lstlisting}[style=tcblatex,escapeinside={(*@}{@*)},nolol=true]
before words(*@$\BeginStartsOnOwnLine$@*)
\begin{myenv}(*@$\BodyStartsOnOwnLine$@*)
body of myenv(*@$\EndStartsOnOwnLine$@*)
@@ -781,7 +1049,7 @@
\\
\cmidrule{2-3}
ifelsefi &
- \begin{lstlisting}[escapeinside={(*@}{@*)},nolol=true]
+ \begin{lstlisting}[style=tcblatex,escapeinside={(*@}{@*)},nolol=true]
before words(*@$\BeginStartsOnOwnLine$@*)
\if...(*@$\BodyStartsOnOwnLine$@*)
body of if statement(*@$\ElseStartsOnOwnLine$@*)
@@ -802,7 +1070,7 @@
\\
\cmidrule{2-3}
optionalArguments &
- \begin{lstlisting}[escapeinside={(*@}{@*)},nolol=true]
+ \begin{lstlisting}[style=tcblatex,escapeinside={(*@}{@*)},nolol=true]
...(*@$\BeginStartsOnOwnLine$@*)
[(*@$\BodyStartsOnOwnLine$@*)
body of opt arg(*@$\EndStartsOnOwnLine$@*)
@@ -819,7 +1087,7 @@
\\
\cmidrule{2-3}
mandatoryArguments &
- \begin{lstlisting}[escapeinside={(*@}{@*)},nolol=true]
+ \begin{lstlisting}[style=tcblatex,escapeinside={(*@}{@*)},nolol=true]
...(*@$\BeginStartsOnOwnLine$@*)
{(*@$\BodyStartsOnOwnLine$@*)
body of mand arg(*@$\EndStartsOnOwnLine$@*)
@@ -836,7 +1104,7 @@
\\
\cmidrule{2-3}
commands &
- \begin{lstlisting}[escapeinside={(*@}{@*)},morekeywords={mycommand},nolol=true,]
+ \begin{lstlisting}[style=tcblatex,escapeinside={(*@}{@*)},morekeywords={mycommand},nolol=true,]
before words(*@$\BeginStartsOnOwnLine$@*)
\mycommand(*@$\BodyStartsOnOwnLine$@*)
(*@$\langle$\itshape{arguments}$\rangle$@*)
@@ -849,7 +1117,7 @@
\\
\cmidrule{2-3}
namedGroupingBraces Brackets &
- \begin{lstlisting}[escapeinside={(*@}{@*)},morekeywords={myname},nolol=true,]
+ \begin{lstlisting}[style=tcblatex,escapeinside={(*@}{@*)},morekeywords={myname},nolol=true,]
before words(*@$\BeginStartsOnOwnLine$@*)
myname(*@$\BodyStartsOnOwnLine$@*)
(*@$\langle$\itshape{braces/brackets}$\rangle$@*)
@@ -862,7 +1130,7 @@
\\
\cmidrule{2-3}
keyEqualsValuesBraces\newline Brackets &
- \begin{lstlisting}[escapeinside={(*@}{@*)},morekeywords={key},nolol=true,]
+ \begin{lstlisting}[style=tcblatex,escapeinside={(*@}{@*)},morekeywords={key},nolol=true,]
before words(*@$\BeginStartsOnOwnLine$@*)
key(*@$\EqualsStartsOnOwnLine$@*)=(*@$\BodyStartsOnOwnLine$@*)
(*@$\langle$\itshape{braces/brackets}$\rangle$@*)
@@ -876,7 +1144,7 @@
\\
\cmidrule{2-3}
items &
- \begin{lstlisting}[escapeinside={(*@}{@*)},nolol=true]
+ \begin{lstlisting}[style=tcblatex,escapeinside={(*@}{@*)},nolol=true]
before words(*@$\BeginStartsOnOwnLine$@*)
\item(*@$\BodyStartsOnOwnLine$@*)
...
@@ -889,7 +1157,7 @@
\\
\cmidrule{2-3}
specialBeginEnd &
- \begin{lstlisting}[escapeinside={(*@}{@*)},nolol=true]
+ \begin{lstlisting}[style=tcblatex,escapeinside={(*@}{@*)},nolol=true]
before words(*@$\BeginStartsOnOwnLine$@*)
\[(*@$\BodyStartsOnOwnLine$@*)
body of special(*@$\EndStartsOnOwnLine$@*)
Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsec-commands-and-their-options.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsec-commands-and-their-options.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsec-commands-and-their-options.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -8,9 +8,9 @@
\yamltitle{commandCodeBlocks}*{fields}
The \texttt{commandCodeBlocks} field%
- \announce*{2017-08-21}*{commandCodeBlocks} contains a few switches detailed in \cref{lst:commandCodeBlocks}.
+ \announce{2017-08-21}*{commandCodeBlocks} contains a few switches detailed in \cref{lst:commandCodeBlocks}.
- \cmhlistingsfromfile*[style=commandCodeBlocks]{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{commandCodeBlocks}}{lst:commandCodeBlocks}
+ \cmhlistingsfromfile[style=commandCodeBlocks]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{commandCodeBlocks}}{lst:commandCodeBlocks}
\yamltitle{roundParenthesesAllowed}{0|1}
@@ -18,11 +18,11 @@
let's consider the code given in \cref{lst:pstricks1}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[columns=fixed]{demonstrations/pstricks1.tex}{\texttt{pstricks1.tex}}{lst:pstricks1}
+ \cmhlistingsfromfile{demonstrations/pstricks1.tex}{\texttt{pstricks1.tex}}{lst:pstricks1}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[columns=fixed]{demonstrations/pstricks1-default.tex}{\texttt{pstricks1} default output}{lst:pstricks1-default}
+ \cmhlistingsfromfile{demonstrations/pstricks1-default.tex}{\texttt{pstricks1} default output}{lst:pstricks1-default}
\end{minipage}
Notice that the \lstinline!\defFunction! command has an optional argument, followed by a
@@ -46,7 +46,7 @@
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/noRoundParentheses.yaml}[yaml-TCB]{\texttt{noRoundParentheses.yaml}}{lst:noRoundParentheses}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/noRoundParentheses.yaml}[yaml-TCB]{\texttt{noRoundParentheses.yaml}}{lst:noRoundParentheses}
\end{minipage}
Notice the difference between \cref{lst:pstricks1-default} and \cref{lst:pstricks1-nrp}; in particular, in \cref{lst:pstricks1-nrp}, because
@@ -61,11 +61,11 @@
then the output is as in \cref{lst:pstricks1-indent-rules}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/pstricks1-indent-rules.tex}{\texttt{pstricks1.tex} using \cref{lst:defFunction}}{lst:pstricks1-indent-rules}
+ \cmhlistingsfromfile[showspaces=true]{demonstrations/pstricks1-indent-rules.tex}{\texttt{pstricks1.tex} using \cref{lst:defFunction}}{lst:pstricks1-indent-rules}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/defFunction.yaml}[yaml-TCB]{\texttt{defFunction.yaml}}{lst:defFunction}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/defFunction.yaml}[yaml-TCB]{\texttt{defFunction.yaml}}{lst:defFunction}
\end{minipage}
Notice in \cref{lst:pstricks1-indent-rules} that the \emph{body} of the \lstinline!defFunction! command i.e, the subsequent lines
@@ -76,11 +76,11 @@
\texttt{latexindent.pl} gives the default output in \cref{lst:tikz-node1-default}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[columns=fixed]{demonstrations/tikz-node1.tex}{\texttt{tikz-node1.tex}}{lst:tikz-node1}
+ \cmhlistingsfromfile[columns=fixed]*{demonstrations/tikz-node1.tex}{\texttt{tikz-node1.tex}}{lst:tikz-node1}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[columns=fixed]{demonstrations/tikz-node1-default.tex}{\texttt{tikz-node1} default output}{lst:tikz-node1-default}
+ \cmhlistingsfromfile[columns=fixed]*{demonstrations/tikz-node1-default.tex}{\texttt{tikz-node1} default output}{lst:tikz-node1-default}
\end{minipage}
With reference to \vref{lst:commandCodeBlocks}, we see that the strings
@@ -108,11 +108,11 @@
we receive the output given in \cref{lst:tikz-node1-draw}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/tikz-node1-draw.tex}{\texttt{tikz-node1.tex} using \cref{lst:draw}}{lst:tikz-node1-draw}
+ \cmhlistingsfromfile[showspaces=true]{demonstrations/tikz-node1-draw.tex}{\texttt{tikz-node1.tex} using \cref{lst:draw}}{lst:tikz-node1-draw}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/draw.yaml}[yaml-TCB]{\texttt{draw.yaml}}{lst:draw}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/draw.yaml}[yaml-TCB]{\texttt{draw.yaml}}{lst:draw}
\end{minipage}
Notice that each line after the \lstinline!\draw! command (its `body') in \cref{lst:tikz-node1-draw} has been given the
@@ -129,7 +129,7 @@
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/no-to.yaml}[yaml-TCB]{\texttt{no-to.yaml}}{lst:no-to}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/no-to.yaml}[yaml-TCB]{\texttt{no-to.yaml}}{lst:no-to}
\end{minipage}
In this case, \texttt{latexindent.pl} sees that:
@@ -141,7 +141,7 @@
\yamltitle{commandNameSpecial}*{fields}
There are some special command names%
- \announce*{2017-08-21}{commandNameSpecial} that do not fit within the names recognized by \texttt{latexindent.pl},
+ \announce{2017-08-21}{commandNameSpecial} that do not fit within the names recognized by \texttt{latexindent.pl},
the first one of which is \lstinline!\@ifnextchar[!. From the perspective of \texttt{latexindent.pl}, the whole of the
text \lstinline!\@ifnextchar[! is is a command, because it is
immediately followed by sets of mandatory arguments. However, without the \texttt{commandNameSpecial} field, \texttt{latexindent.pl}
@@ -150,11 +150,11 @@
For example, consider the sample file in \cref{lst:ifnextchar}, which has default output in \cref{lst:ifnextchar-default}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile*{demonstrations/ifnextchar.tex}{\texttt{ifnextchar.tex}}{lst:ifnextchar}
+ \cmhlistingsfromfile{demonstrations/ifnextchar.tex}{\texttt{ifnextchar.tex}}{lst:ifnextchar}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile*{demonstrations/ifnextchar-default.tex}{\texttt{ifnextchar.tex} default output}{lst:ifnextchar-default}
+ \cmhlistingsfromfile{demonstrations/ifnextchar-default.tex}{\texttt{ifnextchar.tex} default output}{lst:ifnextchar-default}
\end{minipage}
Notice that in \cref{lst:ifnextchar-default} the \texttt{parbox} command has been able to indent its body, because \texttt{latexindent.pl}
@@ -166,9 +166,9 @@
command has not been found.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile*{demonstrations/ifnextchar-off.tex}{\texttt{ifnextchar.tex} using \cref{lst:no-ifnextchar}}{lst:ifnextchar-off}
+ \cmhlistingsfromfile{demonstrations/ifnextchar-off.tex}{\texttt{ifnextchar.tex} using \cref{lst:no-ifnextchar}}{lst:ifnextchar-off}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile*[style=yaml-LST]{demonstrations/no-ifnextchar.yaml}[yaml-TCB]{\texttt{no-ifnextchar.yaml}}{lst:no-ifnextchar}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/no-ifnextchar.yaml}[yaml-TCB]{\texttt{no-ifnextchar.yaml}}{lst:no-ifnextchar}
\end{minipage}
Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsec-conflicting-poly-switches.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsec-conflicting-poly-switches.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsec-conflicting-poly-switches.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -12,7 +12,7 @@
\end{minipage}
\hfill
\begin{minipage}{.55\linewidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mycom-mlb4.yaml}[MLB-TCB,width=\linewidth]{\texttt{mycom-mlb4.yaml}}{lst:mycom-mlb4}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycom-mlb4.yaml}[MLB-TCB,width=\linewidth]{\texttt{mycom-mlb4.yaml}}{lst:mycom-mlb4}
\end{minipage}
Studying \cref{lst:mycom-mlb4}, we see that the two poly-switches are at opposition with one another:
@@ -35,7 +35,7 @@
\end{minipage}
\hfill
\begin{minipage}{.55\linewidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mycom-mlb5.yaml}[MLB-TCB,width=\linewidth]{\texttt{mycom-mlb5.yaml}}{lst:mycom-mlb5}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycom-mlb5.yaml}[MLB-TCB,width=\linewidth]{\texttt{mycom-mlb5.yaml}}{lst:mycom-mlb5}
\end{minipage}
As previously, the most-recently-processed code block takes priority -- as before, the second (i.e, \emph{last}) argument. Exploring this
@@ -46,7 +46,7 @@
\end{minipage}
\hfill
\begin{minipage}{.55\linewidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mycom-mlb6.yaml}[MLB-TCB,width=\linewidth]{\texttt{mycom-mlb6.yaml}}{lst:mycom-mlb6}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycom-mlb6.yaml}[MLB-TCB,width=\linewidth]{\texttt{mycom-mlb6.yaml}}{lst:mycom-mlb6}
\end{minipage}
Note that a \lstinline!%! \emph{has} been added to the trailing first \lstinline!}!; this is because:
@@ -73,7 +73,7 @@
\end{minipage}
\hfill
\begin{minipage}{.55\linewidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/nested-env-mlb1.yaml}[MLB-TCB,width=\linewidth]{\texttt{nested-env-mlb1.yaml}}{lst:nested-env-mlb1-yaml}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/nested-env-mlb1.yaml}[MLB-TCB,width=\linewidth]{\texttt{nested-env-mlb1.yaml}}{lst:nested-env-mlb1-yaml}
\end{minipage}
In \cref{lst:nested-env-mlb1}, let's first of all note that both environments have received the appropriate (default) indentation; secondly,
@@ -121,7 +121,7 @@
\end{minipage}
\hfill
\begin{minipage}{.55\linewidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/nested-env-mlb2.yaml}[MLB-TCB,width=\linewidth]{\texttt{nested-env-mlb2.yaml}}{lst:nested-env-mlb2}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/nested-env-mlb2.yaml}[MLB-TCB,width=\linewidth]{\texttt{nested-env-mlb2.yaml}}{lst:nested-env-mlb2}
\end{minipage}
During Phase 1:
Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsec-partnering-poly-switches.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsec-partnering-poly-switches.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsec-partnering-poly-switches.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -21,7 +21,7 @@
\end{minipage}
\hfill
\begin{minipage}{.55\linewidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mycom-mlb1.yaml}[MLB-TCB,width=\linewidth]{\texttt{mycom-mlb1.yaml}}{lst:mycom-mlb1}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycom-mlb1.yaml}[MLB-TCB,width=\linewidth]{\texttt{mycom-mlb1.yaml}}{lst:mycom-mlb1}
\end{minipage}
Now let's change the YAML file so that it is as in \cref{lst:mycom-mlb2}; upon running the analogous command to that given above,
@@ -32,7 +32,7 @@
\end{minipage}
\hfill
\begin{minipage}{.55\linewidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mycom-mlb2.yaml}[MLB-TCB,width=\linewidth]{\texttt{mycom-mlb2.yaml}}{lst:mycom-mlb2}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycom-mlb2.yaml}[MLB-TCB,width=\linewidth]{\texttt{mycom-mlb2.yaml}}{lst:mycom-mlb2}
\end{minipage}
Now let's change the YAML file so that it is as in \cref{lst:mycom-mlb3}; upon running the analogous command to that given above,
@@ -43,5 +43,5 @@
\end{minipage}
\hfill
\begin{minipage}{.55\linewidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mycom-mlb3.yaml}[MLB-TCB,width=\linewidth]{\texttt{mycom-mlb3.yaml}}{lst:mycom-mlb3}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycom-mlb3.yaml}[MLB-TCB,width=\linewidth]{\texttt{mycom-mlb3.yaml}}{lst:mycom-mlb3}
\end{minipage}
Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-commands-with-arguments.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-commands-with-arguments.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-commands-with-arguments.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -16,11 +16,11 @@
either in `scalar' form, or in `field' form, as shown in \cref{lst:mycommand-noAdd1,lst:mycommand-noAdd2}
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mycommand-noAdd1.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{mycommand-noAdd1.yaml}}{lst:mycommand-noAdd1}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycommand-noAdd1.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{mycommand-noAdd1.yaml}}{lst:mycommand-noAdd1}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mycommand-noAdd2.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{mycommand-noAdd2.yaml}}{lst:mycommand-noAdd2}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycommand-noAdd2.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{mycommand-noAdd2.yaml}}{lst:mycommand-noAdd2}
\end{minipage}
After running the following commands,
@@ -46,11 +46,11 @@
are given in \cref{lst:mycommand-noAdd3,lst:mycommand-noAdd4}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mycommand-noAdd3.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{mycommand-noAdd3.yaml}}{lst:mycommand-noAdd3}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycommand-noAdd3.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{mycommand-noAdd3.yaml}}{lst:mycommand-noAdd3}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mycommand-noAdd4.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{mycommand-noAdd4.yaml}}{lst:mycommand-noAdd4}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycommand-noAdd4.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{mycommand-noAdd4.yaml}}{lst:mycommand-noAdd4}
\end{minipage}
After running the following commands,
@@ -74,11 +74,11 @@
fixed as in \cref{lst:mycommand-noAdd5,lst:mycommand-noAdd6}.\label{page:command:noAddGlobal}
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mycommand-noAdd5.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{mycommand-noAdd5.yaml}}{lst:mycommand-noAdd5}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycommand-noAdd5.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{mycommand-noAdd5.yaml}}{lst:mycommand-noAdd5}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mycommand-noAdd6.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{mycommand-noAdd6.yaml}}{lst:mycommand-noAdd6}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycommand-noAdd6.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{mycommand-noAdd6.yaml}}{lst:mycommand-noAdd6}
\end{minipage}
After running the following commands,
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 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-and-their-arguments.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -10,11 +10,11 @@
as demonstrated in \cref{lst:myenv-noAdd1,lst:myenv-noAdd2}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/myenv-noAdd1.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-noAdd1.yaml}}{lst:myenv-noAdd1}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/myenv-noAdd1.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-noAdd1.yaml}}{lst:myenv-noAdd1}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/myenv-noAdd2.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-noAdd2.yaml}}{lst:myenv-noAdd2}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/myenv-noAdd2.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-noAdd2.yaml}}{lst:myenv-noAdd2}
\end{minipage}
On applying either of the following commands,
@@ -36,11 +36,11 @@
we obtain the output given in \cref{lst:myenv-output-4}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/myenv-noAdd3.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-noAdd3.yaml}}{lst:myenv-noAdd3}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/myenv-noAdd3.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-noAdd3.yaml}}{lst:myenv-noAdd3}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/myenv-noAdd4.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-noAdd4.yaml}}{lst:myenv-noAdd4}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/myenv-noAdd4.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-noAdd4.yaml}}{lst:myenv-noAdd4}
\end{minipage}
\cmhlistingsfromfile{demonstrations/myenvironment-simple-noAdd-body4.tex}{\texttt{myenv.tex output} (using either \cref{lst:myenv-noAdd3} or \cref{lst:myenv-noAdd4})}{lst:myenv-output-4}
@@ -59,11 +59,11 @@
We may customise \texttt{noAdditionalIndent} for optional and mandatory arguments of the \texttt{myenv} environment, as shown in, for example, \cref{lst:myenv-noAdd5,lst:myenv-noAdd6}.
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/myenv-noAdd5.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-noAdd5.yaml}}{lst:myenv-noAdd5}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/myenv-noAdd5.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-noAdd5.yaml}}{lst:myenv-noAdd5}
\end{minipage}
\hfill
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/myenv-noAdd6.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-noAdd6.yaml}}{lst:myenv-noAdd6}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/myenv-noAdd6.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-noAdd6.yaml}}{lst:myenv-noAdd6}
\end{minipage}
Upon running
@@ -88,11 +88,11 @@
\cref{lst:myenv-rules1,lst:myenv-rules2}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/myenv-rules1.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-rules1.yaml}}{lst:myenv-rules1}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/myenv-rules1.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-rules1.yaml}}{lst:myenv-rules1}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/myenv-rules2.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-rules2.yaml}}{lst:myenv-rules2}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/myenv-rules2.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-rules2.yaml}}{lst:myenv-rules2}
\end{minipage}
On applying either of the following commands,
@@ -103,7 +103,7 @@
we obtain the output given in \cref{lst:myenv-rules-output}; note in particular that the environment \texttt{myenv}
has received one tab (from the \texttt{outer} environment) plus three spaces from \cref{lst:myenv-rules1} or \ref{lst:myenv-rules2}.
- \cmhlistingsfromfile{demonstrations/myenv-rules1.tex}{\texttt{myenv.tex output (using either \cref{lst:myenv-rules1} or \cref{lst:myenv-rules2})}}{lst:myenv-rules-output}
+ \cmhlistingsfromfile[showtabs=true,showspaces=true]{demonstrations/myenv-rules1.tex}{\texttt{myenv.tex output (using either \cref{lst:myenv-rules1} or \cref{lst:myenv-rules2})}}{lst:myenv-rules-output}
If you specify a field in \texttt{indentRules} using anything other than horizontal space, it will be ignored.
@@ -111,18 +111,18 @@
\begin{commandshell}
latexindent.pl myenv-args.tex -l=myenv-rules1.yaml
\end{commandshell}
- we obtain the output in \cref{lst:myenv-args-rules1}; note that the body, optional argument and mandatory argument have \emph{all}
- received the same customised indentation.
- \cmhlistingsfromfile{demonstrations/myenvironment-args-rules1.tex}{\texttt{myenv-args.tex} using \cref{lst:myenv-rules1}}{lst:myenv-args-rules1}
+ we obtain the output in \cref{lst:myenv-args-rules1}; note that the body, optional argument and mandatory argument of \texttt{myenv}
+ have \emph{all} received the same customised indentation.
+ \cmhlistingsfromfile[showtabs=true,showspaces=true]{demonstrations/myenvironment-args-rules1.tex}{\texttt{myenv-args.tex} using \cref{lst:myenv-rules1}}{lst:myenv-args-rules1}
You can specify different indentation rules for the different features using, for example, \cref{lst:myenv-rules3,lst:myenv-rules4}
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/myenv-rules3.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-rules3.yaml}}{lst:myenv-rules3}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/myenv-rules3.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-rules3.yaml}}{lst:myenv-rules3}
\end{minipage}
\hfill
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/myenv-rules4.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-rules4.yaml}}{lst:myenv-rules4}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/myenv-rules4.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{myenv-rules4.yaml}}{lst:myenv-rules4}
\end{minipage}
After running
@@ -132,13 +132,15 @@
\end{commandshell}
then we obtain the respective outputs given in \cref{lst:myenv-args-rules3,lst:myenv-args-rules4}.
- \begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/myenvironment-args-rules3.tex}{\texttt{myenv-args.tex} using \cref{lst:myenv-rules3}}{lst:myenv-args-rules3}
- \end{minipage}
- \hfill
- \begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/myenvironment-args-rules4.tex}{\texttt{myenv-args.tex} using \cref{lst:myenv-rules4}}{lst:myenv-args-rules4}
- \end{minipage}
+ \begin{widepage}
+ \begin{minipage}{.5\textwidth}
+ \cmhlistingsfromfile[showtabs=true,showspaces=true]{demonstrations/myenvironment-args-rules3.tex}{\texttt{myenv-args.tex} using \cref{lst:myenv-rules3}}{lst:myenv-args-rules3}
+ \end{minipage}%
+ \hfill
+ \begin{minipage}{.5\textwidth}
+ \cmhlistingsfromfile[showtabs=true,showspaces=true]{demonstrations/myenvironment-args-rules4.tex}{\texttt{myenv-args.tex} using \cref{lst:myenv-rules4}}{lst:myenv-args-rules4}
+ \end{minipage}
+ \end{widepage}
Note that in \cref{lst:myenv-args-rules3}, the optional argument has only received a single space of indentation, while the mandatory argument
has received the default (tab) indentation; the environment body has received three spaces of indentation.
@@ -148,7 +150,7 @@
\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}
+ \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
@@ -179,11 +181,11 @@
arguments; on referencing \cref{lst:opt-args-no-add-glob,lst:mand-args-no-add-glob}
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/opt-args-no-add-glob.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{opt-args-no-add-glob.yaml}}{lst:opt-args-no-add-glob}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/opt-args-no-add-glob.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{opt-args-no-add-glob.yaml}}{lst:opt-args-no-add-glob}
\end{minipage}
\hfill
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mand-args-no-add-glob.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{mand-args-no-add-glob.yaml}}{lst:mand-args-no-add-glob}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mand-args-no-add-glob.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{mand-args-no-add-glob.yaml}}{lst:mand-args-no-add-glob}
\end{minipage}
we may run the commands
@@ -205,7 +207,7 @@
\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}
+ \cmhlistingsfromfile[style=indentRulesGlobalEnv]*{../defaultSettings.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{indentRulesGlobal}}{lst:indentRulesGlobal:environments}
\end{wrapfigure}
The final check that \texttt{latexindent.pl} will make is to look for \texttt{indentRulesGlobal} as detailed in \cref{lst:indentRulesGlobal:environments}; if you change the \texttt{environments}
field to anything involving horizontal space, say \lstinline!" "!, and then run the following commands
@@ -220,21 +222,21 @@
but \texttt{myenv} has received \lstinline!" "!, as specified by the particular \texttt{indentRules} for \texttt{myenv} \vref{lst:myenv-rules1}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/myenvironment-args-global-rules1.tex}{\texttt{myenv-args.tex} using \cref{lst:indentRulesGlobal:environments}}{lst:myenv-args-indent-rules-global1}
+ \cmhlistingsfromfile[showspaces=true]{demonstrations/myenvironment-args-global-rules1.tex}{\texttt{myenv-args.tex} using \cref{lst:indentRulesGlobal:environments}}{lst:myenv-args-indent-rules-global1}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/myenvironment-args-global-rules2.tex}{\texttt{myenv-args.tex} using \cref{lst:myenv-rules1,lst:indentRulesGlobal:environments}}{lst:myenv-args-indent-rules-global2}
+ \cmhlistingsfromfile[showspaces=true]{demonstrations/myenvironment-args-global-rules2.tex}{\texttt{myenv-args.tex} using \cref{lst:myenv-rules1,lst:indentRulesGlobal:environments}}{lst:myenv-args-indent-rules-global2}
\end{minipage}
You can specify \texttt{indentRulesGlobal} for both optional and mandatory arguments, as detailed in \cref{lst:opt-args-indent-rules-glob,lst:mand-args-indent-rules-glob}
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/opt-args-indent-rules-glob.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{opt-args-indent-rules-glob.yaml}}{lst:opt-args-indent-rules-glob}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/opt-args-indent-rules-glob.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{opt-args-indent-rules-glob.yaml}}{lst:opt-args-indent-rules-glob}
\end{minipage}
\hfill
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/mand-args-indent-rules-glob.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{mand-args-indent-rules-glob.yaml}}{lst:mand-args-indent-rules-glob}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mand-args-indent-rules-glob.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{mand-args-indent-rules-glob.yaml}}{lst:mand-args-indent-rules-glob}
\end{minipage}
Upon running the following commands
@@ -246,10 +248,12 @@
argument in \cref{lst:myenv-args-indent-rules-global3} has received two tabs worth of indentation, while the \emph{mandatory} argument has
done so in \cref{lst:myenv-args-indent-rules-global4}.
- \begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/myenvironment-args-global-rules3.tex}{\texttt{myenv-args.tex} using \cref{lst:opt-args-indent-rules-glob}}{lst:myenv-args-indent-rules-global3}
- \end{minipage}
- \hfill
- \begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/myenvironment-args-global-rules4.tex}{\texttt{myenv-args.tex} using \cref{lst:mand-args-indent-rules-glob}}{lst:myenv-args-indent-rules-global4}
- \end{minipage}
+ \begin{widepage}
+ \begin{minipage}{.55\textwidth}
+ \cmhlistingsfromfile[showtabs=true]{demonstrations/myenvironment-args-global-rules3.tex}{\texttt{myenv-args.tex} using \cref{lst:opt-args-indent-rules-glob}}{lst:myenv-args-indent-rules-global3}
+ \end{minipage}
+ \hfill
+ \begin{minipage}{.55\textwidth}
+ \cmhlistingsfromfile[showtabs=true]{demonstrations/myenvironment-args-global-rules4.tex}{\texttt{myenv-args.tex} using \cref{lst:mand-args-indent-rules-glob}}{lst:myenv-args-indent-rules-global4}
+ \end{minipage}
+ \end{widepage}
Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-with-items.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-with-items.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-environments-with-items.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -12,11 +12,11 @@
\texttt{indentRules}, as in \cref{lst:item-rules1}
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/item-noAdd1.yaml}[yaml-TCB]{\texttt{item-noAdd1.yaml}}{lst:item-noAdd1}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/item-noAdd1.yaml}[yaml-TCB]{\texttt{item-noAdd1.yaml}}{lst:item-noAdd1}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/item-rules1.yaml}[yaml-TCB]{\texttt{item-rules1.yaml}}{lst:item-rules1}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/item-rules1.yaml}[yaml-TCB]{\texttt{item-rules1.yaml}}{lst:item-rules1}
\end{minipage}
Upon running the following commands
@@ -33,7 +33,7 @@
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/items1-rules1.tex}{\texttt{items1.tex} using \cref{lst:item-rules1}}{lst:items1-rules1}
+ \cmhlistingsfromfile[showtabs=true,showspaces=true]{demonstrations/items1-rules1.tex}{\texttt{items1.tex} using \cref{lst:item-rules1}}{lst:items1-rules1}
\end{minipage}
Alternatively, you might like to populate \texttt{noAdditionalIndentGlobal} or \texttt{indentRulesGlobal} using the \texttt{items}
@@ -42,11 +42,11 @@
as the \texttt{item} command is a member of \texttt{indentRules} by default.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/items-noAdditionalGlobal.yaml}[yaml-TCB]{\texttt{items-noAdditionalGlobal.yaml}}{lst:items-noAdditionalGlobal}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/items-noAdditionalGlobal.yaml}[yaml-TCB]{\texttt{items-noAdditionalGlobal.yaml}}{lst:items-noAdditionalGlobal}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/items-indentRulesGlobal.yaml}[yaml-TCB]{\texttt{items-indentRulesGlobal.yaml}}{lst:items-indentRulesGlobal}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/items-indentRulesGlobal.yaml}[yaml-TCB]{\texttt{items-indentRulesGlobal.yaml}}{lst:items-indentRulesGlobal}
\end{minipage}
Upon running the following commands,
Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-headings.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-headings.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-headings.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -17,7 +17,7 @@
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/headings3.yaml}[yaml-TCB]{\texttt{headings3.yaml}}{lst:headings3yaml}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/headings3.yaml}[yaml-TCB]{\texttt{headings3.yaml}}{lst:headings3yaml}
\end{minipage}
If we specify \texttt{noAdditionalIndent} as in \cref{lst:headings4yaml} and run the command
@@ -32,7 +32,7 @@
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/headings4.yaml}[yaml-TCB]{\texttt{headings4.yaml}}{lst:headings4yaml}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/headings4.yaml}[yaml-TCB]{\texttt{headings4.yaml}}{lst:headings4yaml}
\end{minipage}
Similarly, if we specify \texttt{indentRules} as in \cref{lst:headings5yaml} and run analogous commands to those above,
@@ -40,11 +40,11 @@
\emph{after the heading} of \texttt{paragraph} have \emph{all} received three tabs worth of indentation.
\begin{minipage}{.55\textwidth}
- \cmhlistingsfromfile{demonstrations/headings2-mod5.tex}{\texttt{headings2.tex} using \cref{lst:headings5yaml}}{lst:headings2-mod5}
+ \cmhlistingsfromfile[showtabs=true]{demonstrations/headings2-mod5.tex}{\texttt{headings2.tex} using \cref{lst:headings5yaml}}{lst:headings2-mod5}
\end{minipage}%
\hfill
\begin{minipage}{.42\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/headings5.yaml}[yaml-TCB]{\texttt{headings5.yaml}}{lst:headings5yaml}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/headings5.yaml}[yaml-TCB]{\texttt{headings5.yaml}}{lst:headings5yaml}
\end{minipage}
We may, instead, specify \texttt{noAdditionalIndent} in `field' form, as in \cref{lst:headings6yaml} which gives the output in \cref{lst:headings2-mod6}.
@@ -54,7 +54,7 @@
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/headings6.yaml}[yaml-TCB]{\texttt{headings6.yaml}}{lst:headings6yaml}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/headings6.yaml}[yaml-TCB]{\texttt{headings6.yaml}}{lst:headings6yaml}
\end{minipage}
Analogously, we may specify \texttt{indentRules} as in \cref{lst:headings7yaml} which gives the output in \cref{lst:headings2-mod7};
@@ -62,11 +62,11 @@
received three tabs worth of indentation.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/headings2-mod7.tex}{\texttt{headings2.tex} using \cref{lst:headings7yaml}}{lst:headings2-mod7}
+ \cmhlistingsfromfile[showtabs=true]{demonstrations/headings2-mod7.tex}{\texttt{headings2.tex} using \cref{lst:headings7yaml}}{lst:headings2-mod7}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/headings7.yaml}[yaml-TCB]{\texttt{headings7.yaml}}{lst:headings7yaml}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/headings7.yaml}[yaml-TCB]{\texttt{headings7.yaml}}{lst:headings7yaml}
\end{minipage}
Finally, let's consider \texttt{noAdditionalIndentGlobal} and \texttt{indentRulesGlobal} shown in \cref{lst:headings8yaml,lst:headings9yaml}
@@ -81,13 +81,13 @@
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/headings8.yaml}[yaml-TCB]{\texttt{headings8.yaml}}{lst:headings8yaml}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/headings8.yaml}[yaml-TCB]{\texttt{headings8.yaml}}{lst:headings8yaml}
\end{minipage}
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/headings2-mod9.tex}{\texttt{headings2.tex} using \cref{lst:headings9yaml}}{lst:headings2-mod9}
+ \cmhlistingsfromfile[showspaces=true,showtabs=true]{demonstrations/headings2-mod9.tex}{\texttt{headings2.tex} using \cref{lst:headings9yaml}}{lst:headings2-mod9}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/headings9.yaml}[yaml-TCB]{\texttt{headings9.yaml}}{lst:headings9yaml}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/headings9.yaml}[yaml-TCB]{\texttt{headings9.yaml}}{lst:headings9yaml}
\end{minipage}
Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-ifelsefi.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-ifelsefi.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-ifelsefi.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -18,11 +18,11 @@
Examples are shown in \cref{lst:ifnum-noAdd,lst:ifnum-indent-rules}.
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/ifnum-noAdd.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{ifnum-noAdd.yaml}}{lst:ifnum-noAdd}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/ifnum-noAdd.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{ifnum-noAdd.yaml}}{lst:ifnum-noAdd}
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/ifnum-indent-rules.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{ifnum-indent-rules.yaml}}{lst:ifnum-indent-rules}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/ifnum-indent-rules.yaml}[width=.8\linewidth,before=\centering,yaml-TCB]{\texttt{ifnum-indent-rules.yaml}}{lst:ifnum-indent-rules}
\end{minipage}
After running the following commands,
@@ -39,17 +39,17 @@
\end{minipage}
\hfill
\begin{minipage}{.5\textwidth}
- \cmhlistingsfromfile{demonstrations/ifelsefi1-indent-rules.tex}{\texttt{ifelsefi1.tex} using \cref{lst:ifnum-indent-rules}}{lst:ifelsefi1-output-indent-rules}
+ \cmhlistingsfromfile[showspaces=true,showtabs=true]{demonstrations/ifelsefi1-indent-rules.tex}{\texttt{ifelsefi1.tex} using \cref{lst:ifnum-indent-rules}}{lst:ifelsefi1-output-indent-rules}
\end{minipage}
We may specify \texttt{noAdditionalIndentGlobal} and \texttt{indentRulesGlobal} as in \cref{lst:ifelsefi-noAdd-glob,lst:ifelsefi-indent-rules-global}.
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/ifelsefi-noAdd-glob.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{ifelsefi-noAdd-glob.yaml}}{lst:ifelsefi-noAdd-glob}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/ifelsefi-noAdd-glob.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{ifelsefi-noAdd-glob.yaml}}{lst:ifelsefi-noAdd-glob}
\end{minipage}
\hfill
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/ifelsefi-indent-rules-global.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{ifelsefi-indent-rules-global.yaml}}{lst:ifelsefi-indent-rules-global}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/ifelsefi-indent-rules-global.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{ifelsefi-indent-rules-global.yaml}}{lst:ifelsefi-indent-rules-global}
\end{minipage}
Upon running the following commands
@@ -66,5 +66,5 @@
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/ifelsefi1-indent-rules-global.tex}{\texttt{ifelsefi1.tex} using \cref{lst:ifelsefi-indent-rules-global}}{lst:ifelsefi1-output-indent-rules-global}
+ \cmhlistingsfromfile[showspaces=true]{demonstrations/ifelsefi1-indent-rules-global.tex}{\texttt{ifelsefi1.tex} using \cref{lst:ifelsefi-indent-rules-global}}{lst:ifelsefi1-output-indent-rules-global}
\end{minipage}
Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-no-add-remaining-code-blocks.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-no-add-remaining-code-blocks.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-no-add-remaining-code-blocks.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -22,7 +22,7 @@
\end{minipage}%
\hfill
\begin{minipage}{.5\textwidth}
- \cmhlistingsfromfile{demonstrations/pgfkeys1-default.tex}{\texttt{pgfkeys1.tex} default output}{lst:pgfkeys1:default}
+ \cmhlistingsfromfile[showtabs=true]{demonstrations/pgfkeys1-default.tex}{\texttt{pgfkeys1.tex} default output}{lst:pgfkeys1:default}
\end{minipage}%
In \cref{lst:pgfkeys1:default}, note that the maximum indentation is three tabs, and these come from:
@@ -48,7 +48,7 @@
\end{minipage}%
\hfill
\begin{minipage}{.5\textwidth}
- \cmhlistingsfromfile{demonstrations/child1-default.tex}{\texttt{child1.tex} default output}{lst:child1:default}
+ \cmhlistingsfromfile[showtabs=true]{demonstrations/child1-default.tex}{\texttt{child1.tex} default output}{lst:child1:default}
\end{minipage}%
In particular, \texttt{latexindent.pl} considers \texttt{child}, \texttt{parent} and \texttt{node} all to be \texttt{namedGroupingBracesBrackets}\footnote{
@@ -77,7 +77,7 @@
\end{minipage}%
\hfill
\begin{minipage}{.5\textwidth}
- \cmhlistingsfromfile{demonstrations/psforeach1-default.tex}{\texttt{psforeach1.tex} default output}{lst:psforeach:default}
+ \cmhlistingsfromfile[showtabs=true]{demonstrations/psforeach1-default.tex}{\texttt{psforeach1.tex} default output}{lst:psforeach:default}
\end{minipage}%
Referencing \cref{lst:psforeach:default}, there are \emph{three} sets of unnamed braces. Note also that the maximum value
@@ -100,10 +100,10 @@
\begin{widepage}
\begin{minipage}{.47\linewidth}
- \cmhlistingsfromfile[style=noAdditionalIndentGlobal]{../defaultSettings.yaml}[before=\centering,yaml-TCB]{\texttt{noAdditionalIndentGlobal}}{lst:noAdditionalIndentGlobal}
+ \cmhlistingsfromfile[style=noAdditionalIndentGlobal]*{../defaultSettings.yaml}[before=\centering,yaml-TCB]{\texttt{noAdditionalIndentGlobal}}{lst:noAdditionalIndentGlobal}
\end{minipage}%
\hfill
\begin{minipage}{.47\linewidth}
- \cmhlistingsfromfile[style=indentRulesGlobal]{../defaultSettings.yaml}[before=\centering,yaml-TCB]{\texttt{indentRulesGlobal}}{lst:indentRulesGlobal}
+ \cmhlistingsfromfile[style=indentRulesGlobal]*{../defaultSettings.yaml}[before=\centering,yaml-TCB]{\texttt{indentRulesGlobal}}{lst:indentRulesGlobal}
\end{minipage}%
\end{widepage}
Modified: trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-special.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-special.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/subsubsec-special.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -8,11 +8,11 @@
Examples are shown in \cref{lst:displayMath-noAdd,lst:displayMath-indent-rules}.
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/displayMath-noAdd.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{displayMath-noAdd.yaml}}{lst:displayMath-noAdd}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/displayMath-noAdd.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{displayMath-noAdd.yaml}}{lst:displayMath-noAdd}
\end{minipage}
\hfill
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/displayMath-indent-rules.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{displayMath-indent-rules.yaml}}{lst:displayMath-indent-rules}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/displayMath-indent-rules.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{displayMath-indent-rules.yaml}}{lst:displayMath-indent-rules}
\end{minipage}
After running the following commands,
@@ -29,17 +29,17 @@
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/special1-indent-rules.tex}{\texttt{special1.tex} using \cref{lst:displayMath-indent-rules}}{lst:special1-output-indent-rules}
+ \cmhlistingsfromfile[showtabs=true]{demonstrations/special1-indent-rules.tex}{\texttt{special1.tex} using \cref{lst:displayMath-indent-rules}}{lst:special1-output-indent-rules}
\end{minipage}
We may specify \texttt{noAdditionalIndentGlobal} and \texttt{indentRulesGlobal} as in \cref{lst:special-noAdd-glob,lst:special-indent-rules-global}.
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/special-noAdd-glob.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{special-noAdd-glob.yaml}}{lst:special-noAdd-glob}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/special-noAdd-glob.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{special-noAdd-glob.yaml}}{lst:special-noAdd-glob}
\end{minipage}
\hfill
\begin{minipage}{.49\textwidth}
- \cmhlistingsfromfile[style=yaml-LST]{demonstrations/special-indent-rules-global.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{special-indent-rules-global.yaml}}{lst:special-indent-rules-global}
+ \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/special-indent-rules-global.yaml}[width=.9\linewidth,before=\centering,yaml-TCB]{\texttt{special-indent-rules-global.yaml}}{lst:special-indent-rules-global}
\end{minipage}
Upon running the following commands
@@ -56,5 +56,5 @@
\end{minipage}
\hfill
\begin{minipage}{.45\textwidth}
- \cmhlistingsfromfile{demonstrations/special1-indent-rules-global.tex}{\texttt{special1.tex} using \cref{lst:special-indent-rules-global}}{lst:special1-output-indent-rules-global}
+ \cmhlistingsfromfile[showspaces=true]{demonstrations/special1-indent-rules-global.tex}{\texttt{special1.tex} using \cref{lst:special-indent-rules-global}}{lst:special1-output-indent-rules-global}
\end{minipage}
Modified: trunk/Master/texmf-dist/doc/support/latexindent/title.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/title.tex 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/doc/support/latexindent/title.tex 2018-01-13 22:26:56 UTC (rev 46303)
@@ -8,24 +8,19 @@
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.3
+ \centering\ttfamily\bfseries latexindent.pl\\[1cm] Version 3.4
\end{tcolorbox}
}
-\author{Chris Hughes \thanks{and contributors! See \vref{sec:contributors}. For
+\author{Chris Hughes \thanks{and contributors!
+ See \vref{sec:contributors}.
+ For
all communication, please visit \cite{latexindent-home}.}}
\maketitle
\begin{adjustwidth}{1cm}{1cm}
\small
- \texttt{latexindent.pl} is a \texttt{Perl} script that indents \texttt{.tex} (and other)
- files according to an indentation scheme that the user can modify to suit their
- taste. Environments, including those with alignment delimiters (such as \texttt{tabular}),
- and commands, including those that can split braces and brackets across lines,
- are \emph{usually} handled correctly by the script. Options for \texttt{verbatim}-like
- environments and commands, together with indentation after headings (such as \lstinline!chapter!, \lstinline!section!, etc)
- are also available. The script also has the ability to modifiy line breaks, and add
- comment symbols. All user options are customisable via the switches in the YAML interface.
+ \texttt{latexindent.pl} is a \texttt{Perl} script that indents \texttt{.tex} (and other) files according to an indentation scheme that the user can modify to suit their taste.
+ Environments, including those with alignment delimiters (such as \texttt{tabular}), and commands, including those that can split braces and brackets across lines, are \emph{usually} handled correctly by the script.
+ Options for \texttt{verbatim}-like environments and commands, together with indentation after headings (such as \lstinline!chapter!, \lstinline!section!, etc) are also available.
+ The script also has the ability to modifiy line breaks, and add comment symbols.
+ All user options are customisable via the switches in the YAML interface; you can find a quick start guide in \vref{sec:quickstart}.
\end{adjustwidth}
-\tableofcontents
-{\small
- \lstlistoflistings
-}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -20,10 +20,12 @@
use Unicode::GCString;
use Data::Dumper;
use Exporter qw/import/;
+use List::Util qw(max);
use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
use LatexIndent::Tokens qw/%tokens/;
+use LatexIndent::LogFile qw/$logger/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
our @EXPORT_OK = qw/align_at_ampersand find_aligned_block/;
our $alignmentBlockCounter;
@@ -38,16 +40,16 @@
# 1 & 2 & 3 & 4 \\
# 5 & & 6 & \\
# %* \end{tabular}
- $self->logger('looking for ALIGNED blocks marked by comments','heading')if($is_t_switch_active);
- $self->logger(Dumper(\%{$masterSettings{lookForAlignDelims}})) if($is_t_switch_active);
+ $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}}){
if(ref $yesno eq "HASH"){
$yesno = (defined ${$yesno}{delims} ) ? ${$yesno}{delims} : 1;
}
if($yesno){
- $self->logger("looking for $alignmentBlock:$yesno environments");
+ $logger->trace("looking for %*\\begin\{$alignmentBlock\} environments");
- my $noIndentRegExp = qr/
+ my $alignmentRegExp = qr/
(
(?!<\\)
%
@@ -71,13 +73,13 @@
#\R
/sx;
- while( ${$self}{body} =~ m/$noIndentRegExp/sx){
+ while( ${$self}{body} =~ m/$alignmentRegExp/sx){
${$self}{body} =~ s/
- $noIndentRegExp
+ $alignmentRegExp
/
# create a new Environment object
- my $alignmentBlock = LatexIndent::AlignmentAtAmpersand->new( begin=>$1,
+ my $alignmentBlockObj = LatexIndent::AlignmentAtAmpersand->new( begin=>$1,
body=>$2,
end=>$3,
name=>$alignmentBlock,
@@ -89,13 +91,17 @@
},
);
+ # log file output
+ $logger->trace("*Alignment block found: %*\\begin\{$alignmentBlock\}") if $is_t_switch_active;
+
# the settings and storage of most objects has a lot in common
- $self->get_settings_and_store_new_object($alignmentBlock);
+ $self->get_settings_and_store_new_object($alignmentBlockObj);
+
${@{${$self}{children}}[-1]}{replacementText};
/xseg;
}
} else {
- $self->logger("*not* looking for $alignmentBlock as $alignmentBlock:$yesno");
+ $logger->trace("*not* looking for $alignmentBlock as $alignmentBlock:$yesno");
}
}
return;
@@ -252,12 +258,16 @@
}
# output some of the info so far to the log file
- $self->logger("Maximum column sizes of horizontally stripped formatted block (${$self}{name}): @maximumColumnWidth") if $is_t_switch_active;
- $self->logger("align at ampersand: ${$self}{lookForAlignDelims}") if $is_t_switch_active;
- $self->logger("align at \\\\: ${$self}{alignDoubleBackSlash}") if $is_t_switch_active;
- $self->logger("spaces before \\\\: ${$self}{spacesBeforeDoubleBackSlash}") if $is_t_switch_active;
- $self->logger("multi column grouping: ${$self}{multiColumnGrouping}") if $is_t_switch_active;
- $self->logger("align rows without maximum delimeters: ${$self}{alignRowsWithoutMaxDelims}") if $is_t_switch_active;
+ $logger->trace("*Alignment at ampersand routine") if $is_t_switch_active;
+ $logger->trace("Maximum column sizes of horizontally stripped formatted block (${$self}{name}): @maximumColumnWidth") if $is_t_switch_active;
+ $logger->trace("align at ampersand: ${$self}{lookForAlignDelims}") if $is_t_switch_active;
+ $logger->trace("align at \\\\: ${$self}{alignDoubleBackSlash}") if $is_t_switch_active;
+ $logger->trace("spaces before \\\\: ${$self}{spacesBeforeDoubleBackSlash}") if $is_t_switch_active;
+ $logger->trace("multi column grouping: ${$self}{multiColumnGrouping}") if $is_t_switch_active;
+ $logger->trace("align rows without maximum delimeters: ${$self}{alignRowsWithoutMaxDelims}") if $is_t_switch_active;
+ $logger->trace("spaces before ampersand: ${$self}{spacesBeforeAmpersand}") if $is_t_switch_active;
+ $logger->trace("spaces after ampersand: ${$self}{spacesAfterAmpersand}") if $is_t_switch_active;
+ $logger->trace("justification: ${$self}{justification}") if $is_t_switch_active;
# acount for multicolumn grouping, if the appropriate switch is set
if(${$self}{multiColumnGrouping}){
@@ -306,19 +316,34 @@
$maxGroupingWidth = $groupingWidth if($groupingWidth > $maxGroupingWidth);
# the cells that receive multicolumn grouping need extra padding; in particular
- # the *last* cell of the multicol group receives the padding, hence the
- # use of $columnMax below
- if(defined @{${$_}{columnSizes}}[$columnMax] and ($columnWidth > ($groupingWidth+3*($multiColSpan-1)) ) and @{${$_}{columnSizes}}[$columnMax] >= 0){
- @{${$_}{multiColPadding}}[$columnMax] = $columnWidth-$groupingWidth-3*($multiColSpan-1);
+ # if the justification is *left*:
+ # the *last* cell of the multicol group receives the padding
+ # if the justification is *right*:
+ # the *first* cell of the multicol group receives the padding
+ #
+ # this motivates the introduction of $columnOffset, which is
+ # 0 if justification is left
+ # $multiColSpan if justification is right
+ my $columnOffset = (${$self}{justification} eq "left") ? $columnMax : $columnCount;
+ if(defined @{${$_}{columnSizes}}[$columnMax] and ($columnWidth > ($groupingWidth+(${$self}{spacesBeforeAmpersand}+1+${$self}{spacesAfterAmpersand})*($multiColSpan-1)) ) and @{${$_}{columnSizes}}[$columnMax] >= 0){
+ my $multiColPadding = $columnWidth-$groupingWidth-(${$self}{spacesBeforeAmpersand}+1+${$self}{spacesAfterAmpersand})*($multiColSpan-1);
+ # it's possible that multiColPadding might already be assigned; in which case,
+ # we need to check that the current value of $multiColPadding is greater than the existing one
+ if(defined @{${$_}{multiColPadding}}[$columnOffset]){
+ @{${$_}{multiColPadding}}[$columnOffset] = max($multiColPadding,@{${$_}{multiColPadding}}[$columnOffset]);
+ } else {
+ @{${$_}{multiColPadding}}[$columnOffset] = $multiColPadding;
+ }
+
# also need to account for maximum column width *including* other multicolumn statements
- if($maximumColumnWidthMC[$columnCount]>$columnWidth){
- @{${$_}{multiColPadding}}[$columnMax] += ($maximumColumnWidthMC[$columnCount]-$columnWidth);
+ if($maximumColumnWidthMC[$columnCount]>$columnWidth and $column !~ m/\\multicolumn\{(\d+)\}/){
+ @{${$_}{multiColPadding}}[$columnOffset] += ($maximumColumnWidthMC[$columnCount]-$columnWidth);
}
}
}
- # update it to account for the ampersands and 1 space either side of ampersands (total of 3)
- $maxGroupingWidth += ($multiColSpan-1)*3;
+ # update it to account for the ampersands and the spacing either side of ampersands
+ $maxGroupingWidth += ($multiColSpan-1)*(${$self}{spacesBeforeAmpersand}+1+${$self}{spacesAfterAmpersand});
# store the maxGroupingWidth for use in the next loop
@{${$_}{maxGroupingWidth}}[$columnCount] = $maxGroupingWidth;
@@ -362,12 +387,29 @@
# underneath the \multicolumn{} statement
my $maxGroupingWidth = ${${$_}{maxGroupingWidth}}[$columnCount];
+ # it's possible to have situations such as
+ #
+ # \multicolumn{3}{l}{one} & \multicolumn{3}{l}{two} & \\
+ # \multicolumn{6}{l}{one} & \\
+ #
+ # in which case we need to loop through the @maximumColumnWidthMC
+ my $groupingWidthMC = 0;
+ my $multicolsEncountered =0;
+ for ($columnCount..($columnCount + ($multiColSpan-1))){
+ if(defined $maximumColumnWidthMC[$_]){
+ $groupingWidthMC += $maximumColumnWidthMC[$_];
+ $multicolsEncountered++ if $maximumColumnWidthMC[$_]>0;
+ }
+ }
+
+ # need to account for (spacesBeforeAmpersands) + length of ampersands (which is 1) + (spacesAfterAmpersands)
+ $groupingWidthMC += ($multicolsEncountered-1)*(${$self}{spacesBeforeAmpersand}+1+${$self}{spacesAfterAmpersand});
+
# set the padding; we need
# maximum( $maxGroupingWidth, $maximumColumnWidthMC[$columnCount] )
- # rather than load another module to give the 'max' function, I use the ternary operator
my $maxValueToUse = 0;
if(defined $maximumColumnWidthMC[$columnCount]){
- $maxValueToUse = ($maxGroupingWidth>$maximumColumnWidthMC[$columnCount]?$maxGroupingWidth:$maximumColumnWidthMC[$columnCount]);
+ $maxValueToUse = max($maxGroupingWidth,$maximumColumnWidthMC[$columnCount],$groupingWidthMC);
} else {
$maxValueToUse = $maxGroupingWidth;
}
@@ -375,6 +417,19 @@
# calculate the padding
$padding = " " x ( $maxValueToUse >= $columnWidth ? $maxValueToUse - $columnWidth : 0 );
+ # to the log file
+ if($is_tt_switch_active){
+ $logger->trace("*---------column-------------");
+ $logger->trace($column);
+ $logger->trace("multiColSpan: $multiColSpan");
+ $logger->trace("groupingWidthMC: $groupingWidthMC");
+ $logger->trace("padding length: ",$maxValueToUse - $columnWidth);
+ $logger->trace("multicolsEncountered: $multicolsEncountered");
+ $logger->trace("maxValueToUse: $maxValueToUse");
+ $logger->trace("maximumColumnWidth: ",join(",", at maximumColumnWidth));
+ $logger->trace("maximumColumnWidthMC: ",join(",", at maximumColumnWidthMC));
+ }
+
# update the columnCount to account for the multiColSpan
$columnCount += $multiColSpan - 1;
} else {
@@ -383,13 +438,19 @@
}
# either way, the row is formed of "COLUMN + PADDING"
- $tmpRow .= $column.$padding.(defined @{${$_}{multiColPadding}}[$columnCount] ? " " x @{${$_}{multiColPadding}}[$columnCount]: q())." & ";
+ if(${$self}{justification} eq "left"){
+ $tmpRow .= $column.$padding.(defined @{${$_}{multiColPadding}}[$columnCount] ? " " x @{${$_}{multiColPadding}}[$columnCount]: q()).(" " x ${$self}{spacesBeforeAmpersand})."&".(" " x ${$self}{spacesAfterAmpersand});
+ } else {
+ $tmpRow .= $padding.(defined @{${$_}{multiColPadding}}[$columnCount] ? " " x @{${$_}{multiColPadding}}[$columnCount]: q()).$column.(" " x ${$self}{spacesBeforeAmpersand})."&".(" " x ${$self}{spacesAfterAmpersand});
+ }
$columnCount++;
}
# remove the final &
- $tmpRow =~ s/\h&\h*$/ /;
- $tmpRow =~ s/\h*$/ /;
+ $tmpRow =~ s/\h*&\h*$/ /;
+ my $finalSpacing = q();
+ $finalSpacing = " " x (${$self}{spacesBeforeDoubleBackSlash}) if ${$self}{spacesBeforeDoubleBackSlash}>=1;
+ $tmpRow =~ s/\h*$/$finalSpacing/;
# replace the row with the formatted row
${$_}{row} = $tmpRow;
@@ -430,7 +491,7 @@
# to the log file
if($is_tt_switch_active){
- $self->logger(${$_}{row},'ttrace') for @formattedBody;
+ $logger->trace(${$_}{row}) for @formattedBody;
}
# delete the original body
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Arguments.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Arguments.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Arguments.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -18,8 +18,9 @@
use warnings;
use LatexIndent::Tokens qw/%tokens/;
use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
-use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
+use LatexIndent::Switches qw/$is_m_switch_active $is_t_switch_active $is_tt_switch_active/;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
@@ -38,7 +39,8 @@
sub indent{
my $self = shift;
- $self->logger("Arguments object doesn't receive any direct indentation, but its children will...",'heading') if $is_t_switch_active;
+ ${$self}{body} =~ s/\R$//s if ($is_m_switch_active and ${$self}{IDFollowedImmediatelyByLineBreak});
+ $logger->trace("*Arguments object doesn't receive any direct indentation, but its children will...") if $is_t_switch_active;
return;
}
@@ -45,7 +47,7 @@
sub find_opt_mand_arguments{
my $self = shift;
- $self->logger("Searching ${$self}{name} for optional and mandatory arguments",'heading') if $is_t_switch_active;
+ $logger->trace("*Searching ${$self}{name} for optional and mandatory arguments") if $is_t_switch_active;
# blank line token
my $blankLineToken = $tokens{blanklines};
@@ -54,7 +56,7 @@
my $objectDependentOptAndMandRegExp = (defined ${$self}{optAndMandArgsRegExp} ? ${$self}{optAndMandArgsRegExp} : $optAndMandRegExpWithLineBreaks);
if(${$self}{body} =~ m/^$objectDependentOptAndMandRegExp\h*($trailingCommentRegExp)?/){
- $self->logger("Optional/Mandatory arguments found in ${$self}{name}: $1",'heading') if $is_t_switch_active;
+ $logger->trace("Optional/Mandatory arguments".(${$masterSettings{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
@@ -81,7 +83,7 @@
if(${$arguments}{body} =~ m/.*?((?<!\\)\{|\[)/s){
if($1 eq "\["){
- $self->logger("Searching for optional arguments, and then mandatory (optional found first)") if $is_t_switch_active;
+ $logger->trace("Searching for optional arguments, and then mandatory (optional found first)") if $is_t_switch_active;
# look for optional arguments
$arguments->find_optional_arguments;
@@ -88,7 +90,7 @@
# look for mandatory arguments
$arguments->find_mandatory_arguments;
} else {
- $self->logger("Searching for mandatory arguments, and then optional (mandatory found first)") if $is_t_switch_active;
+ $logger->trace("Searching for mandatory arguments, and then optional (mandatory found first)") if $is_t_switch_active;
# look for mandatory arguments
$arguments->find_mandatory_arguments;
@@ -97,7 +99,7 @@
}
} else {
- $self->logger("Searching for round brackets ONLY") if $is_t_switch_active;
+ $logger->trace("Searching for round brackets ONLY") if $is_t_switch_active;
# look for round brackets
$arguments->find_round_brackets;
}
@@ -111,8 +113,8 @@
and ${$self}{body} !~ m/^$blankLineToken/){
my $BodyStringLogFile = ${$self}{aliases}{BodyStartsOnOwnLine}||"BodyStartsOnOwnLine";
my $BeginStringLogFile = ${${${$arguments}{children}}[0]}{aliases}{BeginStartsOnOwnLine}||"BeginStartsOnOwnLine";
- $self->logger("$BodyStringLogFile = 1 (in ${$self}{name}), but first argument should not begin on its own line (see $BeginStringLogFile)") if $is_t_switch_active;
- $self->logger("Removing line breaks at the end of ${$self}{begin}") if $is_t_switch_active;
+ $logger->trace("$BodyStringLogFile = 1 (in ${$self}{name}), but first argument should not begin on its own line (see $BeginStringLogFile)") if $is_t_switch_active;
+ $logger->trace("Removing line breaks at the end of ${$self}{begin}") if $is_t_switch_active;
${$self}{begin} =~ s/\R*$//s;
${$self}{linebreaksAtEnd}{begin} = 0;
}
@@ -121,7 +123,7 @@
# situation: preserveBlankLines is active, so the body may well begin with a blank line token
# which means that ${$self}{linebreaksAtEnd}{begin} *should be* 1
if(${${${$arguments}{children}}[0]}{body} =~ m/^($blankLineToken)/){
- $self->logger("Updating {linebreaksAtEnd}{begin} for ${$self}{name} as $blankLineToken or blank line found at beginning of argument child") if $is_t_switch_active;
+ $logger->trace("Updating {linebreaksAtEnd}{begin} for ${$self}{name} as $blankLineToken or blank line found at beginning of argument child") if $is_t_switch_active;
${$self}{linebreaksAtEnd}{begin} = 1
}
@@ -140,20 +142,20 @@
my $BodyStringLogFile = ${$self}{aliases}{BodyStartsOnOwnLine}||"BodyStartsOnOwnLine";
my $BeginStringLogFile = ${${${$arguments}{children}}[0]}{aliases}{BeginStartsOnOwnLine}||"BeginStartsOnOwnLine";
my $BodyValue = (defined ${$self}{BodyStartsOnOwnLine}) ? ${$self}{BodyStartsOnOwnLine} : "0";
- $self->logger("$BodyStringLogFile = $BodyValue (in ${$self}{name}), but first argument *should* begin on its own line (see $BeginStringLogFile)") if $is_t_switch_active;
+ $logger->trace("$BodyStringLogFile = $BodyValue (in ${$self}{name}), but first argument *should* begin on its own line (see $BeginStringLogFile)") if $is_t_switch_active;
# possibly add a comment or a blank line, depending on if BeginStartsOnOwnLine == 2 or 3 respectively
# at the end of the begin statement
my $trailingCharacterToken = q();
if(${${${$arguments}{children}}[0]}{BeginStartsOnOwnLine}==1){
- $self->logger("Adding line breaks at the end of ${$self}{begin} (first argument, see $BeginStringLogFile == ${${${$arguments}{children}}[0]}{BeginStartsOnOwnLine})") if $is_t_switch_active;
+ $logger->trace("Adding line breaks at the end of ${$self}{begin} (first argument, see $BeginStringLogFile == ${${${$arguments}{children}}[0]}{BeginStartsOnOwnLine})") if $is_t_switch_active;
} elsif(${${${$arguments}{children}}[0]}{BeginStartsOnOwnLine}==2){
- $self->logger("Adding a % at the end of begin, ${$self}{begin} followed by a linebreak ($BeginStringLogFile == 2)") if $is_t_switch_active;
+ $logger->trace("Adding a % at the end of begin, ${$self}{begin} followed by a linebreak ($BeginStringLogFile == 2)") if $is_t_switch_active;
$trailingCharacterToken = "%".$self->add_comment_symbol;
- $self->logger("Removing trailing space on ${$self}{begin}") if $is_t_switch_active;
+ $logger->trace("Removing trailing space on ${$self}{begin}") if $is_t_switch_active;
${$self}{begin} =~ s/\h*$//s;
} elsif (${${${$arguments}{children}}[0]}{BeginStartsOnOwnLine}==3) {
- $self->logger("Adding a blank line immediately ${$self}{begin} ($BeginStringLogFile==3)") if $is_t_switch_active;
+ $logger->trace("Adding a blank line immediately ${$self}{begin} ($BeginStringLogFile==3)") if $is_t_switch_active;
$trailingCharacterToken = "\n".(${$masterSettings{modifyLineBreaks}}{preserveBlankLines}?$tokens{blanklines}:q());
}
@@ -168,7 +170,7 @@
# children need to receive ancestor information, see test-cases/commands/commands-triple-nested.tex
foreach (@{${$arguments}{children}}){
- $self->logger("Updating argument children of ${$self}{name} to include ${$self}{id} in ancestors") if $is_t_switch_active;
+ $logger->trace("Updating argument child of ${$self}{name} to include ${$self}{id} in ancestors") if $is_t_switch_active;
push(@{${$_}{ancestors}},{ancestorID=>${$self}{id},ancestorIndentation=>${$self}{indentation},type=>"natural"});
}
@@ -176,7 +178,7 @@
# did not add one at the end, and if BodyStartsOnOwnLine >= 1
if( (defined ${${${$arguments}{children}}[-1]}{EndFinishesWithLineBreak} and ${${${$arguments}{children}}[-1]}{EndFinishesWithLineBreak}<1)
and (defined ${$self}{BodyStartsOnOwnLine} and ${$self}{BodyStartsOnOwnLine}>=1) ){
- $self->logger("Updating replacementtext to include a linebreak for arguments in ${$self}{name}") if $is_t_switch_active;
+ $logger->trace("Updating replacementtext to include a linebreak for arguments in ${$self}{name}") if $is_t_switch_active;
${$arguments}{replacementText} .= "\n" if(${$arguments}{linebreaksAtEnd}{end});
}
@@ -189,10 +191,10 @@
# delete the regexp, as there's no need for it
delete ${${${$self}{children}}[-1]}{regexp};
- $self->logger(Dumper(\%{$arguments}),'ttrace') if($is_tt_switch_active);
- $self->logger("replaced with ID: ${$arguments}{id}") if $is_t_switch_active;
+ $logger->trace(Dumper(\%{$arguments})) if($is_tt_switch_active);
+ $logger->trace("replaced with ID: ${$arguments}{id}") if $is_tt_switch_active;
} else {
- $self->logger("... no arguments found") if $is_t_switch_active;
+ $logger->trace("... no arguments found") if $is_t_switch_active;
}
}
@@ -247,7 +249,7 @@
}
# report to log file
- $self->logger("Strings allowed between arguments $stringsBetweenArguments (see stringsAllowedBetweenArguments)",'heading') if $is_t_switch_active;
+ $logger->trace("*Strings allowed between arguments: $stringsBetweenArguments (see stringsAllowedBetweenArguments)") if $is_t_switch_active;
}
if(defined ${input}{roundBrackets} and ${input}{roundBrackets}==1){
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BackUpFileProcedure.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -18,6 +18,7 @@
use warnings;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
use LatexIndent::Switches qw/%switches/;
+use LatexIndent::LogFile qw/$logger/;
use File::Basename; # to get the filename and directory path
use File::Copy; # to copy the original file to backup (if overwrite option set)
use Exporter qw/import/;
@@ -31,7 +32,7 @@
return unless($switches{overwrite});
# if we want to over write the current file create a backup first
- $self->logger("Backup procedure (-w flag active):",'heading');
+ $logger->info("*Backup procedure (-w flag active):");
my $fileName = ${$self}{fileName};
@@ -56,8 +57,8 @@
# if both ($onlyOneBackUp and $maxNumberOfBackUps) then we have
# a conflict- er on the side of caution and turn off onlyOneBackUp
if($onlyOneBackUp and $maxNumberOfBackUps>1) {
- $self->logger("WARNING: onlyOneBackUp=$onlyOneBackUp and maxNumberOfBackUps: $maxNumberOfBackUps");
- $self->logger("setting onlyOneBackUp=0 which will allow you to reach $maxNumberOfBackUps back ups");
+ $logger->warn("*onlyOneBackUp=$onlyOneBackUp and maxNumberOfBackUps: $maxNumberOfBackUps");
+ $logger->warn("setting onlyOneBackUp=0 which will allow you to reach $maxNumberOfBackUps back ups");
$onlyOneBackUp = 0;
}
@@ -65,7 +66,7 @@
# they only want one backup
if($maxNumberOfBackUps==1) {
$onlyOneBackUp=1 ;
- $self->logger("FYI: you set maxNumberOfBackUps=1, so I'm setting onlyOneBackUp: 1 ");
+ $logger->info("you set maxNumberOfBackUps=1, so I'm setting onlyOneBackUp: 1 ");
} elsif($maxNumberOfBackUps<=0 and !$onlyOneBackUp) {
$onlyOneBackUp=0 ;
$maxNumberOfBackUps=-1;
@@ -75,8 +76,8 @@
# be overwritten each time
if($onlyOneBackUp) {
$backupFile .= $backupExtension;
- $self->logger("copying $fileName to $backupFile");
- $self->logger("$backupFile was overwritten (see onlyOneBackUp)") if (-e $backupFile);
+ $logger->info("copying $fileName to $backupFile");
+ $logger->info("$backupFile was overwritten (see onlyOneBackUp)") if (-e $backupFile);
} else {
# start with a backup file .bak0 (or whatever $backupExtension is present)
my $backupCounter = 0;
@@ -85,7 +86,7 @@
# if it exists, then keep going: .bak0, .bak1, ...
while (-e $backupFile or $maxNumberOfBackUps>1) {
if($backupCounter==$maxNumberOfBackUps) {
- $self->logger("maxNumberOfBackUps reached ($maxNumberOfBackUps, see maxNumberOfBackUps)");
+ $logger->info("maxNumberOfBackUps reached ($maxNumberOfBackUps, see maxNumberOfBackUps)");
# some users may wish to cycle through back up files, e.g:
# copy myfile.bak1 to myfile.bak0
@@ -94,7 +95,7 @@
#
# current back up is stored in myfile.bak4
if($cycleThroughBackUps) {
- $self->logger("cycleThroughBackUps detected (see cycleThroughBackUps) ");
+ $logger->info("cycleThroughBackUps detected (see cycleThroughBackUps) ");
for(my $i=1;$i<=$maxNumberOfBackUps;$i++) {
# remove number from backUpFile
my $oldBackupFile = $backupFile;
@@ -107,7 +108,7 @@
# check that the oldBackupFile exists
if(-e $oldBackupFile){
- $self->logger(" copying $oldBackupFile to $newBackupFile ");
+ $logger->info(" copying $oldBackupFile to $newBackupFile ");
copy($oldBackupFile,$newBackupFile) or die "Could not write to backup file $backupFile. Please check permissions. Exiting.";
}
}
@@ -120,16 +121,16 @@
$maxNumberOfBackUps=1;
last; # break out of the loop
}
- $self->logger(" $backupFile already exists, incrementing by 1... (see maxNumberOfBackUps and onlyOneBackUp)");
+ $logger->info("$backupFile already exists, incrementing by 1... (see maxNumberOfBackUps and onlyOneBackUp)");
$backupCounter++;
$backupFile =~ s/$backupExtension.*/$backupExtension$backupCounter/;
}
- $self->logger("copying $fileName to $backupFile");
+ $logger->info("copying $fileName to $backupFile");
}
# output these lines to the log file
- $self->logger("Backup file: ",$backupFile,"");
- $self->logger("Overwriting file: ",$fileName,"");
+ $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.";
}
1;
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BlankLines.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BlankLines.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/BlankLines.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,6 +19,7 @@
use LatexIndent::Tokens qw/%tokens/;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
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/;
our @EXPORT_OK = qw/protect_blank_lines unprotect_blank_lines condense_blank_lines/;
@@ -27,11 +28,11 @@
my $self = shift;
unless(${$masterSettings{modifyLineBreaks}}{preserveBlankLines}){
- $self->logger("Blank lines will not be protected (preserveBlankLines=0)",'heading') if $is_t_switch_active;
+ $logger->trace("*Blank lines will not be protected (preserveBlankLines=0)") if $is_t_switch_active;
return
}
- $self->logger("Protecting blank lines (see preserveBlankLines)",'heading') if $is_t_switch_active;
+ $logger->trace("*Protecting blank lines (see preserveBlankLines)") if $is_t_switch_active;
${$self}{body} =~ s/^(\h*)?\R/$tokens{blanklines}\n/mg;
return;
}
@@ -43,6 +44,7 @@
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){
@@ -50,12 +52,12 @@
${$masterSettings{modifyLineBreaks}}{preserveBlankLines}=1;
# log file information
- $self->logger("Updating body to inclued blank line token, this requires preserveBlankLines = 1",'ttrace') if($is_tt_switch_active);
- $self->logger("(any blanklines that could have been removed, would have done so by this point)",'ttrace') if($is_tt_switch_active);
+ $logger->trace("Updating body to include blank line token, this requires preserveBlankLines = 1") if($is_tt_switch_active);
+ $logger->trace("(any blanklines that could have been removed, would have done so by this point)") if($is_tt_switch_active);
# make the call
$self->protect_blank_lines ;
- $self->logger("body now looks like:\n${$self}{body}",'ttrace') if($is_tt_switch_active);
+ $logger->trace("body now looks like:\n${$self}{body}") if($is_tt_switch_active);
}
# grab the value from the settings
@@ -65,15 +67,15 @@
my $blankLineToken = $tokens{blanklines};
# condense!
- $self->logger("Condensing multiple blank lines into $condenseMultipleBlankLinesInto (see condenseMultipleBlankLinesInto)",'heading') if $is_t_switch_active;
+ $logger->trace("Condensing multiple blank lines into $condenseMultipleBlankLinesInto (see condenseMultipleBlankLinesInto)") if $is_t_switch_active;
my $replacementToken = $blankLineToken;
for (my $i=1; $i<$condenseMultipleBlankLinesInto; $i++ ){
$replacementToken .= "\n$blankLineToken";
}
- $self->logger("blank line replacement token: $replacementToken",'ttrace') if($is_tt_switch_active);
+ $logger->trace("blank line replacement token: $replacementToken") if($is_tt_switch_active);
${$self}{body} =~ s/($blankLineToken\h*\R*\h*){1,}$blankLineToken/$replacementToken/mgs;
- $self->logger("body now looks like:\n${$self}{body}",'ttrace') if($is_tt_switch_active);
+ $logger->trace("body now looks like:\n${$self}{body}") if($is_tt_switch_active);
return;
}
@@ -83,7 +85,7 @@
return unless ${$masterSettings{modifyLineBreaks}}{preserveBlankLines};
my $self = shift;
- $self->logger("Unprotecting blank lines (see preserveBlankLines)",'heading') if $is_t_switch_active;
+ $logger->trace("Unprotecting blank lines (see preserveBlankLines)") if $is_t_switch_active;
my $blankLineToken = $tokens{blanklines};
# loop through the body, looking for the blank line token
@@ -100,8 +102,9 @@
# when there is only stuff *after* the blank line token
${$self}{body} =~ s/^$blankLineToken\h*(.*?)$/$1."\n"/emg;
}
- $self->logger("Finished unprotecting lines (see preserveBlankLines)",'heading') if $is_t_switch_active;
- $self->logger("body now looks like ${$self}{body}",'ttrace') if($is_tt_switch_active);
+ $logger->trace("Finished unprotecting lines (see preserveBlankLines)") if $is_t_switch_active;
+ $logger->trace("body now looks like:") if($is_tt_switch_active);
+ $logger->trace("${$self}{body}") if($is_tt_switch_active);
}
1;
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Braces.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Braces.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Braces.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -22,6 +22,7 @@
use LatexIndent::NamedGroupingBracesBrackets qw/$grouping_braces_regexp $grouping_braces_regexpTrailingComment/;
use LatexIndent::UnNamedGroupingBracesBrackets qw/$un_named_grouping_braces_RegExp $un_named_grouping_braces_RegExp_trailing_comment/;
use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
+use LatexIndent::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
@@ -32,7 +33,7 @@
my $self = shift;
- $self->logger("Searching for commands with optional and/or mandatory arguments AND key = {value}",'heading') if $is_t_switch_active ;
+ $logger->trace("*Searching for commands with optional and/or mandatory arguments AND key = {value}") if $is_t_switch_active ;
# match either a \\command or key={value}
while( ${$self}{body} =~ m/$commandRegExpTrailingComment/
@@ -49,9 +50,6 @@
${$self}{body} =~ s/
$commandRegExpTrailingComment
/
- # log file output
- $self->logger("command found: $2",'heading') if $is_t_switch_active ;
-
# create a new command object
my $command = LatexIndent::Command->new(begin=>$1.$2.($3?$3:q()).($4?$4:q()),
name=>$2,
@@ -71,6 +69,9 @@
},
optAndMandArgsRegExp=>$optAndMandAndRoundBracketsRegExpLineBreaks,
);
+
+ # log file output
+ $logger->trace("*command found: $2") if $is_t_switch_active ;
# the settings and storage of most objects has a lot in common
$self->get_settings_and_store_new_object($command);
@@ -83,9 +84,6 @@
${$self}{body} =~ s/
$key_equals_values_bracesRegExpTrailingComment
/
- # log file output
- $self->logger("key_equals_values_braces found: $3",'heading') if $is_t_switch_active ;
-
# create a new key_equals_values_braces object
my $key_equals_values_braces = LatexIndent::KeyEqualsValuesBraces->new(
begin=>($2?$2:q()).$3.$4.($5?$5:q()),
@@ -107,6 +105,9 @@
},
additionalAssignments=>["EqualsStartsOnOwnLine"],
);
+
+ # log file output
+ $logger->trace("*key_equals_values_braces found: $3") if $is_t_switch_active ;
# the settings and storage of most objects has a lot in common
$self->get_settings_and_store_new_object($key_equals_values_braces);
@@ -119,9 +120,6 @@
${$self}{body} =~ s/
$grouping_braces_regexpTrailingComment
/
- # log file output
- $self->logger("named grouping braces found: $2",'heading') if $is_t_switch_active ;
-
# create a new key_equals_values_braces object
my $grouping_braces = LatexIndent::NamedGroupingBracesBrackets->new(
begin=>$2.($3?$3:q()).($4?$4:q()),
@@ -142,6 +140,8 @@
BodyStartsOnOwnLine=>"NameFinishesWithLineBreak",
},
);
+ # log file output
+ $logger->trace("*named grouping braces found: $2") if $is_t_switch_active ;
# the settings and storage of most objects has a lot in common
$self->get_settings_and_store_new_object($grouping_braces);
@@ -153,9 +153,6 @@
${$self}{body} =~ s/
$un_named_grouping_braces_RegExp_trailing_comment
/
- # log file output
- $self->logger("UNnamed grouping braces found: (no name, by definition!)",'heading') if $is_t_switch_active ;
-
# create a new Un-named-grouping-braces-brackets object
my $un_named_grouping_braces = LatexIndent::UnNamedGroupingBracesBrackets->new(
begin=>q(),
@@ -175,6 +172,9 @@
BodyStartsOnOwnLine=>0,
);
+ # log file output
+ $logger->trace("*UNnamed grouping braces found: (no name, by definition!)") if $is_t_switch_active ;
+
# the settings and storage of most objects has a lot in common
$self->get_settings_and_store_new_object($un_named_grouping_braces);
${@{${$self}{children}}[-1]}{replacementText}.($6?($8?$8:q()):q());
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Command.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Command.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Command.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -20,6 +20,7 @@
use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
@@ -58,7 +59,7 @@
}
# details to log file
- $self->logger("The special command names regexp is: $commandNameSpecialRegExp (see commandNameSpecial)",'heading') if $is_t_switch_active;
+ $logger->trace("*The special command names regexp is: $commandNameSpecialRegExp (see commandNameSpecial)") if $is_t_switch_active;
# construct the command regexp
$commandRegExp = qr/
@@ -92,7 +93,7 @@
if(${${$self}{linebreaksAtEnd}}{end} == 1
and ${${${$self}{children}}[0]}{body} =~ m/\R$/s
and !${$self}{endImmediatelyFollowedByComment}){
- $self->logger("Removing linebreak from argument container of ${$self}{name}") if $is_t_switch_active;
+ $logger->trace("Removing linebreak from argument container of ${$self}{name}") if $is_t_switch_active;
${${${$self}{children}}[0]}{body} =~ s/\R$//s;
${${${${$self}{children}}[0]}{linebreaksAtEnd}}{body} = 0;
}
@@ -103,7 +104,7 @@
and defined ${${${${$self}{children}}[0]}{children}[-1]}{EndFinishesWithLineBreak}
and ${${${${$self}{children}}[0]}{children}[-1]}{EndFinishesWithLineBreak} == -1
){
- $self->logger("Switching linebreaksAtEnd{end} to be 0 in command ${$self}{name} as last argument specifies EndFinishesWithLineBreak == 0") if $is_t_switch_active;
+ $logger->trace("Switching linebreaksAtEnd{end} to be 0 in command ${$self}{name} as last argument specifies EndFinishesWithLineBreak == 0") if $is_t_switch_active;
${${$self}{linebreaksAtEnd}}{end} = 0;
${$self}{EndFinishesWithLineBreak} = -1;
}
@@ -117,7 +118,7 @@
and !${$self}{endImmediatelyFollowedByComment}){
# update the Command object
- $self->logger("Adjusting linebreaksAtEnd in command ${$self}{name}") if $is_t_switch_active;
+ $logger->trace("Adjusting linebreaksAtEnd in command ${$self}{name}") if $is_t_switch_active;
${${$self}{linebreaksAtEnd}}{end} = ${${${${${$self}{children}}[0]}{children}[-1]}{linebreaksAtEnd}}{end};
${$self}{replacementText} .= "\n";
@@ -124,23 +125,23 @@
# if the last argument has EndFinishesWithLineBreak == 3
if (${${${${$self}{children}}[0]}{children}[-1]}{EndFinishesWithLineBreak} == 3 ){
my $EndStringLogFile = ${${${${$self}{children}}[0]}{children}[-1]}{aliases}{EndFinishesWithLineBreak}||"EndFinishesWithLineBreak";
- $self->logger("Adding another blank line to replacement text for ${$self}{name} as last argument has $EndStringLogFile == 3 ") if $is_t_switch_active;
+ $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";
}
# update the argument object
- $self->logger("Adjusting argument object in command, ${$self}{name}") if $is_t_switch_active;
+ $logger->trace("Adjusting argument object in command, ${$self}{name}") if $is_t_switch_active;
${${${${$self}{children}}[0]}{linebreaksAtEnd}}{body} = 0;
${${${$self}{children}}[0]}{body} =~ s/\R$//s;
# update the last mandatory/optional argument
- $self->logger("Adjusting last argument in command, ${$self}{name}") if $is_t_switch_active;
+ $logger->trace("Adjusting last argument in command, ${$self}{name}") if $is_t_switch_active;
${${${${${$self}{children}}[0]}{children}[-1]}{linebreaksAtEnd}}{end} = 0;
${${${${$self}{children}}[0]}{children}[-1]}{EndFinishesWithLineBreak} = -1;
${${${${$self}{children}}[0]}{children}[-1]}{replacementText} =~ s/\R$//s;
# output to log file
- $self->logger(Dumper(${${${$self}{children}}[0]}{children}[-1])) if $is_t_switch_active;
+ $logger->trace(Dumper(${${${$self}{children}}[0]}{children}[-1])) if $is_tt_switch_active;
}
# situation: ${${$self}{linebreaksAtEnd}}{end} == 1 and the last argument has added
@@ -152,12 +153,12 @@
and !${$self}{endImmediatelyFollowedByComment}){
# last argument adjustment
- $self->logger("Adjusting last argument in command, ${$self}{name} to avoid double line break") if $is_t_switch_active;
+ $logger->trace("Adjusting last argument in command, ${$self}{name} to avoid double line break") if $is_t_switch_active;
${${${${$self}{children}}[0]}{children}[-1]}{replacementText}=~s/\R$//s;
${${${${${$self}{children}}[0]}{children}[-1]}{linebreaksAtEnd}}{end} = 0;
# argument object adjustment
- $self->logger("Adjusting argument object in command, ${$self}{name} to avoid double line break") if $is_t_switch_active;
+ $logger->trace("Adjusting argument object in command, ${$self}{name} to avoid double line break") if $is_t_switch_active;
${${${${$self}{children}}[0]}{linebreaksAtEnd}}{body} = 0;
${${${$self}{children}}[0]}{body}=~s/\R$//s;
}
@@ -167,7 +168,7 @@
#
# see ../test-cases/texexchange/5461.tex which was the first example to demonstrate the need for this
if(!${${${$self}{children}}[0]}{endImmediatelyFollowedByComment} and ${${${$self}{children}}[0]}{body} =~ m/\h*$/ and ${$self}{replacementText} !~ m/\R$/){
- $self->logger("${$self}{name}: trailling horizontal space found in arguments -- removing it from arguments, adding to replacement text") if $is_t_switch_active;
+ $logger->trace("${$self}{name}: trailling horizontal space found in arguments -- removing it from arguments, adding to replacement text") if $is_t_switch_active;
${${${$self}{children}}[0]}{body} =~ s/(\h*)$//s;
${$self}{replacementText} .= "$1";
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -22,12 +22,12 @@
# gain access to subroutines in the following modules
use LatexIndent::Switches qw/storeSwitches %switches $is_m_switch_active $is_t_switch_active $is_tt_switch_active/;
-use LatexIndent::LogFile qw/logger output_logfile processSwitches/;
+use LatexIndent::LogFile qw/processSwitches $logger/;
use LatexIndent::GetYamlSettings qw/readSettings modify_line_breaks_settings get_indentation_settings_for_this_object get_every_or_custom_value get_indentation_information get_object_attribute_for_indentation_settings alignment_at_ampersand_settings %masterSettings/;
use LatexIndent::FileExtension qw/file_extension_check/;
use LatexIndent::BackUpFileProcedure qw/create_back_up_file/;
use LatexIndent::BlankLines qw/protect_blank_lines unprotect_blank_lines condense_blank_lines/;
-use LatexIndent::ModifyLineBreaks qw/modify_line_breaks_body modify_line_breaks_end remove_line_breaks_begin adjust_line_breaks_end_parent max_char_per_line paragraphs_on_one_line construct_paragraph_reg_exp/;
+use LatexIndent::ModifyLineBreaks qw/modify_line_breaks_body modify_line_breaks_end remove_line_breaks_begin adjust_line_breaks_end_parent max_char_per_line paragraphs_on_one_line construct_paragraph_reg_exp one_sentence_per_line/;
use LatexIndent::TrailingComments qw/remove_trailing_comments put_trailing_comments_back_in add_comment_symbol construct_trailing_comment_regexp/;
use LatexIndent::HorizontalWhiteSpace qw/remove_trailing_whitespace remove_leading_space/;
use LatexIndent::Indent qw/indent wrap_up_statement determine_total_indentation indent_begin indent_body indent_end_statement final_indentation_check get_surrounding_indentation indent_children_recursively check_for_blank_lines_at_beginning put_blank_lines_back_in_at_beginning add_surrounding_indentation_to_begin_statement post_indentation_check/;
@@ -64,6 +64,7 @@
my $invocant = shift;
my $class = ref($invocant) || $invocant;
my $self = {@_};
+ $logger->trace(${$masterSettings{logFilePreferences}}{showDecorationStartCodeBlockTrace}) if ${$masterSettings{logFilePreferences}}{showDecorationStartCodeBlockTrace};
bless ($self,$class);
return $self;
}
@@ -72,7 +73,6 @@
my $self = shift;
$self->storeSwitches;
$self->processSwitches;
- $self->readSettings;
$self->file_extension_check;
$self->operate_on_file;
}
@@ -94,6 +94,7 @@
$self->find_file_contents_environments_and_preamble;
$self->dodge_double_backslash;
$self->remove_leading_space;
+ $self->one_sentence_per_line if $is_m_switch_active;
$self->process_body_of_text;
$self->remove_trailing_whitespace(when=>"after");
$self->condense_blank_lines;
@@ -103,7 +104,6 @@
$self->put_trailing_comments_back_in;
$self->put_verbatim_commands_back_in;
$self->output_indented_text;
- $self->output_logfile;
return
}
@@ -125,25 +125,32 @@
sub output_indented_text{
my $self = shift;
- # output to screen, unless silent mode
- print ${$self}{body} unless $switches{silentMode};
+ $logger->info("*Output routine:");
- $self->logger("Output routine",'heading');
-
# if -overwrite is active then output to original fileName
if($switches{overwrite}) {
- $self->logger("Overwriting file ${$self}{fileName}");
+ $logger->info("Overwriting file ${$self}{fileName}");
open(OUTPUTFILE,">",${$self}{fileName});
print OUTPUTFILE ${$self}{body};
close(OUTPUTFILE);
} elsif($switches{outputToFile}) {
- $self->logger("Outputting to file $switches{outputToFile}");
+ $logger->info("Outputting to file $switches{outputToFile}");
open(OUTPUTFILE,">",$switches{outputToFile});
print OUTPUTFILE ${$self}{body};
close(OUTPUTFILE);
} else {
- $self->logger("Not outputting to file; see -w and -o switches for more options.");
+ $logger->info("Not outputting to file; see -w and -o switches for more options.");
}
+
+ # put the final line in the logfile
+ $logger->info("${$masterSettings{logFilePreferences}}{endLogFileWith}") if ${$masterSettings{logFilePreferences}}{endLogFileWith};
+
+ # github info line
+ $logger->info("*Please direct all communication/issues to:\nhttps://github.com/cmhughes/latexindent.pl") if ${$masterSettings{logFilePreferences}}{showGitHubInfoFooter};
+
+ # output to screen, unless silent mode
+ print ${$self}{body} unless $switches{silentMode};
+
return;
}
@@ -151,19 +158,19 @@
my $self = shift;
# find objects recursively
- $self->logger('Phase 1: searching for objects','heading');
+ $logger->info('*Phase 1: searching for objects');
$self->find_objects;
# find all hidden child
- $self->logger('Phase 2: finding surrounding indentation','heading');
+ $logger->info('*Phase 2: finding surrounding indentation');
$self->find_surrounding_indentation_for_children;
# indentation recursively
- $self->logger('Phase 3: indenting objects','heading');
+ $logger->info('*Phase 3: indenting objects');
$self->indent_children_recursively;
# final indentation check
- $self->logger('Phase 4: final indentation check','heading');
+ $logger->info('*Phase 4: final indentation check');
$self->final_indentation_check;
return;
@@ -173,15 +180,15 @@
my $self = shift;
# search for environments
- $self->logger('looking for ENVIRONMENTS') if $is_t_switch_active;
+ $logger->trace('looking for ENVIRONMENTS') if $is_t_switch_active;
$self->find_environments;
# search for ifElseFi blocks
- $self->logger('looking for IFELSEFI') if $is_t_switch_active;
+ $logger->trace('looking for IFELSEFI') if $is_t_switch_active;
$self->find_ifelsefi;
# search for headings (part, chapter, section, setc)
- $self->logger('looking for HEADINGS (chapter, section, part, etc)') if $is_t_switch_active;
+ $logger->trace('looking for HEADINGS (chapter, section, part, etc)') if $is_t_switch_active;
$self->find_heading;
# the ordering of finding commands and special code blocks can change
@@ -195,16 +202,14 @@
# if there are no children, return
if(${$self}{children}){
- $self->logger("Objects have been found.",'heading') if $is_t_switch_active;
+ $logger->trace("*Objects have been found.") if $is_t_switch_active;
} else {
- $self->logger("No objects found.");
+ $logger->trace("No objects found.");
return;
}
# logfile information
- $self->logger(Dumper(\%{$self}),'ttrace') if($is_tt_switch_active);
- $self->logger("Operating on: ${$self}{name}",'heading')if $is_t_switch_active;
- $self->logger("Number of children: ".scalar (@{${$self}{children}})) if $is_t_switch_active;
+ $logger->trace(Dumper(\%{$self})) if($is_tt_switch_active);
return;
}
@@ -216,19 +221,19 @@
# can change depending upon specialBeforeCommand
if(${$masterSettings{specialBeginEnd}}{specialBeforeCommand}){
# search for special begin/end
- $self->logger('looking for SPECIAL begin/end *before* looking for commands (see specialBeforeCommand)') if $is_t_switch_active;
+ $logger->trace('looking for SPECIAL begin/end *before* looking for commands (see specialBeforeCommand)') if $is_t_switch_active;
$self->find_special;
# search for commands with arguments
- $self->logger('looking for COMMANDS and key = {value}') if $is_t_switch_active;
+ $logger->trace('looking for COMMANDS and key = {value}') if $is_t_switch_active;
$self->find_commands_or_key_equals_values_braces;
} else {
# search for commands with arguments
- $self->logger('looking for COMMANDS and key = {value}') if $is_t_switch_active;
+ $logger->trace('looking for COMMANDS and key = {value}') if $is_t_switch_active;
$self->find_commands_or_key_equals_values_braces;
# search for special begin/end
- $self->logger('looking for SPECIAL begin/end') if $is_t_switch_active;
+ $logger->trace('looking for SPECIAL begin/end') if $is_t_switch_active;
$self->find_special;
}
return;
@@ -236,7 +241,7 @@
sub tasks_particular_to_each_object{
my $self = shift;
- $self->logger("There are no tasks particular to ${$self}{name}") if $is_t_switch_active;
+ $logger->trace("There are no tasks particular to ${$self}{name}") if $is_t_switch_active;
}
sub get_settings_and_store_new_object{
@@ -254,6 +259,8 @@
# store children in special hash
push(@{${$self}{children}},$latexIndentObject);
+ # possible decoration in log file
+ $logger->trace(${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
}
sub tasks_common_to_each_object{
@@ -264,12 +271,12 @@
# update/create the ancestor information
if($parent{ancestors}){
- $self->logger("Ancestors *have* been found for ${$self}{name}") if($is_t_switch_active);
+ $logger->trace("Ancestors *have* been found for ${$self}{name}") if($is_t_switch_active);
push(@{${$self}{ancestors}},@{$parent{ancestors}});
} else {
- $self->logger("No ancestors found for ${$self}{name}") if($is_t_switch_active);
+ $logger->trace("No ancestors found for ${$self}{name}") if($is_t_switch_active);
if(defined $parent{id} and $parent{id} ne ''){
- $self->logger("Creating ancestors with $parent{id} as the first one") if($is_t_switch_active);
+ $logger->trace("Creating ancestors with $parent{id} as the first one") if($is_t_switch_active);
push(@{${$self}{ancestors}},{ancestorID=>$parent{id},ancestorIndentation=>\$parent{indentation},type=>"natural",name=>${$self}{name}});
}
}
@@ -328,7 +335,7 @@
# the above regexp, when used below, will remove the trailing linebreak in ${$self}{linebreaksAtEnd}{end}
# so we compensate for it here
- $self->logger("Putting linebreak after replacementText for ${$self}{name}") if($is_t_switch_active);
+ $logger->trace("Putting linebreak after replacementText for ${$self}{name}") if($is_t_switch_active);
if(defined ${$self}{horizontalTrailingSpace}){
${$self}{replacementText} .= ${$self}{horizontalTrailingSpace} unless(!${$self}{endImmediatelyFollowedByComment} and defined ${$self}{EndFinishesWithLineBreak} and ${$self}{EndFinishesWithLineBreak}==2);
}
@@ -345,7 +352,7 @@
my $bodyLineBreaks = 0;
$bodyLineBreaks++ while(${$self}{body} =~ m/\R/sxg);
${$self}{bodyLineBreaks} = $bodyLineBreaks;
- $self->logger("bodyLineBreaks ${$self}{bodyLineBreaks}") if((${$self}{bodyLineBreaks} != $oldBodyLineBreaks) and $is_t_switch_active);
+ $logger->trace("bodyLineBreaks ${$self}{bodyLineBreaks}") if((${$self}{bodyLineBreaks} != $oldBodyLineBreaks) and $is_t_switch_active);
}
sub wrap_up_tasks{
@@ -357,8 +364,8 @@
# check if the last object was the last thing in the body, and if it has adjusted linebreaks
$self->adjust_line_breaks_end_parent;
- $self->logger(Dumper(\%{$child})) if($is_tt_switch_active);
- $self->logger("replaced with ID: ${$child}{id}") if $is_t_switch_active;
+ $logger->trace(Dumper(\%{$child})) if($is_tt_switch_active);
+ $logger->trace("replaced with ID: ${$child}{id}") if $is_t_switch_active;
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Else.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Else.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Else.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,6 +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::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
@@ -37,12 +38,10 @@
sub check_for_else_statement{
my $self = shift;
- $self->logger("Looking for \\else statement (${$self}{name})",'heading') if $is_t_switch_active;
+ $logger->trace("*Looking for \\else statement (${$self}{name})") if $is_t_switch_active;
${$self}{body} =~ s/$elseRegExp(\h*)($trailingCommentRegExp)?
- / # log file output
- $self->logger("else found: ${$self}{name}",'heading')if $is_t_switch_active;
-
+ /
# create a new IfElseFi object
my $else = LatexIndent::Else->new(begin=>$1,
name=>${$self}{name},
@@ -64,6 +63,9 @@
endImmediatelyFollowedByComment=>0,
horizontalTrailingSpace=>q(),
);
+ # log file output
+ $logger->trace("*else found: ${$self}{name}")if $is_t_switch_active;
+
# the settings and storage of most objects has a lot in common
$self->get_settings_and_store_new_object($else);
${@{${$self}{children}}[-1]}{replacementText};
@@ -76,7 +78,7 @@
# there is no white space
my $self = shift;
my $BodyStringLogFile = ${$self}{aliases}{BodyStartsOnOwnLine}||"BodyStartsOnOwnLine";
- $self->logger("Removing linebreak at the end of begin (see $BodyStringLogFile)");
+ $logger->trace("Removing linebreak at the end of begin (see $BodyStringLogFile)");
${$self}{begin} =~ s/\R*$//sx;
${$self}{begin} .= " " unless(${$self}{begin} =~ m/\h$/s or ${$self}{body} =~ m/^\h/s or ${$self}{body} =~ m/^\R/s );
${$self}{linebreaksAtEnd}{begin} = 0;
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,6 +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::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
@@ -61,9 +62,6 @@
${$self}{body} =~ s/
$environmentRegExp(\h*)($trailingCommentRegExp)?
/
- # log file output
- $self->logger("environment found: $2",'heading') if $is_t_switch_active;
-
# create a new Environment object
my $env = LatexIndent::Environment->new(begin=>$1,
name=>$2,
@@ -79,6 +77,9 @@
horizontalTrailingSpace=>$7?$7:q(),
);
+ # log file output
+ $logger->trace("*environment found: $2") if $is_t_switch_active;
+
# the settings and storage of most objects has a lot in common
$self->get_settings_and_store_new_object($env);
${@{${$self}{children}}[-1]}{replacementText}.($9?$9:q()).($10?$10:q());
@@ -93,7 +94,7 @@
# if the environment is empty, we may need to update linebreaksAtEnd{body}
if(${$self}{body} =~ m/^\h*$/s and ${${$self}{linebreaksAtEnd}}{begin}){
- $self->logger("empty environment body (${$self}{name}), updating linebreaksAtEnd{body} to be 1") if($is_t_switch_active);
+ $logger->trace("empty environment body (${$self}{name}), updating linebreaksAtEnd{body} to be 1") if($is_t_switch_active);
${${$self}{linebreaksAtEnd}}{body} = 1;
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileContents.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileContents.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileContents.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,6 +19,7 @@
use LatexIndent::Tokens qw/%tokens/;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
+use LatexIndent::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @EXPORT_OK = qw/find_file_contents_environments_and_preamble/;
@@ -34,11 +35,11 @@
my @fileContentsStorageArray;
# fileContents environments
- $self->logger('looking for FILE CONTENTS environments (see fileContentsEnvironments)','heading') if $is_t_switch_active;
- $self->logger(Dumper(\%{$masterSettings{fileContentsEnvironments}})) if($is_t_switch_active);
+ $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}}){
if($yesno){
- $self->logger("looking for $fileContentsEnv:$yesno environments") if $is_t_switch_active;
+ $logger->trace("looking for $fileContentsEnv environments") if $is_t_switch_active;
# the trailing * needs some care
if($fileContentsEnv =~ m/\*$/){
@@ -93,15 +94,15 @@
push(@fileContentsStorageArray,$fileContentsBlock);
# log file output
- $self->logger("FILECONTENTS environment found: $fileContentsEnv");
+ $logger->trace("FILECONTENTS environment found: $fileContentsEnv");
# remove the environment block, and replace with unique ID
${$self}{body} =~ s/$fileContentsRegExp/${$fileContentsBlock}{replacementText}/sx;
- $self->logger("replaced with ID: ${$fileContentsBlock}{id}");
+ $logger->trace("replaced with ID: ${$fileContentsBlock}{id}") if $is_tt_switch_active;
}
} else {
- $self->logger("*not* looking for $fileContentsEnv as $fileContentsEnv:$yesno");
+ $logger->trace("*not* looking for $fileContentsEnv as $fileContentsEnv:$yesno");
}
}
@@ -119,7 +120,7 @@
# try and find the preamble
if( ${$self}{body} =~ m/$preambleRegExp/sx and ${$masterSettings{lookForPreamble}}{${$self}{fileExtension}}){
- $self->logger("\\begin{document} found in body (after searching for filecontents)-- assuming that a preamble exists",'heading') if $is_t_switch_active ;
+ $logger->trace("\\begin{document} found in body (after searching for filecontents)-- assuming that a preamble exists",'heading') if $is_t_switch_active ;
# create a preamble object
$preamble = LatexIndent::Preamble->new( begin=>q(),
@@ -142,19 +143,19 @@
$preamble->get_replacement_text;
# log file output
- $self->logger("preamble found: $preamble") if $is_t_switch_active;
+ $logger->trace("preamble found: preamble") if $is_t_switch_active;
# remove the environment block, and replace with unique ID
${$self}{body} =~ s/$preambleRegExp/${$preamble}{replacementText}/sx;
- $self->logger("replaced with ID: ${$preamble}{replacementText}") if $is_t_switch_active;
+ $logger->trace("replaced with ID: ${$preamble}{replacementText}") if $is_tt_switch_active;
# indentPreamble set to 1
if($masterSettings{indentPreamble}){
- $self->logger("storing ${$preamble}{id} for indentation (see indentPreamble)");
+ $logger->trace("storing ${$preamble}{id} for indentation (see indentPreamble)");
$needToStorePreamble = 1;
} else {
# indentPreamble set to 0
- $self->logger("NOT storing ${$preamble}{id} for indentation -- will store as VERBATIM object (see indentPreamble)") if $is_t_switch_active;
+ $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;
${$self}{verbatim}{${$preamble}{id}} = $preamble;
}
@@ -167,18 +168,18 @@
my $indentThisChild = 0;
# verbatim children go in special hash
if($preamble ne '' and ${$preamble}{body} =~ m/${$_}{id}/){
- $self->logger("filecontents (${$_}{id}) is within preamble");
+ $logger->trace("filecontents (${$_}{id}) is within preamble");
# indentPreamble set to 1
if($masterSettings{indentPreamble}){
- $self->logger("storing ${$_}{id} for indentation (indentPreamble is 1)");
+ $logger->trace("storing ${$_}{id} for indentation (indentPreamble is 1)");
$indentThisChild = 1;
} else {
# indentPreamble set to 0
- $self->logger("Storing ${$_}{id} as a VERBATIM object (indentPreamble is 0)");
+ $logger->trace("Storing ${$_}{id} as a VERBATIM object (indentPreamble is 0)");
${$self}{verbatim}{${$_}{id}}=$_;
}
} else {
- $self->logger("storing ${$_}{id} for indentation (${$_}{name} found outside of preamble)");
+ $logger->trace("storing ${$_}{id} for indentation (${$_}{name} found outside of preamble)");
$indentThisChild = 1;
}
# store the child, if necessary
@@ -187,6 +188,9 @@
$_->get_indentation_settings_for_this_object;
$_->tasks_particular_to_each_object;
push(@{${$self}{children}},$_);
+
+ # possible decoration in log file
+ $logger->trace(${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace};
}
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileExtension.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileExtension.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/FileExtension.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -21,6 +21,7 @@
use open ':std', ':encoding(UTF-8)';
use File::Basename; # to get the filename and directory path
use Exporter qw/import/;
+use Log::Log4perl qw(get_logger :levels);
use LatexIndent::GetYamlSettings qw/%masterSettings/;
use LatexIndent::Switches qw/%switches/;
our @EXPORT_OK = qw/file_extension_check/;
@@ -28,6 +29,9 @@
sub file_extension_check{
my $self = shift;
+ # grab the logger object
+ my $logger = get_logger("Document");
+
# grab the filename
my $fileName = ${$self}{fileName};
@@ -44,50 +48,47 @@
# check to make sure given file type is supported
if( -e $fileName and !$ext ){
my $message = "The file $fileName exists , but the extension does not correspond to any given in fileExtensionPreference; consinder updating fileExtensionPreference.";
- $self->logger($message,'heading');
- $self->output_logfile;
+ $logger->fatal("*$message");
die($message);
}
# if no extension, search according to fileExtensionPreference
- if (!$ext) {
- $self->logger("File extension work:",'heading');
- $self->logger("latexindent called to act upon $fileName with an, as yet, unrecognised file extension;");
- $self->logger("searching for file with an extension in the following order (see fileExtensionPreference):");
- $self->logger(join("\n", at fileExtensions));
+ if ($fileName ne "-"){
+ if (!$ext) {
+ $logger->info("*File extension work:");
+ $logger->info("latexindent called to act upon $fileName with a file extension;\nsearching for file with an extension in the following order (see fileExtensionPreference):");
+ $logger->info(join("\n", at fileExtensions));
- my $fileFound = 0;
- # loop through the known file extensions (see @fileExtensions)
- foreach (@fileExtensions ){
- if ( -e $fileName.$_ ) {
- $self->logger("$fileName$_ found!");
- $fileName .= $_;
- $self->logger("Updated fileName to $fileName");
- ${$self}{fileName} = $fileName ;
- $fileFound = 1;
- $ext = $_;
- last;
+ my $fileFound = 0;
+ # loop through the known file extensions (see @fileExtensions)
+ foreach (@fileExtensions ){
+ if ( -e $fileName.$_ ) {
+ $logger->info("$fileName$_ found!");
+ $fileName .= $_;
+ $logger->info("Updated fileName to $fileName");
+ ${$self}{fileName} = $fileName ;
+ $fileFound = 1;
+ $ext = $_;
+ last;
+ }
}
- }
- unless($fileFound){
- $self->logger("I couldn't find a match for $fileName in fileExtensionPreference (see defaultSettings.yaml)");
- foreach (@fileExtensions ){
- $self->logger("I searched for $fileName$_");
+ unless($fileFound){
+ $logger->fatal("*I couldn't find a match for $fileName in fileExtensionPreference (see defaultSettings.yaml)");
+ foreach (@fileExtensions ){
+ $logger->fatal("I searched for $fileName$_");
+ }
+ $logger->fatal("but couldn't find any of them.\nConsider updating fileExtensionPreference.\nExiting, no indendation done.");
+ die "I couldn't find a match for $fileName in fileExtensionPreference.\nExiting, no indendation done.";
+ }
+ } else {
+ # if the file has a recognised extension, check that the file exists
+ unless( -e $fileName ){
+ my $message = "I couldn't find $fileName, are you sure it exists?.\nNo indentation done.\nExiting.";
+ $logger->fatal("*$message");
+ die $message;
+ }
}
- $self->logger("but couldn't find any of them.");
- $self->logger("Consider updating fileExtensionPreference. Error: Exiting, no indendation done.");
- $self->output_logfile;
- die "I couldn't find a match for $fileName in fileExtensionPreference.\nExiting, no indendation done.";
- }
- } 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?. No indentation done. Exiting.";
- $self->logger($message);
- $self->output_logfile;
- die $message;
- }
- }
+ }
# store the file extension
${$self}{fileExtension} = $ext;
@@ -95,17 +96,22 @@
# check to see if -o switch is active
if($switches{outputToFile}){
- $self->logger("Output file check",'heading');
+ $logger->info("*-o switch active: output file check");
+ if ($fileName eq "-" and $switches{outputToFile} =~ m/^\+/){
+ $logger->info("STDIN input mode active, -o switch is removing all + symbols");
+ $switches{outputToFile} =~ s/\+//g;
+ }
# the -o file name might begin with a + symbol
if($switches{outputToFile} =~ m/^\+(.*)/ and $1 ne "+"){
- $self->logger("-o switch called with + symbol at the beginning: $switches{outputToFile}");
+ $logger->info("-o switch called with + symbol at the beginning: $switches{outputToFile}");
$switches{outputToFile} = ${$self}{baseName}.$1;
- $self->logger("output file is now: $switches{outputToFile}");
+ $logger->info("output file is now: $switches{outputToFile}");
}
my $strippedFileExtension = ${$self}{fileExtension};
$strippedFileExtension =~ s/\.//;
+ $strippedFileExtension = "tex" if ($strippedFileExtension eq "");
# grab the name, directory, and extension of the output file
my ($name, $dir, $ext) = fileparse($switches{outputToFile}, $strippedFileExtension);
@@ -112,9 +118,9 @@
# if there is no extension, then add the extension from the file to be operated upon
if(!$ext){
- $self->logger("-o switch called with file name without extension: $switches{outputToFile}");
+ $logger->info("-o switch called with file name without extension: $switches{outputToFile}");
$switches{outputToFile} = $name.($name=~m/\.\z/ ? q() : ".").$strippedFileExtension;
- $self->logger("Updated to $switches{outputToFile} as the file extension of the input file is $strippedFileExtension");
+ $logger->info("Updated to $switches{outputToFile} as the file extension of the input file is $strippedFileExtension");
}
# the -o file name might end with ++ in which case we wish to search for existence,
@@ -121,18 +127,18 @@
# and then increment accordingly
$name =~ s/\.$//;
if($name =~ m/\+\+$/){
- $self->logger("-o switch called with file name ending with ++: $switches{outputToFile}");
+ $logger->info("-o switch called with file name ending with ++: $switches{outputToFile}");
$name =~ s/\+\+$//;
$name = ${$self}{baseName} if ($name eq "");
my $outputFileCounter = 0;
my $fileName = $name.$outputFileCounter.".".$strippedFileExtension;
- $self->logger("will search for exisitence and increment counter, starting with $fileName");
+ $logger->info("will search for existence and increment counter, starting with $fileName");
while( -e $fileName ){
- $self->logger("$fileName exists, incrementing counter");
+ $logger->info("$fileName exists, incrementing counter");
$outputFileCounter++;
$fileName = $name.$outputFileCounter.".".$strippedFileExtension;
}
- $self->logger("$fileName does not exist, and will be the output file");
+ $logger->info("$fileName does not exist, and will be the output file");
$switches{outputToFile} = $fileName;
}
}
@@ -139,9 +145,13 @@
# read the file into the Document body
my @lines;
- open(MAINFILE, $fileName) or die "Could not open input file, $fileName";
- push(@lines,$_) while(<MAINFILE>);
- close(MAINFILE);
+ if($fileName ne "-"){
+ open(MAINFILE, $fileName) or die "Could not open input file, $fileName";
+ push(@lines,$_) while(<MAINFILE>);
+ close(MAINFILE);
+ } else {
+ push(@lines,$_) while (<>)
+ }
# the all-important step: update the body
${$self}{body} = join("", at lines);
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -20,6 +20,7 @@
use YAML::Tiny; # interpret defaultSettings.yaml and other potential settings files
use File::Basename; # to get the filename and directory path
use File::HomeDir;
+use Log::Log4perl qw(get_logger :levels);
use Exporter qw/import/;
our @EXPORT_OK = qw/readSettings modify_line_breaks_settings get_indentation_settings_for_this_object get_every_or_custom_value get_indentation_information get_object_attribute_for_indentation_settings alignment_at_ampersand_settings %masterSettings/;
@@ -32,18 +33,32 @@
# previously found settings is a hash, global to this module
our %previouslyFoundSettings;
+# default values for align at ampersand routine
+our @alignAtAmpersandInformation = ( {name=>"lookForAlignDelims",yamlname=>"delims",default=>1},
+ {name=>"alignDoubleBackSlash",default=>1},
+ {name=>"spacesBeforeDoubleBackSlash",default=>1},
+ {name=>"multiColumnGrouping",default=>0},
+ {name=>"alignRowsWithoutMaxDelims",default=>1},
+ {name=>"spacesBeforeAmpersand",default=>1},
+ {name=>"spacesAfterAmpersand",default=>1},
+ {name=>"justification",default=>"left"},
+ );
+
sub readSettings{
my $self = shift;
+ # read the default settings
$defaultSettings = YAML::Tiny->read( "$FindBin::RealBin/defaultSettings.yaml" );
- $self->logger("YAML settings read: defaultSettings.yaml",'heading');
- $self->logger("Reading defaultSettings.yaml from $FindBin::RealBin/defaultSettings.yaml");
+
+ # grab the logger object
+ my $logger = get_logger("Document");
+ $logger->info("*YAML settings read: defaultSettings.yaml\nReading defaultSettings.yaml from $FindBin::RealBin/defaultSettings.yaml");
# 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");
- $self->logger("Reading defaultSettings.yaml (2nd attempt, TeXLive, Windows) from $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");
}
# need to exit if we can't get defaultSettings.yaml
@@ -60,7 +75,7 @@
# we'll need the home directory a lot in what follows
my $homeDir = File::HomeDir->my_home;
- $self->logger("YAML settings read: indentconfig.yaml or .indentconfig.yaml",'heading');
+ $logger->info("*YAML settings read: indentconfig.yaml or .indentconfig.yaml") unless $switches{onlyDefault};
# get information about user settings- first check if indentconfig.yaml exists
my $indentconfig = "$homeDir/indentconfig.yaml";
@@ -70,39 +85,39 @@
# messages for indentconfig.yaml and/or .indentconfig.yaml
if ( -e $indentconfig and !$switches{onlyDefault}) {
- $self->logger("Reading path information from $indentconfig");
+ $logger->info("Reading path information from $indentconfig");
# if both indentconfig.yaml and .indentconfig.yaml exist
if ( -e File::HomeDir->my_home . "/indentconfig.yaml" and -e File::HomeDir->my_home . "/.indentconfig.yaml") {
- $self->logger("$homeDir/.indentconfig.yaml has been found, but $indentconfig takes priority");
+ $logger->info("$homeDir/.indentconfig.yaml has been found, but $indentconfig takes priority");
} elsif ( -e File::HomeDir->my_home . "/indentconfig.yaml" ) {
- $self->logger("(Alternatively $homeDir/.indentconfig.yaml can be used)");
+ $logger->info("(Alternatively $homeDir/.indentconfig.yaml can be used)");
} elsif ( -e File::HomeDir->my_home . "/.indentconfig.yaml" ) {
- $self->logger("(Alternatively $homeDir/indentconfig.yaml can be used)");
+ $logger->info("(Alternatively $homeDir/indentconfig.yaml can be used)");
}
-
+
# read the absolute paths from indentconfig.yaml
$userSettings = YAML::Tiny->read( "$indentconfig" );
# output the contents of indentconfig to the log file
- $self->logger(Dump \%{$userSettings->[0]});
-
+ $logger->info(Dump \%{$userSettings->[0]});
+
# update the absolute paths
@absPaths = @{$userSettings->[0]->{paths}};
} else {
if($switches{onlyDefault}) {
- $self->logger("Only default settings requested, not reading USER settings from $indentconfig");
- $self->logger("Ignoring $switches{readLocalSettings} (you used the -d switch)") if($switches{readLocalSettings});
- $self->logger("Ignoring the -y switch: $switches{yaml} (you used the -d switch)") if($switches{yaml});
+ $logger->info("*-d switch active: only default settings requested");
+ $logger->info("not reading USER settings from $indentconfig") if (-e $indentconfig);
+ $logger->info("Ignoring the -l switch: $switches{readLocalSettings} (you used the -d switch)") if($switches{readLocalSettings});
+ $logger->info("Ignoring the -y switch: $switches{yaml} (you used the -d switch)") if($switches{yaml});
$switches{readLocalSettings}=0;
$switches{yaml}=0;
} else {
# give the user instructions on where to put indentconfig.yaml or .indentconfig.yaml
- $self->logger("Home directory is $homeDir (didn't find either indentconfig.yaml or .indentconfig.yaml)");
- $self->logger("To specify user settings you would put indentconfig.yaml here: $homeDir/indentconfig.yaml");
- $self->logger("Alternatively, you can use the hidden file .indentconfig.yaml as: $homeDir/.indentconfig.yaml");
+ $logger->info("Home directory is $homeDir (didn't find either indentconfig.yaml or .indentconfig.yaml)\nTo specify user settings you would put indentconfig.yaml here: $homeDir/indentconfig.yaml\nAlternatively, you can use the hidden file .indentconfig.yaml as: $homeDir/.indentconfig.yaml");
}
}
+
# local settings can be called with a + symbol, for example
# -l=+myfile.yaml
# -l "+ myfile.yaml"
@@ -117,7 +132,7 @@
# will *only* load localSettings.yaml, and myfile.yaml will be ignored
my @localSettings;
- $self->logger("YAML settings read: -l switch",'heading') if $switches{readLocalSettings};
+ $logger->info("*YAML settings read: -l switch") if $switches{readLocalSettings};
# remove leading, trailing, and intermediate space
$switches{readLocalSettings} =~ s/^\h*//g;
@@ -124,13 +139,13 @@
$switches{readLocalSettings} =~ s/\h*$//g;
$switches{readLocalSettings} =~ s/\h*,\h*/,/g;
if($switches{readLocalSettings} =~ m/\+/){
- $self->logger("+ found in call for -l switch: will add localSettings.yaml");
+ $logger->info("+ found in call for -l switch: will add localSettings.yaml");
# + can be either at the beginning or the end, which determines if where the comma should go
my $commaAtBeginning = ($switches{readLocalSettings} =~ m/^\h*\+/ ? q() : ",");
my $commaAtEnd = ($switches{readLocalSettings} =~ m/^\h*\+/ ? "," : q());
$switches{readLocalSettings} =~ s/\h*\+\h*/$commaAtBeginning."localSettings.yaml".$commaAtEnd/e;
- $self->logger("New value of -l switch: $switches{readLocalSettings}");
+ $logger->info("New value of -l switch: $switches{readLocalSettings}");
}
# local settings can be separated by ,
@@ -138,8 +153,9 @@
# -l = myyaml1.yaml,myyaml2.yaml
# and in which case, we need to read them all
if($switches{readLocalSettings} =~ m/,/){
- $self->logger("Multiple localSettings found, separated by commas:");
+ $logger->info("Multiple localSettings found, separated by commas:");
@localSettings = split(/,/,$switches{readLocalSettings});
+ $logger->info(join(', ', at localSettings));
} else {
push(@localSettings,$switches{readLocalSettings}) if($switches{readLocalSettings});
}
@@ -161,21 +177,21 @@
# check for existence and non-emptiness
if ( (-e $_) and !(-z $_)) {
- $self->logger("Adding $_ to YAML read paths");
+ $logger->info("Adding $_ to YAML read paths");
push(@absPaths,"$_");
} elsif ( !(-e $_) ) {
- $self->logger("WARNING yaml file not found: $_ not found. Proceeding without it.");
+ $logger->warn("*yaml file not found: $_ not found. Proceeding without it.");
}
}
# heading for the log file
- $self->logger("YAML settings, reading from the following files:",'heading') if @absPaths;
+ $logger->info("*YAML settings, reading from the following files:") if @absPaths;
# read in the settings from each file
foreach my $settings (@absPaths) {
# check that the settings file exists and that it isn't empty
if (-e $settings and !(-z $settings)) {
- $self->logger("Reading USER settings from $settings");
+ $logger->info("Reading USER settings from $settings");
$userSettings = YAML::Tiny->read( "$settings" );
# if we can read userSettings
@@ -189,7 +205,7 @@
# if masterSettings 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(ref $masterSettings{$firstLevelKey}{$secondLevelKey} ne "HASH"){
- $self->logger("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);
+ $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} ;
}
while(my ($thirdLevelKey,$thirdLevelValue) = each %{$secondLevelValue}) {
@@ -196,7 +212,7 @@
if (ref $thirdLevelValue eq "HASH"){
# similarly for third level
if (ref $masterSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} ne "HASH"){
- $self->logger("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);
+ $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} ;
}
while(my ($fourthLevelKey,$fourthLevelValue) = each %{$thirdLevelValue}) {
@@ -217,21 +233,21 @@
# output settings to $logfile
if($masterSettings{logFilePreferences}{showEveryYamlRead}){
- $self->logger(Dump \%{$userSettings->[0]});
+ $logger->info(Dump \%{$userSettings->[0]});
} else {
- $self->logger("Not showing settings in the log file (see showEveryYamlRead and showAmalgamatedSettings).");
+ $logger->info("Not showing settings in the log file (see showEveryYamlRead and showAmalgamatedSettings).");
}
} else {
# otherwise print a warning that we can not read userSettings.yaml
- $self->logger("WARNING $settings contains invalid yaml format- not reading from it");
+ $logger->warn("*$settings contains invalid yaml format- not reading from it");
}
} else {
# otherwise keep going, but put a warning in the log file
- $self->logger("WARNING: $homeDir/indentconfig.yaml");
+ $logger->warn("*$homeDir/indentconfig.yaml");
if (-z $settings) {
- $self->logger("specifies $settings but this file is EMPTY -- not reading from it");
+ $logger->info("specifies $settings but this file is EMPTY -- not reading from it");
} else {
- $self->logger("specifies $settings but this file does not exist - unable to read settings from this file");
+ $logger->info("specifies $settings but this file does not exist - unable to read settings from this file");
}
}
}
@@ -239,16 +255,16 @@
# read settings from -y|--yaml switch
if($switches{yaml}){
# report to log file
- $self->logger("YAML settings read: -y switch",'heading');
+ $logger->info("*YAML settings read: -y switch");
# remove any horizontal space before or after , OR : OR ; or at the beginning or end of the switch value
- $switches{yaml} =~ s/\h*(,|:|;)\h*/$1/g;
+ $switches{yaml} =~ s/\h*(,|(?<!\\):|;)\h*/$1/g;
$switches{yaml} =~ s/^\h*//g;
# store settings, possibly multiple ones split by commas
my @yamlSettings;
- if($switches{yaml} =~ m/,/){
- @yamlSettings = split(/,/,$switches{yaml});
+ if($switches{yaml} =~ m/(?<!\\),/){
+ @yamlSettings = split(/(?<!\\),/,$switches{yaml});
} else {
push(@yamlSettings,$switches{yaml});
}
@@ -274,8 +290,8 @@
$settingsCounter++;
# check for a match of the ;
- if($_ =~ m/;/){
- my (@subfield) = split(/;/,$_);
+ if($_ =~ m/(?<!\\);/){
+ my (@subfield) = split(/(?<!\\);/,$_);
# the content up to the first ; is called the 'root'
my $root = shift @subfield;
@@ -312,7 +328,7 @@
# reform the root
$root = join(":", at keysValues);
- $self->logger("Sub-field detected (; present) and the root is: $root") if $is_t_switch_active;
+ $logger->trace("*Sub-field detected (; present) and the root is: $root") if $is_t_switch_active;
# now we need to attach the $root back together with any subfields
foreach(@subfield){
@@ -322,7 +338,7 @@
# increment the counter
$settingsCounter++;
}
- $self->logger("-y switch value interpreted as: ".join(',', at yamlSettings));
+ $logger->info("-y switch value interpreted as: ".join(',', at yamlSettings));
}
}
@@ -329,11 +345,15 @@
# loop through each of the settings specified in the -y switch
foreach(@yamlSettings){
# split each value at semi-colon
- my (@keysValues) = split(/:/,$_);
+ my (@keysValues) = split(/(?<!\\):/,$_);
# $value will always be the last element
my $value = $keysValues[-1];
+ # it's possible that the 'value' will contain an escaped
+ # semi-colon, so we replace it with just a semi-colon
+ $value =~ s/\\:/:/;
+
# horizontal space needs special treatment
if($value =~ m/^(?:"|')(\h*)(?:"|')$/){
# pure horizontal space
@@ -348,13 +368,13 @@
if(scalar(@keysValues) == 2){
# for example, -y="defaultIndent: ' '"
my $key = $keysValues[0];
- $self->logger("Updating masterSettings with $key: $value");
+ $logger->info("Updating masterSettings with $key: $value");
$masterSettings{$key} = $value;
} elsif(scalar(@keysValues) == 3){
# for example, -y="indentRules: one: '\t\t\t\t'"
my $parent = $keysValues[0];
my $child = $keysValues[1];
- $self->logger("Updating masterSettings with $parent: $child: $value");
+ $logger->info("Updating masterSettings with $parent: $child: $value");
$masterSettings{$parent}{$child} = $value;
} elsif(scalar(@keysValues) == 4){
# for example, -y='modifyLineBreaks : environments: EndStartsOnOwnLine:3' -m
@@ -361,7 +381,7 @@
my $parent = $keysValues[0];
my $child = $keysValues[1];
my $grandchild = $keysValues[2];
- $self->logger("Updating masterSettings with $parent: $child: $grandchild: $value");
+ $logger->info("Updating masterSettings with $parent: $child: $grandchild: $value");
$masterSettings{$parent}{$child}{$grandchild} = $value;
} elsif(scalar(@keysValues) == 5){
# for example, -y='modifyLineBreaks : environments: one: EndStartsOnOwnLine:3' -m
@@ -369,7 +389,7 @@
my $child = $keysValues[1];
my $grandchild = $keysValues[2];
my $greatgrandchild = $keysValues[3];
- $self->logger("Updating masterSettings with $parent: $child: $grandchild: $greatgrandchild: $value");
+ $logger->info("Updating masterSettings with $parent: $child: $grandchild: $greatgrandchild: $value");
$masterSettings{$parent}{$child}{$grandchild}{$greatgrandchild} = $value;
}
}
@@ -379,8 +399,8 @@
# which details the overall state of the settings modified
# from the default in various user files
if($masterSettings{logFilePreferences}{showAmalgamatedSettings}){
- $self->logger("Amalgamated/overall settings to be used:",'heading');
- $self->logger(Dump \%masterSettings);
+ $logger->info("Amalgamated/overall settings to be used:");
+ $logger->info(Dump \%masterSettings);
}
return;
@@ -392,12 +412,15 @@
# create a name for previously found settings
my $storageName = ${$self}{name}.${$self}{modifyLineBreaksYamlName}.(defined ${$self}{storageNameAppend}?${$self}{storageNameAppend}:q());
+ # grab the logging object
+ my $logger = get_logger("Document");
+
# check for storage of repeated objects
if ($previouslyFoundSettings{$storageName}){
- $self->logger("Using stored settings for $storageName") if($is_t_switch_active);
+ $logger->trace("*Using stored settings for $storageName") if($is_t_switch_active);
} else {
my $name = ${$self}{name};
- $self->logger("Storing settings for $storageName") if($is_t_switch_active);
+ $logger->trace("Storing settings for $storageName") if($is_t_switch_active);
# check for noAdditionalIndent and indentRules
# otherwise use defaultIndent
@@ -420,11 +443,9 @@
);
# don't forget alignment settings!
- ${${previouslyFoundSettings}{$storageName}}{lookForAlignDelims} = ${$self}{lookForAlignDelims} if(defined ${$self}{lookForAlignDelims});
- ${${previouslyFoundSettings}{$storageName}}{alignDoubleBackSlash} = ${$self}{alignDoubleBackSlash} if(defined ${$self}{alignDoubleBackSlash});
- ${${previouslyFoundSettings}{$storageName}}{spacesBeforeDoubleBackSlash} = ${$self}{spacesBeforeDoubleBackSlash} if(defined ${$self}{spacesBeforeDoubleBackSlash});
- ${${previouslyFoundSettings}{$storageName}}{multiColumnGrouping} = ${$self}{multiColumnGrouping} if(defined ${$self}{multiColumnGrouping});
- ${${previouslyFoundSettings}{$storageName}}{alignRowsWithoutMaxDelims} = ${$self}{alignRowsWithoutMaxDelims} if(defined ${$self}{alignRowsWithoutMaxDelims});
+ foreach (@alignAtAmpersandInformation){
+ ${${previouslyFoundSettings}{$storageName}}{${$_}{name}} = ${$self}{${$_}{name}} if(defined ${$self}{${$_}{name}});
+ }
# some objects, e.g ifElseFi, can have extra assignments, e.g ElseStartsOnOwnLine
# these need to be stored as well!
@@ -432,6 +453,10 @@
${${previouslyFoundSettings}{$storageName}}{$_} = ${$self}{$_};
}
+ # log file information
+ $logger->trace("Settings for $name (stored for future use):") if $is_tt_switch_active;
+ $logger->trace(Dump \%{${previouslyFoundSettings}{$storageName}}) if $is_tt_switch_active;
+
}
# append indentation settings to the current object
@@ -461,17 +486,25 @@
return unless ${$masterSettings{lookForAlignDelims}}{$name};
if(ref ${$masterSettings{lookForAlignDelims}}{$name} eq "HASH"){
- ${$self}{lookForAlignDelims} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{delims} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{delims} : 1;
- ${$self}{alignDoubleBackSlash} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{alignDoubleBackSlash} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{alignDoubleBackSlash} : 1;
- ${$self}{spacesBeforeDoubleBackSlash} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{spacesBeforeDoubleBackSlash} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{spacesBeforeDoubleBackSlash} : -1;
- ${$self}{multiColumnGrouping} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{multiColumnGrouping} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{multiColumnGrouping} : 0;
- ${$self}{alignRowsWithoutMaxDelims} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{alignRowsWithoutMaxDelims} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{alignRowsWithoutMaxDelims} : 1;
+ # specified as a hash, e.g
+ #
+ # lookForAlignDelims:
+ # tabular:
+ # delims: 1
+ # alignDoubleBackSlash: 1
+ # spacesBeforeDoubleBackSlash: 2
+ foreach (@alignAtAmpersandInformation){
+ my $yamlname = (defined ${$_}{yamlname} ? ${$_}{yamlname}: ${$_}{name});
+ ${$self}{${$_}{name}} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{$yamlname} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{$yamlname} : ${$_}{default};
+ }
} else {
- ${$self}{lookForAlignDelims} = 1;
- ${$self}{alignDoubleBackSlash} = 1;
- ${$self}{spacesBeforeDoubleBackSlash} = -1;
- ${$self}{multiColumnGrouping} = 0;
- ${$self}{alignRowsWithoutMaxDelims} = 1;
+ # specified as a scalar, e.g
+ #
+ # lookForAlignDelims:
+ # tabular: 1
+ foreach (@alignAtAmpersandInformation){
+ ${$self}{${$_}{name}} = ${$_}{default};
+ }
}
return;
}
@@ -482,8 +515,11 @@
my $self = shift;
+ # grab the logging object
+ my $logger = get_logger("Document");
+
# details to the log file
- $self->logger("-m modifylinebreaks switch active, looking for settings for ${$self}{name} ",'heading') if $is_t_switch_active;
+ $logger->trace("*-m modifylinebreaks switch active, looking for settings for ${$self}{name} ") if $is_t_switch_active;
# some objects, e.g ifElseFi, can have extra assignments, e.g ElseStartsOnOwnLine
my @toBeAssignedTo = ${$self}{additionalAssignments} ? @{${$self}{additionalAssignments}} : ();
@@ -522,11 +558,11 @@
my $name = ($YamlName =~ m/Arguments/) ? ${$self}{parent} : ${$self}{name};
if(ref ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName} eq "HASH"){
- $self->logger("$YamlName specified with fields in removeParagraphLineBreaks, looking for $name") if $is_t_switch_active;
+ $logger->trace("*$YamlName specified with fields in removeParagraphLineBreaks, looking for $name") if $is_t_switch_active;
${$self}{removeParagraphLineBreaks} = ${${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName}}{$name}||0;
} else {
if(defined ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName}){
- $self->logger("$YamlName specified with just a number in removeParagraphLineBreaks ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName}") if $is_t_switch_active;
+ $logger->trace("*$YamlName specified with just a number in removeParagraphLineBreaks ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName}") if $is_t_switch_active;
${$self}{removeParagraphLineBreaks} = ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName};
}
}
@@ -540,9 +576,12 @@
my $toBeAssignedTo = $input{toBeAssignedTo};
my $toBeAssignedToAlias = $input{toBeAssignedToAlias};
+ # grab the logging object
+ my $logger = get_logger("Document");
+
# alias
if(${$self}{aliases}{$toBeAssignedTo}){
- $self->logger("aliased $toBeAssignedTo using ${$self}{aliases}{$toBeAssignedTo}") if($is_t_switch_active);
+ $logger->trace("aliased $toBeAssignedTo using ${$self}{aliases}{$toBeAssignedTo}") if($is_t_switch_active);
}
# name of the object in the modifyLineBreaks yaml (e.g environments, ifElseFi, etc)
@@ -557,12 +596,12 @@
# check for the *custom* value
if (defined $customValue){
- $self->logger("$name: $toBeAssignedToAlias=$customValue, (*custom* value) adjusting $toBeAssignedTo") if($is_t_switch_active);
+ $logger->trace("$name: $toBeAssignedToAlias=$customValue, (*custom* value) adjusting $toBeAssignedTo") if($is_t_switch_active);
${$self}{$toBeAssignedTo} = $customValue !=0 ? $customValue : undef;
} else {
# check for the *every* value
if (defined $everyValue and $everyValue != 0){
- $self->logger("$name: $toBeAssignedToAlias=$everyValue, (*every* value) adjusting $toBeAssignedTo") if($is_t_switch_active);
+ $logger->trace("$name: $toBeAssignedToAlias=$everyValue, (*every* value) adjusting $toBeAssignedTo") if($is_t_switch_active);
${$self}{$toBeAssignedTo} = $everyValue;
}
}
@@ -619,24 +658,27 @@
# if the YamlName is not optionalArguments, mandatoryArguments, heading (possibly others) then assume we're looking for 'body'
my $YamlName = $self->get_object_attribute_for_indentation_settings;
+ # grab the logging object
+ my $logger = get_logger("Document");
+
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"){
- $self->logger("$indentationAbout indentation specified with multiple fields for $name, searching for $name: $YamlName (see $indentationAbout)") if $is_t_switch_active ;
+ $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};
} else {
$indentationInformation = ${$masterSettings{$indentationAbout}}{$name};
- $self->logger("$indentationAbout indentation specified for $name (for *all* fields, body, optionalArguments, mandatoryArguments, afterHeading), using '$indentationInformation' (see $indentationAbout)") if $is_t_switch_active ;
+ $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
if(defined $indentationInformation){
if($indentationAbout eq "noAdditionalIndent" and $indentationInformation == 1){
- $self->logger("Found! Using '' (see $indentationAbout)") if $is_t_switch_active;
+ $logger->trace("Found! Using '' (see $indentationAbout)") if $is_t_switch_active;
return q();
} elsif($indentationAbout eq "indentRules" and $indentationInformation=~m/^\h*$/){
- $self->logger("Found! Using '$indentationInformation' (see $indentationAbout)") if $is_t_switch_active;
+ $logger->trace("Found! Using '$indentationInformation' (see $indentationAbout)") if $is_t_switch_active;
return $indentationInformation ;
}
}
@@ -651,20 +693,20 @@
my $globalInformation = $indentationAbout."Global";
next if(!(defined ${$masterSettings{$globalInformation}}{$YamlName}));
if( ($globalInformation eq "noAdditionalIndentGlobal") and ${$masterSettings{$globalInformation}}{$YamlName}==1){
- $self->logger("$globalInformation specified for $YamlName (see $globalInformation)") if $is_t_switch_active;
+ $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*$/){
- $self->logger("$globalInformation specified for $YamlName (see $globalInformation)") if $is_t_switch_active;
+ $logger->trace("$globalInformation specified for $YamlName (see $globalInformation)") if $is_t_switch_active;
return ${$masterSettings{$globalInformation}}{$YamlName};
} else {
- $self->logger("$globalInformation specified (${$masterSettings{$globalInformation}}{$YamlName}) for $YamlName, but it needs to only contain horizontal space -- I'm ignoring this one") if $is_t_switch_active;
+ $logger->trace("$globalInformation specified (${$masterSettings{$globalInformation}}{$YamlName}) for $YamlName, but it needs to only contain horizontal space -- I'm ignoring this one") if $is_t_switch_active;
}
}
}
# return defaultIndent, by default
- $self->logger("Using defaultIndent for $name") if $is_t_switch_active;
+ $logger->trace("Using defaultIndent for $name") if $is_t_switch_active;
return $masterSettings{defaultIndent};
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Heading.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Heading.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Heading.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -20,6 +20,7 @@
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::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
@@ -35,20 +36,20 @@
my %headingsLevels = %{$masterSettings{indentAfterHeadings}};
# output to log file
- $self->logger("Constructing headings reg exp for example, chapter, section, etc (see indentAfterThisHeading)") if $is_t_switch_active ;
+ $logger->trace("*Constructing headings reg exp for example, chapter, section, etc (see indentAfterThisHeading)") if $is_t_switch_active ;
# delete the values that have indentAfterThisHeading set to 0
while( my ($headingName,$headingInfo)= each %headingsLevels){
if(!${$headingsLevels{$headingName}}{indentAfterThisHeading}){
- $self->logger("Not indenting after $headingName (see indentAfterThisHeading)",'heading') if $is_t_switch_active;
+ $logger->trace("Not indenting after $headingName (see indentAfterThisHeading)") if $is_t_switch_active;
delete $headingsLevels{$headingName};
} else {
- # *all heading* regexp, remembering put starred headings at the front of the regexp
+ # *all heading* regexp, remembering to put starred headings at the front of the regexp
if($headingName =~ m/\*/){
- $self->logger("Putting $headingName at the beginning of the allHeadings regexp, as it contains a *") if $is_t_switch_active ;
+ $logger->trace("Putting $headingName at the beginning of the allHeadings regexp, as it contains a *") if $is_t_switch_active ;
$allHeadingsRegexp = $headingName.($allHeadingsRegexp eq '' ?q():"|$allHeadingsRegexp");
} else {
- $self->logger("Putting $headingName at the END of the allHeadings regexp, as it contains a *") if $is_t_switch_active ;
+ $logger->trace("Putting $headingName at the END of the allHeadings regexp") if $is_t_switch_active ;
$allHeadingsRegexp .= ($allHeadingsRegexp eq '' ?q():"|").$headingName ;
}
}
@@ -63,8 +64,8 @@
# it could be that @sortedByLevels is empty;
return if !@sortedByLevels;
- $self->logger("All headings regexp: $allHeadingsRegexp",'heading') if $is_t_switch_active;
- $self->logger("Now to construct headings regexp for each level:",'heading') if $is_t_switch_active;
+ $logger->trace("*All headings regexp: $allHeadingsRegexp") if $is_tt_switch_active;
+ $logger->trace("*Now to construct headings regexp for each level:") if $is_t_switch_active;
# loop through the levels, and create a regexp for each (min and max values are the first and last values respectively from sortedByLevels)
for(my $i = ${$headingsLevels{$sortedByLevels[0]}}{level}; $i <= ${$headingsLevels{$sortedByLevels[-1]}}{level}; $i++ ){
@@ -75,10 +76,10 @@
foreach(@tmp){
# put starred headings at the front of the regexp
if($_ =~ m/\*/){
- $self->logger("Putting $_ at the beginning of this regexp, as it contains a *") if $is_t_switch_active;
+ $logger->trace("Putting $_ at the beginning of this regexp (level $i), as it contains a *") if $is_t_switch_active;
$headingsAtThisLevel = $_.($headingsAtThisLevel eq '' ?q():"|$headingsAtThisLevel");
} else {
- $self->logger("Putting $_ at the END of this regexp, as it contains a *") if $is_t_switch_active;
+ $logger->trace("Putting $_ at the END of this regexp (level $i)") if $is_t_switch_active;
$headingsAtThisLevel .= ($headingsAtThisLevel eq '' ?q():"|").$_ ;
}
}
@@ -86,7 +87,7 @@
# make the stars escaped correctly
$headingsAtThisLevel =~ s/\*/\\\*/g;
push(@headingsRegexpArray,$headingsAtThisLevel);
- $self->logger("Heading level regexp for level $i will contain: $headingsAtThisLevel") if $is_t_switch_active;
+ $logger->trace("Heading level regexp for level $i will contain: $headingsAtThisLevel") if $is_t_switch_active;
}
}
}
@@ -99,7 +100,7 @@
my $self = shift;
# otherwise loop through the headings regexp
- $self->logger("Searching for headings ") if $is_t_switch_active;
+ $logger->trace("*Searching ${$self}{name} for headings ") if $is_t_switch_active;
# loop through each headings match; note that we need to
# do it in *reverse* so as to ensure that the lower level headings get matched first of all
@@ -120,7 +121,7 @@
while(${$self}{body} =~ m/$headingRegExp/){
# log file output
- $self->logger("heading found: $2",'heading');
+ $logger->trace("heading found: $2") if $is_t_switch_active;
${$self}{body} =~ s/
$headingRegExp
@@ -154,7 +155,7 @@
my $self = shift;
# the replacement text for a heading (chapter, section, etc) needs to put the trailing part back in
- $self->logger("Custom replacement text routine for heading ${$self}{name}");
+ $logger->trace("Custom replacement text routine for ${$self}{name}") if $is_t_switch_active;
${$self}{replacementText} = ${$self}{id}.${$self}{afterbit};
delete ${$self}{afterbit};
}
@@ -209,15 +210,15 @@
#
# then we need to transfer this information to the heading object
if($is_m_switch_active){
- $self->logger("Searching for linebreak preferences immediately infront of ${$self}{parent}",'heading');
+ $logger->trace("Searching for linebreak preferences immediately infront of ${$self}{parent}") if $is_t_switch_active;
foreach(@{${$self}{children}}){
if(${$_}{name} eq ${$self}{parent}){
- $self->logger("Named child found: ${$_}{name}");
+ $logger->trace("Named child found: ${$_}{name}") if $is_t_switch_active;
if(defined ${$_}{BeginStartsOnOwnLine}){
- $self->logger("Transferring information from ${$_}{id} (${$_}{name}) to ${$self}{id} (${$self}{name}) for BeginStartsOnOwnLine");
+ $logger->trace("Transferring information from ${$_}{id} (${$_}{name}) to ${$self}{id} (${$self}{name}) for BeginStartsOnOwnLine") if $is_t_switch_active;
${$self}{BeginStartsOnOwnLine} = ${$_}{BeginStartsOnOwnLine};
} else {
- $self->logger("No information found in ${$_}{name} for BeginStartsOnOwnLine");
+ $logger->trace("No information found in ${$_}{name} for BeginStartsOnOwnLine") if $is_t_switch_active;
}
last;
}
@@ -235,7 +236,7 @@
# but some (e.g HEADING) have their own method
my $self = shift;
- $self->logger("Adding surrounding indentation after (empty, by design!) begin statement of ${$self}{name} (${$self}{id})");
+ $logger->trace("Adding surrounding indentation after (empty, by design!) begin statement of ${$self}{name} (${$self}{id})") if $is_t_switch_active;
${$self}{begin} .= ${$self}{surroundingIndentation}; # add indentation
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/HiddenChildren.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/HiddenChildren.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/HiddenChildren.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -18,6 +18,7 @@
use warnings;
use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
use LatexIndent::Tokens qw/%tokens/;
+use LatexIndent::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @EXPORT_OK = qw/find_surrounding_indentation_for_children update_family_tree get_family_tree check_for_hidden_children %familyTree/;
@@ -71,23 +72,23 @@
my $self = shift;
# output to logfile
- $self->logger("FamilyTree before update:",'heading') if $is_t_switch_active;
- $self->logger(Dumper(\%familyTree)) if($is_t_switch_active);
+ $logger->trace("*FamilyTree before update:") if $is_tt_switch_active;
+ $logger->trace(Dumper(\%familyTree)) if($is_tt_switch_active);
# update the family tree with ancestors
$self->update_family_tree;
# output information to the logfile
- $self->logger("FamilyTree after update:",'heading') if $is_t_switch_active;
- $self->logger(Dumper(\%familyTree)) if($is_t_switch_active);
+ $logger->trace("*FamilyTree after update:") if $is_tt_switch_active;
+ $logger->trace(Dumper(\%familyTree)) if($is_tt_switch_active);
while( my ($idToSearch,$ancestorToSearch) = each %familyTree){
- $self->logger("Hidden child ID: ,$idToSearch, here are its ancestors:",'heading') if $is_t_switch_active;
+ $logger->trace("*Hidden child ID: ,$idToSearch, here are its ancestors:") if $is_t_switch_active;
foreach(@{${$ancestorToSearch}{ancestors}}){
- $self->logger("ID: ${$_}{ancestorID}") if($is_t_switch_active);
+ $logger->trace("ID: ${$_}{ancestorID}") if($is_t_switch_active);
my $tmpIndentation = ref(${$_}{ancestorIndentation}) eq 'SCALAR'?${${$_}{ancestorIndentation}}:${$_}{ancestorIndentation};
$tmpIndentation = $tmpIndentation ? $tmpIndentation : q();
- $self->logger("indentation: '$tmpIndentation'") if($is_t_switch_active);
+ $logger->trace("indentation: '$tmpIndentation'") if($is_t_switch_active);
}
}
@@ -98,19 +99,19 @@
my $self = shift;
# loop through the hash
- $self->logger("Updating FamilyTree...",'heading') if $is_t_switch_active;
+ $logger->trace("*Updating FamilyTree...") if $is_t_switch_active;
while( my ($idToSearch,$ancestorToSearch)= each %familyTree){
foreach(@{${$ancestorToSearch}{ancestors}}){
my $ancestorID = ${$_}{ancestorID};
- $self->logger("current ID: $idToSearch, ancestor: $ancestorID") if($is_t_switch_active);
+ $logger->trace("current ID: $idToSearch, ancestor: $ancestorID") if($is_t_switch_active);
if($familyTree{$ancestorID}){
- $self->logger("$ancestorID is a key within familyTree, grabbing its ancestors") if($is_t_switch_active);
+ $logger->trace("$ancestorID is a key within familyTree, grabbing its ancestors") if($is_t_switch_active);
my $naturalAncestors = q();
foreach(@{${$familyTree{$idToSearch}}{ancestors}}){
$naturalAncestors .= "---".${$_}{ancestorID} if(${$_}{type} eq "natural");
}
foreach(@{${$familyTree{$ancestorID}}{ancestors}}){
- $self->logger("ancestor of *hidden* child: ${$_}{ancestorID}") if($is_t_switch_active);
+ $logger->trace("ancestor of *hidden* child: ${$_}{ancestorID}") if($is_t_switch_active);
my $newAncestorId = ${$_}{ancestorID};
my $type;
if($naturalAncestors =~ m/$ancestorID/){
@@ -126,7 +127,7 @@
foreach(@{${$familyTree{$idToSearch}}{ancestors}}){
$naturalAncestors .= "---".${$_}{ancestorID} if(${$_}{type} eq "natural");
}
- $self->logger("natural ancestors of $ancestorID: $naturalAncestors") if($is_t_switch_active);
+ $logger->trace("natural ancestors of $ancestorID: $naturalAncestors") if($is_t_switch_active);
foreach(@{${$allChildren{$ancestorID}}{ancestors}}){
my $newAncestorId = ${$_}{ancestorID};
my $type;
@@ -137,7 +138,7 @@
}
my $matched = grep { $_->{ancestorID} eq $newAncestorId } @{${$familyTree{$idToSearch}}{ancestors}};
unless($matched){
- $self->logger("ancestor of UNHIDDEN child: ${$_}{ancestorID}") if($is_t_switch_active);
+ $logger->trace("ancestor of UNHIDDEN child: ${$_}{ancestorID}") if($is_t_switch_active);
push(@{${$familyTree{$idToSearch}}{ancestors}},{ancestorID=>${$_}{ancestorID},ancestorIndentation=>${$_}{ancestorIndentation},type=>$type});
}
}
@@ -158,8 +159,8 @@
my @matched = (${$self}{body} =~ /((?:$tokens{ifelsefiSpecial})?$tokens{beginOfToken}.[-a-z0-9]+?$tokens{endOfToken})/ig);
# log file
- $self->logger("Hidden children check") if $is_t_switch_active;
- $self->logger(join("|", at matched)) if $is_t_switch_active;
+ $logger->trace("*Hidden children check") if $is_t_switch_active;
+ $logger->trace(join("|", at matched)) if $is_t_switch_active;
my $naturalAncestors = ${$self}{naturalAncestors};
@@ -171,7 +172,7 @@
my $newAncestorId = ${$_}{ancestorID};
unless (grep { $_->{ancestorID} eq $newAncestorId } @{${$familyTree{$match}}{ancestors}}){
my $type = ($naturalAncestors =~ m/${$_}{ancestorID}/ ) ? "natural" : "adopted";
- $self->logger("Adding ${$_}{ancestorID} to the $type family tree of $match") if($is_t_switch_active);
+ $logger->trace("Adding ${$_}{ancestorID} to the $type family tree of $match") if($is_t_switch_active);
push(@{$familyTree{$match}{ancestors}},{ancestorID=>${$_}{ancestorID},ancestorIndentation=>${$_}{ancestorIndentation},type=>$type});
}
}
@@ -180,7 +181,7 @@
# update the family tree with self
unless (grep { $_->{ancestorID} eq ${$self}{id}} @{${$familyTree{$match}}{ancestors}}){
my $type = ($naturalAncestors =~ m/${$self}{id}/ ) ? "natural" : "adopted";
- $self->logger("Adding ${$self}{id} to the $type family tree of hiddenChild $match") if($is_t_switch_active);
+ $logger->trace("Adding ${$self}{id} to the $type family tree of hiddenChild $match") if($is_t_switch_active);
push(@{$familyTree{$match}{ancestors}},{ancestorID=>${$self}{id},ancestorIndentation=>${$self}{indentation},type=>$type});
}
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/HorizontalWhiteSpace.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/HorizontalWhiteSpace.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/HorizontalWhiteSpace.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -18,6 +18,7 @@
use warnings;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
+use LatexIndent::LogFile qw/$logger/;
use Exporter qw/import/;
our @EXPORT_OK = qw/remove_trailing_whitespace remove_leading_space/;
@@ -25,10 +26,12 @@
my $self = shift;
my %input = @_;
+ $logger->trace("*Horizontal space removal routine") if $is_t_switch_active;
+
# 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'){
- $self->logger("removeTrailingWhitespace specified as scalar, will update it to be a hash",'heading') if $is_t_switch_active;
+ $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};
@@ -38,17 +41,17 @@
# redefine it as a hash
${$masterSettings{removeTrailingWhitespace}}{beforeProcessing} = $removeTWS;
${$masterSettings{removeTrailingWhitespace}}{afterProcessing} = $removeTWS;
- $self->logger("removeTrailingWhitespace: beforeProcessing is now $removeTWS") if $is_t_switch_active;
- $self->logger("removeTrailingWhitespace: afterProcessing is now $removeTWS") if $is_t_switch_active;
+ $logger->trace("removeTrailingWhitespace: beforeProcessing is now $removeTWS") if $is_t_switch_active;
+ $logger->trace("removeTrailingWhitespace: afterProcessing is now $removeTWS") if $is_t_switch_active;
}
# this method can be called before the indendation, and after, depending upon the input
if($input{when} eq "before"){
return unless(${$masterSettings{removeTrailingWhitespace}}{beforeProcessing});
- $self->logger("Removing trailing white space *before* the document is processed (see removeTrailingWhitespace: beforeProcessing)",'heading') if $is_t_switch_active;
+ $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});
- $self->logger("Removing trailing white space *after* the document is processed (see removeTrailingWhitespace: afterProcessing)",'heading') if $is_t_switch_active;
+ $logger->trace("Removing trailing white space *after* the document is processed (see removeTrailingWhitespace: afterProcessing)") if $is_t_switch_active;
} else {
return;
}
@@ -58,14 +61,11 @@
$ # up to the end of a line
//xsmg;
- $self->logger("Processed body, *$input{when}* indentation (${$self}{name}):") if($is_t_switch_active);
- $self->logger(${$self}{body}) if($is_t_switch_active);
-
}
sub remove_leading_space{
my $self = shift;
- $self->logger("Removing leading space from ${$self}{name} (verbatim/noindentblock already accounted for)",'heading') if $is_t_switch_active;
+ $logger->trace("*Removing leading space from ${$self}{name} (verbatim/noindentblock already accounted for)") if $is_t_switch_active;
${$self}{body} =~ s/
(
^ # beginning of the line
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/IfElseFi.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/IfElseFi.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/IfElseFi.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,6 +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::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
@@ -62,9 +63,6 @@
${$self}{body} =~ s/
$ifElseFiRegExp(\h*)($trailingCommentRegExp)?
/
- # log file output
- $self->logger("IfElseFi found: $2",'heading')if $is_t_switch_active;
-
# create a new IfElseFi object
my $ifElseFi = LatexIndent::IfElseFi->new(begin=>$1.(($4 eq "\n" and !$3)?"\n":q()),
name=>$2,
@@ -88,6 +86,9 @@
endImmediatelyFollowedByComment=>$9?0:($11?1:0),
horizontalTrailingSpace=>$8?$8:q(),
);
+ # log file output
+ $logger->trace("*IfElseFi found: $2")if $is_t_switch_active;
+
# the settings and storage of most objects has a lot in common
$self->get_settings_and_store_new_object($ifElseFi);
${@{${$self}{children}}[-1]}{replacementText}.($10?$10:q()).($11?$11:q());
@@ -104,7 +105,7 @@
and
!(${$self}{body} =~ m/^\h*\\else/s and ${$self}{linebreaksAtEnd}{begin}==0)
){
- $self->logger("Adding surrounding indentation to \\else statement ('${$self}{surroundingIndentation}')") if $is_t_switch_active;
+ $logger->trace("*Adding surrounding indentation to \\else statement ('${$self}{surroundingIndentation}')") if $is_t_switch_active;
${$self}{body} =~ s/^\h*\\else/${$self}{surroundingIndentation}\\else/sm;
}
return;
@@ -155,10 +156,10 @@
# text
# after:
# \fitext
- $self->logger("Adding a single space after \\fi statement (otherwise \\fi can be comined with next line of text in an unwanted way)",'heading') if $is_t_switch_active;
+ $logger->trace("*Adding a single space after \\fi statement (otherwise \\fi can be comined with next line of text in an unwanted way)") if $is_t_switch_active;
${$self}{end} =${$self}{end}." ";
}
- $self->logger("Finished indenting ${$self}{name}",'heading') if $is_t_switch_active;
+ $logger->trace("*Finished indenting ${$self}{name}") if $is_t_switch_active;
return $self;
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Indent.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Indent.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Indent.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -20,6 +20,7 @@
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::LogFile qw/$logger/;
use Text::Tabs;
use Data::Dumper;
use Exporter qw/import/;
@@ -42,7 +43,7 @@
$self->indent_end_statement;
# output the completed object to the log file
- $self->logger("Complete indented object (${$self}{name}) after indentation:\n${$self}{begin}${$self}{body}${$self}{end}") if $is_t_switch_active;
+ $logger->trace("Complete indented object (${$self}{name}) after indentation:\n${$self}{begin}${$self}{body}${$self}{end}") if $is_tt_switch_active;
# wrap-up statement
$self->wrap_up_statement;
@@ -51,7 +52,7 @@
sub wrap_up_statement{
my $self = shift;
- $self->logger("Finished indenting ${$self}{name}",'heading') if $is_t_switch_active;
+ $logger->trace("*Finished indenting ${$self}{name}") if $is_t_switch_active;
return $self;
}
@@ -63,13 +64,13 @@
# logfile information
my $surroundingIndentation = ${$self}{surroundingIndentation};
- $self->logger("indenting object ${$self}{name}") if($is_t_switch_active);
+ $logger->trace("indenting object ${$self}{name}") if($is_t_switch_active);
(my $during = $surroundingIndentation) =~ s/\t/TAB/g;
- $self->logger("indentation *surrounding* object: '$during'") if($is_t_switch_active);
+ $logger->trace("indentation *surrounding* object: '$during'") if($is_t_switch_active);
($during = ${$self}{indentation}) =~ s/\t/TAB/g;
- $self->logger("indentation *of* object: '$during'") if($is_t_switch_active);
+ $logger->trace("indentation *of* object: '$during'") if($is_t_switch_active);
($during = $surroundingIndentation.${$self}{indentation}) =~ s/\t/TAB/g;
- $self->logger("*total* indentation to be added: '$during'") if($is_t_switch_active);
+ $logger->trace("*total* indentation to be added: '$during'") if($is_t_switch_active);
# form the total indentation of the object
${$self}{indentation} = $surroundingIndentation.${$self}{indentation};
@@ -82,11 +83,11 @@
my $surroundingIndentation = q();
if($familyTree{${$self}{id}}){
- $self->logger("Adopted ancestors found!") if($is_t_switch_active);
+ $logger->trace("Adopted ancestors found!") if($is_t_switch_active);
foreach(@{${$familyTree{${$self}{id}}}{ancestors}}){
if(${$_}{type} eq "adopted"){
my $newAncestorId = ${$_}{ancestorID};
- $self->logger("ancestor ID: $newAncestorId, adding indentation of $newAncestorId to surroundingIndentation of ${$self}{id}") if($is_t_switch_active);
+ $logger->trace("ancestor ID: $newAncestorId, adding indentation of $newAncestorId to surroundingIndentation of ${$self}{id}") if($is_t_switch_active);
$surroundingIndentation .= ref(${$_}{ancestorIndentation}) eq 'SCALAR'
?
(${${$_}{ancestorIndentation}}?${${$_}{ancestorIndentation}}:q())
@@ -111,7 +112,7 @@
my $indentation = ${$self}{indentation};
# output to the logfile
- $self->logger("Body (${$self}{name}) before indentation:\n${$self}{body}") if $is_t_switch_active;
+ $logger->trace("Body (${$self}{name}) before indentation:\n${$self}{body}") if $is_tt_switch_active;
# last minute check for modified bodyLineBreaks
$self->count_body_line_breaks if $is_m_switch_active;
@@ -128,10 +129,10 @@
# body indendation
if(${$self}{linebreaksAtEnd}{begin}==1){
if(${$self}{body} =~ m/^\h*$/s){
- $self->logger("Body of ${$self}{name} is empty, not applying indentation") if $is_t_switch_active;
+ $logger->trace("Body of ${$self}{name} is empty, not applying indentation") if $is_t_switch_active;
} else {
# put any existing horizontal space after the current indentation
- $self->logger("Entire body of ${$self}{name} receives indendentation") if $is_t_switch_active;
+ $logger->trace("Entire body of ${$self}{name} receives indendentation") if $is_t_switch_active;
${$self}{body} =~ s/^(\h*)/$indentation$1/mg; # add indentation
}
} elsif(${$self}{linebreaksAtEnd}{begin}==0 and ${$self}{bodyLineBreaks}>0) {
@@ -142,12 +143,12 @@
/sx){
my $bodyFirstLine = $1;
my $remainingBody = $2;
- $self->logger("first line of body: $bodyFirstLine",'heading') if $is_t_switch_active;
- $self->logger("remaining body (before indentation):\n'$remainingBody'") if($is_t_switch_active);
+ $logger->trace("first line of body: $bodyFirstLine") if $is_tt_switch_active;
+ $logger->trace("remaining body (before indentation):\n'$remainingBody'") if($is_tt_switch_active);
# add the indentation to all the body except first line
$remainingBody =~ s/^/$indentation/mg unless($remainingBody eq ''); # add indentation
- $self->logger("remaining body (after indentation):\n$remainingBody'") if($is_t_switch_active);
+ $logger->trace("remaining body (after indentation):\n$remainingBody'") if($is_tt_switch_active);
# put the body back together
${$self}{body} = $bodyFirstLine."\n".$remainingBody;
@@ -162,12 +163,12 @@
# the final linebreak can be modified by a child object; see test-cases/commands/figureValign-mod5.tex, for example
if($is_m_switch_active and defined ${$self}{linebreaksAtEnd}{body} and ${$self}{linebreaksAtEnd}{body}==1 and ${$self}{body} !~ m/\R$/ and ${$self}{body} ne ''){
- $self->logger("Adding a linebreak at end of body for ${$self}{name} to contain a linebreak at the end (linebreaksAtEnd is 1, but there isn't currently a linebreak)") if($is_t_switch_active);
+ $logger->trace("Adding a linebreak at end of body for ${$self}{name} to contain a linebreak at the end (linebreaksAtEnd is 1, but there isn't currently a linebreak)") if($is_t_switch_active);
${$self}{body} .= "\n";
}
# output to the logfile
- $self->logger("Body (${$self}{name}) after indentation:\n${$self}{body}") if $is_t_switch_active;
+ $logger->trace("Body (${$self}{name}) after indentation:\n${$self}{body}") if $is_tt_switch_active;
return $self;
}
@@ -195,7 +196,7 @@
# end{statement} indentation, e.g \end{environment}, \fi, }, etc
if(${$self}{linebreaksAtEnd}{body}){
${$self}{end} =~ s/^\h*/$surroundingIndentation/mg; # add indentation
- $self->logger("Adding surrounding indentation to ${$self}{end} (${$self}{name}: '$surroundingIndentation')") if($is_t_switch_active);
+ $logger->trace("Adding surrounding indentation to ${$self}{end} (${$self}{name}: '$surroundingIndentation')") if($is_t_switch_active);
}
return $self;
}
@@ -222,12 +223,12 @@
# count the number of tabs
$numberOfTABS = () = $indentation=~ \/\t\/g;
- $self->logger("Number of tabs: $numberOfTABS") if($is_t_switch_active);
+ $logger->trace("Number of tabs: $numberOfTABS") if($is_t_switch_active);
# log the after
($after = $indentation) =~ s|\t||g;
$after = "TAB"x$numberOfTABS.$after;
- $self->logger("Indentation after: '$after'") if($is_t_switch_active);
+ $logger->trace("Indentation after: '$after'") if($is_t_switch_active);
($indentation = $after) =~s|TAB|\t|g;
$indentation;
@@ -236,7 +237,7 @@
return unless($masterSettings{maximumIndentation} =~ m/^\h+$/);
# maximum indentation check
- $self->logger("Maximum indentation check",'heading') if($is_t_switch_active);
+ $logger->trace("*Maximum indentation check") if($is_t_switch_active);
# replace any leading tabs with spaces, and update the body
my @expanded_lines = expand(${$self}{body});
@@ -255,22 +256,22 @@
my $self = shift;
unless(defined ${$self}{children}) {
- $self->logger("No child objects (${$self}{name})") if $is_t_switch_active;
+ $logger->trace("No child objects (${$self}{name})") if $is_t_switch_active;
return;
}
- $self->logger('Pre-processed body:','heading') if $is_t_switch_active;
- $self->logger(${$self}{body}) if($is_t_switch_active);
+ $logger->trace('Pre-processed body:') if $is_tt_switch_active;
+ $logger->trace(${$self}{body}) if($is_tt_switch_active);
# send the children through this indentation routine recursively
if(defined ${$self}{children}){
foreach my $child (@{${$self}{children}}){
- $self->logger("Indenting child objects on ${$child}{name}") if $is_t_switch_active;
+ $logger->trace("Indenting child objects on ${$child}{name}") if $is_t_switch_active;
$child->indent_children_recursively;
}
}
- $self->logger("Replacing ids with begin, body, and end statements:",'heading') if $is_t_switch_active;
+ $logger->trace("*Replacing ids with begin, body, and end statements:") if $is_t_switch_active;
# loop through document children hash
while( scalar (@{${$self}{children}}) > 0 ){
@@ -277,7 +278,7 @@
my $index = 0;
# we work through the array *in order*
foreach my $child (@{${$self}{children}}){
- $self->logger("Searching ${$self}{name} for ${$child}{id}...",'heading') if $is_t_switch_active;
+ $logger->trace("Searching ${$self}{name} for ${$child}{id}...") if $is_t_switch_active;
if(${$self}{body} =~ m/${$child}{id}/s){
# we only care if id is first non-white space character
# and if followed by line break
@@ -291,13 +292,14 @@
or
${$self}{body} =~ m/^\h\h*${$child}{id}/m
) ?1:0;
- $IDFollowedImmediatelyByLineBreak = (${$self}{body} =~ m/${$child}{id}\h*\R*/m) ?1:0;
+ $IDFollowedImmediatelyByLineBreak = (${$self}{body} =~ m/${$child}{id}\h*\R+/m) ?1:0;
+ ${$child}{IDFollowedImmediatelyByLineBreak} = $IDFollowedImmediatelyByLineBreak;
}
# log file info
- $self->logger("${$child}{id} found!") if($is_t_switch_active);
- $self->logger("Indenting ${$child}{name} (id: ${$child}{id})",'heading') if $is_t_switch_active;
- $self->logger("looking up indentation scheme for ${$child}{name}") if($is_t_switch_active);
+ $logger->trace("${$child}{id} found!") if($is_t_switch_active);
+ $logger->trace("*Indenting ${$child}{name} (id: ${$child}{id})") if $is_t_switch_active;
+ $logger->trace("looking up indentation scheme for ${$child}{name}") if($is_t_switch_active);
# line break checks *after* <end statement>
if (defined ${$child}{EndFinishesWithLineBreak}
@@ -305,7 +307,7 @@
and $IDFollowedImmediatelyByLineBreak) {
# remove line break *after* <end statement>, if appropriate
my $EndStringLogFile = ${$child}{aliases}{EndFinishesWithLineBreak}||"EndFinishesWithLineBreak";
- $self->logger("Removing linebreak after ${$child}{end} (see $EndStringLogFile)") if $is_t_switch_active;
+ $logger->trace("Removing linebreak after ${$child}{end} (see $EndStringLogFile)") if $is_t_switch_active;
${$self}{body} =~ s/${$child}{id}(\h*)?(\R|\h)*/${$child}{id}$1/s;
${$child}{linebreaksAtEnd}{end} = 0;
}
@@ -329,15 +331,15 @@
# by default, assume that no trailing comment token is needed
my $trailingCharacterToken = q();
if(${$child}{BeginStartsOnOwnLine}==2){
- $self->logger("Removing space immediately before ${$child}{id}, in preparation for adding % ($BeginStringLogFile == 2)") if $is_t_switch_active;
+ $logger->trace("Removing space immediately before ${$child}{id}, in preparation for adding % ($BeginStringLogFile == 2)") if $is_t_switch_active;
${$self}{body} =~ s/\h*${$child}{id}/${$child}{id}/s;
- $self->logger("Adding a % at the end of the line that ${$child}{begin} is on, then a linebreak ($BeginStringLogFile == 2)") if $is_t_switch_active;
+ $logger->trace("Adding a % at the end of the line that ${$child}{begin} is on, then a linebreak ($BeginStringLogFile == 2)") if $is_t_switch_active;
$trailingCharacterToken = "%".$self->add_comment_symbol;
} elsif (${$child}{BeginStartsOnOwnLine}==3){
- $self->logger("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;
+ $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());
} else {
- $self->logger("Adding a linebreak at the beginning of ${$child}{begin} (see $BeginStringLogFile)") if $is_t_switch_active;
+ $logger->trace("Adding a linebreak at the beginning of ${$child}{begin} (see $BeginStringLogFile)") if $is_t_switch_active;
}
# the trailing comment/linebreak magic
@@ -351,33 +353,33 @@
# important to check we don't move the begin statement next to a blank-line-token
my $blankLineToken = $tokens{blanklines};
if(${$self}{body} !~ m/$blankLineToken\R*\h*${$child}{id}/s){
- $self->logger("Removing linebreak before ${$child}{begin} (see $BeginStringLogFile in ${$child}{modifyLineBreaksYamlName} YAML)") if $is_t_switch_active;
+ $logger->trace("Removing linebreak before ${$child}{begin} (see $BeginStringLogFile in ${$child}{modifyLineBreaksYamlName} YAML)") if $is_t_switch_active;
${$self}{body} =~ s/(\h*)(?:\R*|\h*)+${$child}{id}/$1${$child}{id}/s;
} else {
- $self->logger("Not removing linebreak ahead of ${$child}{begin}, as blank-line-token present (see preserveBlankLines)") if $is_t_switch_active;
+ $logger->trace("Not removing linebreak ahead of ${$child}{begin}, as blank-line-token present (see preserveBlankLines)") if $is_t_switch_active;
}
}
}
- $self->logger(Dumper(\%{$child}),'ttrace') if($is_tt_switch_active);
+ $logger->trace(Dumper(\%{$child})) if($is_tt_switch_active);
# replace ids with body
${$self}{body} =~ s/${$child}{id}/${$child}{begin}${$child}{body}${$child}{end}/;
# log file info
- $self->logger("Body (${$self}{name}) now looks like:",'heading') if $is_t_switch_active;
- $self->logger(${$self}{body}) if($is_t_switch_active);
+ $logger->trace("Body (${$self}{name}) now looks like:") if $is_tt_switch_active;
+ $logger->trace(${$self}{body}) if($is_tt_switch_active);
# remove element from array: http://stackoverflow.com/questions/174292/what-is-the-best-way-to-delete-a-value-from-an-array-in-perl
splice(@{${$self}{children}}, $index, 1);
# output to the log file
- $self->logger("deleted child key ${$child}{name} (parent is: ${$self}{name})") if $is_t_switch_active;
+ $logger->trace("deleted child key ${$child}{name} (parent is: ${$self}{name})") if $is_t_switch_active;
# restart the loop, as the size of the array has changed
last;
} else {
- $self->logger("${$child}{id} not found") if($is_t_switch_active);
+ $logger->trace("${$child}{id} not found") if($is_t_switch_active);
}
# increment the loop counter
@@ -386,10 +388,10 @@
}
# logfile info
- $self->logger("${$self}{name} has this many children:",'heading') if $is_t_switch_active;
- $self->logger(scalar @{${$self}{children}}) if $is_t_switch_active;
- $self->logger("Post-processed body (${$self}{name}):") if($is_t_switch_active);
- $self->logger(${$self}{body}) if($is_t_switch_active);
+ $logger->trace("${$self}{name} has this many children:") if $is_tt_switch_active;
+ $logger->trace(scalar @{${$self}{children}}) if $is_tt_switch_active;
+ $logger->trace("Post-processed body (${$self}{name}):") if($is_tt_switch_active);
+ $logger->trace(${$self}{body}) if($is_tt_switch_active);
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Item.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Item.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Item.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -20,6 +20,7 @@
use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
+use LatexIndent::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
@@ -37,7 +38,7 @@
}
# detail items in the log
- $self->logger("List of items: $listOfItems (see itemNames)",'heading') if $is_t_switch_active;
+ $logger->trace("*List of items: $listOfItems (see itemNames)") if $is_t_switch_active;
$itemRegExp = qr/
(
@@ -68,13 +69,13 @@
return unless ${$masterSettings{indentAfterItems}}{${$self}{name}};
# otherwise loop through the item names
- $self->logger("Searching for items (see itemNames) in ${$self}{name} (see indentAfterItems)") if $is_t_switch_active;
- $self->logger(Dumper(\%{$masterSettings{itemNames}})) if $is_t_switch_active;
+ $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;
while(${$self}{body} =~ m/$itemRegExp\h*($trailingCommentRegExp)?/){
# log file output
- $self->logger("Item found: $2",'heading') if $is_t_switch_active;
+ $logger->trace("*Item found: $2") if $is_t_switch_active;
${$self}{body} =~ s/
$itemRegExp(\h*)($trailingCommentRegExp)?
@@ -137,7 +138,7 @@
# there is no white space
my $self = shift;
my $BodyStringLogFile = ${$self}{aliases}{BodyStartsOnOwnLine}||"BodyStartsOnOwnLine";
- $self->logger("Removing linebreak at the end of begin (see $BodyStringLogFile)");
+ $logger->trace("Removing linebreak at the end of begin (see $BodyStringLogFile)");
${$self}{begin} =~ s/\R*$//sx;
${$self}{begin} .= " " unless(${$self}{begin} =~ m/\h$/s or ${$self}{body} =~ m/^\h/s or ${$self}{body} =~ m/^\R/s );
${$self}{linebreaksAtEnd}{begin} = 0;
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/KeyEqualsValuesBraces.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/KeyEqualsValuesBraces.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/KeyEqualsValuesBraces.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -18,8 +18,8 @@
use warnings;
use LatexIndent::Tokens qw/%tokens/;
use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
-use LatexIndent::Switches qw/$is_m_switch_active/;
-use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
+use LatexIndent::Switches qw/$is_m_switch_active $is_t_switch_active $is_tt_switch_active/;
+use LatexIndent::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @ISA = "LatexIndent::Command"; # class inheritance, Programming Perl, pg 321
@@ -73,7 +73,7 @@
my $blankLineToken = $tokens{blanklines};
if(${$self}{begin} =~ /\R=/s or ${$self}{begin} =~ /$blankLineToken\h*=/s ){
- $self->logger("= found on own line in ${$self}{name}, adding indentation") if $is_t_switch_active;
+ $logger->trace("= found on own line in ${$self}{name}, adding indentation") if $is_t_switch_active;
${$self}{begin} =~ s/=/${$self}{indentation}=/s;
}
}
@@ -87,15 +87,15 @@
# linebreaks *infront* of = symbol
if(${$self}{begin} =~ /\R\h*=/s){
if(defined ${$self}{EqualsStartsOnOwnLine} and ${$self}{EqualsStartsOnOwnLine}==-1){
- $self->logger("Removing linebreak before = symbol in ${$self}{name} (see EqualsStartsOnOwnLine)") if $is_t_switch_active;
+ $logger->trace("Removing linebreak before = symbol in ${$self}{name} (see EqualsStartsOnOwnLine)") if $is_t_switch_active;
${$self}{begin} =~ s/(\R|\h)*=/=/s;
}
} else {
if(defined ${$self}{EqualsStartsOnOwnLine} and ${$self}{EqualsStartsOnOwnLine}==1){
- $self->logger("Adding a linebreak before = symbol for ${$self}{name} (see EqualsStartsOnOwnLine)") if $is_t_switch_active;
+ $logger->trace("Adding a linebreak before = symbol for ${$self}{name} (see EqualsStartsOnOwnLine)") if $is_t_switch_active;
${$self}{begin} =~ s/=/\n=/s;
} elsif(defined ${$self}{EqualsStartsOnOwnLine} and ${$self}{EqualsStartsOnOwnLine}==2){
- $self->logger("Adding a % linebreak immediately before = symbol for ${$self}{name} (see EqualsStartsOnOwnLine)") if $is_t_switch_active;
+ $logger->trace("Adding a % linebreak immediately before = symbol for ${$self}{name} (see EqualsStartsOnOwnLine)") if $is_t_switch_active;
${$self}{begin} =~ s/\h*=/%\n=/s;
}
}
@@ -114,7 +114,7 @@
my $self = shift;
# the replacement text for a key = {value} needes to accomodate the leading [ OR { OR % OR , OR any combination thereof
- $self->logger("Custom replacement text routine for ${$self}{name}") if $is_t_switch_active;
+ $logger->trace("Custom replacement text routine for ${$self}{name}") if $is_t_switch_active;
${$self}{replacementText} = ${$self}{beginningbit}.${$self}{id};
delete ${$self}{beginningbit};
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -16,39 +16,25 @@
# For all communication, please visit: https://github.com/cmhughes/latexindent.pl
use strict;
use warnings;
+use FindBin;
+use File::Basename; # to get the filename and directory path
+use Exporter qw/import/;
+use Log::Log4perl qw(get_logger :levels);
+use Log::Log4perl::Appender::Screen;
+use Log::Dispatch::File;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
use LatexIndent::Switches qw/%switches/;
use LatexIndent::Version qw/$versionNumber $versionDate/;
-use FindBin;
-use File::Basename; # to get the filename and directory path
-use Exporter qw/import/;
-our @EXPORT_OK = qw/logger output_logfile processSwitches/;
+our @EXPORT_OK = qw/processSwitches $logger/;
our @logFileNotes;
+our $logger = get_logger("Document");
-# log file methods
-# log file methods
-# log file methods
-# reference: http://stackoverflow.com/questions/6736998/help-calling-a-sub-routine-from-a-perl-module-and-printing-to-logfile
+# log file methods, using log4perl; references
+# pattern layout: http://search.cpan.org/~mschilli/Log-Log4perl-1.32/lib/Log/Log4perl/Layout/PatternLayout.pm
+# multiple appenders: https://stackoverflow.com/questions/8620347/perl-log4perl-printing-and-logging-at-the-same-time-in-a-line?rq=1
+# getting started: https://www.perl.com/pub/2002/09/11/log4perl.html
-sub logger{
- shift;
- my $line = shift;
- my $infoLevel = shift;
- push(@logFileNotes,{line=>$line,level=>$infoLevel?$infoLevel:'default'});
- return
-}
-
sub processSwitches{
- my $self = shift;
-
- # details of the script to log file
- $self->logger("$FindBin::Script version $versionNumber, $versionDate, a script to indent .tex files",'heading');
- $self->logger("$FindBin::Script lives here: $FindBin::RealBin/");
-
- # time the script is used
- my $time = localtime();
- $self->logger("$time");
-
# -v switch is just to show the version number
if($switches{version}) {
print $versionNumber,", ",$versionDate,"\n";
@@ -63,6 +49,8 @@
displays the version number and date of release
-h, --help
help (see the documentation for detailed instructions and examples)
+ -sl, --screenlog
+ log file will also be output to the screen
-o, --outputfile=<name-of-output-file>
output to another file; sample usage:
latexindent.pl -o outputfile.tex myfile.tex
@@ -97,84 +85,154 @@
exit(2);
}
+ # if we've made it this far, the processing of switches and logging begins
+ my $self = shift;
+
+ ($switches{trace}||$switches{ttrace}) ? $logger->level($TRACE): $logger->level($INFO);
+
+ # cruft directory
+ ${$self}{cruftDirectory} = $switches{cruftDirectory}||(dirname ${$self}{fileName});
+ die "Could not find directory ${$self}{cruftDirectory}\nExiting, no indentation done." if(!(-d ${$self}{cruftDirectory}));
+
+ my $logfileName = ($switches{cruftDirectory} ? ${$self}{cruftDirectory} : '').($switches{logFileName}||"indent.log");
+
+ # layout of the logfile information, for example
+ #
+ # 2017/09/16 11:59:09 INFO: message
+ # 2017/09/16 12:23:53 INFO: LogFile.pm:156 LatexIndent::LogFile::processSwitches - message
+ # reference: https://stackoverflow.com/questions/46262844/log4perl-grouping-messages/46309392#46309392
+ Log::Log4perl::Layout::PatternLayout::add_global_cspec(
+ 'A', sub {
+ if($_[1] =~ /^\*/){
+ $_[1]=~s/^\*//;
+ if($_[1]=~m/\R/s){
+ my $indentation = ' '.(' ' x length $_[3]);
+ $_[1] =~ s/\R/\n$indentation/gs;
+ }
+ return "$_[3]: ".$_[1];
+ } else {
+ my $indentation = ' '.(' ' x length $_[3]);
+ $_[1] =~ s/\R/\n$indentation/gs if($_[1]=~m/\R/s);
+ return $indentation.$_[1];
+ }
+ });
+
+ my $layout = Log::Log4perl::Layout::PatternLayout->new("%A%n");
+
+ # details for the Log4perl logging
+ my $appender = Log::Log4perl::Appender->new(
+ "Log::Dispatch::File",
+ filename => $logfileName,
+ mode => "write",
+ utf8 => 1,
+ );
+
+ # add the layout
+ $appender->layout($layout);
+
+ # adjust the logger object
+ $logger->add_appender($appender);
+
+ # appender object for output to screen
+ my $appender_screen = q();
+
+ # output to screen, if appropriate
+ if($switches{screenlog}){
+ $appender_screen = Log::Log4perl::Appender->new(
+ "Log::Log4perl::Appender::Screen",
+ stderr => 0,
+ utf8 => 1,
+ );
+
+ $appender_screen->layout($layout);
+ $logger->add_appender($appender_screen);
+ }
+
+ # details of the script to log file
+ $logger->info("*$FindBin::Script version $versionNumber, $versionDate, a script to indent .tex files");
+ $logger->info("$FindBin::Script lives here: $FindBin::RealBin/");
+
+ my $time = localtime();
+ $logger->info($time);
+
+ if (${$self}{fileName} ne "-"){
+ $logger->info("Filename: ${$self}{fileName}");
+ } else {
+ $logger->info("Reading input from STDIN");
+ }
+
# log the switches from the user
- $self->logger('Processing switches','heading');
+ $logger->info("*Processing switches:");
# check on the trace mode switch (should be turned on if ttrace mode active)
$switches{trace} = $switches{ttrace} ? 1 : $switches{trace};
-
+
# output details of switches
- $self->logger('-t|--trace: Trace mode active (you have used either -t or --trace)') if($switches{trace} and !$switches{ttrace});
- $self->logger('-tt|--ttrace: TTrace mode active (you have used either -tt or --ttrace)') if($switches{tracingModeVeryDetailed});
- $self->logger('-s|--silent: Silent mode active (you have used either -s or --silent)') if($switches{silentMode});
- $self->logger('-d|--onlydefault: Only defaultSettings.yaml will be used (you have used either -d or --onlydefault)') if($switches{onlyDefault});
- $self->logger("-w|--overwrite: Overwrite mode active, will make a back up of ${$self}{fileName} first") if($switches{overwrite});
- $self->logger("-l|--localSettings: Read localSettings YAML file") if($switches{readLocalSettings});
- $self->logger("-y|--yaml: YAML settings specified via command line") if($switches{yaml});
- $self->logger("-o|--outputfile: output to file") if($switches{outputToFile});
- $self->logger("-m|--modifylinebreaks: modify line breaks") if($switches{modifyLineBreaks});
- $self->logger("-g|--logfile: logfile name") if($switches{logFileName});
- $self->logger("-c|--cruft: cruft directory") if($switches{cruftDirectory});
+ $logger->info("-sl|--screenlog: log file will also be output to the screen") if($switches{screenlog});
+ $logger->info("-t|--trace: Trace mode active (you have used either -t or --trace)") if($switches{trace} and !$switches{ttrace});
+ $logger->info("-tt|--ttrace: TTrace mode active (you have used either -tt or --ttrace)") if($switches{ttrace});
+ $logger->info("-s|--silent: Silent mode active (you have used either -s or --silent)") if($switches{silentMode});
+ $logger->info("-d|--onlydefault: Only defaultSettings.yaml will be used (you have used either -d or --onlydefault)") if($switches{onlyDefault});
+ $logger->info("-w|--overwrite: Overwrite mode active, will make a back up of ${$self}{fileName} first") if($switches{overwrite});
+ $logger->info("-l|--localSettings: Read localSettings YAML file") if($switches{readLocalSettings});
+ $logger->info("-y|--yaml: YAML settings specified via command line") if($switches{yaml});
+ $logger->info("-o|--outputfile: output to file") if($switches{outputToFile});
+ $logger->info("-m|--modifylinebreaks: modify line breaks") if($switches{modifyLineBreaks});
+ $logger->info("-g|--logfile: logfile name") if($switches{logFileName});
+ $logger->info("-c|--cruft: cruft directory") if($switches{cruftDirectory});
# check if overwrite and outputfile are active similtaneously
if($switches{overwrite} and $switches{outputToFile}){
- $self->logger("Options check",'heading');
- $self->logger("You have called latexindent.pl with both -o and -w");
- $self->logger("-o (output to file) will take priority, and -w (over write) will be ignored");
+ $logger->info("Options check, -w and -o specified\nYou have called latexindent.pl with both -o and -w\noutput to file) will take priority, and -w (over write) will be ignored");
$switches{overwrite}=0;
}
- # cruft directory
- ${$self}{cruftDirectory} = $switches{cruftDirectory}||(dirname ${$self}{fileName});
- die "Could not find directory ${$self}{cruftDirectory}\nExiting, no indentation done." if(!(-d ${$self}{cruftDirectory}));
- my $logfileName = $switches{logFileName}||"indent.log";
- $self->logger("Directory for backup files and $logfileName: ${$self}{cruftDirectory}",'heading');
+ $logger->info("*Directory for backup files and $logfileName: ${$self}{cruftDirectory}");
# output location of modules
if($FindBin::Script eq 'latexindent.pl' or ($FindBin::Script eq 'latexindent.exe' and $switches{trace} )) {
- my @listOfModules = ('FindBin', 'YAML::Tiny', 'File::Copy', 'File::Basename', 'Getopt::Long','File::HomeDir','Unicode::GCString');
- $self->logger("Perl modules are being loaded from the following directories:",'heading');
+ my @listOfModules = ('FindBin', 'YAML::Tiny', 'File::Copy', 'File::Basename', 'Getopt::Long','File::HomeDir','Unicode::GCString','Log::Log4perl');
+ $logger->info("*Perl modules are being loaded from the following directories:");
foreach my $moduleName (@listOfModules) {
(my $file = $moduleName) =~ s|::|/|g;
- require $file . '.pm';
- $self->logger($INC{$file .'.pm'});
+ $logger->info($INC{$file .'.pm'});
}
- $self->logger("Latex Indent perl modules are being loaded from, for example:",'heading');
+ $logger->info("*Latex Indent perl modules are being loaded from, for example:");
(my $file = 'LatexIndent::Document') =~ s|::|/|g;
- require $file . '.pm';
- $self->logger($INC{$file .'.pm'});
+ $logger->info($INC{$file .'.pm'});
}
- return;
-}
-sub output_logfile{
- my $self = shift;
- my $logfile;
- my $logfileName = $switches{logFileName}||"indent.log";
+ # read the YAML settings
+ $self->readSettings;
+
+ # the user may have specified their own settings for the rest of the log file,
+ # for example:
+ #
+ # logFilePreferences:
+ # PatternLayout:
+ # default: "%p: %m{indent}%n"
+ # trace: "%p: %m{indent}%n"
+ # ttrace: "%d %p: %F{1}:%L %M - %m{indent}%n"
+ #
+ # e.g, default mode:
+ # 2017/09/16 11:59:09 INFO: message
+ # or trace mode:
+ # 2017/09/16 11:59:09 INFO: message
+ # or in trace mode:
+ # 2017/09/16 12:23:53 INFO: LogFile.pm:156 LatexIndent::LogFile::processSwitches - message
+ my $pattern = q();
+ if($switches{ttrace}){
+ $pattern = ${${$masterSettings{logFilePreferences}}{PatternLayout}}{ttrace};
+ } elsif($switches{trace}){
+ $pattern = ${${$masterSettings{logFilePreferences}}{PatternLayout}}{trace};
+ } else {
+ $pattern = ${${$masterSettings{logFilePreferences}}{PatternLayout}}{default};
+ }
+ $layout = Log::Log4perl::Layout::PatternLayout->new($pattern);
+ $appender->layout($layout);
- open($logfile,">","${$self}{cruftDirectory}/$logfileName") or die "Can't open $logfileName";
-
- # put the final line in the logfile
- $self->logger("${$masterSettings{logFilePreferences}}{endLogFileWith}",'heading');
-
- # github info line
- $self->logger("Please direct all communication/issues to: ",'heading') if ${$masterSettings{logFilePreferences}}{showGitHubInfoFooter};
- $self->logger("https://github.com/cmhughes/latexindent.pl") if ${$masterSettings{logFilePreferences}}{showGitHubInfoFooter};
-
- # output the logfile
- foreach my $line (@logFileNotes){
- if(${$line}{level} eq 'heading'){
- print $logfile ${$line}{line},"\n";
- } elsif(${$line}{level} eq 'default') {
- # add tabs to the beginning of lines
- # for default logfile lines
- ${$line}{line} =~ s/^/\t/mg;
- print $logfile ${$line}{line},"\n";
- }
- }
-
- close($logfile);
+ $appender_screen->layout($layout) if $switches{screenlog};
+ return;
}
-
1;
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/MandatoryArgument.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/MandatoryArgument.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/MandatoryArgument.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,6 +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::LogFile qw/$logger/;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
our @EXPORT_OK = qw/find_mandatory_arguments get_mand_arg_reg_exp/;
@@ -32,8 +33,8 @@
# pick out the mandatory arguments
while(${$self}{body} =~ m/$mandArgRegExp\h*($trailingCommentRegExp)*(.*)/s){
# log file output
- $self->logger("Mandatory argument found, body in ${$self}{name}",'heading') if $is_t_switch_active;
- $self->logger("(last argument)") if($9 eq '' and $is_t_switch_active);
+ $logger->trace("*Mandatory argument found, body in ${$self}{name}") if $is_t_switch_active;
+ $logger->trace("(last argument)") if($9 eq '' and $is_t_switch_active);
${$self}{body} =~ s/
$mandArgRegExp(\h*)($trailingCommentRegExp)*(.*)
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -24,7 +24,8 @@
use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
use LatexIndent::Switches qw/$is_m_switch_active $is_t_switch_active $is_tt_switch_active/;
use LatexIndent::Item qw/$listOfItems/;
-our @EXPORT_OK = qw/modify_line_breaks_body modify_line_breaks_end adjust_line_breaks_end_parent remove_line_breaks_begin max_char_per_line paragraphs_on_one_line construct_paragraph_reg_exp/;
+use LatexIndent::LogFile qw/$logger/;
+our @EXPORT_OK = qw/modify_line_breaks_body modify_line_breaks_end adjust_line_breaks_end_parent remove_line_breaks_begin max_char_per_line paragraphs_on_one_line construct_paragraph_reg_exp one_sentence_per_line/;
our $paragraphRegExp = q();
@@ -42,10 +43,10 @@
# BodyStartsOnOwnLine == 3 add a blank line, and then new line
if(${$self}{BodyStartsOnOwnLine}==1){
# modify the begin statement
- $self->logger("Adding a linebreak at the end of begin, ${$self}{begin} (see $BodyStringLogFile)") if $is_t_switch_active;
+ $logger->trace("Adding a linebreak at the end of begin, ${$self}{begin} (see $BodyStringLogFile)") if $is_t_switch_active;
${$self}{begin} .= "\n";
${$self}{linebreaksAtEnd}{begin} = 1;
- $self->logger("Removing leading space from body of ${$self}{name} (see $BodyStringLogFile)") if $is_t_switch_active;
+ $logger->trace("Removing leading space from body of ${$self}{name} (see $BodyStringLogFile)") if $is_t_switch_active;
${$self}{body} =~ s/^\h*//;
} elsif(${$self}{BodyStartsOnOwnLine}==2){
# by default, assume that no trailing comment token is needed
@@ -52,23 +53,23 @@
my $trailingCommentToken = q();
if(${$self}{body} !~ m/^\h*$trailingCommentRegExp/s){
# modify the begin statement
- $self->logger("Adding a % at the end of begin ${$self}{begin} followed by a linebreak ($BodyStringLogFile == 2)") if $is_t_switch_active;
+ $logger->trace("Adding a % at the end of begin ${$self}{begin} followed by a linebreak ($BodyStringLogFile == 2)") if $is_t_switch_active;
$trailingCommentToken = "%".$self->add_comment_symbol;
${$self}{begin} =~ s/\h*$//;
${$self}{begin} .= "$trailingCommentToken\n";
${$self}{linebreaksAtEnd}{begin} = 1;
- $self->logger("Removing leading space from body of ${$self}{name} (see $BodyStringLogFile)") if $is_t_switch_active;
+ $logger->trace("Removing leading space from body of ${$self}{name} (see $BodyStringLogFile)") if $is_t_switch_active;
${$self}{body} =~ s/^\h*//;
} else {
- $self->logger("Even though $BodyStringLogFile == 2, ${$self}{begin} already finishes with a %, so not adding another.") if $is_t_switch_active;
+ $logger->trace("Even though $BodyStringLogFile == 2, ${$self}{begin} already finishes with a %, so not adding another.") if $is_t_switch_active;
}
} elsif (${$self}{BodyStartsOnOwnLine}==3){
my $trailingCharacterToken = q();
- $self->logger("Adding a blank line at the end of begin ${$self}{begin} followed by a linebreak ($BodyStringLogFile == 3)") if $is_t_switch_active;
+ $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}{linebreaksAtEnd}{begin} = 1;
- $self->logger("Removing leading space from body of ${$self}{name} (see $BodyStringLogFile)") if $is_t_switch_active;
+ $logger->trace("Removing leading space from body of ${$self}{name} (see $BodyStringLogFile)") if $is_t_switch_active;
${$self}{body} =~ s/^\h*//;
}
} elsif (${$self}{BodyStartsOnOwnLine}==-1 and ${$self}{linebreaksAtEnd}{begin}){
@@ -81,7 +82,7 @@
sub remove_line_breaks_begin{
my $self = shift;
my $BodyStringLogFile = ${$self}{aliases}{BodyStartsOnOwnLine}||"BodyStartsOnOwnLine";
- $self->logger("Removing linebreak at the end of begin (see $BodyStringLogFile)") if $is_t_switch_active;
+ $logger->trace("Removing linebreak at the end of begin (see $BodyStringLogFile)") if $is_t_switch_active;
${$self}{begin} =~ s/\R*$//sx;
${$self}{linebreaksAtEnd}{begin} = 0;
}
@@ -98,16 +99,16 @@
# EndStartsOnOwnLine == 1 just add a new line
# EndStartsOnOwnLine == 2 add a comment, and then new line
# EndStartsOnOwnLine == 3 add a blank line, and then new line
- $self->logger("Adding a linebreak at the end of body (see $EndStringLogFile)") if $is_t_switch_active;
+ $logger->trace("Adding a linebreak at the end of body (see $EndStringLogFile)") if $is_t_switch_active;
# by default, assume that no trailing character token is needed
my $trailingCharacterToken = q();
if(${$self}{EndStartsOnOwnLine}==2){
- $self->logger("Adding a % immediately after body of ${$self}{name} ($EndStringLogFile==2)") if $is_t_switch_active;
+ $logger->trace("Adding a % immediately after body of ${$self}{name} ($EndStringLogFile==2)") if $is_t_switch_active;
$trailingCharacterToken = "%".$self->add_comment_symbol;
${$self}{body} =~ s/\h*$//s;
} elsif (${$self}{EndStartsOnOwnLine}==3) {
- $self->logger("Adding a blank line immediately after body of ${$self}{name} ($EndStringLogFile==3)") if $is_t_switch_active;
+ $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());
${$self}{body} =~ s/\h*$//s;
}
@@ -125,11 +126,11 @@
# check to see that body does *not* finish with blank-line-token,
# if so, then don't remove that final line break
if(${$self}{body} !~ m/$tokens{blanklines}$/s){
- $self->logger("Removing linebreak at the end of body (see $EndStringLogFile)") if $is_t_switch_active;
+ $logger->trace("Removing linebreak at the end of body (see $EndStringLogFile)") if $is_t_switch_active;
${$self}{body} =~ s/\R*$//sx;
${$self}{linebreaksAtEnd}{body} = 0;
} else {
- $self->logger("Blank line token found at end of body (${$self}{name}), see preserveBlankLines, not removing line break before ${$self}{end}") if $is_t_switch_active;
+ $logger->trace("Blank line token found at end of body (${$self}{name}), see preserveBlankLines, not removing line break before ${$self}{end}") if $is_t_switch_active;
}
}
}
@@ -145,7 +146,7 @@
# EndFinishesWithLineBreak == 3 add a blank line, and then new line
my $EndStringLogFile = ${$self}{aliases}{EndFinishesWithLineBreak}||"EndFinishesWithLineBreak";
if(${$self}{EndFinishesWithLineBreak}==1){
- $self->logger("Adding a linebreak at the end of ${$self}{end} ($EndStringLogFile==1)") if $is_t_switch_active;
+ $logger->trace("Adding a linebreak at the end of ${$self}{end} ($EndStringLogFile==1)") if $is_t_switch_active;
${$self}{linebreaksAtEnd}{end} = 1;
# modified end statement
@@ -153,10 +154,10 @@
} elsif(${$self}{EndFinishesWithLineBreak}==2){
if(${$self}{endImmediatelyFollowedByComment}){
# no need to add a % if one already exists
- $self->logger("Even though $EndStringLogFile == 2, ${$self}{end} is immediately followed by a %, so not adding another; not adding line break.") if $is_t_switch_active;
+ $logger->trace("Even though $EndStringLogFile == 2, ${$self}{end} is immediately followed by a %, so not adding another; not adding line break.") if $is_t_switch_active;
} else {
# otherwise, create a trailing comment, and tack it on
- $self->logger("Adding a % immediately after, ${$self}{end} ($EndStringLogFile==2)") if $is_t_switch_active;
+ $logger->trace("Adding a % immediately after, ${$self}{end} ($EndStringLogFile==2)") if $is_t_switch_active;
my $trailingCommentToken = "%".$self->add_comment_symbol;
${$self}{end} =~ s/\h*$//s;
${$self}{replacementText} .= "$trailingCommentToken\n";
@@ -163,7 +164,7 @@
${$self}{linebreaksAtEnd}{end} = 1;
}
} elsif(${$self}{EndFinishesWithLineBreak}==3){
- $self->logger("Adding a blank line at the end of ${$self}{end} ($EndStringLogFile==3)") if $is_t_switch_active;
+ $logger->trace("Adding a blank line at the end of ${$self}{end} ($EndStringLogFile==3)") if $is_t_switch_active;
${$self}{linebreaksAtEnd}{end} = 1;
# modified end statement
@@ -185,9 +186,9 @@
# adjust parent linebreaks information
if(${$child}{linebreaksAtEnd}{end} and ${$self}{body} =~ m/${$child}{replacementText}\h*\R*$/s and !${$self}{linebreaksAtEnd}{body}){
- $self->logger("ID: ${$child}{id}") if($is_t_switch_active);
- $self->logger("${$child}{begin}...${$child}{end} is found at the END of body of parent, ${$self}{name}, avoiding a double line break:") if($is_t_switch_active);
- $self->logger("adjusting ${$self}{name} linebreaksAtEnd{body} to be 1") if($is_t_switch_active);
+ $logger->trace("ID: ${$child}{id}") if($is_t_switch_active);
+ $logger->trace("${$child}{begin}...${$child}{end} is found at the END of body of parent, ${$self}{name}, avoiding a double line break:") if($is_t_switch_active);
+ $logger->trace("adjusting ${$self}{name} linebreaksAtEnd{body} to be 1") if($is_t_switch_active);
${$self}{linebreaksAtEnd}{body}=1;
}
@@ -197,8 +198,8 @@
and !${$child}{linebreaksAtEnd}{body}
and ${$child}{body} =~ m/\R(?:$trailingCommentRegExp\h*)?$/s ){
# log file information
- $self->logger("Undisclosed line break at the end of body of ${$child}{name}: '${$child}{end}'") if($is_t_switch_active);
- $self->logger("Adding a linebreak at the end of body for ${$child}{id}") if($is_t_switch_active);
+ $logger->trace("Undisclosed line break at the end of body of ${$child}{name}: '${$child}{end}'") if($is_t_switch_active);
+ $logger->trace("Adding a linebreak at the end of body for ${$child}{id}") if($is_t_switch_active);
# make the adjustments
${$child}{body} .= "\n";
@@ -224,6 +225,7 @@
sub construct_paragraph_reg_exp{
my $self = shift;
+ $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}}){
if($yesNo){
@@ -234,7 +236,7 @@
$paragraphStopAt = "trailingComment" if($paragraphStopAt eq "comments");
# output to log file
- $self->logger("The paragraph-stop regexp WILL include $tokens{$paragraphStopAt} (see paragraphsStopAt)",'heading') if $is_t_switch_active ;
+ $logger->trace("The paragraph-stop regexp WILL include $tokens{$paragraphStopAt} (see paragraphsStopAt)") if $is_t_switch_active ;
# update the regexp
if($paragraphStopAt eq "items"){
@@ -243,7 +245,7 @@
$stopAtRegExp .= "|(?:".($paragraphStopAt eq "trailingComment" ? "%" : q() ).$tokens{$paragraphStopAt}."\\d+)";
}
} else {
- $self->logger("The paragraph-stop regexp won't include $tokens{$paragraphStopAt} (see paragraphsStopAt)",'heading') if ($tokens{$paragraphStopAt} and $is_t_switch_active);
+ $logger->trace("The paragraph-stop regexp won't include $tokens{$paragraphStopAt} (see paragraphsStopAt)") if ($tokens{$paragraphStopAt} and $is_t_switch_active);
}
}
@@ -265,8 +267,8 @@
\z # end of string
)/sxm;
- $self->logger("The paragraph-stop-regexp is:",'heading') if $is_tt_switch_active ;
- $self->logger($paragraphRegExp) if $is_tt_switch_active ;
+ $logger->trace("The paragraph-stop-regexp is:") if $is_tt_switch_active ;
+ $logger->trace($paragraphRegExp) if $is_tt_switch_active ;
}
sub paragraphs_on_one_line{
@@ -276,7 +278,7 @@
# alignment at ampersand can take priority
return if(${$self}{lookForAlignDelims} and ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{alignAtAmpersandTakesPriority});
- $self->logger("Checking ${$self}{name} for paragraphs (see removeParagraphLineBreaks)") if $is_t_switch_active;
+ $logger->trace("Checking ${$self}{name} for paragraphs (see removeParagraphLineBreaks)") if $is_t_switch_active;
my $paragraphCounter;
my @paragraphStorage;
@@ -296,4 +298,197 @@
}
}
+sub one_sentence_per_line{
+ my $self = shift;
+
+ return unless ${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{manipulateSentences};
+ $logger->trace("*One sentence per line regular expression construction: (see oneSentencePerLine: manipulateSentences)") if $is_t_switch_active;
+
+ # sentences FOLLOW
+ # sentences FOLLOW
+ # sentences FOLLOW
+ my $sentencesFollow = q();
+
+ while( my ($sentencesFollowEachPart,$yesNo)= each %{${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}){
+ if($yesNo){
+ if($sentencesFollowEachPart eq "par"){
+ $sentencesFollowEachPart = qr/\R?\\par/s;
+ } elsif ($sentencesFollowEachPart eq "blankLine"){
+ $sentencesFollowEachPart = qr/
+ (?:\A(?:$tokens{blanklines}\R)+) # the order of each of these
+ | # is important, as (like always) the first
+ (?:\G(?:$tokens{blanklines}\R)+) # thing to be matched will
+ | # be accepted
+ (?:(?:$tokens{blanklines}\h*\R)+)
+ |
+ \R{2,}
+ |
+ \G
+ /sx;
+ } elsif ($sentencesFollowEachPart eq "fullStop"){
+ $sentencesFollowEachPart = qr/\./s;
+ } elsif ($sentencesFollowEachPart eq "exclamationMark"){
+ $sentencesFollowEachPart = qr/\!/s;
+ } elsif ($sentencesFollowEachPart eq "questionMark"){
+ $sentencesFollowEachPart = qr/\?/s;
+ } elsif ($sentencesFollowEachPart eq "rightBrace"){
+ $sentencesFollowEachPart = qr/\}/s;
+ } elsif ($sentencesFollowEachPart eq "commentOnPreviousLine"){
+ $sentencesFollowEachPart = qr/$trailingCommentRegExp\h*\R/s;
+ } elsif ($sentencesFollowEachPart eq "other"){
+ $sentencesFollowEachPart = qr/$yesNo/;
+ }
+ $sentencesFollow .= ($sentencesFollow eq '' ? q() : "|").qr/$sentencesFollowEachPart/sx;
+ }
+ }
+ # 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}){
+ $sentencesFollow .= ($sentencesFollow eq '' ? q() : "|").
+ qr/
+ \G
+ (?!$tokens{blanklines})
+ /sx;
+ }
+
+ if(${${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}{blankLine}){
+ $sentencesFollow = ($sentencesFollow eq '' ? q() : qr/(?:$sentencesFollow)(?:\h|\R)*/sx );
+ } else {
+ $sentencesFollow = ($sentencesFollow eq '' ? q() : qr/(?:$sentencesFollow)(?:\h*\R?)/sx );
+ }
+
+
+ $logger->trace("Sentences follow regexp:") if $is_tt_switch_active;
+ $logger->trace($sentencesFollow) if $is_tt_switch_active;
+
+ # sentences BEGIN with
+ # sentences BEGIN with
+ # sentences BEGIN with
+ my $sentencesBeginWith = q();
+
+ while( my ($sentencesBeginWithEachPart,$yesNo)= each %{${$masterSettings{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;
+ $sentencesBeginWithEachPart = qr/(?!(?:$tokens{blanklines}|$tokens{verbatim}|$tokens{preamble}))[A-Z]/;
+ } elsif ($sentencesBeginWithEachPart eq "a-z"){
+ $logger->trace("sentence BEGINS with lower-case letters (see oneSentencePerLine:sentencesBeginWith:a-z)") if $is_t_switch_active;
+ $sentencesBeginWithEachPart = qr/[a-z]/;
+ } elsif ($sentencesBeginWithEachPart eq "other"){
+ $logger->trace("sentence BEGINS with other $yesNo (reg exp) (see oneSentencePerLine:sentencesBeginWith:other)") if $is_t_switch_active;
+ $sentencesBeginWithEachPart = qr/$yesNo/;
+ }
+ $sentencesBeginWith .= ($sentencesBeginWith eq "" ? q(): "|" ).$sentencesBeginWithEachPart;
+ }
+ }
+ $sentencesBeginWith = qr/$sentencesBeginWith/;
+
+ # sentences END with
+ # sentences END with
+ # sentences END with
+ ${${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesEndWith}}{basicFullStop} = 0 if ${${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesEndWith}}{betterFullStop};
+ my $sentencesEndWith = q();
+
+ while( my ($sentencesEndWithEachPart,$yesNo)= each %{${$masterSettings{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;
+ $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/(?:\.\)(?!\h*[a-z]))|(?:(?<!(?:(?:e\.g)|(?:i\.e)|(?:etc))))\.(?!(?:[a-z]|[A-Z]|\-|\,|[0-9]))/;
+ } elsif ($sentencesEndWithEachPart eq "exclamationMark"){
+ $logger->trace("sentence ENDS with exclamation mark (see oneSentencePerLine:sentencesEndWith:exclamationMark)") if $is_t_switch_active;
+ $sentencesEndWithEachPart = qr/!/;
+ } elsif ($sentencesEndWithEachPart eq "questionMark"){
+ $logger->trace("sentence ENDS with question mark (see oneSentencePerLine:sentencesEndWith:questionMark)") if $is_t_switch_active;
+ $sentencesEndWithEachPart = qr/\?/;
+ } elsif ($sentencesEndWithEachPart eq "other"){
+ $logger->trace("sentence ENDS with other $yesNo (reg exp) (see oneSentencePerLine:sentencesEndWith:other)") if $is_t_switch_active;
+ $sentencesEndWithEachPart = qr/$yesNo/;
+ }
+ $sentencesEndWith .= ($sentencesEndWith eq "" ? q(): "|" ).$sentencesEndWithEachPart;
+ }
+ }
+ $sentencesEndWith = qr/$sentencesEndWith/;
+
+ # the OVERALL sentence regexp
+ # the OVERALL sentence regexp
+ # the OVERALL sentence regexp
+ $logger->trace("Overall sentences end with regexp:") if $is_tt_switch_active;
+ $logger->trace($sentencesEndWith) if $is_tt_switch_active;
+
+ $logger->trace("Finding sentences...") if $is_t_switch_active;
+
+ my $notWithinSentence = qr/$trailingCommentRegExp/s;
+
+ # if
+ #
+ # modifyLineBreaks
+ # oneSentencePerLine
+ # sentencesFollow
+ # blankLine
+ #
+ # 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}){
+ $notWithinSentence .= "|".qr/(?:\h*\R?$tokens{blanklines})/s;
+ }
+
+ # similarly for \par
+ if(${${$masterSettings{modifyLineBreaks}{oneSentencePerLine}}{sentencesFollow}}{par}){
+ $notWithinSentence .= "|".qr/(?:\R?\\par)/s;
+ }
+
+ # initiate the sentence counter
+ my $sentenceCounter;
+ my @sentenceStorage;
+
+ # make the sentence manipulation
+ ${$self}{body} =~ s/((?:$sentencesFollow))
+ (\h*)
+ (?!$notWithinSentence)
+ ((?:$sentencesBeginWith).*?)
+ ($sentencesEndWith)/
+ my $beginning = $1;
+ my $h_space = ($2?$2:q());
+ my $middle = $3;
+ my $end = $4;
+ my $trailingComments = q();
+ # remove trailing comments from within the body of the sentence
+ while($middle =~ m|$trailingCommentRegExp|){
+ $middle =~ s|\h*($trailingCommentRegExp)||s;
+ $trailingComments .= $1;
+ }
+ # remove line breaks from within a sentence
+ $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};
+ $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;
+ $logger->trace("ends with: $end") if $is_tt_switch_active;
+ # reconstruct the sentence
+ $sentenceCounter++;
+ push(@sentenceStorage,{id=>$tokens{sentence}.$sentenceCounter.$tokens{endOfToken},value=>$middle.$end});
+ $beginning.$h_space.$tokens{sentence}.$sentenceCounter.$tokens{endOfToken}.$trailingComments;
+ /xsge;
+
+ # loop back through the sentenceStorage and replace with the sentence, adjusting line breaks
+ # before and after appropriately
+ while( my $sentence = pop @sentenceStorage){
+ my $sentenceStorageID = ${$sentence}{id};
+ my $sentenceStorageValue = ${$sentence}{value};
+ # sentence at the very END
+ ${$self}{body} =~ s/\h*$sentenceStorageID\h*$/$sentenceStorageValue/s;
+ # sentence at the very BEGINNING
+ ${$self}{body} =~ s/^$sentenceStorageID\h*\R?/$sentenceStorageValue\n/s;
+ # all other sentences
+ ${$self}{body} =~ s/\R?\h*$sentenceStorageID\h*\R?/\n$sentenceStorageValue\n/s;
+ }
+
+}
+
1;
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/NamedGroupingBracesBrackets.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/NamedGroupingBracesBrackets.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/NamedGroupingBracesBrackets.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,6 +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::LogFile qw/$logger/;
use Exporter qw/import/;
our @ISA = "LatexIndent::Command"; # class inheritance, Programming Perl, pg 321
our @EXPORT_OK = qw/construct_grouping_braces_brackets_regexp $grouping_braces_regexp $grouping_braces_regexpTrailingComment/;
@@ -63,7 +64,7 @@
my $self = shift;
# the replacement text for a key = {value} needes to accomodate the leading [ OR { OR % OR , OR any combination thereof
- $self->logger("Custom replacement text routine for ${$self}{name}") if $is_t_switch_active;
+ $logger->trace("Custom replacement text routine for ${$self}{name}") if $is_t_switch_active;
${$self}{replacementText} = ${$self}{beginningbit}.${$self}{id};
delete ${$self}{beginningbit};
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/OptionalArgument.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/OptionalArgument.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/OptionalArgument.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,6 +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::LogFile qw/$logger/;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
our @EXPORT_OK = qw/find_optional_arguments/;
@@ -46,8 +47,8 @@
# pick out the optional arguments
while(${$self}{body} =~ m/$optArgRegExp\h*($trailingCommentRegExp)*(.*)/s){
# log file output
- $self->logger("Optional argument found, body in ${$self}{name}",'heading') if $is_t_switch_active;
- $self->logger("(last argument)") if($9 eq '' and $is_t_switch_active);
+ $logger->trace("*Optional argument found, body in ${$self}{name}") if $is_t_switch_active;
+ $logger->trace("(last argument)") if($9 eq '' and $is_t_switch_active);
${$self}{body} =~ s/
$optArgRegExp(\h*)($trailingCommentRegExp)*(.*)
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Preamble.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Preamble.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Preamble.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,6 +19,7 @@
use LatexIndent::Tokens qw/%tokens/;
use LatexIndent::Switches qw/$is_t_switch_active/;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
+use LatexIndent::LogFile qw/$logger/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
our $preambleCounter;
@@ -34,7 +35,7 @@
my $self = shift;
# the replacement text for preamble needs to put the \\begin{document} back in
- $self->logger("Custom replacement text routine for preamble ${$self}{name}") if $is_t_switch_active;
+ $logger->trace("Custom replacement text routine for preamble ${$self}{name}") if $is_t_switch_active;
${$self}{replacementText} = ${$self}{id}.${$self}{afterbit};
delete ${$self}{afterbit};
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Special.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -20,6 +20,7 @@
use LatexIndent::TrailingComments qw/$trailingCommentRegExp/;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
+use LatexIndent::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
@@ -83,7 +84,7 @@
/sx
} else {
- $self->logger("The special regexps won't include anything from $specialName (see lookForThis)",'heading') if $is_t_switch_active ;
+ $logger->trace("*The special regexps won't include anything from $specialName (see lookForThis)") if $is_t_switch_active ;
}
}
@@ -94,10 +95,12 @@
}
# info to the log file
- $self->logger("The special beginnings regexp is: $specialBegins (see specialBeginEnd)",'heading') if $is_t_switch_active;
+ $logger->trace("*The special beginnings regexp is: (see specialBeginEnd)") if $is_tt_switch_active;
+ $logger->trace($specialBegins) if $is_tt_switch_active;
# overall special regexp
- $self->logger("The overall special regexp is: $specialAllMatchesRegExp(see specialBeginEnd)",'heading') if $is_t_switch_active;
+ $logger->trace("*The overall special regexp is: (see specialBeginEnd)") if $is_tt_switch_active;
+ $logger->trace($specialAllMatchesRegExp) if $is_tt_switch_active;
}
@@ -108,8 +111,8 @@
return if($specialBegins eq "");
# otherwise loop through the special begin/end
- $self->logger("Searching for special begin/end (see specialBeginEnd)") if $is_t_switch_active ;
- $self->logger(Dumper(\%{$masterSettings{specialBeginEnd}})) if $is_tt_switch_active;
+ $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;
# keep looping as long as there is a special match of some kind
while(${$self}{body} =~ m/$specialAllMatchesRegExp/sx){
@@ -119,9 +122,9 @@
# log file
if((ref($BeginEnd) eq "HASH") and ${$BeginEnd}{lookForThis}){
- $self->logger("Looking for $specialName",'heading') if $is_t_switch_active ;
+ $logger->trace("Looking for $specialName") if $is_t_switch_active ;
} else {
- $self->logger("Not looking for $specialName (see lookForThis)",'heading') if ($is_t_switch_active and (ref($BeginEnd) eq "HASH"));
+ $logger->trace("Not looking for $specialName (see lookForThis)") if ($is_t_switch_active and (ref($BeginEnd) eq "HASH"));
next;
}
@@ -134,9 +137,6 @@
${$self}{body} =~ s/
$specialRegExp(\h*)($trailingCommentRegExp)?
/
- # log file output
- $self->logger("special found: $specialName",'heading') if $is_t_switch_active;
-
# create a new special object
my $specialObject = LatexIndent::Special->new(begin=>$1,
body=>$3,
@@ -162,6 +162,9 @@
horizontalTrailingSpace=>$6?$6:q(),
);
+ # log file output
+ $logger->trace("*Special found: $specialName",'heading') if $is_t_switch_active;
+
# the settings and storage of most objects has a lot in common
$self->get_settings_and_store_new_object($specialObject);
${@{${$self}{children}}[-1]}{replacementText}.($8?$8:q()).($9?$9:q());
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -18,6 +18,7 @@
use warnings;
use Exporter qw/import/;
use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/;
+use LatexIndent::LogFile qw/$logger/;
our @EXPORT_OK = qw/token_check %tokens/;
# each of the tokens begins the same way -- this is exploited during the hidden Children routine
@@ -52,6 +53,7 @@
doubleBackSlash=>$beginningToken."DOUBLEBACKSLASH",
alignmentBlock=>$beginningToken."ALIGNMENTBLOCK",
paragraph=>$beginningToken."PARA",
+ sentence=>$beginningToken."SENTENCE",
endOfToken=>"-END",
);
@@ -58,11 +60,11 @@
sub token_check{
my $self = shift;
- $self->logger("Token check",'heading') if $is_t_switch_active;
+ $logger->trace("*Token check") if $is_t_switch_active;
# we use tokens for trailing comments, environments, commands, etc, so check that they're not in the body
foreach( keys %tokens){
while(${$self}{body} =~ m/$tokens{$_}/si){
- $self->logger("Found $tokens{$_} within body, updating replacement token to $tokens{$_}-LIN") if($is_t_switch_active);
+ $logger->trace("Found $tokens{$_} within body, updating replacement token to $tokens{$_}-LIN") if($is_t_switch_active);
$tokens{$_} .= "-LIN";
}
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/TrailingComments.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,6 +19,7 @@
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::LogFile qw/$logger/;
use Data::Dumper;
use Exporter qw/import/;
our @EXPORT_OK = qw/remove_trailing_comments put_trailing_comments_back_in $trailingCommentRegExp add_comment_symbol construct_trailing_comment_regexp/;
@@ -42,8 +43,8 @@
push(@trailingComments,{id=>$tokens{trailingComment}.$commentCounter.$tokens{endOfToken},value=>q()});
# log file info
- $self->logger("Updating trailing comment array",'heading')if $is_t_switch_active;
- $self->logger(Dumper(\@trailingComments),'ttrace') if($is_tt_switch_active);
+ $logger->trace("*Updating trailing comment array")if $is_t_switch_active;
+ $logger->trace(Dumper(\@trailingComments),'ttrace') if($is_tt_switch_active);
# the returned value
return $tokens{trailingComment}.$commentCounter.$tokens{endOfToken};
@@ -51,7 +52,7 @@
sub remove_trailing_comments{
my $self = shift;
- $self->logger("Storing trailing comments",'heading')if $is_t_switch_active;
+ $logger->trace("*Storing trailing comments")if $is_t_switch_active;
# perform the substitution
${$self}{body} =~ s/
@@ -71,10 +72,10 @@
"%".$tokens{trailingComment}.$commentCounter.$tokens{endOfToken};
/xsmeg;
if(@trailingComments){
- $self->logger("Trailing comments stored in:") if($is_t_switch_active);
- $self->logger(Dumper(\@trailingComments)) if($is_t_switch_active);
+ $logger->trace("Trailing comments stored in:") if($is_tt_switch_active);
+ $logger->trace(Dumper(\@trailingComments)) if($is_tt_switch_active);
} else {
- $self->logger("No trailing comments found") if($is_t_switch_active);
+ $logger->trace("No trailing comments found") if($is_t_switch_active);
}
return;
}
@@ -83,7 +84,7 @@
my $self = shift;
return unless( @trailingComments > 0 );
- $self->logger("Returning trailing comments to body",'heading')if $is_t_switch_active;
+ $logger->trace("*Returning trailing comments to body")if $is_t_switch_active;
# loop through trailing comments in reverse so that, for example,
# latexindenttrailingcomment1 doesn't match the first
@@ -95,7 +96,7 @@
# the -m switch can modify max characters per line, and trailing comment IDs can
# be split across lines
if($is_m_switch_active and ${$self}{body} !~ m/%$trailingcommentID/m){
- $self->logger("$trailingcommentID not found in body using /m matching, assuming it has been split across line (see modifyLineBreaks: textWrapOptions)") if($is_t_switch_active);
+ $logger->trace("$trailingcommentID not found in body using /m matching, assuming it has been split across line (see modifyLineBreaks: textWrapOptions)") if($is_t_switch_active);
my $trailingcommentIDwithLineBreaks;
# construct a reg exp that contains possible line breaks in between each character
@@ -107,7 +108,7 @@
my $trailingcommentIDwithLineBreaksRegExp = qr/$trailingcommentIDwithLineBreaks/s;
# replace the line-broken trailing comment ID with a non-broken trailing comment ID
- ${$self}{body} =~ s/%$trailingcommentIDwithLineBreaksRegExp/%$trailingcommentID/s;
+ ${$self}{body} =~ s/%\R?$trailingcommentIDwithLineBreaksRegExp/%$trailingcommentID/s;
}
if(${$self}{body} =~ m/%$trailingcommentID
(
@@ -118,12 +119,12 @@
) # captured into $1
(\h*)?$
/mx and $1 ne ''){
- $self->logger("Comment not at end of line $trailingcommentID, moving it to end of line")if $is_t_switch_active;
+ $logger->trace("Comment not at end of line $trailingcommentID, moving it to end of line")if $is_t_switch_active;
${$self}{body} =~ s/%$trailingcommentID(.*)$/$1%$trailingcommentValue/m;
} else {
${$self}{body} =~ s/%$trailingcommentID/%$trailingcommentValue/;
}
- $self->logger("replace %$trailingcommentID with %$trailingcommentValue") if($is_t_switch_active);
+ $logger->trace("replace %$trailingcommentID with %$trailingcommentValue") if($is_tt_switch_active);
}
return;
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/UnNamedGroupingBracesBrackets.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/UnNamedGroupingBracesBrackets.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/UnNamedGroupingBracesBrackets.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,6 +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::LogFile qw/$logger/;
use Exporter qw/import/;
our @ISA = "LatexIndent::Command"; # class inheritance, Programming Perl, pg 321
our @EXPORT_OK = qw/construct_unnamed_grouping_braces_brackets_regexp $un_named_grouping_braces_RegExp $un_named_grouping_braces_RegExp_trailing_comment/;
@@ -76,7 +77,7 @@
my $self = shift;
# the replacement text for a key = {value} needes to accomodate the leading [ OR { OR % OR , OR any combination thereof
- $self->logger("Custom replacement text routine for ${$self}{name}") if $is_t_switch_active;
+ $logger->trace("Custom replacement text routine for ${$self}{name}") if $is_t_switch_active;
# the un-named object is a little special, as it doesn't have a name; as such, if there are blank lines before
# the braces/brackets, we have to insert them
@@ -89,7 +90,7 @@
# but now turn off the switch for linebreaksAtEnd{begin}, otherwise the first brace gets too much indentation
# (see, for example, test-cases/namedGroupingBracesBrackets/special-characters-minimal.tex)
${${$self}{linebreaksAtEnd}}{begin} = 0;
- $self->logger("Beginning bit is: ${$self}{beginningbit}") if($is_t_switch_active);
+ $logger->trace("Beginning bit is: ${$self}{beginningbit}") if($is_t_switch_active);
delete ${$self}{beginningbit};
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -16,11 +16,12 @@
# For all communication, please visit: https://github.com/cmhughes/latexindent.pl
use strict;
use warnings;
+use Data::Dumper;
+use Exporter qw/import/;
use LatexIndent::Tokens qw/%tokens/;
use LatexIndent::GetYamlSettings qw/%masterSettings/;
use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_m_switch_active/;
-use Data::Dumper;
-use Exporter qw/import/;
+use LatexIndent::LogFile qw/$logger/;
our @EXPORT_OK = qw/put_verbatim_back_in find_verbatim_environments find_noindent_block find_verbatim_commands put_verbatim_commands_back_in/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
our $verbatimCounter;
@@ -29,11 +30,11 @@
my $self = shift;
# noindent block
- $self->logger('looking for NOINDENTBLOCk environments (see noIndentBlock)','heading') if $is_t_switch_active;
- $self->logger(Dumper(\%{$masterSettings{noIndentBlock}})) if($is_t_switch_active);
+ $logger->trace('*Searching for NOINDENTBLOCk environments (see noIndentBlock)') if $is_t_switch_active;
+ $logger->trace(Dumper(\%{$masterSettings{noIndentBlock}})) if($is_tt_switch_active);
while( my ($noIndentBlock,$yesno)= each %{$masterSettings{noIndentBlock}}){
if($yesno){
- $self->logger("looking for $noIndentBlock:$yesno environments") if $is_t_switch_active;
+ $logger->trace("looking for $noIndentBlock:$yesno environments") if $is_t_switch_active;
my $noIndentRegExp = qr/
(
@@ -58,7 +59,7 @@
while( ${$self}{body} =~ m/$noIndentRegExp/sx){
# create a new Environment object
- my $noIndentBlock = LatexIndent::Verbatim->new( begin=>$1,
+ my $noIndentBlockObj = LatexIndent::Verbatim->new( begin=>$1,
body=>$2,
end=>$3,
name=>$noIndentBlock,
@@ -65,21 +66,24 @@
);
# give unique id
- $noIndentBlock->create_unique_id;
+ $noIndentBlockObj->create_unique_id;
# verbatim children go in special hash
- ${$self}{verbatim}{${$noIndentBlock}{id}}=$noIndentBlock;
+ ${$self}{verbatim}{${$noIndentBlockObj}{id}}=$noIndentBlockObj;
# log file output
- $self->logger("NOINDENTBLOCK environment found: $noIndentBlock") if $is_t_switch_active;
+ $logger->trace("*NOINDENTBLOCK environment found: $noIndentBlock") if $is_t_switch_active;
# remove the environment block, and replace with unique ID
- ${$self}{body} =~ s/$noIndentRegExp/${$noIndentBlock}{id}/sx;
+ ${$self}{body} =~ s/$noIndentRegExp/${$noIndentBlockObj}{id}/sx;
- $self->logger("replaced with ID: ${$noIndentBlock}{id}") if $is_t_switch_active;
+ $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};
}
} else {
- $self->logger("*not* looking for $noIndentBlock as $noIndentBlock:$yesno") if $is_t_switch_active;
+ $logger->trace("*not* looking for $noIndentBlock as $noIndentBlock:$yesno") if $is_t_switch_active;
}
}
return;
@@ -89,11 +93,11 @@
my $self = shift;
# verbatim environments
- $self->logger('looking for VERBATIM environments (see verbatimEnvironments)','heading') if $is_t_switch_active;
- $self->logger(Dumper(\%{$masterSettings{verbatimEnvironments}})) if($is_t_switch_active);
+ $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}}){
if($yesno){
- $self->logger("looking for $verbEnv:$yesno environments") if $is_t_switch_active;
+ $logger->trace("looking for $verbEnv:$yesno environments") if $is_t_switch_active;
my $verbatimRegExp = qr/
(
@@ -124,15 +128,18 @@
${$self}{verbatim}{${$verbatimBlock}{id}}=$verbatimBlock;
# log file output
- $self->logger("VERBATIM environment found: $verbEnv") if $is_t_switch_active;
+ $logger->trace("*VERBATIM environment found: $verbEnv") if $is_t_switch_active;
# remove the environment block, and replace with unique ID
${$self}{body} =~ s/$verbatimRegExp/${$verbatimBlock}{id}/sx;
- $self->logger("replaced with ID: ${$verbatimBlock}{id}") if $is_t_switch_active;
+ $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};
}
} else {
- $self->logger("*not* looking for $verbEnv as $verbEnv:$yesno") if $is_t_switch_active;
+ $logger->trace("*not* looking for $verbEnv as $verbEnv:$yesno") if $is_t_switch_active;
}
}
return;
@@ -146,11 +153,11 @@
# would need to be found *before* trailing comments have been removed. Similarly,
# verbatim commands need to be put back in *after* trailing comments have been put
# back in
- $self->logger('looking for VERBATIM commands (see verbatimCommands)','heading') if $is_t_switch_active;
- $self->logger(Dumper(\%{$masterSettings{verbatimCommands}})) if($is_tt_switch_active);
+ $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}}){
if($yesno){
- $self->logger("looking for $verbCommand:$yesno Commands") if $is_t_switch_active;
+ $logger->trace("looking for $verbCommand:$yesno Commands") if $is_t_switch_active;
my $verbatimCommandRegExp = qr/
(
@@ -190,21 +197,24 @@
$verbatimCommand->create_unique_id;
# output, if desired
- $self->logger(Dumper($verbatimCommand),'ttrace') if($is_tt_switch_active);
+ $logger->trace(Dumper($verbatimCommand),'ttrace') if($is_tt_switch_active);
# verbatim children go in special hash
${$self}{verbatimCommands}{${$verbatimCommand}{id}}=$verbatimCommand;
# log file output
- $self->logger("VERBATIM command found: $verbCommand") if $is_t_switch_active;
+ $logger->trace("*VERBATIM command found: $verbCommand") if $is_t_switch_active;
# remove the environment block, and replace with unique ID
${$self}{body} =~ s/$verbatimCommandRegExp/${$verbatimCommand}{id}/sx;
- $self->logger("replaced with ID: ${$verbatimCommand}{id}") if $is_t_switch_active;
+ $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};
}
} else {
- $self->logger("*not* looking for $verbCommand as $verbCommand:$yesno") if $is_t_switch_active;
+ $logger->trace("*not* looking for $verbCommand as $verbCommand:$yesno") if $is_t_switch_active;
}
}
return;
@@ -218,8 +228,8 @@
return unless(${$self}{verbatim});
# search for environments/commands
- $self->logger('Putting verbatim back in, here is the pre-processed body:','heading') if $is_t_switch_active;
- $self->logger(${$self}{body}) if($is_t_switch_active);
+ $logger->trace('*Putting verbatim back in, here is the pre-processed body:') if $is_tt_switch_active;
+ $logger->trace(${$self}{body}) if($is_tt_switch_active);
# loop through document children hash
while( (scalar keys %{${$self}{verbatim}})>0 ){
@@ -230,14 +240,13 @@
${$self}{body} =~ s/${$child}{id}/${$child}{begin}${$child}{body}${$child}{end}/;
# log file info
- $self->logger('Body now looks like:','heading') if $is_tt_switch_active;
- $self->logger(${$self}{body},'ttrace') if($is_tt_switch_active);
+ $logger->trace('Body now looks like:') if $is_tt_switch_active;
+ $logger->trace(${$self}{body},'ttrace') if($is_tt_switch_active);
# delete the hash so it won't be operated upon again
delete ${$self}{verbatim}{${$child}{id}};
- $self->logger("deleted key") if $is_t_switch_active;
} elsif ($is_m_switch_active and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1 and ${$self}{body} !~ m/${$child}{id}/){
- $self->logger("${$child}{id} not found in body using /m matching, it may have been split across line (see modifyLineBreaks: textWrapOptions)") if($is_t_switch_active);
+ $logger->trace("${$child}{id} not found in body using /m matching, it may have been split across line (see modifyLineBreaks: textWrapOptions)") if($is_t_switch_active);
# search for a version of the verbatim ID that may have line breaks
my $verbatimIDwithLineBreaks = join("\\R?",split(//,${$child}{id}));
@@ -250,10 +259,8 @@
}
# logfile info
- $self->logger("Number of children:",'heading') if $is_t_switch_active;
- $self->logger(scalar keys %{${$self}{verbatim}}) if $is_t_switch_active;
- $self->logger('Post-processed body:','heading') if $is_t_switch_active;
- $self->logger(${$self}{body}) if($is_t_switch_active);
+ $logger->trace('*Post-processed body:') if $is_tt_switch_active;
+ $logger->trace(${$self}{body}) if($is_tt_switch_active);
return;
}
@@ -264,8 +271,8 @@
return unless(${$self}{verbatimCommands});
# search for environments/commands
- $self->logger('Putting verbatim commands back in, here is the pre-processed body:','heading') if $is_t_switch_active;
- $self->logger(${$self}{body}) if($is_t_switch_active);
+ $logger->trace('*Putting verbatim commands back in, here is the pre-processed body:') if $is_tt_switch_active;
+ $logger->trace(${$self}{body}) if($is_tt_switch_active);
# loop through document children hash
while( (scalar keys %{${$self}{verbatimCommands}})>0 ){
@@ -276,14 +283,13 @@
${$self}{body} =~ s/${$child}{id}/${$child}{begin}${$child}{body}${$child}{end}/;
# log file info
- $self->logger('Body now looks like:','heading') if $is_tt_switch_active;
- $self->logger(${$self}{body},'ttrace') if($is_tt_switch_active);
+ $logger->trace('Body now looks like:') if $is_tt_switch_active;
+ $logger->trace(${$self}{body},'ttrace') if($is_tt_switch_active);
# delete the hash so it won't be operated upon again
delete ${$self}{verbatimCommands}{${$child}{id}};
- $self->logger("deleted key") if $is_t_switch_active;
} elsif ($is_m_switch_active and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1 and ${$self}{body} !~ m/${$child}{id}/){
- $self->logger("${$child}{id} not found in body using /m matching, it may have been split across line (see modifyLineBreaks: textWrapOptions)") if($is_t_switch_active);
+ $logger->trace("${$child}{id} not found in body using /m matching, it may have been split across line (see modifyLineBreaks: textWrapOptions)") if($is_t_switch_active);
# search for a version of the verbatim ID that may have line breaks
my $verbatimIDwithLineBreaks = join("\\R?",split(//,${$child}{id}));
@@ -296,10 +302,8 @@
}
# logfile info
- $self->logger("Number of children:",'heading');
- $self->logger(scalar keys %{${$self}{verbatimCommands}});
- $self->logger('Post-processed body:','heading') if $is_t_switch_active;
- $self->logger(${$self}{body}) if($is_t_switch_active);
+ $logger->trace('*Post-processed body:') if $is_tt_switch_active;
+ $logger->trace(${$self}{body}) if($is_tt_switch_active);
return;
}
Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm 2018-01-13 22:26:56 UTC (rev 46303)
@@ -19,6 +19,6 @@
use Exporter qw/import/;
our @EXPORT_OK = qw/$versionNumber $versionDate/;
-our $versionNumber = '3.3';
-our $versionDate = '2017-08-21';
+our $versionNumber = '3.4';
+our $versionDate = '2018-01-13';
1
Modified: trunk/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml 2018-01-13 22:26:15 UTC (rev 46302)
+++ trunk/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml 2018-01-13 22:26:56 UTC (rev 46303)
@@ -1,4 +1,4 @@
-# defaultSettings.yaml for latexindent.pl, version 3.3, 2017-08-21
+# defaultSettings.yaml for latexindent.pl, version 3.4, 2018-01-13
# a script that aims to
# beautify .tex, .sty, .cls files
#
@@ -79,8 +79,14 @@
logFilePreferences:
showEveryYamlRead: 1
showAmalgamatedSettings: 0
+ showDecorationStartCodeBlockTrace: 0
+ showDecorationFinishCodeBlockTrace: 0
endLogFileWith: '--------------'
showGitHubInfoFooter: 1
+ PatternLayout:
+ default: "%A%n"
+ trace: "%A%n"
+ ttrace: "%A%n"
# verbatim environments- environments specified
# in this hash table will not be changed at all!
@@ -139,9 +145,12 @@
tabular:
delims: 1
alignDoubleBackSlash: 1
- spacesBeforeDoubleBackSlash: 2
+ spacesBeforeDoubleBackSlash: 1
multiColumnGrouping: 0
alignRowsWithoutMaxDelims: 1
+ spacesBeforeAmpersand: 1
+ spacesAfterAmpersand: 1
+ justification: "left"
tabularx:
delims: 1
longtable: 1
@@ -385,6 +394,28 @@
textWrapOptions:
columns: 0
separator: ""
+ oneSentencePerLine:
+ manipulateSentences: 0
+ removeSentenceLineBreaks: 1
+ sentencesFollow:
+ par: 1
+ blankLine: 1
+ fullStop: 1
+ exclamationMark: 1
+ questionMark: 1
+ rightBrace: 1
+ commentOnPreviousLine: 1
+ other: 0
+ sentencesBeginWith:
+ A-Z: 1
+ a-z: 0
+ other: 0
+ sentencesEndWith:
+ basicFullStop: 0
+ betterFullStop: 1
+ exclamationMark: 1
+ questionMark: 1
+ other: 0
removeParagraphLineBreaks:
all: 0
alignAtAmpersandTakesPriority: 1
Modified: trunk/Master/texmf-dist/scripts/latexindent/latexindent.pl
===================================================================
(Binary files differ)
More information about the tex-live-commits
mailing list