summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-05-20 20:19:20 +0000
committerKarl Berry <karl@freefriends.org>2023-05-20 20:19:20 +0000
commit966f5266f47369fceb572fa736ea9a975c86d8bd (patch)
treeaccd6c93996e158d896d2d6b733f3322231e3e13
parent06cccdee5db849d30c6de6e7981c6015b7772342 (diff)
latexindent (20may23)
git-svn-id: svn://tug.org/texlive/trunk@67174 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xBuild/source/texk/texlive/linked_scripts/latexindent/latexindent.pl2
-rwxr-xr-xMaster/bin/windows/latexindent.exebin8704281 -> 8705088 bytes
-rw-r--r--Master/texmf-dist/doc/support/latexindent/README2
-rw-r--r--Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json2
-rw-r--r--Master/texmf-dist/doc/support/latexindent/latexindent.pdfbin1246412 -> 1246969 bytes
-rw-r--r--Master/texmf-dist/doc/support/latexindent/latexindent.tex13
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm2
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm42
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm4
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm79
-rwxr-xr-xMaster/texmf-dist/scripts/latexindent/defaultSettings.yaml2
-rwxr-xr-xMaster/texmf-dist/scripts/latexindent/latexindent.pl2
12 files changed, 131 insertions, 19 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/latexindent/latexindent.pl b/Build/source/texk/texlive/linked_scripts/latexindent/latexindent.pl
index e9f37442d24..4b8e2b75278 100755
--- a/Build/source/texk/texlive/linked_scripts/latexindent/latexindent.pl
+++ b/Build/source/texk/texlive/linked_scripts/latexindent/latexindent.pl
@@ -1,5 +1,5 @@
#!/usr/bin/env perl
-# latexindent.pl, version 3.21, 2023-05-01
+# latexindent.pl, version 3.21.1, 2023-05-20
#
# 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
diff --git a/Master/bin/windows/latexindent.exe b/Master/bin/windows/latexindent.exe
index d97c6c114ba..5c6280ff7f4 100755
--- a/Master/bin/windows/latexindent.exe
+++ b/Master/bin/windows/latexindent.exe
Binary files differ
diff --git a/Master/texmf-dist/doc/support/latexindent/README b/Master/texmf-dist/doc/support/latexindent/README
index c799fc2b290..88398cdba95 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.21, 2023-05-01
+ latexindent.pl, version 3.21.1, 2023-05-20
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 b29664e2c05..4084168a8be 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.21 2023-05-01",
+ "description": "latexindent.pl YAML schema helper, V3.21.1 2023-05-20",
"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 dfdeea52ccf..a853ce27c94 100644
--- a/Master/texmf-dist/doc/support/latexindent/latexindent.pdf
+++ b/Master/texmf-dist/doc/support/latexindent/latexindent.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent.tex b/Master/texmf-dist/doc/support/latexindent/latexindent.tex
index a85bdfafaef..618b49cad16 100644
--- a/Master/texmf-dist/doc/support/latexindent/latexindent.tex
+++ b/Master/texmf-dist/doc/support/latexindent/latexindent.tex
@@ -4315,7 +4315,7 @@ latexindent.pl headings2.tex -l headings4.yaml
\end{example}
\paragraph{namedGroupingBracesBrackets} This type of code block is mostly motivated by
- tikz-based code; we define this code block as follows:
+ tikz-based code; we define this code block as follows:
\begin{itemize}
\item it must immediately follow either \emph{horizontal space} OR \emph{one or more
line breaks} OR \lstinline!{! OR \lstinline![! OR \lstinline!$! OR \lstinline!)!
@@ -4351,8 +4351,9 @@ latexindent.pl headings2.tex -l headings4.yaml
\end{itemize}
\end{example}
- \paragraph{UnNamedGroupingBracesBrackets} occur in a variety of situations; specifically,
- we define this type of code block as satisfying the following criteria:
+ \paragraph{UnNamedGroupingBracesBrackets} occur in a variety of situations;
+ specifically, we define this type of code block as satisfying the following
+ criteria:
\begin{itemize}
\item it must immediately follow either \lstinline!{! OR \lstinline![! OR
\lstinline!,! OR \lstinline!&! OR \lstinline!)! OR \lstinline!(! OR
@@ -4391,7 +4392,7 @@ latexindent.pl headings2.tex -l headings4.yaml
\texttt{always-un-named}.
\paragraph{filecontents} code blocks behave just as \texttt{environments}, except that
- neither arguments nor items are sought.
+ neither arguments nor items are sought.
\subsubsection{Summary}
\index{indentation!summary}
@@ -8260,6 +8261,10 @@ latexindent.pl bib2.bib -l bibsettings1.yaml,bibsettings2.yaml -o=+-mod2
\begin{description}
\item[multicolumn alignment] when working with code blocks in which multicolumn
commands overlap, the algorithm can fail; see \vref{lst:tabular2-mod2}.
+ \item[textWrap after] when operating with \texttt{indentRules} (see
+ \vref{sec:noadd-indent-rules}) may not always cooperate with one another; if you
+ have a specific example that does not work, please report it to
+ \cite{latexindent-home}.
\item[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}); I hope
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm
index 16a01bf2092..59188a7234a 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm
@@ -187,12 +187,12 @@ sub operate_on_file {
$self->remove_leading_space;
$self->process_body_of_text;
${$self}{body} =~ s/\r\n/\n/sg if $mainSettings{dos2unixlinebreaks};
- $self->remove_trailing_whitespace( when => "after" );
$self->condense_blank_lines
if ( $is_m_switch_active and ${ $mainSettings{modifyLineBreaks} }{condenseMultipleBlankLinesInto} );
$self->unprotect_blank_lines
if ( $is_m_switch_active and ${ $mainSettings{modifyLineBreaks} }{preserveBlankLines} );
$self->un_dodge_double_backslash;
+ $self->remove_trailing_whitespace( when => "after" );
$self->make_replacements( when => "after" ) if $is_rv_switch_active;
$self->put_verbatim_back_in( match => "everything-except-commands" );
$self->put_trailing_comments_back_in;
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
index c46d0c5164d..6b97e617375 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
@@ -26,7 +26,7 @@ use Cwd;
use Exporter qw/import/;
use LatexIndent::LogFile qw/$logger/;
our @EXPORT_OK
- = qw/yaml_read_settings yaml_modify_line_breaks_settings yaml_get_indentation_settings_for_this_object yaml_poly_switch_get_every_or_custom_value yaml_get_indentation_information yaml_get_object_attribute_for_indentation_settings yaml_alignment_at_ampersand_settings %mainSettings/;
+ = qw/yaml_read_settings yaml_modify_line_breaks_settings yaml_get_indentation_settings_for_this_object yaml_poly_switch_get_every_or_custom_value yaml_get_indentation_information yaml_get_object_attribute_for_indentation_settings yaml_alignment_at_ampersand_settings %mainSettings %previouslyFoundSettings/;
# Read in defaultSettings.YAML file
our $defaultSettings;
@@ -818,6 +818,14 @@ sub yaml_get_indentation_settings_for_this_object {
columns => ${$self}{columns},
);
+ # text wrap 'after' information
+ if ( $is_m_switch_active
+ and ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after'
+ and defined ${$self}{indentRule} )
+ {
+ ${ ${previouslyFoundSettings}{textWrapAfter} }{$name} = $indentation;
+ }
+
# don't forget alignment settings!
foreach (@alignAtAmpersandInformation) {
${ ${previouslyFoundSettings}{$storageName} }{ ${$_}{name} } = ${$self}{ ${$_}{name} }
@@ -1091,11 +1099,27 @@ sub yaml_get_indentation_information {
if ( defined $indentationInformation ) {
if ( $indentationAbout eq "noAdditionalIndent" and $indentationInformation == 1 ) {
$logger->trace("Found! Using '' (see $indentationAbout)") if $is_t_switch_active;
+
+ # text wrapping 'after' requires knowledge of indent rules
+ #
+ if ( $is_m_switch_active
+ and ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after' )
+ {
+ ${$self}{indentRule} = $indentationInformation;
+ }
return q();
}
elsif ( $indentationAbout eq "indentRules" and $indentationInformation =~ m/^\h*$/ ) {
$logger->trace("Found! Using '$indentationInformation' (see $indentationAbout)")
if $is_t_switch_active;
+
+ # text wrapping 'after' requires knowledge of indent rules
+ #
+ if ( $is_m_switch_active
+ and ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after' )
+ {
+ ${$self}{indentRule} = $indentationInformation;
+ }
return $indentationInformation;
}
}
@@ -1115,12 +1139,28 @@ sub yaml_get_indentation_information {
{
$logger->trace("$globalInformation specified for $YamlName (see $globalInformation)")
if $is_t_switch_active;
+
+ # text wrapping 'after' requires knowledge of indent rules
+ #
+ if ( $is_m_switch_active
+ and ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after' )
+ {
+ ${$self}{indentRule} = $indentationInformation;
+ }
return q();
}
elsif ( $globalInformation eq "indentRulesGlobal" ) {
if ( ${ $mainSettings{$globalInformation} }{$YamlName} =~ m/^\h*$/ ) {
$logger->trace("$globalInformation specified for $YamlName (see $globalInformation)")
if $is_t_switch_active;
+
+ # text wrapping 'after' requires knowledge of indent rules
+ #
+ if ( $is_m_switch_active
+ and ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after' )
+ {
+ ${$self}{indentRule} = $indentationInformation;
+ }
return ${ $mainSettings{$globalInformation} }{$YamlName};
}
elsif ( ${ $mainSettings{$globalInformation} }{$YamlName} ne '0' ) {
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm
index c20ea7afb19..59ed17e3e02 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm
@@ -20,6 +20,6 @@ use warnings;
use Exporter qw/import/;
our @EXPORT_OK = qw/$versionNumber $versionDate/;
-our $versionNumber = '3.21';
-our $versionDate = '2023-05-01';
+our $versionNumber = '3.21.1';
+our $versionDate = '2023-05-20';
1
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm
index 9185459dae7..dc99170452f 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm
@@ -21,7 +21,7 @@ use Text::Wrap;
use LatexIndent::Tokens qw/%tokens/;
use LatexIndent::AlignmentAtAmpersand qw/get_column_width/;
use LatexIndent::TrailingComments qw/$trailingCommentRegExp @trailingComments/;
-use LatexIndent::GetYamlSettings qw/%mainSettings/;
+use LatexIndent::GetYamlSettings qw/%mainSettings %previouslyFoundSettings/;
use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_m_switch_active/;
use LatexIndent::LogFile qw/$logger/;
use LatexIndent::Verbatim qw/%verbatimStorage/;
@@ -207,7 +207,7 @@ sub text_wrap {
# store the text wrap blocks
my @textWrapBlockStorage = split( /($blocksFollow)/, ${$self}{body} );
- @textWrapBlockStorage = split( /(\s*$blocksFollow)/, ${$self}{body} )
+ @textWrapBlockStorage = split( /(\s*$blocksFollow+)/, ${$self}{body} )
if ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after';
# sentences need special treatment
@@ -273,6 +273,7 @@ sub text_wrap {
#
# see also: test-cases/text-wrap/issue-359*.tex
#
+ my $firstLineColumns = 0;
if ( ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after' ) {
# reset columns
@@ -288,7 +289,7 @@ sub text_wrap {
my $thingToMeasure = ( split( /\R/, ${$self}{follows} ) )[-1];
$subsequentSpace
- = ( ${$self}{follows} ? " " x length($thingToMeasure) : q() );
+ = ( ${$self}{follows} ? " " x &get_column_width($thingToMeasure) : q() );
# possible tab adjustments
$thingToMeasure = q() if ( not defined $thingToMeasure );
@@ -329,7 +330,7 @@ sub text_wrap {
$subsequentSpace = (
$textWrapBlockCount == 0
? q()
- : " " x length($thingToMeasure)
+ : " " x &get_column_width($thingToMeasure)
);
# possible tab adjustments
@@ -337,8 +338,45 @@ sub text_wrap {
for ( my $i = 1; $i <= $numberOfTABS; $i++ ) {
$subsequentSpace =~ s/ / /;
}
+
+ # check for custom indentRules see
+ #
+ # test-cases/text-wrap/issue-444.tex and friends
+ #
+ # https://github.com/cmhughes/latexindent.pl/issues/444
+ #
+ # WARNING: this routine isn't perfect, it's *VERY DIFFICULT*
+ # to figure out what a code block is without actually
+ # finding the code block
+ #
+ # **known issue** with textWrap: after and indentRules
+ #
+ # the below will likely need to be built upon
+ #
+ my $name = $thingToMeasure;
+ $name =~ s/\\begin//sg;
+ $name =~ s/[^a-zA-Z\@0-9]//sg;
+
+ # check that $name is within indentRules
+ if ( $textWrapBlockCount > 0
+ and $name !~ m/^\h*$/
+ and defined $previouslyFoundSettings{textWrapAfter}
+ and defined ${ $previouslyFoundSettings{textWrapAfter} }{$name}
+ and ${ $previouslyFoundSettings{textWrapAfter} }{$name} =~ m/^\h*$/ )
+ {
+
+ $firstLineColumns = $columns - length($subsequentSpace);
+
+ $thingToMeasure =~ s/^\h*//;
+ for ( my $i = 0; $i < &get_column_width($thingToMeasure); $i++ ) {
+ $subsequentSpace =~ s/ //;
+ }
+ $subsequentSpace .= ${ $previouslyFoundSettings{textWrapAfter} }{$name};
+ }
+
}
}
+
$Text::Wrap::columns = $columns - length($subsequentSpace);
# possible tab adjustments
@@ -470,8 +508,37 @@ sub text_wrap {
}
# perform the text wrap routine
- $textWrapBlockStorageValue = wrap( '', '', $textWrapBlockStorageValue )
- if ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{columns} > 0;
+ if ( $firstLineColumns > 0 ) {
+
+ # when 'after' is active, and indentation rules specified, they need attention
+ #
+ # noAdditionalIndent *per-name* basis
+ # indentRules *per-name* basis
+ # noAdditionalIndentGlobal
+ # indentRulesGlobal
+ #
+ # see
+ #
+ # test-cases/text-wrap/issue-444.tex
+ #
+ my $secondLineOnwardsColumns = $Text::Wrap::columns;
+
+ # wrap the *first* line
+ $Text::Wrap::columns = $firstLineColumns;
+ $textWrapBlockStorageValue = wrap( '', '', $textWrapBlockStorageValue );
+ my @tmpBlock = split( /\R/, $textWrapBlockStorageValue );
+ my $firstLine = shift(@tmpBlock);
+
+ # wrap the *subsequent* lines
+ my $secondLineOnwards = join( " ", @tmpBlock );
+ $Text::Wrap::columns = $secondLineOnwardsColumns;
+ $secondLineOnwards = wrap( '', '', $secondLineOnwards );
+ $textWrapBlockStorageValue = $firstLine . "\n" . $secondLineOnwards;
+ }
+ else {
+ $textWrapBlockStorageValue = wrap( '', '', $textWrapBlockStorageValue )
+ if ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{columns} > 0;
+ }
# if text wrap has happened *AFTER* indentation,
# then we need to add the leading indentation
diff --git a/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml b/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml
index 698ef09c118..a3582b934b2 100755
--- a/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml
+++ b/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml
@@ -1,5 +1,5 @@
#
-# latexindent.pl, version 3.21, 2023-05-01
+# latexindent.pl, version 3.21.1, 2023-05-20
#
# defaultSettings.yaml, the default settings for latexindent.pl
#
diff --git a/Master/texmf-dist/scripts/latexindent/latexindent.pl b/Master/texmf-dist/scripts/latexindent/latexindent.pl
index e9f37442d24..4b8e2b75278 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.21, 2023-05-01
+# latexindent.pl, version 3.21.1, 2023-05-20
#
# 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