summaryrefslogtreecommitdiff
path: root/support/latexindent/LatexIndent/HorizontalWhiteSpace.pm
diff options
context:
space:
mode:
Diffstat (limited to 'support/latexindent/LatexIndent/HorizontalWhiteSpace.pm')
-rw-r--r--support/latexindent/LatexIndent/HorizontalWhiteSpace.pm43
1 files changed, 26 insertions, 17 deletions
diff --git a/support/latexindent/LatexIndent/HorizontalWhiteSpace.pm b/support/latexindent/LatexIndent/HorizontalWhiteSpace.pm
index 695e18223f..3ca67433a8 100644
--- a/support/latexindent/LatexIndent/HorizontalWhiteSpace.pm
+++ b/support/latexindent/LatexIndent/HorizontalWhiteSpace.pm
@@ -1,4 +1,5 @@
package LatexIndent::HorizontalWhiteSpace;
+
# 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
# the Free Software Foundation, either version 3 of the License, or
@@ -22,16 +23,18 @@ use LatexIndent::LogFile qw/$logger/;
use Exporter qw/import/;
our @EXPORT_OK = qw/remove_trailing_whitespace remove_leading_space/;
-sub remove_trailing_whitespace{
- my $self = shift;
+sub remove_trailing_whitespace {
+ my $self = shift;
my %input = @_;
$logger->trace("*Horizontal space removal routine") if $is_t_switch_active;
# removeTrailingWhitespace can be either a hash or a scalar, but if
# it's a scalar, we need to fix it
- if(ref($mainSettings{removeTrailingWhitespace}) ne 'HASH'){
- $logger->trace("removeTrailingWhitespace specified as scalar, will update it to be a hash") if $is_t_switch_active;
+ if ( ref( $mainSettings{removeTrailingWhitespace} ) ne 'HASH' ) {
+ $logger->trace("removeTrailingWhitespace specified as scalar, will update it to be a hash")
+ if $is_t_switch_active;
+
# grab the value
my $removeTWS = $mainSettings{removeTrailingWhitespace};
@@ -39,20 +42,26 @@ sub remove_trailing_whitespace{
delete $mainSettings{removeTrailingWhitespace};
# redefine it as a hash
- ${$mainSettings{removeTrailingWhitespace}}{beforeProcessing} = $removeTWS;
- ${$mainSettings{removeTrailingWhitespace}}{afterProcessing} = $removeTWS;
+ ${ $mainSettings{removeTrailingWhitespace} }{beforeProcessing} = $removeTWS;
+ ${ $mainSettings{removeTrailingWhitespace} }{afterProcessing} = $removeTWS;
$logger->trace("removeTrailingWhitespace: beforeProcessing is now $removeTWS") if $is_t_switch_active;
- $logger->trace("removeTrailingWhitespace: afterProcessing is now $removeTWS") if $is_t_switch_active;
+ $logger->trace("removeTrailingWhitespace: afterProcessing is now $removeTWS") if $is_t_switch_active;
}
# this method can be called before the indendation, and after, depending upon the input
- if($input{when} eq "before"){
- return unless(${$mainSettings{removeTrailingWhitespace}}{beforeProcessing});
- $logger->trace("Removing trailing white space *before* the document is processed (see removeTrailingWhitespace: beforeProcessing)") if $is_t_switch_active;
- } elsif($input{when} eq "after"){
- return unless(${$mainSettings{removeTrailingWhitespace}}{afterProcessing});
- $logger->trace("Removing trailing white space *after* the document is processed (see removeTrailingWhitespace: afterProcessing)") if $is_t_switch_active;
- } else {
+ if ( $input{when} eq "before" ) {
+ return unless ( ${ $mainSettings{removeTrailingWhitespace} }{beforeProcessing} );
+ $logger->trace(
+ "Removing trailing white space *before* the document is processed (see removeTrailingWhitespace: beforeProcessing)"
+ ) if $is_t_switch_active;
+ }
+ elsif ( $input{when} eq "after" ) {
+ return unless ( ${ $mainSettings{removeTrailingWhitespace} }{afterProcessing} );
+ $logger->trace(
+ "Removing trailing white space *after* the document is processed (see removeTrailingWhitespace: afterProcessing)"
+ ) if $is_t_switch_active;
+ }
+ else {
return;
}
@@ -63,9 +72,10 @@ sub remove_trailing_whitespace{
}
-sub remove_leading_space{
+sub remove_leading_space {
my $self = shift;
- $logger->trace("*Removing leading space from ${$self}{name} (verbatim/noindentblock already accounted for)") if $is_t_switch_active;
+ $logger->trace("*Removing leading space from ${$self}{name} (verbatim/noindentblock already accounted for)")
+ if $is_t_switch_active;
${$self}{body} =~ s/
(
^ # beginning of the line
@@ -75,5 +85,4 @@ sub remove_leading_space{
return;
}
-
1;