This release implements two new features:
Additionally, mainDocument is now used as a preference instead of masterDocument for the textWrap routine, although masterDocument is still supported and will be for all V3.* of latexindent.pl.
check switch: interface
- new switch:
-kor--checkwhich checks if the indented text is different from the original; a 'poor man's diff' is given to the log file - new switch:
-kvor--checkvwhich does the same thing as the-kswitch, but additionally outputs the 'poor man's diff' to the terminal.
For both switches, then the exit codes are as you detailed in the original post; explicitly:
latexindent.plwill exit with0if the indented text is not differentlatexindent.plwill exit with1if the indented text is different
check switch: demonstration 1
Let's begin with the following file, say myfile.tex
here is a nested test
\begin{one}
to be nested to be nested
to be nested to be nested
to be nested to be nested
\begin{two}
nested text nested tex nested tex
nested text nested tex nested tex
nested text nested tex nested tex
nested text nested tex nested tex
\end{two}
\end{one}
between nests
between nests
between nests
\begin{one}
to be nested to be nested one
to be nested to be nested two
to be nested to be nested three
\end{one}
here is a nested test
\begin{one}
to be nested to be nested
to be nested to be nested
to be nested to be nested
\begin{two}
nested text nested tex nested tex
nested text nested tex nested tex
nested text nested tex nested tex
nested text nested tex nested tex
\end{two}
\end{one}
more
of this
again
and againIf we run
latexindent.pl --check myfile.tex -s -y "defaultIndent: ' '"
echo $?
Then, crucially, the exit code is 1
If we run
latexindent.pl --checkv myfile.tex -s -y "defaultIndent: ' '"
echo $?
then the 'simple diff' is output as follows:
@@ 3 -- 11 @@
- to be nested to be nested
- to be nested to be nested
- to be nested to be nested
- \begin{two}
- nested text nested tex nested tex
- nested text nested tex nested tex
- nested text nested tex nested tex
- nested text nested tex nested tex
- \end{two}
+ to be nested to be nested
+ to be nested to be nested
+ to be nested to be nested
+ \begin{two}
+ nested text nested tex nested tex
+ nested text nested tex nested tex
+ nested text nested tex nested tex
+ nested text nested tex nested tex
+ \end{two}
@@ 17 -- 19 @@
- to be nested to be nested one
- to be nested to be nested two
- to be nested to be nested three
+ to be nested to be nested one
+ to be nested to be nested two
+ to be nested to be nested three
@@ 23 -- 31 @@
- to be nested to be nested
- to be nested to be nested
- to be nested to be nested
- \begin{two}
- nested text nested tex nested tex
- nested text nested tex nested tex
- nested text nested tex nested tex
- nested text nested tex nested tex
- \end{two}
+ to be nested to be nested
+ to be nested to be nested
+ to be nested to be nested
+ \begin{two}
+ nested text nested tex nested tex
+ nested text nested tex nested tex
+ nested text nested tex nested tex
+ nested text nested tex nested tex
+ \end{two}
@@ 34 -- 36 @@
- of this
- again
- and again
+of this
+again
+and again
--lines switch available syntax
- line range, as in - -lines 3-7
- single line, as in --lines 5
- multiple line ranges separated by commas, as in --lines 3-5,8-10
- negated line ranges, as in --lines !3-5 which translates to --lines 1-2,6-N, where N is the number of lines in your file;
lines switch: demonstration 2
Starting with
here is a nested test
\begin{one}
first block, second line
first block, third line
first block, fourth line
\begin{two}
second block, first line
second block, second line
second block, third line
second block, fourth line
\end{two}
\end{one}and running
latexindent.pl --lines 3-5 myfile.tex
gives
here is a nested test
\begin{one}
first block, second line
first block, third line
first block, fourth line
\begin{two}
second block, first line
second block, second line
second block, third line
second block, fourth line
\end{two}
\end{one}
lines switch: demonstration 3
Running
latexindent.pl --lines 3-5,8-10 myfile.tex
gives
here is a nested test
\begin{one}
first block, second line
first block, third line
first block, fourth line
\begin{two}
second block, first line
second block, second line
second block, third line
second block, fourth line
\end{two}
\end{one}