From 5f9cfbb3fbea3864e278a8cd717c283064040308 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 5 Dec 2022 21:30:10 +0000 Subject: latexindent (5dec22) git-svn-id: svn://tug.org/texlive/trunk@65208 c570f23f-e606-0410-a88d-b1316a301751 --- .../latexindent/LatexIndent/ModifyLineBreaks.pm | 59 ++++++++++++---------- .../scripts/latexindent/LatexIndent/Version.pm | 4 +- .../scripts/latexindent/defaultSettings.yaml | 2 +- .../texmf-dist/scripts/latexindent/latexindent.pl | 2 +- 4 files changed, 37 insertions(+), 30 deletions(-) (limited to 'Master/texmf-dist/scripts') diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm index 5d3a915f618..35cb04d35ac 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/ModifyLineBreaks.pm @@ -317,36 +317,43 @@ sub verbatim_modify_line_breaks { my $BeginStringLogFile = ${$child}{aliases}{BeginStartsOnOwnLine}; $logger->trace("*$BeginStringLogFile is ${$child}{BeginStartsOnOwnLine} for ${$child}{name}") if $is_t_switch_active; - if ( ${$child}{BeginStartsOnOwnLine} == -1 ) { - # VerbatimStartsOnOwnLine = -1 - if ( ${$self}{body} =~ m/^\h*${$child}{id}/m ) { - $logger->trace("${$child}{name} begins on its own line, removing leading line break") - if $is_t_switch_active; - ${$self}{body} =~ s/(\R|\h)*${$child}{id}/${$child}{id}/s; - } - } - elsif ( ${$child}{BeginStartsOnOwnLine} >= 1 and ${$self}{body} !~ m/^\h*${$child}{id}/m ) { + my @polySwitchValues + = ( ${$child}{BeginStartsOnOwnLine} == 4 ) ? ( -1, 3 ) : ( ${$child}{BeginStartsOnOwnLine} ); - # VerbatimStartsOnOwnLine = 1, 2 or 3 - my $trailingCharacterToken = q(); - if ( ${$child}{BeginStartsOnOwnLine} == 1 ) { - $logger->trace("Adding a linebreak at the beginning of ${$child}{begin} (see $BeginStringLogFile)") - if $is_t_switch_active; - } - elsif ( ${$child}{BeginStartsOnOwnLine} == 2 ) { - $logger->trace( - "Adding a % at the end of the line that ${$child}{begin} is on, then a linebreak ($BeginStringLogFile == 2)" - ) if $is_t_switch_active; - $trailingCharacterToken = "%" . $self->add_comment_symbol; + foreach (@polySwitchValues) { + if ( $_ == -1 ) { + + # VerbatimStartsOnOwnLine = -1 + if ( ${$self}{body} =~ m/^\h*${$child}{id}/m ) { + $logger->trace("${$child}{name} begins on its own line, removing leading line break") + if $is_t_switch_active; + ${$self}{body} =~ s/(\R|\h)*${$child}{id}/${$child}{id}/s; + } } - elsif ( ${$child}{BeginStartsOnOwnLine} == 3 ) { - $logger->trace( - "Adding a blank line at the end of the line that ${$child}{begin} is on, then a linebreak ($BeginStringLogFile == 3)" - ) if $is_t_switch_active; - $trailingCharacterToken = "\n"; + elsif ( $_ >= 1 and ${$self}{body} !~ m/^\h*${$child}{id}/m ) { + + # VerbatimStartsOnOwnLine = 1, 2 or 3 + my $trailingCharacterToken = q(); + if ( $_ == 1 ) { + $logger->trace( + "Adding a linebreak at the beginning of ${$child}{begin} (see $BeginStringLogFile)") + if $is_t_switch_active; + } + elsif ( $_ == 2 ) { + $logger->trace( + "Adding a % at the end of the line that ${$child}{begin} is on, then a linebreak ($BeginStringLogFile == 2)" + ) if $is_t_switch_active; + $trailingCharacterToken = "%" . $self->add_comment_symbol; + } + elsif ( $_ == 3 ) { + $logger->trace( + "Adding a blank line at the end of the line that ${$child}{begin} is on, then a linebreak ($BeginStringLogFile == 3)" + ) if $is_t_switch_active; + $trailingCharacterToken = "\n"; + } + ${$self}{body} =~ s/\h*${$child}{id}/$trailingCharacterToken\n${$child}{id}/s; } - ${$self}{body} =~ s/\h*${$child}{id}/$trailingCharacterToken\n${$child}{id}/s; } } diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Version.pm index 04aaf11759d..9773c55fcdb 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.19'; -our $versionDate = '2022-10-30'; +our $versionNumber = '3.19.1'; +our $versionDate = '2022-12-04'; 1 diff --git a/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml b/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml index 91f6fb9a70c..c61de167a91 100755 --- a/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml +++ b/Master/texmf-dist/scripts/latexindent/defaultSettings.yaml @@ -1,4 +1,4 @@ -# defaultSettings.yaml for latexindent.pl, version 3.19, 2022-10-30 +# defaultSettings.yaml for latexindent.pl, version 3.19.1, 2022-12-04 # a script that aims to # beautify .tex, .sty, .cls files # diff --git a/Master/texmf-dist/scripts/latexindent/latexindent.pl b/Master/texmf-dist/scripts/latexindent/latexindent.pl index 838b5ba3281..c9fc83e1d3b 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.19, 2022-10-30 +# latexindent.pl, version 3.19.1, 2022-12-04 # # 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