Releases: cmhughes/latexindent.pl
V3.13.2
defaultSettings.yaml
can (optionally) now be located in LatexIndent/
folder.
This was proposed in conda-forge/staged-recipes#16914
V3.13.1
Upgrade to -y
switch #296, and minor updates to documentation #299 and #300
Thank you to @XuehaiPan for their contribution.
V3.13
This release implements an upgrade to the verbatim
blocks, and friends. Thank you to @XuehaiPan for this contribution.
See #288 for discussion and history.
Summary
- Anything specified within
noIndentBlock
,verbatimEnvironments
andverbatimCommands
can now be specified in the form
verbatimEnvironments:
nameAsRegex:
name: '\w+code\*?'
lookForThis: 1
- the
lookForThis
field is optional, and if not present, will assumed to be1
(this is consistent with other settings in the script) - we have used
nameAsRegex
but it could be named as anything, for example, it could be namedmintedalias
verbatimEnvironments:
mintedalias:
name: '\w+code\*?'
lookForThis: 1
- if the users code only contains
\begin{pythoncode}...\end{pythoncode}
then the above YAML settings is equivalent to
verbatimEnvironments:
pythoncode: 1
- For
noIndentBlock
users can specifybegin
andend
(both) or onlyname
:
noIndentBlock:
beginend:
begin: regex_begin
end: regex_end
body: regex_body # optional
nameonly:
name: regex_name
body: regex_body # optional
# the above is equivalent to the follows when `regex_name` does not contain `'*'` and body is omitted
regex_name: 1
- The following settings are examples of incomplete/conflicted settings, which will be ignored:
# the followings are ignored
none: # incomplete settings, ignored
lookForThis: 1
beginonly: # incomplete settings, ignored
begin: regex_begin
endonly: # incomplete settings, ignored
end: regex_end
namebeginend: # conflict settings, ignored
begin: regex_begin
end: regex_end
name: regex_name
namebegin: # conflict settings, ignored
begin: regex_begin
name: regex_name
nameend: # conflict settings, ignored
end: regex_end
name: regex_name
V3.12
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:
-k
or--check
which checks if the indented text is different from the original; a 'poor man's diff' is given to the log file - new switch:
-kv
or--checkv
which does the same thing as the-k
switch, 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.pl
will exit with0
if the indented text is not differentlatexindent.pl
will exit with1
if 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 again
If 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}
V3.11
Upgrade to textWrap
This release implements an upgrade to textWrap
: in particular, a new feature beforeFindingChildCodeBlocks
to be
used with perCodeBlockBasis
.
This was implemented in relation to the issues raised in issue 158
and issue 228. Demonstrations are given within these threads, and are documented.
GitHub Actions
This has been implemented to create and publish latexindent.exe
automatically. Hopefully
more automated actions will follow.
V3.10.1
changes to defaults:
- textWrap: Huge now set to overflow by default; this means that words and other strings of characters will not be broken mid-word by the text wrapping routine. Users are encouraged not to change this, but have the option to do so.
enhancements:
- users should see improved performance when the -m switch is active; see
benchmark details within #268 - users should see improved behaviour in the alignment at ampersand routine,
a long standing issue detailed at #85
example: issue 85
from #85 starting with
\matrix {
c01 & c02 \\
c_{11} & c12 \\
}
gives, by default
\matrix {
c01 & c02 \\
c_{11} & c12 \\
}
example: issue 162
from #162 starting with
\begin{align}
A & =\begin{array}{cc}
BBB & CCC\\
E & F
\end{array}\\
Z & =\begin{array}{cc}
Y & X\\
W & V
\end{array}
\end{align}
gives, by default,
\begin{align}
A & =\begin{array}{cc}
BBB & CCC \\
E & F
\end{array} \\
Z & =\begin{array}{cc}
Y & X \\
W & V
\end{array}
\end{align}
example: issue 212
from #212 starting with
\begin{equation}
\begin{aligned}
x =& x^2 \mqty[a_{11} & a_{12} \\ a_{21} & a_{22}] =& f(x) \\
y =& f(y) =& y^2 \\
z =& f(z) =& z^2
\end{aligned}
\end{equation}
gives, by default,
\begin{equation}
\begin{aligned}
x = & x^2 \mqty[a_{11} & a_{12} \\ a_{21} & a_{22}] =& f(x) \\
y = & f(y) = & y^2 \\
z = & f(z) = & z^2
\end{aligned}
\end{equation}
example: issue 251
from #251 starting with
\begin{tabular}{ll}
Testing & Line 1 \\
Testing & Line 2 \\
Testing & Line 3 \verb|X| \\
Testing & Line 4 \\
\end{tabular}
gives, by default,
\begin{tabular}{ll}
Testing & Line 1 \\
Testing & Line 2 \\
Testing & Line 3 \verb|X| \\
Testing & Line 4 \\
\end{tabular}
V3.10
enhancements
- logFilePreferences updated with more options, particularly for when -tt switch active #276
- spacesBeforeAmpersand enhanced with new option for leading blank column behaviour #275
- fineTuning and noIndentBlock enhanced, demonstrated below #274
- indentconfig.yaml enhanced with details at #263 and in documentation
- removeWhiteSpace dos2unixlinebreaks: new switch, documented and details at #256
bug fix
- #183, oneSetencePerLine, removeParagraphLineBreaks
demonstration 1: fineTuning trailing comments
starting with
some before text
\href{Handbook%20for%30Spoken%40document.pdf}{my document}
some after text
and using
modifyLineBreaks:
textWrapOptions:
columns: 80
huge: overflow
all: 1
perCodeBlockBasis: 1
removeParagraphLineBreaks:
all: 1
fineTuning:
trailingComments:
notPreceededBy: '(?:(?<!Handbook)(?<!for)(?<!Spoken))'
then the output is (using -m switch):
some before text \href{Handbook%20for%30Spoken%40document.pdf}{my document} some after text
demonstration 2: noIndentBlock with begin and end
starting with
some before text
this code
won't
be touched
by
latexindent.pl!
some after text
and using
noIndentBlock:
demo:
begin: 'some\hbefore'
body: '.*?'
end: 'some\hafter\htext'
lookForThis: 1
gives the output
some before text
this code
won't
be touched
by
latexindent.pl!
some after text
Note that lookForThis
is optional in the noIndentBlock
field; default is 1.
demonstration 3: spacesBeforeAmpersand
Starting with
\begin{equation}
\begin{aligned}
& a = b, \\
& c = d.
\end{aligned}
\end{equation}
\begin{equation}
\begin{aligned}
a & = b, \\
c & = d.
\end{aligned}
\end{equation}
and using
defaultIndent: ' '
noAdditionalIndent:
aligned: 1
lookForAlignDelims:
aligned:
spacesBeforeAmpersand:
default: 2
leadingBlankColumn: 0
then the result is
\begin{equation}
\begin{aligned}
& a = b, \\
& c = d.
\end{aligned}
\end{equation}
\begin{equation}
\begin{aligned}
a & = b, \\
c & = d.
\end{aligned}
\end{equation}
The fields default
and leadingBlankColumn
both take integer values that represent the spaces to be added before ampersands. They are both optional.
V3.9.3
A minor release that updates log file creation #145; in particular, users can specify, for example,
latexindent.pl -g /dev/null myfile.tex
so that the log file will not be created. Prior to this release, latexindent.pl
would fail if the log file could not be created.
The other minor tweak to the logging procedure is that the FATAL
method has been created, for situations in which latexindent
is called to act on files that do not exist.
V3.9.2
V3.9.1
Minor updates to documentation, details at #255 and #259
Minor updates to fineTuning:
keyEqualsValuesBracesBrackets
, #257 which means that, by default,keyEqualsValuesBracesBrackets
no longer begin with braces.namedGroupingBracesBrackets
, #258 now starts with a lower-case 'n' infineTuning
so as to be consistent with its appearance elsewhere indefaultSettings.yaml
. As this was my mistake,LatexIndent/NamedGroupingBracesBrackets.pm
will read fromNamedGroupingBracesBrackets
(note the upper-case 'N') and a warning is given to the logfile. I plan to support bothfineTuning:namedGroupingBracesBrackets
andfineTuning:NamedGroupingBracesBrackets
for V3.*, but if V4.0 is created, then onlynamedGroupingBracesBrackets
will be supported. I recommend users migrate tonamedGroupingBracesBrackets