From ac0972ebf6b5b92c6cc75542aa4add3bc6f8b15c Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 14 Jul 2023 21:03:52 +0000 Subject: latexindent (14jul23) git-svn-id: svn://tug.org/texlive/trunk@67628 c570f23f-e606-0410-a88d-b1316a301751 --- Master/bin/windows/latexindent.exe | Bin 8705316 -> 9938595 bytes Master/texmf-dist/doc/support/latexindent/README | 2 +- .../doc/support/latexindent/contributors.bib | 7 +++++++ .../latexindent/latexindent-yaml-schema.json | 2 +- .../doc/support/latexindent/latexindent.pdf | Bin 1250154 -> 1250829 bytes .../doc/support/latexindent/latexindent.tex | 6 +++++- .../scripts/latexindent/LatexIndent/Else.pm | 4 ++++ .../scripts/latexindent/LatexIndent/LogFile.pm | 18 +++++++++++++----- .../scripts/latexindent/LatexIndent/Version.pm | 4 ++-- .../scripts/latexindent/LatexIndent/Wrap.pm | 8 +++++++- .../scripts/latexindent/defaultSettings.yaml | 2 +- .../texmf-dist/scripts/latexindent/latexindent.pl | 2 +- 12 files changed, 42 insertions(+), 13 deletions(-) (limited to 'Master') diff --git a/Master/bin/windows/latexindent.exe b/Master/bin/windows/latexindent.exe index a10d2409708..b1818f983ae 100755 Binary files a/Master/bin/windows/latexindent.exe and b/Master/bin/windows/latexindent.exe differ diff --git a/Master/texmf-dist/doc/support/latexindent/README b/Master/texmf-dist/doc/support/latexindent/README index 5bda1fba77a..79fd8335cc4 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.22.1, 2023-07-02 + latexindent.pl, version 3.22.2, 2023-07-14 PERL script to indent code within environments, and align delimited environments in .tex files. diff --git a/Master/texmf-dist/doc/support/latexindent/contributors.bib b/Master/texmf-dist/doc/support/latexindent/contributors.bib index 50a10e91183..2da6ea818d5 100644 --- a/Master/texmf-dist/doc/support/latexindent/contributors.bib +++ b/Master/texmf-dist/doc/support/latexindent/contributors.bib @@ -217,3 +217,10 @@ urldate = {2023-05-25}, keywords = {contributor},} +@online{jessestricker, + title = "Create cruft directory if it does not exist", + url = "https://github.com/cmhughes/latexindent.pl/pull/453", + date = {2023-07-12}, + author = "Jesse Stricker", + urldate = {2023-07-12}, + keywords = {contributor},} 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 003c26d5454..356439255b1 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.22.1 2023-07-02", + "description": "latexindent.pl YAML schema helper, V3.22.2 2023-07-14", "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 b8e3cab83b9..7498187ea1d 100644 Binary files a/Master/texmf-dist/doc/support/latexindent/latexindent.pdf and b/Master/texmf-dist/doc/support/latexindent/latexindent.pdf differ diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent.tex b/Master/texmf-dist/doc/support/latexindent/latexindent.tex index b74e1eee32d..309dc502a34 100644 --- a/Master/texmf-dist/doc/support/latexindent/latexindent.tex +++ b/Master/texmf-dist/doc/support/latexindent/latexindent.tex @@ -1559,6 +1559,9 @@ latexindent.pl -c=/path/to/directory/ myfile.tex than the current working directory, then you can send these `cruft' files to another directory. Note the use of a trailing forward slash. % this switch was made as a result of http://tex.stackexchange.com/questions/142652/output-latexindent-auxiliary-files-to-a-different-directory + If the cruft directory does not exist, \texttt{latexindent.pl} will attempt to create + it. + \flagbox{-g, --logfile=} \index{switches!-g, --logfile definition and details} @@ -1781,7 +1784,7 @@ latexindent.pl myfile.tex 3 & \faClose & failure, myfile.tex not found \\ 4 & \faClose & failure, myfile.tex exists but cannot be read \\ 5 & \faClose & failure, \texttt{-w} active, and back-up file cannot be written \\ - 6 & \faClose & failure, \texttt{-c} active, and cruft directory does not exist \\ + 6 & \faClose & failure, \texttt{-c} active, and cruft directory could not be created \\ \bottomrule \end{tabular} \end{table} @@ -8359,6 +8362,7 @@ use Text::Tabs; # | use FindBin; # | use File::Copy; # | use File::Basename; # | +use File::Path; # | use File::HomeDir; # <--- typically requires install via cpanm use YAML::Tiny; # <--- typically requires install via cpanm diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Else.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Else.pm index 62a14a677bf..e78aa6b8b54 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Else.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Else.pm @@ -142,4 +142,8 @@ sub create_unique_id { return; } +sub modify_line_breaks_end { + return; +} + 1; diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm index 5847ca42f42..4e9064c937a 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/LogFile.pm @@ -19,6 +19,7 @@ use strict; use warnings; use FindBin; use File::Basename; # to get the filename and directory path +use File::Path qw(make_path); use Exporter qw/import/; use LatexIndent::Switches qw/%switches/; use LatexIndent::Version qw/$versionNumber $versionDate/; @@ -129,12 +130,18 @@ ENDQUOTE # cruft directory ${$self}{cruftDirectory} = $switches{cruftDirectory} || ( dirname ${$self}{fileName} ); - # if cruft directory does not exist + my $cruftDirectoryCreation = 0; + + # if cruft directory does not exist, create it if ( !( -d ${$self}{cruftDirectory} ) ) { - $logger->fatal( "*Could not find directory " . decode( "utf-8", ${$self}{cruftDirectory} ) ); - $logger->fatal("Exiting, no indentation done."); - $self->output_logfile(); - exit(6); + eval { make_path( ${$self}{cruftDirectory} ) }; + if ($@) { + $logger->fatal( "*Could not create cruft directory " . decode( "utf-8", ${$self}{cruftDirectory} ) ); + $logger->fatal("Exiting, no indentation done."); + $self->output_logfile(); + exit(6); + } + $cruftDirectoryCreation = 1; } my $logfileName = ( $switches{cruftDirectory} ? ${$self}{cruftDirectory} . "/" : '' ) @@ -247,6 +254,7 @@ ENDQUOTE $logger->info("*Directory for backup files and $logfileName:"); $logger->info( $switches{cruftDirectory} ? decode( "utf-8", ${$self}{cruftDirectory} ) : ${$self}{cruftDirectory} ); + $logger->info("cruft directory creation: ${$self}{cruftDirectory}") if $cruftDirectoryCreation; # output location of modules if ( $FindBin::Script eq 'latexindent.pl' or ( $FindBin::Script eq 'latexindent.exe' and $switches{trace} ) ) { diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm index ae69bb7928d..eb1bfbe1431 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.22.1'; -our $versionDate = '2023-07-02'; +our $versionNumber = '3.22.2'; +our $versionDate = '2023-07-14'; 1 diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm index c600d28e188..6b545c7e28d 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Wrap.pm @@ -41,6 +41,8 @@ sub text_wrap { my $blocksFollow = q(); my $blocksFollowHash = \%{ ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{blocksFollow} }; + my $headingsRegEx = q(); + foreach my $blocksFollowEachPart ( sort keys %{$blocksFollowHash} ) { last if ${$self}{modifyLineBreaksYamlName} eq 'sentence'; @@ -90,6 +92,9 @@ sub text_wrap { # $headingName = qr/\\$headingName\h*(?:\[[^]]*?\])?\h*\{[^}]*?\}\h*(?:\\label\{[^}]*?\})?/m; + # stored for possible use with 'after' + $headingsRegEx = $headingName . ( $headingsRegEx eq '' ? q() : "|$headingsRegEx" ); + # put starred headings at the front of the regexp if ( $headingName =~ m/\*/ ) { $blocksFollowEachPart @@ -332,8 +337,9 @@ sub text_wrap { else { my $thingToMeasure = ( split( /\R/, $textWrapBlockStorage[ $textWrapBlockCount - 1 ] ) )[-1]; $thingToMeasure =~ s/$tokens{blanklines}//; - $thingToMeasure =~ s/$tokens{verbatim}//; + $thingToMeasure =~ s/$tokens{verbatim}\d+$tokens{endOfToken}//; $thingToMeasure =~ s/$trailingCommentRegExp//; + $thingToMeasure =~ s/$headingsRegEx//; $subsequentSpace = ( $textWrapBlockCount == 0 diff --git a/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml b/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml index e626458b63f..de0c1335ca5 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.22.1, 2023-07-02 +# latexindent.pl, version 3.22.2, 2023-07-14 # # 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 a4cf71ab954..61ee1131b4d 100755 --- a/Master/texmf-dist/scripts/latexindent/latexindent.pl +++ b/Master/texmf-dist/scripts/latexindent/latexindent.pl @@ -1,6 +1,6 @@ #!/usr/bin/env perl # -# latexindent.pl, version 3.22.1, 2023-07-02 +# latexindent.pl, version 3.22.2, 2023-07-14 # # 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 -- cgit v1.2.3