summaryrefslogtreecommitdiff
path: root/support/latexindent/LatexIndent/ModifyLineBreaks.pm
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-12-06 03:01:31 +0000
committerNorbert Preining <norbert@preining.info>2022-12-06 03:01:31 +0000
commit9858bb195fd9c52c986155223a79c6fa1158e94c (patch)
tree664f41fbb2b86c7de0942ea98aba6d84b7745ef3 /support/latexindent/LatexIndent/ModifyLineBreaks.pm
parent673717f7c662dd135f63b61c1da1ecd59bcdbe90 (diff)
CTAN sync 202212060301
Diffstat (limited to 'support/latexindent/LatexIndent/ModifyLineBreaks.pm')
-rw-r--r--support/latexindent/LatexIndent/ModifyLineBreaks.pm59
1 files changed, 33 insertions, 26 deletions
diff --git a/support/latexindent/LatexIndent/ModifyLineBreaks.pm b/support/latexindent/LatexIndent/ModifyLineBreaks.pm
index 5d3a915f61..35cb04d35a 100644
--- a/support/latexindent/LatexIndent/ModifyLineBreaks.pm
+++ b/support/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;
}
}