summaryrefslogtreecommitdiff
path: root/support/latexindent/LatexIndent/Special.pm
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-06-20 03:01:22 +0000
committerNorbert Preining <norbert@preining.info>2021-06-20 03:01:22 +0000
commit0b024adf546cd484554e4de5bd1a9919a4fdd03d (patch)
treef688c8afa79d522868966c9c91e09088f28b5248 /support/latexindent/LatexIndent/Special.pm
parentdaa6873fe1d06863ffc2980970295b39071f02ba (diff)
CTAN sync 202106200301
Diffstat (limited to 'support/latexindent/LatexIndent/Special.pm')
-rw-r--r--support/latexindent/LatexIndent/Special.pm78
1 files changed, 45 insertions, 33 deletions
diff --git a/support/latexindent/LatexIndent/Special.pm b/support/latexindent/LatexIndent/Special.pm
index 8898697d0f..4e1a8020b3 100644
--- a/support/latexindent/LatexIndent/Special.pm
+++ b/support/latexindent/LatexIndent/Special.pm
@@ -36,9 +36,17 @@ our $specialBeginBasicRegExp;
sub construct_special_begin{
my $self = shift;
+ $logger->trace("*Constructing specialBeginEnd regex (see specialBeginEnd)") if $is_t_switch_active;
+
# put together a list of the begin terms in special
while( my ($specialName,$BeginEnd)= each %{$masterSettings{specialBeginEnd}}){
if(ref($BeginEnd) eq "HASH"){
+ if (not defined ${$BeginEnd}{lookForThis}){
+ ${$BeginEnd}{lookForThis} = 1;
+ ${${$masterSettings{specialBeginEnd}}{$specialName}}{lookForThis} = 1;
+ $logger->trace("setting lookForThis:1 for $specialName (lookForThis not specified)") if $is_t_switch_active;
+ }
+
# only append the regexps if lookForThis is 1
$specialBegins .= ($specialBegins eq ""?q():"|").${$BeginEnd}{begin} if(${$BeginEnd}{lookForThis}=~m/\d/s and ${$BeginEnd}{lookForThis} == 1);
}
@@ -48,45 +56,49 @@ sub construct_special_begin{
while( my ($specialName,$BeginEnd)= each %{$masterSettings{specialBeginEnd}}){
# only append the regexps if lookForThis is 1
- if( (ref($BeginEnd) eq "HASH") and ${$BeginEnd}{lookForThis}=~m/\d/s and ${$BeginEnd}{lookForThis} == 1){
+ if( ref($BeginEnd) eq "HASH" ){
+ if ( ${$BeginEnd}{lookForThis}=~m/\d/s and ${$BeginEnd}{lookForThis} == 0 ){
+ $logger->trace("The specialBeginEnd regexps won't include anything from $specialName (lookForThis: 0)") if $is_t_switch_active ;
+ next;
+ }
+ } else {
+ next;
+ }
- # the overall regexp
- $specialAllMatchesRegExp .= ($specialAllMatchesRegExp eq ""?q():"|")
- .qr/
+ # the overall regexp
+ $specialAllMatchesRegExp .= ($specialAllMatchesRegExp eq ""?q():"|")
+ .qr/
+ ${$BeginEnd}{begin}
+ (?: # cluster-only (), don't capture
+ (?!
+ (?:$specialBegins) # cluster-only (), don't capture
+ ). # any character, but not anything in $specialBegins
+ )*?
+ ${$BeginEnd}{end}
+ /sx;
+
+ # store the individual special regexp
+ $individualSpecialRegExps{$specialName} = qr/
+ (
${$BeginEnd}{begin}
+ \h*
+ (\R*)?
+ )
+ (
(?: # cluster-only (), don't capture
(?!
(?:$specialBegins) # cluster-only (), don't capture
). # any character, but not anything in $specialBegins
)*?
- ${$BeginEnd}{end}
- /sx;
-
- # store the individual special regexp
- $individualSpecialRegExps{$specialName} = qr/
- (
- ${$BeginEnd}{begin}
- \h*
- (\R*)?
- )
- (
- (?: # cluster-only (), don't capture
- (?!
- (?:$specialBegins) # cluster-only (), don't capture
- ). # any character, but not anything in $specialBegins
- )*?
- (\R*)?
- )
- (
- ${$BeginEnd}{end}
- )
- (\h*)
- (\R)?
- /sx
-
- } else {
- $logger->trace("*The special regexps won't include anything from $specialName (see lookForThis)") if $is_t_switch_active ;
- }
+ (\R*)?
+ )
+ (
+ ${$BeginEnd}{end}
+ )
+ (\h*)
+ (\R)?
+ /sx
+
}
# move $$ to the beginning
@@ -176,7 +188,7 @@ sub find_special{
${@{${$self}{children}}[-1]}{replacementText}.($8?$8:q()).($9?$9:q());
/xseg;
- $self->wrap_up_tasks;
+ $self->wrap_up_tasks;
}
}
}