diff options
author | Karl Berry <karl@freefriends.org> | 2019-05-05 21:29:26 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-05-05 21:29:26 +0000 |
commit | 68d8522544f91b9bf99e420d505dd558389bbe61 (patch) | |
tree | 5a5c569c1541628a0fa108d04ee68485600a708e /Master | |
parent | 8b3f105e5c735e3dff4098328dd7e7004822224c (diff) |
latexindent (5may19)
git-svn-id: svn://tug.org/texlive/trunk@51015 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
15 files changed, 281 insertions, 162 deletions
diff --git a/Master/bin/win32/latexindent.exe b/Master/bin/win32/latexindent.exe Binary files differindex 0031cd39a9d..cd0ee4190cb 100755 --- a/Master/bin/win32/latexindent.exe +++ b/Master/bin/win32/latexindent.exe diff --git a/Master/texmf-dist/doc/support/latexindent/README b/Master/texmf-dist/doc/support/latexindent/README index 059ab7a4db7..70999521516 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.5.3, 2018-10-13 + latexindent.pl, version 3.6, 2019-05-05 PERL script to indent code within environments, and align delimited environments in .tex files. diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent.pdf b/Master/texmf-dist/doc/support/latexindent/latexindent.pdf Binary files differindex 89a0cc077e4..e26105457e2 100644 --- a/Master/texmf-dist/doc/support/latexindent/latexindent.pdf +++ b/Master/texmf-dist/doc/support/latexindent/latexindent.pdf diff --git a/Master/texmf-dist/doc/support/latexindent/logo.tex b/Master/texmf-dist/doc/support/latexindent/logo.tex index 3b0841fcae5..e2db1161204 100644 --- a/Master/texmf-dist/doc/support/latexindent/logo.tex +++ b/Master/texmf-dist/doc/support/latexindent/logo.tex @@ -18,3 +18,16 @@ \node[logo,fill,draw=bakeoffgreen,fill=bakeoffblue]{}; & \node[logo,double,draw=cmhgold,fill=harvestgold]{};\\}; \end{tikzpicture} \end{document} + +% for reference, the following puts the GitHub logo in the background; also needs +% \usetikzlibrary{backgrounds} +\pagecolor{white} +\begin{tikzpicture}[logo/.style={draw=blue,circle,fill=none,fill opacity=0.75}] + \matrix{% + \node[logo,dash pattern=on .5pt off 1.0pt,thick,draw=purple!75!white]{}; & \node[logo,draw=burntorange]{}; \\ + \node[logo,fill,draw=bakeoffgreen,fill=bakeoffblue]{}; & \node[logo,double,draw=cmhgold,fill=harvestgold]{};\\}; + \begin{scope}[on background layer] + %\node [yshift=0.01em,xshift=0.07em] {\resizebox{1cm}{!}{\color{gray!50!white}\faGithub}}; + \node {\resizebox{1cm}{!}{\color{gray!25!white}\faGithub}}; + \end{scope} +\end{tikzpicture} diff --git a/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex b/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex index 6f3c355107f..761d1ea5473 100644 --- a/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex +++ b/Master/texmf-dist/doc/support/latexindent/sec-default-user-local.tex @@ -577,7 +577,7 @@ latexindent.pl special2.tex -l=middle1 \end{itemize} You may%% - \announce*{2018-08-13}{specialBeginEnd verbatim} specify fields in + \announce{2018-08-13}{specialBeginEnd verbatim} specify fields in \texttt{specialBeginEnd} to be treated as verbatim code blocks by changing \texttt{lookForThis} to be \texttt{verbatim}. @@ -589,11 +589,11 @@ latexindent.pl special3.tex -l=special-verb1 then the output in \cref{lst:special3-mod1} is unchanged. \begin{minipage}{.4\linewidth} - \cmhlistingsfromfile*{demonstrations/special-verb1.yaml}[yaml-TCB]{\texttt{special-verb1.yaml}}{lst:special-verb1-yaml} + \cmhlistingsfromfile{demonstrations/special-verb1.yaml}[yaml-TCB]{\texttt{special-verb1.yaml}}{lst:special-verb1-yaml} \end{minipage} \hfill \begin{minipage}{.5\linewidth} - \cmhlistingsfromfile*{demonstrations/special3-mod1.tex}{\texttt{special3.tex} and output using \cref{lst:special-verb1-yaml}}{lst:special3-mod1} + \cmhlistingsfromfile{demonstrations/special3-mod1.tex}{\texttt{special3.tex} and output using \cref{lst:special-verb1-yaml}}{lst:special3-mod1} \end{minipage} \yamltitle{indentAfterHeadings}*{fields} diff --git a/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex b/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex index 0ff58be3153..0e959b2cf77 100644 --- a/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex +++ b/Master/texmf-dist/doc/support/latexindent/sec-the-m-switch.tex @@ -152,7 +152,7 @@ latexindent.pl -m textwrap4.tex -o textwrap4-mod2.tex -l textwrap2.yaml \subsubsection{text wrapping on a per-code-block basis} By default, if the value of \texttt{columns} is greater than 0 and the \texttt{-m} switch is active, then% - \announce*{2018-08-13}*{updates to textWrapOptions} the text wrapping routine will operate before the code blocks + \announce{2018-08-13}*{updates to textWrapOptions} the text wrapping routine will operate before the code blocks have been searched for. This behaviour is customisable; in particular, you can instead instruct \texttt{latexindent.pl} to apply \texttt{textWrap} on a per-code-block basis. Thanks to \cite{zoehneto} for their help in testing and @@ -161,7 +161,7 @@ latexindent.pl -m textwrap4.tex -o textwrap4-mod2.tex -l textwrap2.yaml The full details of \texttt{textWrapOptions} are shown in \cref{lst:textWrapOptionsAll}. In particular, note the field \texttt{perCodeBlockBasis: 0}. - \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} The code blocks detailed in \cref{lst:textWrapOptionsAll} are with direct reference to those detailed in \vref{tab:code-blocks}. The only special case is the @@ -176,7 +176,7 @@ latexindent.pl -m textwrap4.tex -o textwrap4-mod2.tex -l textwrap2.yaml the \texttt{masterDocument}. \begin{widepage} - \cmhlistingsfromfile*{demonstrations/textwrap5.tex}{\texttt{textwrap5.tex}}{lst:textwrap5} + \cmhlistingsfromfile{demonstrations/textwrap5.tex}{\texttt{textwrap5.tex}}{lst:textwrap5} \end{widepage} With reference to this codeblock, the settings given in \cref{lst:textwrap3-yaml,lst:textwrap4-yaml,lst:textwrap5-yaml} each @@ -184,13 +184,13 @@ latexindent.pl -m textwrap4.tex -o textwrap4-mod2.tex -l textwrap2.yaml \begin{adjustwidth}{-3.5cm}{-2.5cm} \begin{minipage}{.33\linewidth} - \cmhlistingsfromfile*{demonstrations/textwrap3.yaml}[MLB-TCB]{\texttt{textwrap3.yaml}}{lst:textwrap3-yaml} + \cmhlistingsfromfile{demonstrations/textwrap3.yaml}[MLB-TCB]{\texttt{textwrap3.yaml}}{lst:textwrap3-yaml} \end{minipage}% \begin{minipage}{.33\linewidth} - \cmhlistingsfromfile*{demonstrations/textwrap4.yaml}[MLB-TCB]{\texttt{textwrap4.yaml}}{lst:textwrap4-yaml} + \cmhlistingsfromfile{demonstrations/textwrap4.yaml}[MLB-TCB]{\texttt{textwrap4.yaml}}{lst:textwrap4-yaml} \end{minipage}% \begin{minipage}{.33\linewidth} - \cmhlistingsfromfile*{demonstrations/textwrap5.yaml}[MLB-TCB]{\texttt{textwrap5.yaml}}{lst:textwrap5-yaml} + \cmhlistingsfromfile{demonstrations/textwrap5.yaml}[MLB-TCB]{\texttt{textwrap5.yaml}}{lst:textwrap5-yaml} \end{minipage} \end{adjustwidth} @@ -217,13 +217,13 @@ latexindent.pl -s textwrap5.tex -l=textwrap5.yaml -m \end{commandshell} we obtain the output shown in \cref{lst:textwrap5-mod3}. - \cmhlistingsfromfile*{demonstrations/textwrap5-mod3.tex}{\texttt{textwrap5-mod3.tex}}{lst:textwrap5-mod3} + \cmhlistingsfromfile{demonstrations/textwrap5-mod3.tex}{\texttt{textwrap5-mod3.tex}}{lst:textwrap5-mod3} We can explore the idea of per-name text wrapping given in \cref{lst:textwrap5-yaml} by using \cref{lst:textwrap6}. \begin{widepage} - \cmhlistingsfromfile*{demonstrations/textwrap6.tex}{\texttt{textwrap6.tex}}{lst:textwrap6} + \cmhlistingsfromfile{demonstrations/textwrap6.tex}{\texttt{textwrap6.tex}}{lst:textwrap6} \end{widepage} In particular, upon running @@ -233,7 +233,7 @@ latexindent.pl -s textwrap6.tex -l=textwrap5.yaml -m we obtain the output given in \cref{lst:textwrap6-mod5}. \begin{widepage} - \cmhlistingsfromfile*{demonstrations/textwrap6-mod5.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap5-yaml}}{lst:textwrap6-mod5} + \cmhlistingsfromfile{demonstrations/textwrap6-mod5.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap5-yaml}}{lst:textwrap6-mod5} \end{widepage} Notice that, because \texttt{environments} has been specified only for @@ -246,13 +246,13 @@ latexindent.pl -s textwrap6.tex -l=textwrap5.yaml -m \begin{adjustwidth}{-3.5cm}{-2.5cm} \begin{minipage}{.33\linewidth} - \cmhlistingsfromfile*{demonstrations/textwrap6.yaml}[MLB-TCB]{\texttt{textwrap6.yaml}}{lst:textwrap6-yaml} + \cmhlistingsfromfile{demonstrations/textwrap6.yaml}[MLB-TCB]{\texttt{textwrap6.yaml}}{lst:textwrap6-yaml} \end{minipage}% \begin{minipage}{.33\linewidth} - \cmhlistingsfromfile*{demonstrations/textwrap7.yaml}[MLB-TCB]{\texttt{textwrap7.yaml}}{lst:textwrap7-yaml} + \cmhlistingsfromfile{demonstrations/textwrap7.yaml}[MLB-TCB]{\texttt{textwrap7.yaml}}{lst:textwrap7-yaml} \end{minipage}% \begin{minipage}{.33\linewidth} - \cmhlistingsfromfile*{demonstrations/textwrap8.yaml}[MLB-TCB]{\texttt{textwrap8.yaml}}{lst:textwrap8-yaml} + \cmhlistingsfromfile{demonstrations/textwrap8.yaml}[MLB-TCB]{\texttt{textwrap8.yaml}}{lst:textwrap8-yaml} \end{minipage} \end{adjustwidth} @@ -264,11 +264,11 @@ latexindent.pl -s textwrap6.tex -l=textwrap8.yaml -m \end{commandshell} we receive the respective output given in \crefrange{lst:textwrap6-mod6}{lst:textwrap6-mod8}. \begin{widepage} - \cmhlistingsfromfile*{demonstrations/textwrap6-mod6.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap6-yaml}}{lst:textwrap6-mod6} + \cmhlistingsfromfile{demonstrations/textwrap6-mod6.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap6-yaml}}{lst:textwrap6-mod6} - \cmhlistingsfromfile*{demonstrations/textwrap6-mod7.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap7-yaml}}{lst:textwrap6-mod7} + \cmhlistingsfromfile{demonstrations/textwrap6-mod7.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap7-yaml}}{lst:textwrap6-mod7} - \cmhlistingsfromfile*{demonstrations/textwrap6-mod8.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap8-yaml}}{lst:textwrap6-mod8} + \cmhlistingsfromfile{demonstrations/textwrap6-mod8.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap8-yaml}}{lst:textwrap6-mod8} \end{widepage} Notice that: @@ -290,13 +290,13 @@ latexindent.pl -s textwrap6.tex -l=textwrap8.yaml -m \begin{adjustwidth}{-3.5cm}{-2.5cm} \begin{minipage}{.33\linewidth} - \cmhlistingsfromfile*{demonstrations/textwrap9.yaml}[MLB-TCB]{\texttt{textwrap9.yaml}}{lst:textwrap9-yaml} + \cmhlistingsfromfile{demonstrations/textwrap9.yaml}[MLB-TCB]{\texttt{textwrap9.yaml}}{lst:textwrap9-yaml} \end{minipage}% \begin{minipage}{.33\linewidth} - \cmhlistingsfromfile*{demonstrations/textwrap10.yaml}[MLB-TCB]{\texttt{textwrap10.yaml}}{lst:textwrap10-yaml} + \cmhlistingsfromfile{demonstrations/textwrap10.yaml}[MLB-TCB]{\texttt{textwrap10.yaml}}{lst:textwrap10-yaml} \end{minipage}% \begin{minipage}{.33\linewidth} - \cmhlistingsfromfile*{demonstrations/textwrap11.yaml}[MLB-TCB]{\texttt{textwrap11.yaml}}{lst:textwrap11-yaml} + \cmhlistingsfromfile{demonstrations/textwrap11.yaml}[MLB-TCB]{\texttt{textwrap11.yaml}}{lst:textwrap11-yaml} \end{minipage} \end{adjustwidth} @@ -309,9 +309,9 @@ latexindent.pl -s textwrap6.tex -l=textwrap11.yaml -m we receive the respective output given in \cref{lst:textwrap6-mod9,lst:textwrap6-mod11}. \begin{widepage} - \cmhlistingsfromfile*{demonstrations/textwrap6-mod9.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap9-yaml}}{lst:textwrap6-mod9} + \cmhlistingsfromfile{demonstrations/textwrap6-mod9.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap9-yaml}}{lst:textwrap6-mod9} - \cmhlistingsfromfile*{demonstrations/textwrap6-mod11.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap11-yaml}}{lst:textwrap6-mod11} + \cmhlistingsfromfile{demonstrations/textwrap6-mod11.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap11-yaml}}{lst:textwrap6-mod11} \end{widepage} Notice that: @@ -347,7 +347,7 @@ latexindent.pl -s textwrap6.tex -l=textwrap11.yaml -m \item comments will \emph{not} be affected by the text wrapping routine (see \vref{lst:textwrap3-mod1}); \item it is possible to wrap text on a per-code-block and a per-name basis; - \announce*{2018-08-13}*{updates to textWrapOptions} + \announce{2018-08-13}*{updates to textWrapOptions} \item the text wrapping routine sets \texttt{preserveBlankLines} as \texttt{1}; \item indentation is performed \emph{after} the text wrapping routine; as such, @@ -363,7 +363,7 @@ latexindent.pl -s textwrap6.tex -l=textwrap11.yaml -m 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} + \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 @@ -651,12 +651,12 @@ latexindent.pl multiple-sentences4 -m -l=item-rules2.yaml \subsubsection{text wrapping and indenting sentences} The \texttt{oneSentencePerLine}%%% - \announce*{2018-08-13}{oneSentencePerline text wrap and indent} can be instructed to perform + \announce{2018-08-13}{oneSentencePerline text wrap and indent} can be instructed to perform text wrapping and indentation upon sentences. Let's use the code in \cref{lst:multiple-sentences5}. - \cmhlistingsfromfile*{demonstrations/multiple-sentences5.tex}{\texttt{multiple-sentences5.tex}}{lst:multiple-sentences5} + \cmhlistingsfromfile{demonstrations/multiple-sentences5.tex}{\texttt{multiple-sentences5.tex}}{lst:multiple-sentences5} Referencing \cref{lst:sentence-wrap1-yaml}, and running the following command \begin{commandshell} @@ -666,11 +666,11 @@ latexindent.pl multiple-sentences5 -m -l=sentence-wrap1.yaml \begin{widepage} \begin{minipage}{.55\linewidth} - \cmhlistingsfromfile*{demonstrations/multiple-sentences5-mod1.tex}{\texttt{multiple-sentences5.tex} using \cref{lst:sentence-wrap1-yaml}}{lst:multiple-sentences5-mod1} + \cmhlistingsfromfile{demonstrations/multiple-sentences5-mod1.tex}{\texttt{multiple-sentences5.tex} using \cref{lst:sentence-wrap1-yaml}}{lst:multiple-sentences5-mod1} \end{minipage}% \hfill \begin{minipage}{.45\linewidth} - \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/sentence-wrap1.yaml}[MLB-TCB]{\texttt{sentence-wrap1.yaml}}{lst:sentence-wrap1-yaml} + \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/sentence-wrap1.yaml}[MLB-TCB]{\texttt{sentence-wrap1.yaml}}{lst:sentence-wrap1-yaml} \end{minipage} \end{widepage} @@ -683,7 +683,7 @@ latexindent.pl multiple-sentences5 -m -l=sentence-wrap1.yaml means that you may need to tweak \vref{lst:sentencesEndWith}. Let's explore this in relation to \cref{lst:multiple-sentences6}. - \cmhlistingsfromfile*{demonstrations/multiple-sentences6.tex}{\texttt{multiple-sentences6.tex}}{lst:multiple-sentences6} + \cmhlistingsfromfile{demonstrations/multiple-sentences6.tex}{\texttt{multiple-sentences6.tex}}{lst:multiple-sentences6} By default, \texttt{latexindent.pl} will find the full-stop within the first \texttt{item}, which means that, upon running the following commands @@ -694,9 +694,9 @@ latexindent.pl multiple-sentences6 -m -l=sentence-wrap1.yaml -y="modifyLineBreak we receive the respective output in \cref{lst:multiple-sentences6-mod1} and \cref{lst:multiple-sentences6-mod2}. - \cmhlistingsfromfile*{demonstrations/multiple-sentences6-mod1.tex}{\texttt{multiple-sentences6-mod1.tex} using \cref{lst:sentence-wrap1-yaml}}{lst:multiple-sentences6-mod1} + \cmhlistingsfromfile{demonstrations/multiple-sentences6-mod1.tex}{\texttt{multiple-sentences6-mod1.tex} using \cref{lst:sentence-wrap1-yaml}}{lst:multiple-sentences6-mod1} - \cmhlistingsfromfile*{demonstrations/multiple-sentences6-mod2.tex}{\texttt{multiple-sentences6-mod2.tex} using \cref{lst:sentence-wrap1-yaml} and no sentence indentation}{lst:multiple-sentences6-mod2} + \cmhlistingsfromfile{demonstrations/multiple-sentences6-mod2.tex}{\texttt{multiple-sentences6-mod2.tex} using \cref{lst:sentence-wrap1-yaml} and no sentence indentation}{lst:multiple-sentences6-mod2} We note that \cref{lst:multiple-sentences6-mod1} the \texttt{itemize} code block has \emph{not} been indented appropriately. This is because the @@ -708,7 +708,7 @@ latexindent.pl multiple-sentences6 -m -l=sentence-wrap1.yaml -y="modifyLineBreak contains \lstinline!\end{itemize}! as in \cref{lst:itemize-yaml} (if you intend to use this, ensure that you remove the line breaks from the \texttt{other} field). - \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/itemized.yaml}[MLB-TCB]{\texttt{itemize.yaml}}{lst:itemize-yaml} + \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/itemized.yaml}[MLB-TCB]{\texttt{itemize.yaml}}{lst:itemize-yaml} Upon running \begin{commandshell} @@ -716,7 +716,7 @@ latexindent.pl multiple-sentences6 -m -l=sentence-wrap1.yaml,itemize.yaml \end{commandshell} we receive the output in \cref{lst:multiple-sentences6-mod3}. - \cmhlistingsfromfile*{demonstrations/multiple-sentences6-mod3.tex}{\texttt{multiple-sentences6-mod3.tex} using \cref{lst:sentence-wrap1-yaml} and \cref{lst:itemize-yaml}}{lst:multiple-sentences6-mod3} + \cmhlistingsfromfile{demonstrations/multiple-sentences6-mod3.tex}{\texttt{multiple-sentences6-mod3.tex} using \cref{lst:sentence-wrap1-yaml} and \cref{lst:itemize-yaml}}{lst:multiple-sentences6-mod3} Notice that the sentence has received indentation, and that the \texttt{itemize} code block has been found and indented correctly. @@ -731,7 +731,7 @@ latexindent.pl multiple-sentences6 -m -l=sentence-wrap1.yaml,itemize.yaml 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} @@ -864,7 +864,7 @@ latexindent.pl -m shortlines-md.tex -o shortlines-md4.tex -l remove-para4.yaml then we obtain the output in \cref{lst:shortlines-md4}. \cmhlistingsfromfile{demonstrations/shortlines-md4.tex}{\texttt{shortlines-md4.tex}}{lst:shortlines-md4} Note%%%%% - \announce*{2018-08-13}*{updates to all in removeParagraphLineBreaks} that the + \announce{2018-08-13}*{updates to all in removeParagraphLineBreaks} that the \texttt{all} field can take the same exceptions detailed in \cref{lst:textwrap6-yaml}{lst:textwrap8-yaml}. @@ -874,7 +874,7 @@ latexindent.pl -m shortlines-md.tex -o shortlines-md4.tex -l remove-para4.yaml \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 @@ -932,18 +932,18 @@ latexindent.pl -m sl-stop.tex -o sl-stop4-comment.tex -l=remove-para4.yaml,stop- \subsection{Combining removeParagraphLineBreaks and textWrapOptions}\label{subsec:removeparagraphlinebreaks:and:textwrap} The%%%%% - \announce*{2018-08-13}{combine text wrap and remove paragraph line breaks} text wrapping + \announce{2018-08-13}{combine text wrap and remove paragraph line breaks} text wrapping routine (\vref{subsec:textwrapping}) and remove paragraph line breaks routine (\vref{subsec:removeparagraphlinebreaks}) can be combined. We motivate this feature with the code given in \cref{lst:textwrap7}. - \cmhlistingsfromfile*{demonstrations/textwrap7.tex}{\texttt{textwrap7.tex}}{lst:textwrap7} + \cmhlistingsfromfile{demonstrations/textwrap7.tex}{\texttt{textwrap7.tex}}{lst:textwrap7} Applying the text wrap routine from \vref{subsec:textwrapping} with, for example, \vref{lst:textwrap3-yaml} gives the output in \cref{lst:textwrap7-mod3}. - \cmhlistingsfromfile*{demonstrations/textwrap7-mod3.tex}{\texttt{textwrap7.tex} using \cref{lst:textwrap3-yaml}}{lst:textwrap7-mod3} + \cmhlistingsfromfile{demonstrations/textwrap7-mod3.tex}{\texttt{textwrap7.tex} using \cref{lst:textwrap3-yaml}}{lst:textwrap7-mod3} The text wrapping routine has behaved as expected, but it may be desired to remove paragraph line breaks \emph{before} performing the text wrapping routine. @@ -957,11 +957,11 @@ latexindent.pl -m textwrap7.tex -l=textwrap12.yaml -o=+-mod12 we obtain the output in \cref{lst:textwrap7-mod12}. \begin{minipage}{.45\linewidth} - \cmhlistingsfromfile*{demonstrations/textwrap7-mod12.tex}{\texttt{textwrap7-mod12.tex}}{lst:textwrap7-mod12} + \cmhlistingsfromfile{demonstrations/textwrap7-mod12.tex}{\texttt{textwrap7-mod12.tex}}{lst:textwrap7-mod12} \end{minipage} \hfill \begin{minipage}{.49\linewidth} - \cmhlistingsfromfile*{demonstrations/textwrap12.yaml}[MLB-TCB]{\texttt{textwrap12.yaml}}{lst:textwrap12-yaml} + \cmhlistingsfromfile{demonstrations/textwrap12.yaml}[MLB-TCB]{\texttt{textwrap12.yaml}}{lst:textwrap12-yaml} \end{minipage} In \cref{lst:textwrap7-mod12} the paragraph linebreaks have first been removed from @@ -1448,11 +1448,14 @@ latexindent.pl -m env-mlb7.tex -l env-mlb13.yaml,env-mlb14.yaml,UnpreserveBlankL \vref{sec:modifylinebreaks-environments}), we choose to detail the poly-switches for all other code blocks in \cref{tab:poly-switch-mapping}; note that each and every one of these poly-switches is \emph{off by default}, i.e, set to \texttt{0}. - Note also that, by design, line breaks involving \texttt{verbatim}, + + Note also that, by design, line breaks involving, \texttt{filecontents} and `comment-marked' code blocks (\vref{lst:alignmentmarkup}) can \emph{not} be modified using - \texttt{latexindent.pl}. + \texttt{latexindent.pl}.\announce*{2019-05-05}*{verbatim poly-switch} However, there are two poly-switches available for \texttt{verbatim} + code blocks: environments (\vref{lst:verbatimEnvironments}), commands (\vref{lst:verbatimCommands}) and \texttt{specialBeginEnd} (\vref{lst:special-verb1-yaml}). + \clearpage \begin{longtable}{llll} \caption{Poly-switch mappings for all code-block types}\label{tab:poly-switch-mapping} \\ \toprule @@ -1511,5 +1514,9 @@ latexindent.pl -m env-mlb7.tex -l env-mlb13.yaml,env-mlb14.yaml,UnpreserveBlankL & body of special/middle $\EndStartsOnOwnLine$ & $\EndStartsOnOwnLine$ & SpecialEndStartsOnOwnLine \\ & \verb!\]!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & SpecialEndFinishesWithLineBreak \\ & after words & & \\ + \cmidrule{2-4} + verbatim & before words$\BeginStartsOnOwnLine$\verb!\begin{verbatim}! & $\BeginStartsOnOwnLine$ & VerbatimBeginStartsOnOwnLine \\ + \announce*{2019-05-05}{verbatim poly-switches} & body of verbatim \verb!\end{verbatim}!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & VerbatimEndFinishesWithLineBreak \\ + & after words & & \\ \bottomrule \end{longtable} diff --git a/Master/texmf-dist/doc/support/latexindent/title.tex b/Master/texmf-dist/doc/support/latexindent/title.tex index ab7249bbff6..22959c788e4 100644 --- a/Master/texmf-dist/doc/support/latexindent/title.tex +++ b/Master/texmf-dist/doc/support/latexindent/title.tex @@ -8,7 +8,7 @@ sharp corners, enhanced, overlay={\node[anchor=north east,outer sep=2pt] at ([xshift=3cm,yshift=4mm]frame.north east) {\includegraphics[width=3cm]{logo}}; }] - \centering\ttfamily\bfseries latexindent.pl\\[1cm] Version 3.5.3 + \centering\ttfamily\bfseries latexindent.pl\\[1cm] Version 3.6 \end{tcolorbox} } \author{Chris Hughes \thanks{and contributors! diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm index 491b9bce7f3..b4441b99455 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm @@ -27,7 +27,7 @@ use LatexIndent::GetYamlSettings qw/yaml_read_settings yaml_modify_line_breaks_s 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 text_wrap remove_paragraph_line_breaks construct_paragraph_reg_exp text_wrap_remove_paragraph_line_breaks/; +use LatexIndent::ModifyLineBreaks qw/modify_line_breaks_body modify_line_breaks_end remove_line_breaks_begin adjust_line_breaks_end_parent text_wrap remove_paragraph_line_breaks construct_paragraph_reg_exp text_wrap_remove_paragraph_line_breaks verbatim_modify_line_breaks/; use LatexIndent::Sentence qw/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/; @@ -38,7 +38,7 @@ use LatexIndent::AlignmentAtAmpersand qw/align_at_ampersand find_aligned_block/; use LatexIndent::DoubleBackSlash qw/dodge_double_backslash un_dodge_double_backslash/; # code blocks -use LatexIndent::Verbatim qw/put_verbatim_back_in find_verbatim_environments find_noindent_block find_verbatim_commands put_verbatim_commands_back_in find_verbatim_special/; +use LatexIndent::Verbatim qw/put_verbatim_back_in find_verbatim_environments find_noindent_block find_verbatim_commands find_verbatim_special verbatim_common_tasks/; use LatexIndent::Environment qw/find_environments $environmentBasicRegExp/; use LatexIndent::IfElseFi qw/find_ifelsefi construct_ifelsefi_regexp $ifElseFiBasicRegExp/; use LatexIndent::Else qw/check_for_else_statement/; @@ -90,6 +90,7 @@ sub operate_on_file{ $self->remove_trailing_comments; $self->find_verbatim_environments; $self->find_verbatim_special; + $self->verbatim_modify_line_breaks if $is_m_switch_active; $self->text_wrap if ($is_m_switch_active and !${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1); $self->protect_blank_lines; $self->remove_trailing_whitespace(when=>"before"); @@ -101,9 +102,9 @@ sub operate_on_file{ $self->condense_blank_lines; $self->unprotect_blank_lines; $self->un_dodge_double_backslash; - $self->put_verbatim_back_in; + $self->put_verbatim_back_in (match=>"everything-except-commands"); $self->put_trailing_comments_back_in; - $self->put_verbatim_commands_back_in; + $self->put_verbatim_back_in (match=>"just-commands"); $self->output_indented_text; return } diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm index a190d1e5f8c..97cb36df823 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm @@ -780,12 +780,12 @@ sub yaml_poly_switch_get_every_or_custom_value{ # check for the *custom* value if (defined $customValue){ - $logger->trace("$name: $toBeAssignedToAlias=$customValue, (*custom* value) adjusting $toBeAssignedTo") if($is_t_switch_active); + $logger->trace("$name: $toBeAssignedToAlias=$customValue, (*per-name* 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){ - $logger->trace("$name: $toBeAssignedToAlias=$everyValue, (*every* value) adjusting $toBeAssignedTo") if($is_t_switch_active); + $logger->trace("$name: $toBeAssignedToAlias=$everyValue, (*global* value) adjusting $toBeAssignedTo") if($is_t_switch_active); ${$self}{$toBeAssignedTo} = $everyValue; } } diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm index 2faa53b2920..a0763456e02 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm @@ -25,7 +25,7 @@ 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/; 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 text_wrap remove_paragraph_line_breaks construct_paragraph_reg_exp text_wrap_remove_paragraph_line_breaks/; +our @EXPORT_OK = qw/modify_line_breaks_body modify_line_breaks_end adjust_line_breaks_end_parent remove_line_breaks_begin text_wrap remove_paragraph_line_breaks construct_paragraph_reg_exp text_wrap_remove_paragraph_line_breaks verbatim_modify_line_breaks/; our $paragraphRegExp = q(); @@ -207,6 +207,37 @@ sub adjust_line_breaks_end_parent{ } +sub verbatim_modify_line_breaks{ + # verbatim modify line breaks are a bit special, as they happen before + # any of the main processes have been done + my $self = shift; + while ( my ($key,$child)= each %{${$self}{verbatim}}){ + if(defined ${$child}{BeginStartsOnOwnLine}){ + my $BeginStringLogFile = ${$child}{aliases}{BeginStartsOnOwnLine}; + $logger->trace("*$BeginStringLogFile is ${$child}{BeginStartsOnOwnLine} for ${$child}{name}") if $is_t_switch_active ; + if (${$child}{BeginStartsOnOwnLine}==-1){ + # VerbatimStartsOnOwnLine = -1 + if(${$self}{body}=~m/^\h*${$child}{id}/m){ + $logger->trace("${$child}{name} begins on its own line, removing leading line break") if $is_t_switch_active ; + ${$self}{body} =~ s/(\R|\h)*${$child}{id}/${$child}{id}/s; + } + } elsif (${$child}{BeginStartsOnOwnLine}>=1 and ${$self}{body}!~m/^\h*${$child}{id}/m){ + # VerbatimStartsOnOwnLine = 1, 2 or 3 + my $trailingCharacterToken = q(); + if(${$child}{BeginStartsOnOwnLine}==1){ + $logger->trace("Adding a linebreak at the beginning of ${$child}{begin} (see $BeginStringLogFile)") if $is_t_switch_active; + } elsif (${$child}{BeginStartsOnOwnLine}==2){ + $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){ + $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"; + } + ${$self}{body} =~ s/\h*${$child}{id}/$trailingCharacterToken\n${$child}{id}/s; + } + } + } +} sub text_wrap_remove_paragraph_line_breaks{ my $self = shift; diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Sentence.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Sentence.pm index c7bc39c284b..48ae0379d6c 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Sentence.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Sentence.pm @@ -129,7 +129,7 @@ sub one_sentence_per_line{ $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]))/; + $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/!/; diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm index f283eb0661c..d115bf078f7 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Verbatim.pm @@ -22,7 +22,7 @@ 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 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 find_verbatim_special/; +our @EXPORT_OK = qw/put_verbatim_back_in find_verbatim_environments find_noindent_block find_verbatim_commands find_verbatim_special verbatim_common_tasks/; our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321 our $verbatimCounter; @@ -59,11 +59,13 @@ sub find_noindent_block{ while( ${$self}{body} =~ m/$noIndentRegExp/sx){ - # create a new Environment object + # create a new Verbatim object my $noIndentBlockObj = LatexIndent::Verbatim->new( begin=>$1, body=>$2, end=>$3, name=>$noIndentBlock, + type=>"noindentblock", + modifyLineBreaksYamlName=>"verbatim", ); # give unique id @@ -113,19 +115,34 @@ sub find_verbatim_environments{ ( \\end\{$verbEnvSpec\} # \end{<something>} statement ) + (\h*)? # possibly followed by horizontal space + (\R)? # possibly followed by a line break /sx; while( ${$self}{body} =~ m/$verbatimRegExp/sx){ - # create a new Environment object + # create a new Verbatim object my $verbatimBlock = LatexIndent::Verbatim->new( begin=>$1, body=>$2, end=>$3, name=>$verbEnv, + type=>"environment", + modifyLineBreaksYamlName=>"verbatim", + linebreaksAtEnd=>{ + end=>$5?1:0, + }, + horizontalTrailingSpace=>$4?$4:q(), + aliases=>{ + # begin statements + BeginStartsOnOwnLine=>"VerbatimBeginStartsOnOwnLine", + # after end statements + EndFinishesWithLineBreak=>"VerbatimEndFinishesWithLineBreak", + }, ); - # give unique id - $verbatimBlock->create_unique_id; + # there are common tasks for each of the verbatim objects + $verbatimBlock->verbatim_common_tasks; + # verbatim children go in special hash ${$self}{verbatim}{${$verbatimBlock}{id}}=$verbatimBlock; @@ -133,7 +150,7 @@ sub find_verbatim_environments{ $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}{body} =~ s/$verbatimRegExp/${$verbatimBlock}{replacementText}/sx; $logger->trace("replaced with ID: ${$verbatimBlock}{id}") if $is_t_switch_active; @@ -161,7 +178,7 @@ sub find_verbatim_commands{ if($yesno){ $logger->trace("looking for $verbCommand:$yesno Commands") if $is_t_switch_active; - my $verbatimCommandRegExp = qr/ + my $verbatimRegExp = qr/ ( \\$verbCommand \h* @@ -176,39 +193,53 @@ sub find_verbatim_commands{ (?<!\\) # not immediately pre-ceeded by \ \] # [optional arguments] \h* - )? # opt arg into $2 + )? # opt arg into $2 ( . - ) # delimiter into $3 + ) # delimiter into $3 ( .*? - ) # body into $4 + ) # body into $4 \3 + (\h*)? # possibly followed by horizontal space + (\R)? # possibly followed by a line break /mx; - while( ${$self}{body} =~ m/$verbatimCommandRegExp/){ + while( ${$self}{body} =~ m/$verbatimRegExp/){ - # create a new Environment object + # create a new Verbatim object my $verbatimCommand = LatexIndent::Verbatim->new( begin=>$1.($2?$2:q()).$3, body=>$4, end=>$3, name=>$verbCommand, + type=>"command", + modifyLineBreaksYamlName=>"verbatim", + linebreaksAtEnd=>{ + end=>$6?1:0, + }, + horizontalTrailingSpace=>$5?$5:q(), + aliases=>{ + # begin statements + BeginStartsOnOwnLine=>"VerbatimBeginStartsOnOwnLine", + # after end statements + EndFinishesWithLineBreak=>"VerbatimEndFinishesWithLineBreak", + }, optArg=>$2?$2:q(), ); - # give unique id - $verbatimCommand->create_unique_id; + # there are common tasks for each of the verbatim objects + $verbatimCommand->verbatim_common_tasks; # output, if desired $logger->trace(Dumper($verbatimCommand),'ttrace') if($is_tt_switch_active); # verbatim children go in special hash - ${$self}{verbatimCommands}{${$verbatimCommand}{id}}=$verbatimCommand; + ${$self}{verbatim}{${$verbatimCommand}{id}}=$verbatimCommand; # log file output $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}{body} =~ s/$verbatimRegExp/${$verbatimCommand}{replacementText}/sx; $logger->trace("replaced with ID: ${$verbatimCommand}{id}") if $is_t_switch_active; @@ -223,73 +254,127 @@ sub find_verbatim_commands{ } -sub put_verbatim_back_in { +sub find_verbatim_special{ my $self = shift; - # if there are no verbatim children, return - return unless(${$self}{verbatim}); + # loop through specialBeginEnd + while( my ($specialName,$BeginEnd)= each %{$masterSettings{specialBeginEnd}}){ - # search for environments/commands - $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); + # only classify special Verbatim if lookForThis is 'verbatim' + if( (ref($BeginEnd) eq "HASH") and ${$BeginEnd}{lookForThis}=~m/v/s and ${$BeginEnd}{lookForThis} eq 'verbatim'){ + $logger->trace('*Searching for VERBATIM special (see specialBeginEnd)') if $is_t_switch_active; - # loop through document children hash - while( (scalar keys %{${$self}{verbatim}})>0 ){ - while( my ($key,$child)= each %{${$self}{verbatim}}){ - if(${$self}{body} =~ m/${$child}{id}/mx){ + my $verbatimRegExp = qr/ + ( + ${$BeginEnd}{begin} + ) + ( + .*? + ) + ( + ${$BeginEnd}{end} + ) + (\h*)? # possibly followed by horizontal space + (\R)? # possibly followed by a line break + /sx; - # replace ids with body - ${$self}{body} =~ s/${$child}{id}/${$child}{begin}${$child}{body}${$child}{end}/; + while( ${$self}{body} =~ m/$verbatimRegExp/sx){ - # log file info - $logger->trace('Body now looks like:') if $is_tt_switch_active; - $logger->trace(${$self}{body},'ttrace') if($is_tt_switch_active); + # create a new Verbatim object + my $verbatimBlock = LatexIndent::Verbatim->new( begin=>$1, + body=>$2, + end=>$3, + name=>$specialName, + modifyLineBreaksYamlName=>"specialBeginEnd", + linebreaksAtEnd=>{ + end=>$5?1:0, + }, + horizontalTrailingSpace=>$4?$4:q(), + type=>"special", + aliases=>{ + # begin statements + BeginStartsOnOwnLine=>"SpecialBeginStartsOnOwnLine", + # after end statements + EndFinishesWithLineBreak=>"SpecialEndFinishesWithLineBreak", + }, + ); + # there are common tasks for each of the verbatim objects + $verbatimBlock->verbatim_common_tasks; - # delete the hash so it won't be operated upon again - delete ${$self}{verbatim}{${$child}{id}}; - } elsif ($is_m_switch_active and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1 and ${$self}{body} !~ m/${$child}{id}/){ - $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); + # verbatim children go in special hash + ${$self}{verbatim}{${$verbatimBlock}{id}}=$verbatimBlock; - # search for a version of the verbatim ID that may have line breaks - my $verbatimIDwithLineBreaks = join("\\R?",split(//,${$child}{id})); - my $verbatimIDwithLineBreaksRegExp = qr/$verbatimIDwithLineBreaks/s; + # log file output + $logger->trace("*VERBATIM special found: $specialName") if $is_t_switch_active; - # replace the line-broken verbatim ID with a non-broken verbatim ID - ${$self}{body} =~ s/$verbatimIDwithLineBreaksRegExp/${$child}{id}/s; - } - } - } + # remove the special block, and replace with unique ID + ${$self}{body} =~ s/$verbatimRegExp/${$verbatimBlock}{replacementText}/sx; - # logfile info - $logger->trace('*Post-processed body:') if $is_tt_switch_active; - $logger->trace(${$self}{body}) if($is_tt_switch_active); - return; + $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}; + } + } + } } -sub put_verbatim_commands_back_in { +sub put_verbatim_back_in { my $self = shift; + my %input = @_; # if there are no verbatim children, return - return unless(${$self}{verbatimCommands}); + return unless(${$self}{verbatim}); + my $verbatimCount=0; + my $toMatch = q(); + if($input{match} eq "everything-except-commands"){ + $toMatch = "noindentblockenvironmentspecial"; + + # count the number of non-command verbatim objects + while( my ($key,$child)= each %{${$self}{verbatim}}){ + ${$child}{type} = "environment" if !(defined ${$child}{type}); + $verbatimCount++ if($toMatch =~ m/${$child}{type}/); + } + return unless($verbatimCount>0); + } else { + $toMatch = "command"; + # count the number of command verbatim objects + while( my ($key,$child)= each %{${$self}{verbatim}}){ + ${$child}{type} = "environment" if !(defined ${$child}{type}); + $verbatimCount++ if($toMatch =~ m/${$child}{type}/); + } + return unless($verbatimCount>0); + } + # search for environments/commands - $logger->trace('*Putting verbatim commands back in, here is the pre-processed body:') if $is_tt_switch_active; + $logger->trace('*Putting verbatim back in') if $is_t_switch_active; + $logger->trace('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 ){ - while( my ($key,$child)= each %{${$self}{verbatimCommands}}){ + my $verbatimFound=0; + while($verbatimFound < $verbatimCount){ + while( my ($key,$child)= each %{${$self}{verbatim}}){ + if($toMatch =~ m/${$child}{type}/){ if(${$self}{body} =~ m/${$child}{id}/mx){ - + # possibly remove trailing line break + if(defined ${$child}{EndFinishesWithLineBreak} + and ${$child}{EndFinishesWithLineBreak}==-1 + and ${$self}{body} =~ m/${$child}{id}\h*\R/s){ + $logger->trace("m-switch active, removing trailing line breaks from ${$child}{name}") if $is_t_switch_active; + ${$self}{body} =~ s/${$child}{id}(\h*)?(\R|\h)*/${$child}{id} /s; + } # replace ids with body - ${$self}{body} =~ s/${$child}{id}/${$child}{begin}${$child}{body}${$child}{end}/; + ${$self}{body} =~ s/${$child}{id}/${$child}{begin}${$child}{body}${$child}{end}/s; # log file info $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}}; + # delete the child so it won't be operated upon again + delete ${$self}{verbatim}{${$child}{id}}; + $verbatimFound++; } elsif ($is_m_switch_active and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1 and ${$self}{body} !~ m/${$child}{id}/){ $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); @@ -299,65 +384,39 @@ sub put_verbatim_commands_back_in { # replace the line-broken verbatim ID with a non-broken verbatim ID ${$self}{body} =~ s/$verbatimIDwithLineBreaksRegExp/${$child}{id}/s; + + # note: we do *not* label this as found, as we need to go back through + # and search for the newly modified ID } } - } - # logfile info - $logger->trace('*Post-processed body:') if $is_tt_switch_active; - $logger->trace(${$self}{body}) if($is_tt_switch_active); + # logfile info + $logger->trace('*Post-processed body:') if $is_tt_switch_active; + $logger->trace(${$self}{body}) if($is_tt_switch_active); + } + } return; } -sub find_verbatim_special{ - my $self = shift; - - # loop through specialBeginEnd - while( my ($specialName,$BeginEnd)= each %{$masterSettings{specialBeginEnd}}){ - - # only classify special Verbatim if lookForThis is 'verbatim' - if( (ref($BeginEnd) eq "HASH") and ${$BeginEnd}{lookForThis}=~m/v/s and ${$BeginEnd}{lookForThis} eq 'verbatim'){ - $logger->trace('*Searching for VERBATIM special (see specialBeginEnd)') if $is_t_switch_active; - - my $verbatimRegExp = qr/ - ( - ${$BeginEnd}{begin} - ) - ( - .*? - ) - ( - ${$BeginEnd}{end} - ) - /sx; - - while( ${$self}{body} =~ m/$verbatimRegExp/sx){ +sub verbatim_common_tasks{ - # create a new Environment object - my $verbatimBlock = LatexIndent::Verbatim->new( begin=>$1, - body=>$2, - end=>$3, - name=>$specialName, - ); - # give unique id - $verbatimBlock->create_unique_id; + my $self = shift; - # verbatim children go in special hash - ${$self}{verbatim}{${$verbatimBlock}{id}}=$verbatimBlock; + # get yaml settings + $self->yaml_modify_line_breaks_settings if $is_m_switch_active; - # log file output - $logger->trace("*VERBATIM special found: $specialName") if $is_t_switch_active; + # give unique id + $self->create_unique_id; - # remove the special block, and replace with unique ID - ${$self}{body} =~ s/$verbatimRegExp/${$verbatimBlock}{id}/sx; + # the replacement text can be just the ID, but the ID might have a line break at the end of it + $self->get_replacement_text; - $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}; - } - } - } + # the above regexp, when used below, will remove the trailing linebreak in ${$self}{linebreaksAtEnd}{end} + # so we compensate for it here + $self->adjust_replacement_text_line_breaks_at_end; + + # modify line breaks end statements + $self->modify_line_breaks_end if $is_m_switch_active; } sub create_unique_id{ @@ -368,4 +427,9 @@ sub create_unique_id{ return; } +sub yaml_get_textwrap_removeparagraphline_breaks{ + my $self = shift; + $logger->trace("No text wrap or remove paragraph line breaks for verbatim code blocks, ${$self}{name}") if ${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}; +} + 1; diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm index 4dd9ec1da57..52a659dc79c 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm @@ -19,6 +19,6 @@ use warnings; use Exporter qw/import/; our @EXPORT_OK = qw/$versionNumber $versionDate/; -our $versionNumber = '3.5.3'; -our $versionDate = '2018-10-13'; +our $versionNumber = '3.6'; +our $versionDate = '2019-05-05'; 1 diff --git a/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml b/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml index ad6a61fed57..d457e96e3a3 100755 --- a/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml +++ b/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml @@ -1,4 +1,4 @@ -# defaultSettings.yaml for latexindent.pl, version 3.5.3, 2018-10-13 +# defaultSettings.yaml for latexindent.pl, version 3.6, 2019-05-05 # a script that aims to # beautify .tex, .sty, .cls files # @@ -516,3 +516,6 @@ modifyLineBreaks: SpecialBodyStartsOnOwnLine: 0 SpecialEndStartsOnOwnLine: 0 SpecialEndFinishesWithLineBreak: 0 + verbatim: + VerbatimBeginStartsOnOwnLine: 0 + VerbatimEndFinishesWithLineBreak: 0 diff --git a/Master/texmf-dist/scripts/latexindent/latexindent.pl b/Master/texmf-dist/scripts/latexindent/latexindent.pl index d55682eadde..cb2208d1176 100755 --- a/Master/texmf-dist/scripts/latexindent/latexindent.pl +++ b/Master/texmf-dist/scripts/latexindent/latexindent.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# latexindent.pl, version 3.5.3, 2018-10-13 +# latexindent.pl, version 3.6, 2019-05-05 # # 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 |