From 96b00a78469d97b34c7e89477725a37ab3fd32a1 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 14 Apr 2022 19:48:17 +0000 Subject: latexindent (14apr22) git-svn-id: svn://tug.org/texlive/trunk@63027 c570f23f-e606-0410-a88d-b1316a301751 --- Master/bin/win32/latexindent.exe | Bin 9813934 -> 9815551 bytes Master/texmf-dist/doc/support/latexindent/README | 2 +- .../latexindent/latexindent-yaml-schema.json | 2 +- .../doc/support/latexindent/latexindent.pdf | Bin 1069437 -> 1088780 bytes .../doc/support/latexindent/latexindent.tex | 46 +- .../doc/support/latexindent/sec-appendices.tex | 30 +- .../doc/support/latexindent/sec-introduction.tex | 153 +- .../latexindent/subsec-one-sentence-per-line.tex | 2 +- .../texmf-dist/doc/support/latexindent/title.tex | 8 +- .../LatexIndent/AlignmentAtAmpersand.pm | 1999 ++++++++++---------- .../scripts/latexindent/LatexIndent/Arguments.pm | 308 +-- .../latexindent/LatexIndent/BackUpFileProcedure.pm | 118 +- .../scripts/latexindent/LatexIndent/BlankLines.pm | 58 +- .../scripts/latexindent/LatexIndent/Braces.pm | 61 +- .../scripts/latexindent/LatexIndent/Check.pm | 117 +- .../scripts/latexindent/LatexIndent/Command.pm | 193 +- .../scripts/latexindent/LatexIndent/Document.pm | 362 ++-- .../latexindent/LatexIndent/DoubleBackSlash.pm | 7 +- .../scripts/latexindent/LatexIndent/Else.pm | 30 +- .../scripts/latexindent/LatexIndent/Environment.pm | 47 +- .../latexindent/LatexIndent/FileContents.pm | 252 +-- .../latexindent/LatexIndent/FileExtension.pm | 193 +- .../latexindent/LatexIndent/GetYamlSettings.pm | 1241 ++++++------ .../scripts/latexindent/LatexIndent/Heading.pm | 143 +- .../latexindent/LatexIndent/HiddenChildren.pm | 268 +-- .../LatexIndent/HorizontalWhiteSpace.pm | 43 +- .../scripts/latexindent/LatexIndent/IfElseFi.pm | 122 +- .../scripts/latexindent/LatexIndent/Indent.pm | 360 ++-- .../scripts/latexindent/LatexIndent/Item.pm | 46 +- .../LatexIndent/KeyEqualsValuesBraces.pm | 65 +- .../scripts/latexindent/LatexIndent/Lines.pm | 280 +-- .../scripts/latexindent/LatexIndent/LogFile.pm | 161 +- .../scripts/latexindent/LatexIndent/Logger.pm | 61 +- .../latexindent/LatexIndent/MandatoryArgument.pm | 34 +- .../latexindent/LatexIndent/ModifyLineBreaks.pm | 471 +++-- .../LatexIndent/NamedGroupingBracesBrackets.pm | 46 +- .../latexindent/LatexIndent/OptionalArgument.pm | 30 +- .../scripts/latexindent/LatexIndent/Preamble.pm | 24 +- .../scripts/latexindent/LatexIndent/Replacement.pm | 76 +- .../latexindent/LatexIndent/RoundBrackets.pm | 22 +- .../scripts/latexindent/LatexIndent/Sentence.pm | 352 ++-- .../scripts/latexindent/LatexIndent/Special.pm | 221 ++- .../scripts/latexindent/LatexIndent/Switches.pm | 38 +- .../scripts/latexindent/LatexIndent/Tokens.pm | 76 +- .../latexindent/LatexIndent/TrailingComments.pm | 113 +- .../LatexIndent/UnNamedGroupingBracesBrackets.pm | 62 +- .../scripts/latexindent/LatexIndent/Verbatim.pm | 582 +++--- .../scripts/latexindent/LatexIndent/Version.pm | 5 +- .../scripts/latexindent/LatexIndent/Wrap.pm | 406 ++-- .../scripts/latexindent/defaultSettings.yaml | 3 +- .../texmf-dist/scripts/latexindent/latexindent.pl | 71 +- 51 files changed, 5252 insertions(+), 4158 deletions(-) (limited to 'Master') diff --git a/Master/bin/win32/latexindent.exe b/Master/bin/win32/latexindent.exe index 71f3f17cebe..358fff9453a 100755 Binary files a/Master/bin/win32/latexindent.exe and b/Master/bin/win32/latexindent.exe differ diff --git a/Master/texmf-dist/doc/support/latexindent/README b/Master/texmf-dist/doc/support/latexindent/README index 2f683cea5b6..6ea4b951d14 100644 --- a/Master/texmf-dist/doc/support/latexindent/README +++ b/Master/texmf-dist/doc/support/latexindent/README @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - latexindent.pl, version 3.17.1, 2022-04-04 + latexindent.pl, version 3.17.2, 2022-04-14 PERL script to indent code within environments, and align delimited environments in .tex files. diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json b/Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json index de89322c5a9..8b5378679c0 100644 --- a/Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json +++ b/Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/schema", "$id": "latexindent-yaml-schema.json", "title": "latexindent.pl YAML schema", - "description": "latexindent.pl YAML schema helper, V3.17.1 2022-04-04", + "description": "latexindent.pl YAML schema helper, V3.17.2 2022-04-14", "type": "object", "properties": { "fileExtensionPreference": { diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent.pdf b/Master/texmf-dist/doc/support/latexindent/latexindent.pdf index 5ed8a71c1b7..86b5f93d0b4 100644 Binary files a/Master/texmf-dist/doc/support/latexindent/latexindent.pdf and b/Master/texmf-dist/doc/support/latexindent/latexindent.pdf differ diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent.tex b/Master/texmf-dist/doc/support/latexindent/latexindent.tex index 56405b93688..2bfe0248d17 100644 --- a/Master/texmf-dist/doc/support/latexindent/latexindent.tex +++ b/Master/texmf-dist/doc/support/latexindent/latexindent.tex @@ -93,7 +93,8 @@ \IfBooleanTF{#1}% {% \announce* % NEW in current version - \tcbdocmarginnote[overlay={\node at ([yshift=0mm,xshift=1mm]frame.north east) {\stardemo}; }]{% + \tcbdocmarginnote[colframe=orange, + overlay={\node at ([yshift=0mm,xshift=1mm]frame.north east) {\stardemo}; }]{% \IfBooleanTF{#3}% {% \announce*{date}*[text] means *updated* as of \tcbdocupdated{#2}% @@ -112,7 +113,10 @@ }% {% \announce % NOT new in current version - \tcbdocmarginnote{% + \tcbdocmarginnote[colframe=gray!50!white, + doclang/new={{\color{gray}N\normalfont\color{gray}}}, + doclang/updated={{\color{gray}U\normalfont\color{gray}}}, + ]{% \IfBooleanTF{#3}% {% \announce{date}*[text] means *updated* as of \tcbdocupdated{#2}% @@ -402,115 +406,115 @@ \lstdefinestyle{indentAfterItems}{ style=yaml-LST, - firstnumber=233,linerange={233-240}, + firstnumber=234,linerange={234-241}, numbers=left, } \lstdefinestyle{itemNames}{ style=yaml-LST, - firstnumber=246,linerange={246-248}, + firstnumber=247,linerange={247-249}, numbers=left, } \lstdefinestyle{specialBeginEnd}{ style=yaml-LST, - firstnumber=252,linerange={252-265}, + firstnumber=253,linerange={253-266}, numbers=left, } \lstdefinestyle{indentAfterHeadings}{ style=yaml-LST, - firstnumber=275,linerange={275-284}, + firstnumber=276,linerange={276-285}, numbers=left, } \lstdefinestyle{noAdditionalIndentGlobalEnv}{ style=yaml-LST, - firstnumber=333,linerange={333-334}, + firstnumber=334,linerange={334-335}, numbers=left, } \lstdefinestyle{noAdditionalIndentGlobal}{ style=yaml-LST, - firstnumber=333,linerange={333-345}, + firstnumber=334,linerange={334-346}, numbers=left, } \lstdefinestyle{indentRulesGlobalEnv}{ style=yaml-LST, - firstnumber=349,linerange={349-350}, + firstnumber=350,linerange={350-351}, numbers=left, } \lstdefinestyle{indentRulesGlobal}{ style=yaml-LST, - firstnumber=349,linerange={349-361}, + firstnumber=350,linerange={350-362}, numbers=left, } \lstdefinestyle{commandCodeBlocks}{ style=yaml-LST, - firstnumber=364,linerange={364-379}, + firstnumber=365,linerange={365-380}, numbers=left, } \lstdefinestyle{modifylinebreaks}{ style=yaml-LST, - firstnumber=494,linerange={494-496}, + firstnumber=495,linerange={495-497}, numbers=left, } \lstdefinestyle{textWrapOptions}{ style=yaml-LST, - firstnumber=522,linerange={522-523}, + firstnumber=523,linerange={523-524}, numbers=left, } \lstdefinestyle{textWrapOptionsAll}{ style=yaml-LST, - firstnumber=522,linerange={522-545}, + firstnumber=523,linerange={523-546}, numbers=left, } \lstdefinestyle{oneSentencePerLine}{ style=yaml-LST, - firstnumber=497,linerange={497-521}, + firstnumber=498,linerange={498-522}, numbers=left, } \lstdefinestyle{sentencesFollow}{ style=yaml-LST, - firstnumber=503,linerange={503-511}, + firstnumber=504,linerange={504-512}, numbers=left, } \lstdefinestyle{sentencesBeginWith}{ style=yaml-LST, - firstnumber=512,linerange={512-515}, + firstnumber=513,linerange={513-516}, numbers=left, } \lstdefinestyle{sentencesEndWith}{ style=yaml-LST, - firstnumber=516,linerange={516-521}, + firstnumber=517,linerange={517-522}, numbers=left, } \lstdefinestyle{modifylinebreaksEnv}{ style=yaml-LST, - firstnumber=547,linerange={547-556}, + firstnumber=548,linerange={548-557}, numbers=left, } \lstdefinestyle{replacements}{ style=yaml-LST, - firstnumber=608,linerange={608-616}, + firstnumber=609,linerange={609-617}, numbers=left, } \lstdefinestyle{fineTuning}{ style=yaml-LST, - firstnumber=619,linerange={619-671}, + firstnumber=620,linerange={620-672}, numbers=left, } diff --git a/Master/texmf-dist/doc/support/latexindent/sec-appendices.tex b/Master/texmf-dist/doc/support/latexindent/sec-appendices.tex index 9238c242a08..ca4608a2592 100644 --- a/Master/texmf-dist/doc/support/latexindent/sec-appendices.tex +++ b/Master/texmf-dist/doc/support/latexindent/sec-appendices.tex @@ -10,21 +10,21 @@ \begin{cmhlistings}[style=tcblatex,language=Perl]{\texttt{helloworld.pl}}{lst:helloworld} #!/usr/bin/perl -use strict; -use warnings; -use PerlIO::encoding; -use open ':std', ':encoding(UTF-8)'; -use Text::Wrap; -use Text::Tabs; -use FindBin; -use YAML::Tiny; -use File::Copy; -use File::Basename; -use File::HomeDir; -use Encode; -use Getopt::Long; -use Data::Dumper; -use List::Util qw(max); +use strict; # | +use warnings; # | +use Encode; # | +use Getopt::Long; # | +use Data::Dumper; # these modules are +use List::Util qw(max); # generally part +use PerlIO::encoding; # of a default perl distribution +use open ':std', ':encoding(UTF-8)';# | +use Text::Wrap; # | +use Text::Tabs; # | +use FindBin; # | +use File::Copy; # | +use File::Basename; # | +use File::HomeDir; # <--- typically requires install via cpanm +use YAML::Tiny; # <--- typically requires install via cpanm print "hello world"; exit; diff --git a/Master/texmf-dist/doc/support/latexindent/sec-introduction.tex b/Master/texmf-dist/doc/support/latexindent/sec-introduction.tex index d0b0e2012f5..5920a176b48 100644 --- a/Master/texmf-dist/doc/support/latexindent/sec-introduction.tex +++ b/Master/texmf-dist/doc/support/latexindent/sec-introduction.tex @@ -51,6 +51,139 @@ are a few changes to the interface; see \vref{app:differences} and the comments throughout this document for details}. +\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. + + We give an introduction to \texttt{latexindent.pl} using \cref{lst:quick-start}; there is + no explanation in this section, which is deliberate for a quick start. The rest of the + manual is more verbose. + + \cmhlistingsfromfile*{demonstrations/quick-start.tex}{\texttt{quick-start.tex}}{lst:quick-start} + + Running + \begin{commandshell} +latexindent.pl quick-start.tex +\end{commandshell} + gives \cref{lst:quick-start-default}. + + \cmhlistingsfromfile*{demonstrations/quick-start-default.tex}{\texttt{quick-start-default.tex}}{lst:quick-start-default} + + \begin{example} + Running + \begin{commandshell} +latexindent.pl -l quick-start1.yaml quick-start.tex +\end{commandshell} + gives \cref{lst:quick-start-mod1}. + + \begin{cmhtcbraster} + \cmhlistingsfromfile*{demonstrations/quick-start1.yaml}[yaml-TCB]{\texttt{quick-start1.yaml}}{lst:quick-start1yaml} + \cmhlistingsfromfile*[showspaces=true]{demonstrations/quick-start-mod1.tex}{\texttt{quick-start-mod1.tex}}{lst:quick-start-mod1} + \end{cmhtcbraster} + \end{example} + + \begin{example} + Running + \begin{commandshell} +latexindent.pl -l quick-start2.yaml quick-start.tex +\end{commandshell} + gives \cref{lst:quick-start-mod2}. + + \begin{cmhtcbraster} + \cmhlistingsfromfile*{demonstrations/quick-start2.yaml}[yaml-TCB]{\texttt{quick-start2.yaml}}{lst:quick-start2yaml} + \cmhlistingsfromfile*[showspaces=true]{demonstrations/quick-start-mod2.tex}{\texttt{quick-start-mod2.tex}}{lst:quick-start-mod2} + \end{cmhtcbraster} + \end{example} + + \begin{example} + Running + \begin{commandshell} +latexindent.pl -l quick-start3.yaml quick-start.tex +\end{commandshell} + gives \cref{lst:quick-start-mod3}. + + \begin{cmhtcbraster} + \cmhlistingsfromfile*{demonstrations/quick-start3.yaml}[yaml-TCB]{\texttt{quick-start3.yaml}}{lst:quick-start3yaml} + \cmhlistingsfromfile*{demonstrations/quick-start-mod3.tex}{\texttt{quick-start-mod3.tex}}{lst:quick-start-mod3} + \end{cmhtcbraster} + \end{example} + + \begin{example} + Running + \begin{commandshell} +latexindent.pl -m -l quick-start4.yaml quick-start.tex +\end{commandshell} + gives \cref{lst:quick-start-mod4}. + + \begin{cmhtcbraster} + \cmhlistingsfromfile*{demonstrations/quick-start4.yaml}[MLB-TCB]{\texttt{quick-start4.yaml}}{lst:quick-start4yaml} + \cmhlistingsfromfile*{demonstrations/quick-start-mod4.tex}{\texttt{quick-start-mod4.tex}}{lst:quick-start-mod4} + \end{cmhtcbraster} + Full details of text wrapping in \cref{subsec:textwrapping}. + \end{example} + + \begin{example} + Running + \begin{commandshell} +latexindent.pl -m -l quick-start5.yaml quick-start.tex +\end{commandshell} + gives \cref{lst:quick-start-mod5}. + + \begin{cmhtcbraster} + \cmhlistingsfromfile*{demonstrations/quick-start5.yaml}[MLB-TCB]{\texttt{quick-start5.yaml}}{lst:quick-start5yaml} + \cmhlistingsfromfile*{demonstrations/quick-start-mod5.tex}{\texttt{quick-start-mod5.tex}}{lst:quick-start-mod5} + \end{cmhtcbraster} + Full details of text wrapping in \cref{subsec:textwrapping}. + \end{example} + + \begin{example} + Running + \begin{commandshell} +latexindent.pl -m -l quick-start6.yaml quick-start.tex +\end{commandshell} + gives \cref{lst:quick-start-mod6}. + + \begin{cmhtcbraster} + \cmhlistingsfromfile*{demonstrations/quick-start6.yaml}[MLB-TCB]{\texttt{quick-start6.yaml}}{lst:quick-start6yaml} + \cmhlistingsfromfile*{demonstrations/quick-start-mod6.tex}{\texttt{quick-start-mod6.tex}}{lst:quick-start-mod6} + \end{cmhtcbraster} + This is an example of a \emph{poly-switch}; full details of \emph{poly-switches} are + covered in \cref{sec:poly-switches}. + \end{example} + + \begin{example} + Running + \begin{commandshell} +latexindent.pl -m -l quick-start7.yaml quick-start.tex +\end{commandshell} + gives \cref{lst:quick-start-mod7}. + + \begin{cmhtcbraster} + \cmhlistingsfromfile*{demonstrations/quick-start7.yaml}[MLB-TCB]{\texttt{quick-start7.yaml}}{lst:quick-start7yaml} + \cmhlistingsfromfile*{demonstrations/quick-start-mod7.tex}{\texttt{quick-start-mod7.tex}}{lst:quick-start-mod7} + \end{cmhtcbraster} + Full details of \emph{poly-switches} are covered in \cref{sec:poly-switches}. + \end{example} + +\subsection{Required perl modules} + 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}. + \subsection{About this documentation} As you read through this documentation, you will see many listings; in this version of the documentation, there are a total of \totallstlistings. This may seem a lot, but I @@ -109,26 +242,6 @@ highlight new and updated features. The new and updated features in this documentation (\gitRel) are on the following pages: \listOfNewFeatures% % \end{latexonly} -\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}. - \subsection{A word about regular expressions} \index{regular expressions!a word about} As you read this documentation, you may encounter the term \emph{regular expressions}. diff --git a/Master/texmf-dist/doc/support/latexindent/subsec-one-sentence-per-line.tex b/Master/texmf-dist/doc/support/latexindent/subsec-one-sentence-per-line.tex index d6ffd476cb0..fd16d193be7 100644 --- a/Master/texmf-dist/doc/support/latexindent/subsec-one-sentence-per-line.tex +++ b/Master/texmf-dist/doc/support/latexindent/subsec-one-sentence-per-line.tex @@ -10,7 +10,7 @@ \index{regular expressions!lowercase alph a-z} \index{regular expressions!uppercase alph A-Z}% - \cmhlistingsfromfile*[style=oneSentencePerLine]{../defaultSettings.yaml}[MLB-TCB,width=.85\linewidth,before=\centering]{\texttt{oneSentencePerLine}}{lst:oneSentencePerLine} + \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 diff --git a/Master/texmf-dist/doc/support/latexindent/title.tex b/Master/texmf-dist/doc/support/latexindent/title.tex index d2598ebafa6..ef2c39d1c29 100644 --- a/Master/texmf-dist/doc/support/latexindent/title.tex +++ b/Master/texmf-dist/doc/support/latexindent/title.tex @@ -8,14 +8,14 @@ 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.17.1 + \centering\ttfamily\bfseries latexindent.pl\\[1cm] Version 3.17.2 \end{tcolorbox} } \author{Chris Hughes \thanks{and contributors! See \vref{sec:contributors}. For all communication, please visit \cite{latexindent-home}.}} -\date{2022-04-04} +\date{2022-04-14} \maketitle \begin{adjustwidth}{1cm}{1cm} \small @@ -24,5 +24,7 @@ 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 modify line breaks, and to add comment symbols and blank lines; furthermore, it permits string or regex-based substitutions. - All user options are customisable via the switches and the YAML interface; you can find a quick start guide in \vref{sec:quickstart}. + All user options are customisable via the switches and the YAML interface. + + A quick start guide is given in \vref{sec:quickstart}. \end{adjustwidth} diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm index 6607bf6c9d4..746041893d7 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm @@ -1,4 +1,5 @@ package LatexIndent::AlignmentAtAmpersand; + # 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 @@ -26,33 +27,34 @@ use LatexIndent::Tokens qw/%tokens/; use LatexIndent::LogFile qw/$logger/; use LatexIndent::HiddenChildren qw/%familyTree/; use LatexIndent::Verbatim qw/%verbatimStorage/; -our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321 -our @EXPORT_OK = qw/align_at_ampersand find_aligned_block double_back_slash_else main_formatting individual_padding multicolumn_padding multicolumn_pre_check multicolumn_post_check dont_measure hidden_child_cell_row_width hidden_child_row_width get_column_width/; +our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321 +our @EXPORT_OK + = qw/align_at_ampersand find_aligned_block double_back_slash_else main_formatting individual_padding multicolumn_padding multicolumn_pre_check multicolumn_post_check dont_measure hidden_child_cell_row_width hidden_child_row_width get_column_width/; our $alignmentBlockCounter; -our @cellStorage; # two-dimensional storage array containing the cell information -our @formattedBody; # array for the new body +our @cellStorage; # two-dimensional storage array containing the cell information +our @formattedBody; # array for the new body our @minMultiColSpan; our @maxColumnWidth; our @maxDelimiterWidth; -sub find_aligned_block{ +sub find_aligned_block { my $self = shift; - return unless (${$self}{body} =~ m/(?!<\\)%\*\h*\\begin\{/s); + return unless ( ${$self}{body} =~ m/(?!<\\)%\*\h*\\begin\{/s ); # aligned block - # %* \begin{tabular} - # 1 & 2 & 3 & 4 \\ - # 5 & & 6 & \\ - # %* \end{tabular} - $logger->trace('*Searching for ALIGNED blocks marked by comments')if($is_t_switch_active); - $logger->trace(Dumper(\%{$mainSettings{lookForAlignDelims}})) if($is_tt_switch_active); - while( my ($alignmentBlock,$yesno)= each %{$mainSettings{lookForAlignDelims}}){ - if(ref $yesno eq "HASH"){ - $yesno = (defined ${$yesno}{delims} ) ? ${$yesno}{delims} : 1; - } - if($yesno){ + # %* \begin{tabular} + # 1 & 2 & 3 & 4 \\ + # 5 & & 6 & \\ + # %* \end{tabular} + $logger->trace('*Searching for ALIGNED blocks marked by comments') if ($is_t_switch_active); + $logger->trace( Dumper( \%{ $mainSettings{lookForAlignDelims} } ) ) if ($is_tt_switch_active); + while ( my ( $alignmentBlock, $yesno ) = each %{ $mainSettings{lookForAlignDelims} } ) { + if ( ref $yesno eq "HASH" ) { + $yesno = ( defined ${$yesno}{delims} ) ? ${$yesno}{delims} : 1; + } + if ($yesno) { $logger->trace("looking for %*\\begin\{$alignmentBlock\} environments"); my $alignmentRegExp = qr/ @@ -78,9 +80,9 @@ sub find_aligned_block{ ) /sx; - while( ${$self}{body} =~ m/$alignmentRegExp/sx){ + while ( ${$self}{body} =~ m/$alignmentRegExp/sx ) { - ${$self}{body} =~ s/ + ${$self}{body} =~ s/ $alignmentRegExp / # create a new Environment object @@ -104,23 +106,24 @@ sub find_aligned_block{ ${@{${$self}{children}}[-1]}{replacementText}; /xseg; - } - } else { + } + } + else { $logger->trace("*not* looking for $alignmentBlock as $alignmentBlock:$yesno"); - } + } } return; } -sub yaml_modify_line_breaks_settings{ +sub yaml_modify_line_breaks_settings { return; } -sub tasks_particular_to_each_object{ +sub tasks_particular_to_each_object { return; } -sub create_unique_id{ +sub create_unique_id { my $self = shift; $alignmentBlockCounter++; @@ -128,55 +131,56 @@ sub create_unique_id{ return; } -sub align_at_ampersand{ +sub align_at_ampersand { my $self = shift; - return if(${$self}{bodyLineBreaks}==0); + return if ( ${$self}{bodyLineBreaks} == 0 ); # some blocks may contain verbatim to be measured - ${$self}{measureVerbatim} = (${$self}{body}=~m/$tokens{verbatim}/ ? 1 : 0); + ${$self}{measureVerbatim} = ( ${$self}{body} =~ m/$tokens{verbatim}/ ? 1 : 0 ); my $maximumNumberOfAmpersands = 0; # clear the global arrays - @formattedBody = (); - @cellStorage = (); - @minMultiColSpan = (); - @maxColumnWidth = (); + @formattedBody = (); + @cellStorage = (); + @minMultiColSpan = (); + @maxColumnWidth = (); @maxDelimiterWidth = (); # maximum column widths my @maximumColumnWidths; - my $rowCounter = -1; + my $rowCounter = -1; my $columnCounter = -1; - $logger->trace("*dontMeasure routine, row mode") if(${$self}{dontMeasure} and $is_t_switch_active); + $logger->trace("*dontMeasure routine, row mode") if ( ${$self}{dontMeasure} and $is_t_switch_active ); # initial loop for column storage and measuring # initial loop for column storage and measuring # initial loop for column storage and measuring - foreach(split("\n",${$self}{body})){ + foreach ( split( "\n", ${$self}{body} ) ) { $rowCounter++; # default is to measure this row, but it can be switched off by the dont_measure routine ${$self}{measureRow} = 1; # call the dont_measure routine - $self->dont_measure(mode=>"row",row=>$_) if ${$self}{dontMeasure}; + $self->dont_measure( mode => "row", row => $_ ) if ${$self}{dontMeasure}; # remove \\ and anything following it my $endPiece = q(); - if($_ =~ m/(\\\\.*)/){ - if(${$self}{alignFinalDoubleBackSlash} ){ + if ( $_ =~ m/(\\\\.*)/ ) { + if ( ${$self}{alignFinalDoubleBackSlash} ) { + # for example, if we want: # # Name & \shortstack{Hi \\ Lo} \\