texlive[67174] trunk: latexindent (20may23)

commits+karl at tug.org commits+karl at tug.org
Sat May 20 22:19:20 CEST 2023


Revision: 67174
          http://tug.org/svn/texlive?view=revision&revision=67174
Author:   karl
Date:     2023-05-20 22:19:20 +0200 (Sat, 20 May 2023)
Log Message:
-----------
latexindent (20may23)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/latexindent/latexindent.pl
    trunk/Master/bin/windows/latexindent.exe
    trunk/Master/texmf-dist/doc/support/latexindent/README
    trunk/Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json
    trunk/Master/texmf-dist/doc/support/latexindent/latexindent.pdf
    trunk/Master/texmf-dist/doc/support/latexindent/latexindent.tex
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm
    trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm
    trunk/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml
    trunk/Master/texmf-dist/scripts/latexindent/latexindent.pl

Modified: trunk/Build/source/texk/texlive/linked_scripts/latexindent/latexindent.pl
===================================================================
(Binary files differ)

Modified: trunk/Master/bin/windows/latexindent.exe
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/latexindent/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/README	2023-05-20 20:19:04 UTC (rev 67173)
+++ trunk/Master/texmf-dist/doc/support/latexindent/README	2023-05-20 20:19:20 UTC (rev 67174)
@@ -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.

Modified: trunk/Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json	2023-05-20 20:19:04 UTC (rev 67173)
+++ trunk/Master/texmf-dist/doc/support/latexindent/latexindent-yaml-schema.json	2023-05-20 20:19:20 UTC (rev 67174)
@@ -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": {

Modified: trunk/Master/texmf-dist/doc/support/latexindent/latexindent.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/latexindent/latexindent.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexindent/latexindent.tex	2023-05-20 20:19:04 UTC (rev 67173)
+++ trunk/Master/texmf-dist/doc/support/latexindent/latexindent.tex	2023-05-20 20:19:20 UTC (rev 67174)
@@ -4315,7 +4315,7 @@
   \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 @@
   \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 @@
   \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 @@
  \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

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm	2023-05-20 20:19:04 UTC (rev 67173)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Document.pm	2023-05-20 20:19:20 UTC (rev 67174)
@@ -187,12 +187,12 @@
         $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;

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm	2023-05-20 20:19:04 UTC (rev 67173)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm	2023-05-20 20:19:20 UTC (rev 67174)
@@ -26,7 +26,7 @@
 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 @@
             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 @@
             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,6 +1139,14 @@
         {
             $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" ) {
@@ -1121,6 +1153,14 @@
             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' ) {

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm	2023-05-20 20:19:04 UTC (rev 67173)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm	2023-05-20 20:19:20 UTC (rev 67174)
@@ -20,6 +20,6 @@
 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

Modified: trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm	2023-05-20 20:19:04 UTC (rev 67173)
+++ trunk/Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm	2023-05-20 20:19:20 UTC (rev 67174)
@@ -21,7 +21,7 @@
 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 @@
 
     # 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 @@
 #
 # 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 @@
                     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 @@
                         $subsequentSpace = (
                             $textWrapBlockCount == 0
                             ? q()
-                            : " " x length($thingToMeasure)
+                            : " " x &get_column_width($thingToMeasure)
                         );
 
                         # possible tab adjustments
@@ -337,8 +338,45 @@
                         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,9 +508,38 @@
             }
 
             # 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
             # onto the lines of the text wrap block

Modified: trunk/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml
===================================================================
--- trunk/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml	2023-05-20 20:19:04 UTC (rev 67173)
+++ trunk/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml	2023-05-20 20:19:20 UTC (rev 67174)
@@ -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
 # 

Modified: trunk/Master/texmf-dist/scripts/latexindent/latexindent.pl
===================================================================
(Binary files differ)



More information about the tex-live-commits mailing list.