summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm')
-rwxr-xr-xMaster/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm56
1 files changed, 31 insertions, 25 deletions
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm
index 2c74f47554e..401cbecbee2 100755
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm
@@ -28,35 +28,41 @@ use LatexIndent::Special qw/$specialBeginAndBracesBracketsBasicRegExp/;
use Data::Dumper;
use Exporter qw/import/;
our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321
-our @EXPORT_OK = qw/find_environments $environmentBasicRegExp/;
+our @EXPORT_OK = qw/find_environments $environmentBasicRegExp construct_environments_regexp/;
our $environmentCounter;
our $environmentBasicRegExp = qr/\\begin\{/;
+our $environmentRegExp;
# store the regular expresssion for matching and replacing the \begin{}...\end{} statements
-our $environmentRegExp = qr/
- (
- \\begin\{
- (
- [a-zA-Z@\*0-9_\\]+ # lowercase|uppercase letters, @, *, numbers
- ) # environment name captured into $2
- \} # \begin{<something>} statement
- \h* # horizontal space
- (\R*)? # possible line breaks (into $3)
- ) # begin statement captured into $1
- (
- (?: # cluster-only (), don't capture
- (?! # don't include \begin in the body
- (?:\\begin) # cluster-only (), don't capture
- ). # any character, but not \\begin
- )*? # non-greedy
- (\R*)? # possible line breaks (into $5)
- ) # environment body captured into $4
- (
- \\end\{\2\} # \end{<something>} statement
- ) # captured into $6
- (\h*)? # possibly followed by horizontal space
- (\R)? # possibly followed by a line break
- /sx;
+sub construct_environments_regexp{
+
+ # read from fine tuning
+ my $environmentNameRegExp = qr/${${$masterSettings{fineTuning}}{environments}}{name}/;
+ $environmentRegExp = qr/
+ (
+ \\begin\{
+ (
+ $environmentNameRegExp # lowercase|uppercase letters, @, *, numbers
+ ) # environment name captured into $2
+ \} # \begin{<something>} statement
+ \h* # horizontal space
+ (\R*)? # possible line breaks (into $3)
+ ) # begin statement captured into $1
+ (
+ (?: # cluster-only (), don't capture
+ (?! # don't include \begin in the body
+ (?:\\begin) # cluster-only (), don't capture
+ ). # any character, but not \\begin
+ )*? # non-greedy
+ (\R*)? # possible line breaks (into $5)
+ ) # environment body captured into $4
+ (
+ \\end\{\2\} # \end{<something>} statement
+ ) # captured into $6
+ (\h*)? # possibly followed by horizontal space
+ (\R)? # possibly followed by a line break
+ /sx;
+}
sub find_environments{
my $self = shift;