diff options
Diffstat (limited to 'Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm')
-rw-r--r-- | Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm index 98926a97594..adea6481abc 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Tokens.pm @@ -1,4 +1,5 @@ package LatexIndent::Tokens; + # 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,54 +23,57 @@ use LatexIndent::LogFile qw/$logger/; our @EXPORT_OK = qw/token_check %tokens/; # each of the tokens begins the same way -- this is exploited during the hidden Children routine -my $beginningToken = "LTXIN-TK-"; +my $beginningToken = "LTXIN-TK-"; my $ifelsefiSpecial = "!-!"; # the %tokens hash is passed around many modules our %tokens = ( - # user-facing naming convention - environments=>$beginningToken."ENVIRONMENT", - commands=>$beginningToken."COMMAND", - optionalArguments=>$beginningToken."OPTIONAL-ARGUMENT", - mandatoryArguments=>$beginningToken."MANDATORY-ARGUMENT", - ifElseFi=>$ifelsefiSpecial.$beginningToken."IFELSEFI", - else=>$beginningToken."ELSE", - items=>$beginningToken."ITEMS", - keyEqualsValuesBracesBrackets=>$beginningToken."KEY-VALUE-BRACES", - namedGroupingBracesBrackets=>$beginningToken."GROUPING-BRACES", - UnNamedGroupingBracesBrackets=>$beginningToken."UN-NAMED-GROUPING-BRACES", - specialBeginEnd=>$beginningToken."SPECIAL", - afterHeading=>$beginningToken."HEADING", - filecontents=>$beginningToken."FILECONTENTS", - # internal-facing naming convention - trailingComment=>"latexindenttrailingcomment", - ifelsefiSpecial=>$ifelsefiSpecial, - blanklines=>$beginningToken."blank-line", - arguments=>$beginningToken."ARGUMENTS", - roundBracket=>$beginningToken."ROUND-BRACKET", - verbatim=>$beginningToken."VERBATIM", - verbatimInline=>$beginningToken."VERBATIM-inline", - preamble=>$beginningToken."preamble", - beginOfToken=>$beginningToken, - doubleBackSlash=>$beginningToken."DOUBLEBACKSLASH", - alignmentBlock=>$beginningToken."ALIGNMENTBLOCK", - paragraph=>$beginningToken."PARA", - sentence=>$beginningToken."SENTENCE", - endOfToken=>"-END", - ); -sub token_check{ + # user-facing naming convention + environments => $beginningToken . "ENVIRONMENT", + commands => $beginningToken . "COMMAND", + optionalArguments => $beginningToken . "OPTIONAL-ARGUMENT", + mandatoryArguments => $beginningToken . "MANDATORY-ARGUMENT", + ifElseFi => $ifelsefiSpecial . $beginningToken . "IFELSEFI", + else => $beginningToken . "ELSE", + items => $beginningToken . "ITEMS", + keyEqualsValuesBracesBrackets => $beginningToken . "KEY-VALUE-BRACES", + namedGroupingBracesBrackets => $beginningToken . "GROUPING-BRACES", + UnNamedGroupingBracesBrackets => $beginningToken . "UN-NAMED-GROUPING-BRACES", + specialBeginEnd => $beginningToken . "SPECIAL", + afterHeading => $beginningToken . "HEADING", + filecontents => $beginningToken . "FILECONTENTS", + + # internal-facing naming convention + trailingComment => "latexindenttrailingcomment", + ifelsefiSpecial => $ifelsefiSpecial, + blanklines => $beginningToken . "blank-line", + arguments => $beginningToken . "ARGUMENTS", + roundBracket => $beginningToken . "ROUND-BRACKET", + verbatim => $beginningToken . "VERBATIM", + verbatimInline => $beginningToken . "VERBATIM-inline", + preamble => $beginningToken . "preamble", + beginOfToken => $beginningToken, + doubleBackSlash => $beginningToken . "DOUBLEBACKSLASH", + alignmentBlock => $beginningToken . "ALIGNMENTBLOCK", + paragraph => $beginningToken . "PARA", + sentence => $beginningToken . "SENTENCE", + endOfToken => "-END", +); + +sub token_check { my $self = shift; $logger->trace("*Token check") if $is_t_switch_active; + # we use tokens for trailing comments, environments, commands, etc, so check that they're not in the body - foreach( keys %tokens){ - while(${$self}{body} =~ m/$tokens{$_}/si){ - $logger->trace("Found $tokens{$_} within body, updating replacement token to $tokens{$_}-LIN") if($is_t_switch_active); + foreach ( keys %tokens ) { + while ( ${$self}{body} =~ m/$tokens{$_}/si ) { + $logger->trace("Found $tokens{$_} within body, updating replacement token to $tokens{$_}-LIN") + if ($is_t_switch_active); $tokens{$_} .= "-LIN"; } } } - 1; |