diff options
author | Karl Berry <karl@freefriends.org> | 2019-07-13 21:40:12 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-07-13 21:40:12 +0000 |
commit | 757d85974d6b7911f766ae371404144ec3bdce34 (patch) | |
tree | 795c61e735cf8826289bb477020f3e50ec5aa914 /Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm | |
parent | 8e8c05aa6d6db2c28633a8924de4a0b941b52030 (diff) |
latexindent (13jul19)
git-svn-id: svn://tug.org/texlive/trunk@51635 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm')
-rwxr-xr-x | Master/texmf-dist/scripts/latexindent/LatexIndent/Environment.pm | 56 |
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; |