diff options
Diffstat (limited to 'support')
-rw-r--r-- | support/latexindent/LatexIndent/AlignmentAtAmpersand.pm | 29 | ||||
-rw-r--r-- | support/latexindent/LatexIndent/FileContents.pm | 22 | ||||
-rw-r--r-- | support/latexindent/LatexIndent/Verbatim.pm | 358 | ||||
-rw-r--r-- | support/latexindent/LatexIndent/Version.pm | 4 | ||||
-rw-r--r-- | support/latexindent/README | 2 | ||||
-rw-r--r-- | support/latexindent/defaultSettings.yaml | 4 | ||||
-rw-r--r-- | support/latexindent/documentation/latexindent.pdf | bin | 1001116 -> 1012198 bytes | |||
-rw-r--r-- | support/latexindent/documentation/latexindent.tex | 2 | ||||
-rw-r--r-- | support/latexindent/documentation/sec-default-user-local.tex | 73 | ||||
-rw-r--r-- | support/latexindent/documentation/sec-fine-tuning.tex | 81 | ||||
-rw-r--r-- | support/latexindent/documentation/sec-how-to-use.tex | 10 | ||||
-rw-r--r-- | support/latexindent/documentation/sec-the-line-switch.tex | 20 | ||||
-rw-r--r-- | support/latexindent/documentation/subsec-remove-para-line-breaks.tex | 2 | ||||
-rw-r--r-- | support/latexindent/documentation/subsec-text-wrap.tex | 4 | ||||
-rw-r--r-- | support/latexindent/documentation/title.tex | 4 | ||||
-rwxr-xr-x | support/latexindent/latexindent.pl | 2 |
16 files changed, 415 insertions, 202 deletions
diff --git a/support/latexindent/LatexIndent/AlignmentAtAmpersand.pm b/support/latexindent/LatexIndent/AlignmentAtAmpersand.pm index c015e08a87..22de133bf1 100644 --- a/support/latexindent/LatexIndent/AlignmentAtAmpersand.pm +++ b/support/latexindent/LatexIndent/AlignmentAtAmpersand.pm @@ -61,23 +61,22 @@ sub find_aligned_block{ (?!<\\) % \* - \h* # possible horizontal spaces + \h* # possible horizontal spaces \\begin\{ - $alignmentBlock # environment name captured into $2 - \} # %* \begin{alignmentBlock} statement + ($alignmentBlock) # environment name captured into $2 + \} # \begin{alignmentBlock} statement captured into $1 ) ( - .*? + .*? # non-greedy match (body) into $3 ) - \R - \h* + \R # a line break + \h* # possible horizontal spaces ( (?!<\\) - %\* # % - \h* # possible horizontal spaces - \\end\{$alignmentBlock\} # \end{alignmentBlock} - ) # %* \end{<something>} statement - #\R + %\* # % + \h* # possible horizontal spaces + \\end\{\2\} # \end{alignmentBlock} statement captured into $4 + ) /sx; while( ${$self}{body} =~ m/$alignmentRegExp/sx){ @@ -87,9 +86,9 @@ sub find_aligned_block{ / # create a new Environment object my $alignmentBlockObj = LatexIndent::AlignmentAtAmpersand->new( begin=>$1, - body=>$2, - end=>$3, - name=>$alignmentBlock, + body=>$3, + end=>$4, + name=>$2, modifyLineBreaksYamlName=>"environments", linebreaksAtEnd=>{ begin=>1, @@ -99,7 +98,7 @@ sub find_aligned_block{ ); # log file output - $logger->trace("*Alignment block found: %*\\begin\{$alignmentBlock\}") if $is_t_switch_active; + $logger->trace("*Alignment block found: %*\\begin\{${$alignmentBlock}{name}\}") if $is_t_switch_active; # the settings and storage of most objects has a lot in common $self->get_settings_and_store_new_object($alignmentBlockObj); diff --git a/support/latexindent/LatexIndent/FileContents.pm b/support/latexindent/LatexIndent/FileContents.pm index b18feae6bd..439e764b31 100644 --- a/support/latexindent/LatexIndent/FileContents.pm +++ b/support/latexindent/LatexIndent/FileContents.pm @@ -60,30 +60,30 @@ sub find_file_contents_environments_and_preamble{ my $fileContentsRegExp = qr/ ( \\begin\{ - $fileContentsEnv - \} + ($fileContentsEnv) # environment name captured into $2 + \} # begin statement captured into $1 ) ( - .*? + .*? # non-greedy match (body) into $3 ) ( - \\end\{$fileContentsEnv\} - \h* + \\end\{\2\} # end statement captured into $4 + \h* # possible horizontal spaces ) - (\R)? + (\R)? # possibly followed by a line break /sx; while( ${$self}{body} =~ m/$fileContentsRegExp/sx){ # create a new Environment object my $fileContentsBlock = LatexIndent::FileContents->new( begin=>$1, - body=>$2, - end=>$3, - name=>$fileContentsEnv, + body=>$3, + end=>$4, + name=>$2, linebreaksAtEnd=>{ begin=>0, body=>0, - end=>$4?1:0, + end=>$5?1:0, }, modifyLineBreaksYamlName=>"filecontents", ); @@ -112,7 +112,7 @@ sub find_file_contents_environments_and_preamble{ push(@fileContentsStorageArray,$fileContentsBlock); # log file output - $logger->trace("FILECONTENTS environment found: $fileContentsEnv")if $is_t_switch_active; + $logger->trace("FILECONTENTS environment found: ${$fileContentsEnv}{name}")if $is_t_switch_active; # remove the environment block, and replace with unique ID ${$self}{body} =~ s/$fileContentsRegExp/${$fileContentsBlock}{replacementText}/sx; diff --git a/support/latexindent/LatexIndent/Verbatim.pm b/support/latexindent/LatexIndent/Verbatim.pm index 3abe2e0d46..0bb41c5227 100644 --- a/support/latexindent/LatexIndent/Verbatim.pm +++ b/support/latexindent/LatexIndent/Verbatim.pm @@ -31,31 +31,46 @@ sub find_noindent_block{ my $self = shift; # noindent block - $logger->trace('*Searching for NOINDENTBLOCk (see noIndentBlock)') if $is_t_switch_active; + $logger->trace('*Searching for NOINDENTBLOCK (see noIndentBlock)') if $is_t_switch_active; $logger->trace(Dumper(\%{$mainSettings{noIndentBlock}})) if($is_tt_switch_active); while( my ($noIndentBlock,$yesno)= each %{$mainSettings{noIndentBlock}}){ # integrity check on the field for noIndentBlock if ( ref($yesno) eq "HASH" ){ - if (not defined ${$yesno}{begin}){ - $logger->trace(" *not* looking for $noIndentBlock as $noIndentBlock:begin not specified") if $is_t_switch_active; - next; - } elsif (not defined ${$yesno}{end}) { - $logger->trace(" *not* looking for $noIndentBlock as $noIndentBlock:end not specified") if $is_t_switch_active; - next; - } elsif (defined ${$yesno}{lookForThis} and !${$yesno}{lookForThis}){ - $logger->trace(" *not* looking for $noIndentBlock as lookForThis: 0") if $is_t_switch_active; - next; - } + if (defined ${$yesno}{lookForThis} and !${$yesno}{lookForThis}){ + $logger->trace(" *not* looking for $noIndentBlock as lookForThis: 0") if $is_t_switch_active; + next; + } + if (not defined ${$yesno}{name}) { + if (not defined ${$yesno}{begin}){ + $logger->trace(" *not* looking for $noIndentBlock as $noIndentBlock:begin not specified") if $is_t_switch_active; + next; + } elsif (not defined ${$yesno}{end}) { + $logger->trace(" *not* looking for $noIndentBlock as $noIndentBlock:end not specified") if $is_t_switch_active; + next; + } + } elsif (defined ${$yesno}{begin} or defined ${$yesno}{end}){ + $logger->trace(" *not* looking for $noIndentBlock as $noIndentBlock:name specified with begin and/or end") if $is_t_switch_active; + next; + } } elsif( ref($yesno) ne "HASH" and !$yesno ){ - $logger->trace(" *not* looking for $noIndentBlock as $noIndentBlock:$yesno") if $is_t_switch_active; - next; + $logger->trace(" *not* looking for $noIndentBlock as $noIndentBlock:$yesno") if $is_t_switch_active; + next; } # if we've made it this far, then we're good to go my $noIndentRegExp; + my $noIndentBlockObj; if (ref($yesno) eq "HASH"){ + # default value of begin and end + if (defined ${$yesno}{name} and not defined ${$yesno}{begin} and not defined ${$yesno}{end}){ + ${$yesno}{begin} = "\\\\begin\\{(${$yesno}{name})\\}"; + ${$yesno}{end} = "\\\\end\\{\\2\\}"; + $logger->trace("looking for regex based $noIndentBlock, name: ${$yesno}{name}") if $is_t_switch_active; + $logger->trace("begin not specified for $noIndentBlock, setting default ${$yesno}{begin}") if $is_t_switch_active; + $logger->trace("end not specified for $noIndentBlock, setting default ${$yesno}{end}") if $is_t_switch_active; + } # default value of body if (not defined ${$yesno}{body}){ $logger->trace("looking for regex based $noIndentBlock, begin: ${$yesno}{begin}, end: ${$yesno}{end}") if $is_t_switch_active; @@ -70,8 +85,8 @@ sub find_noindent_block{ $noIndentRegExp = qr/ (${$yesno}{begin}) - (${$yesno}{body}) - (${$yesno}{end}) + (${$yesno}{body}) + (${$yesno}{end}) /sx; } else { $logger->trace("looking for $noIndentBlock:$yesno noIndentBlock") if $is_t_switch_active; @@ -81,32 +96,44 @@ sub find_noindent_block{ ( (?!<\\) % - (?:\h|(?!<\\)%)* # possible horizontal spaces + (?:\h|(?!<\\)%)* # possible horizontal spaces \\begin\{ - $noIndentBlockSpec - \} # % \begin{noindentblock} statement - ) # begin captured into $1 + ($noIndentBlockSpec) # environment name captured into $2 + \} # % \begin{noindentblock} statement + ) # begin statement captured into $1 ( - .*? - ) # non-greedy match (body) into $2 + .*? # non-greedy match (body) into $3 + ) ( (?!<\\) - % # % - (?:\h|(?!<\\)%)* # possible horizontal spaces - \\end\{$noIndentBlockSpec\} # \end{noindentblock} - ) # % \end{<something>} statement into $3 + % # % + (?:\h|(?!<\\)%)* # possible horizontal spaces + \\end\{\2\} # % \end{noindentblock} statement + ) # end statement captured into $4 /sx; } while( ${$self}{body} =~ m/$noIndentRegExp/sx){ # create a new Verbatim object - my $noIndentBlockObj = LatexIndent::Verbatim->new( begin=>$1, + if (ref($yesno) eq "HASH" and not defined ${$yesno}{name}){ + # user defined begin and end statements + $noIndentBlockObj = LatexIndent::Verbatim->new( begin=>$1, body=>$2, end=>$3, name=>$noIndentBlock, type=>"noindentblock", modifyLineBreaksYamlName=>"verbatim", ); + } else { + # specified by name (entry:1 or entry: name: regex) + $noIndentBlockObj = LatexIndent::Verbatim->new( begin=>$1, + body=>$3, + end=>$4, + name=>$2, + type=>"noindentblock", + modifyLineBreaksYamlName=>"verbatim", + ); + } # give unique id $noIndentBlockObj->create_unique_id; @@ -115,7 +142,7 @@ sub find_noindent_block{ $verbatimStorage{${$noIndentBlockObj}{id}}=$noIndentBlockObj; # log file output - $logger->trace("NOINDENTBLOCK found: $noIndentBlock") if $is_t_switch_active; + $logger->trace("NOINDENTBLOCK found: ${$noIndentBlockObj}{name}") if $is_t_switch_active; # remove the environment block, and replace with unique ID ${$self}{body} =~ s/$noIndentRegExp/${$noIndentBlockObj}{id}/sx; @@ -136,67 +163,83 @@ sub find_verbatim_environments{ $logger->trace('*Searching for VERBATIM environments (see verbatimEnvironments)') if $is_t_switch_active; $logger->trace(Dumper(\%{$mainSettings{verbatimEnvironments}})) if($is_tt_switch_active); while( my ($verbEnv,$yesno)= each %{$mainSettings{verbatimEnvironments}}){ - if($yesno){ - $logger->trace("looking for $verbEnv:$yesno environments") if $is_t_switch_active; + my $verbEnvSpec; - (my $verbEnvSpec = $verbEnv) =~ s/\*/\\*/sg; - my $verbatimRegExp = qr/ - ( - \\begin\{ - $verbEnvSpec # environment name captured into $1 - \} # \begin{<something>} statement - ) - ( - .*? - ) # any character, but not \\begin - ( - \\end\{$verbEnvSpec\} # \end{<something>} statement - ) - (\h*)? # possibly followed by horizontal space - (\R)? # possibly followed by a line break - /sx; - - while( ${$self}{body} =~ m/$verbatimRegExp/sx){ + # integrity check on the field for noIndentBlock + if ( ref($yesno) eq "HASH" ){ + if (defined ${$yesno}{lookForThis} and !${$yesno}{lookForThis}){ + $logger->trace(" *not* looking for $verbEnv as lookForThis: 0") if $is_t_switch_active; + next; + } elsif (not defined ${$yesno}{name}){ + $logger->trace(" *not* looking for $verbEnv as $verbEnv:name not specified") if $is_t_switch_active; + next; + } else { + $logger->trace("looking for VERBATIM-environments $verbEnv, name: ${$yesno}{name}") if $is_t_switch_active; + $verbEnvSpec = ${$yesno}{name}; + } + } elsif( ref($yesno) ne "HASH" and $yesno ){ + $logger->trace("looking for $verbEnv:$yesno environments") if $is_t_switch_active; + ($verbEnvSpec = $verbEnv) =~ s/\*/\\*/sg; + } else { + $logger->trace(" *not* looking for $verbEnv as $verbEnv:$yesno") if $is_t_switch_active; + next; + } - # create a new Verbatim object - my $verbatimBlock = LatexIndent::Verbatim->new( begin=>$1, - body=>$2, - end=>$3, - name=>$verbEnv, - type=>"environment", - modifyLineBreaksYamlName=>"verbatim", - linebreaksAtEnd=>{ - end=>$5?1:0, - }, - horizontalTrailingSpace=>$4?$4:q(), - aliases=>{ - # begin statements - BeginStartsOnOwnLine=>"VerbatimBeginStartsOnOwnLine", - # after end statements - EndFinishesWithLineBreak=>"VerbatimEndFinishesWithLineBreak", - }, - ); + # if we've made it this far, then we're good to go + my $verbatimRegExp = qr/ + ( + \\begin\{ + ($verbEnvSpec) # environment name captured into $2 + \} # \begin{<something>} statement captured into $1 + ) + ( + .*? # non-greedy match (body) into $3 + ) # any character, but not \\begin + ( + \\end\{\2\} # \end{<something>} statement captured into $4 + ) + (\h*)? # possibly followed by horizontal space + (\R)? # possibly followed by a line break + /sx; + + while( ${$self}{body} =~ m/$verbatimRegExp/sx){ + + # create a new Verbatim object + my $verbatimBlock = LatexIndent::Verbatim->new( begin=>$1, + body=>$3, + end=>$4, + name=>$2, + type=>"environment", + modifyLineBreaksYamlName=>"verbatim", + linebreaksAtEnd=>{ + end=>$6?1:0, + }, + horizontalTrailingSpace=>$5?$5:q(), + aliases=>{ + # begin statements + BeginStartsOnOwnLine=>"VerbatimBeginStartsOnOwnLine", + # after end statements + EndFinishesWithLineBreak=>"VerbatimEndFinishesWithLineBreak", + }, + ); - # there are common tasks for each of the verbatim objects - $verbatimBlock->verbatim_common_tasks; - - # verbatim children go in special hash - $verbatimStorage{${$verbatimBlock}{id}}=$verbatimBlock; + # there are common tasks for each of the verbatim objects + $verbatimBlock->verbatim_common_tasks; + + # verbatim children go in special hash + $verbatimStorage{${$verbatimBlock}{id}}=$verbatimBlock; - # log file output - $logger->trace("*VERBATIM environment found: $verbEnv") if $is_t_switch_active; + # log file output + $logger->trace("*VERBATIM environment found: ${$verbatimBlock}{name}") if $is_t_switch_active; - # remove the environment block, and replace with unique ID - ${$self}{body} =~ s/$verbatimRegExp/${$verbatimBlock}{replacementText}/sx; + # remove the environment block, and replace with unique ID + ${$self}{body} =~ s/$verbatimRegExp/${$verbatimBlock}{replacementText}/sx; - $logger->trace("replaced with ID: ${$verbatimBlock}{id}") if $is_t_switch_active; - - # possible decoration in log file - $logger->trace(${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}; - } - } else { - $logger->trace("*not* looking for $verbEnv as $verbEnv:$yesno") if $is_t_switch_active; - } + $logger->trace("replaced with ID: ${$verbatimBlock}{id}") if $is_t_switch_active; + + # possible decoration in log file + $logger->trace(${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}; + } } return; } @@ -212,80 +255,97 @@ sub find_verbatim_commands{ $logger->trace('*Searching for VERBATIM commands (see verbatimCommands)') if $is_t_switch_active; $logger->trace(Dumper(\%{$mainSettings{verbatimCommands}})) if($is_tt_switch_active); while( my ($verbCommand,$yesno)= each %{$mainSettings{verbatimCommands}}){ - if($yesno){ - $logger->trace("looking for $verbCommand:$yesno Commands") if $is_t_switch_active; + my $verbCommandSpec; - my $verbatimRegExp = qr/ - ( - \\$verbCommand - \h* - ) # name of command into $1 - ( - \[ - (?: - (?! - (?:(?<!\\)\[) - ). - )*? # not including [, but \[ ok - (?<!\\) # not immediately pre-ceeded by \ - \] # [optional arguments] - \h* - )? # opt arg into $2 - ( - . - ) # delimiter into $3 - ( - .*? - ) # body into $4 - \3 - (\h*)? # possibly followed by horizontal space - (\R)? # possibly followed by a line break - /mx; - - while( ${$self}{body} =~ m/$verbatimRegExp/){ + # integrity check on the field for noIndentBlock + if ( ref($yesno) eq "HASH" ){ + if (defined ${$yesno}{lookForThis} and !${$yesno}{lookForThis}){ + $logger->trace(" *not* looking for $verbCommand as lookForThis: 0") if $is_t_switch_active; + next; + } elsif (not defined ${$yesno}{name}){ + $logger->trace(" *not* looking for $verbCommand as $verbCommand:name not specified") if $is_t_switch_active; + next; + } else { + $logger->trace("looking for regex based VERBATIM-commands $verbCommand, name: ${$yesno}{name}") if $is_t_switch_active; + $verbCommandSpec = ${$yesno}{name}; + } + } elsif( ref($yesno) ne "HASH" and $yesno ){ + $logger->trace("looking for $verbCommand:$yesno Commands") if $is_t_switch_active; + $verbCommandSpec = $verbCommand; + } else { + $logger->trace("*not* looking for $verbCommand as $verbCommand:$yesno") if $is_t_switch_active; + next; + } - # create a new Verbatim object - my $verbatimCommand = LatexIndent::Verbatim->new( begin=>$1.($2?$2:q()).$3, - body=>$4, - end=>$3, - name=>$verbCommand, - type=>"command", - modifyLineBreaksYamlName=>"verbatim", - linebreaksAtEnd=>{ - end=>$6?1:0, - }, - horizontalTrailingSpace=>$5?$5:q(), - aliases=>{ - # begin statements - BeginStartsOnOwnLine=>"VerbatimBeginStartsOnOwnLine", - # after end statements - EndFinishesWithLineBreak=>"VerbatimEndFinishesWithLineBreak", - }, - optArg=>$2?$2:q(), - ); - # there are common tasks for each of the verbatim objects - $verbatimCommand->verbatim_common_tasks; + # if we've made it this far, then we're good to go + my $verbatimRegExp = qr/ + ( + \\($verbCommandSpec) # name of command into $2 + \h* + ) + ( + \[ + (?: + (?! + (?:(?<!\\)\[) + ). + )*? # not including [, but \[ ok + (?<!\\) # not immediately pre-ceeded by \ + \] # [optional arguments] + \h* + )? # opt arg into $3 + ( + . + ) # delimiter into $4 + ( + .*? + ) # body into $5 + \4 + (\h*)? # possibly followed by horizontal space + (\R)? # possibly followed by a line break + /mx; + + while( ${$self}{body} =~ m/$verbatimRegExp/){ + + # create a new Verbatim object + my $verbatimCommand = LatexIndent::Verbatim->new( begin=>$1.($3?$3:q()).$4, + body=>$5, + end=>$4, + name=>$2, + type=>"command", + modifyLineBreaksYamlName=>"verbatim", + linebreaksAtEnd=>{ + end=>$7?1:0, + }, + horizontalTrailingSpace=>$6?$6:q(), + aliases=>{ + # begin statements + BeginStartsOnOwnLine=>"VerbatimBeginStartsOnOwnLine", + # after end statements + EndFinishesWithLineBreak=>"VerbatimEndFinishesWithLineBreak", + }, + optArg=>$3?$3:q(), + ); + # there are common tasks for each of the verbatim objects + $verbatimCommand->verbatim_common_tasks; - # output, if desired - $logger->trace(Dumper($verbatimCommand),'ttrace') if($is_tt_switch_active); + # output, if desired + $logger->trace(Dumper($verbatimCommand),'ttrace') if($is_tt_switch_active); - # verbatim children go in special hash - $verbatimStorage{${$verbatimCommand}{id}}=$verbatimCommand; + # verbatim children go in special hash + $verbatimStorage{${$verbatimCommand}{id}}=$verbatimCommand; - # log file output - $logger->trace("*VERBATIM command found: $verbCommand") if $is_t_switch_active; + # log file output + $logger->trace("*VERBATIM command found: ${$verbatimCommand}{name}") if $is_t_switch_active; - # remove the environment block, and replace with unique ID - ${$self}{body} =~ s/$verbatimRegExp/${$verbatimCommand}{replacementText}/sx; + # remove the environment block, and replace with unique ID + ${$self}{body} =~ s/$verbatimRegExp/${$verbatimCommand}{replacementText}/sx; - $logger->trace("replaced with ID: ${$verbatimCommand}{id}") if $is_t_switch_active; - - # possible decoration in log file - $logger->trace(${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}; - } - } else { - $logger->trace("*not* looking for $verbCommand as $verbCommand:$yesno") if $is_t_switch_active; - } + $logger->trace("replaced with ID: ${$verbatimCommand}{id}") if $is_t_switch_active; + + # possible decoration in log file + $logger->trace(${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$mainSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}; + } } return; diff --git a/support/latexindent/LatexIndent/Version.pm b/support/latexindent/LatexIndent/Version.pm index cd4878cbaa..d25b4f55ab 100644 --- a/support/latexindent/LatexIndent/Version.pm +++ b/support/latexindent/LatexIndent/Version.pm @@ -19,6 +19,6 @@ use warnings; use Exporter qw/import/; our @EXPORT_OK = qw/$versionNumber $versionDate/; -our $versionNumber = '3.12'; -our $versionDate = '2021-09-16'; +our $versionNumber = '3.13'; +our $versionDate = '2021-10-30'; 1 diff --git a/support/latexindent/README b/support/latexindent/README index 85200ba048..b1381a2165 100644 --- a/support/latexindent/README +++ b/support/latexindent/README @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - latexindent.pl, version 3.12, 2021-09-16 + latexindent.pl, version 3.13, 2021-10-30 PERL script to indent code within environments, and align delimited environments in .tex files. diff --git a/support/latexindent/defaultSettings.yaml b/support/latexindent/defaultSettings.yaml index fc4be94bc0..01a766633b 100644 --- a/support/latexindent/defaultSettings.yaml +++ b/support/latexindent/defaultSettings.yaml @@ -1,4 +1,4 @@ -# defaultSettings.yaml for latexindent.pl, version 3.12, 2021-09-16 +# defaultSettings.yaml for latexindent.pl, version 3.13, 2021-10-30 # a script that aims to # beautify .tex, .sty, .cls files # @@ -621,7 +621,7 @@ replacements: - this: 'latexindent.pl' that: 'pl.latexindent' - lookForThis: 1 + lookForThis: 0 when: before # fineTuning allows you to tweak the internal pattern matching that diff --git a/support/latexindent/documentation/latexindent.pdf b/support/latexindent/documentation/latexindent.pdf Binary files differindex 12ad2f551c..c3262e7f9e 100644 --- a/support/latexindent/documentation/latexindent.pdf +++ b/support/latexindent/documentation/latexindent.pdf diff --git a/support/latexindent/documentation/latexindent.tex b/support/latexindent/documentation/latexindent.tex index a97d778742..7607baa809 100644 --- a/support/latexindent/documentation/latexindent.tex +++ b/support/latexindent/documentation/latexindent.tex @@ -798,7 +798,6 @@ \renewcommand*{\thefootnote}{\arabic{footnote}} \input{title.tex} \tableofcontents -{\small\lstlistoflistings} % start sections on new page \newcommand{\sectionbreak}{\clearpage\thispagestyle{plain}} \input{sec-introduction} @@ -830,5 +829,6 @@ \input{sec-conclusions-know-limitations} \input{references} \input{appendices} + {\clearpage\small\lstlistoflistings} \printindex \end{document} diff --git a/support/latexindent/documentation/sec-default-user-local.tex b/support/latexindent/documentation/sec-default-user-local.tex index b649f54f9c..50e99e7dd9 100644 --- a/support/latexindent/documentation/sec-default-user-local.tex +++ b/support/latexindent/documentation/sec-default-user-local.tex @@ -137,6 +137,30 @@ copy myfile.bak4 to myfile.bak3 such as \texttt{lookForAlignDelims} or \texttt{noAdditionalIndent} then \texttt{latexindent.pl} will \emph{always} prioritize \texttt{verbatimEnvironments}. + You can, optionally, specify + \announce*{2021-10-30}{verbatim name feature} the + \texttt{verbatim} field using the \texttt{name} field which takes a regular expression as + its argument; thank you to \cite{XuehaiPan} for contributing this feature. + + For demonstration, then assuming that your file contains the environments + \texttt{latexcode}, \texttt{latexcode*}, \texttt{pythoncode} and \texttt{pythoncode*}, + then the listings given in \cref{lst:nameAsRegex1,lst:nameAsRegex2} are equivalent. + + \begin{cmhtcbraster}[raster column skip=.1\linewidth] + \cmhlistingsfromfile*{demonstrations/nameAsRegex1.yaml}[yaml-TCB]{\texttt{nameAsRegex1.yaml}}{lst:nameAsRegex1} + \cmhlistingsfromfile*{demonstrations/nameAsRegex2.yaml}[yaml-TCB]{\texttt{nameAsRegex2.yaml}}{lst:nameAsRegex2} + \end{cmhtcbraster} + + With reference to \cref{lst:nameAsRegex2}: + \begin{itemize} + \item the \texttt{name} field as specified here means \emph{any word followed by the word code, + optionally followed by *}; + \item we have used \texttt{nameAsRegex} to identify this field, but you can use any description + you like; + \item the \texttt{lookForThis} field is optional, and can take the values 0 (off) or 1 (on); by + default, it is assumed to be 1 (on). + \end{itemize} + \yamltitle{verbatimCommands}*{fields} A field that contains a list of commands that are verbatim commands, for example \lstinline|\lstinline|; any commands populated in this field are protected from line @@ -149,6 +173,30 @@ copy myfile.bak4 to myfile.bak3 body as anything up to the next occurrence of the character; this means that, for example, \lstinline|\verb!x+3!| is treated as a \texttt{verbatimCommands}. + You can, optionally, specify + \announce*{2021-10-30}{verbatimCommands name feature} the + \texttt{verbatimCommands} field using the \texttt{name} field which takes a regular + expression as its argument; thank you to \cite{XuehaiPan} for contributing this feature. + + For demonstration, then assuming that your file contains the commands + \texttt{verbinline}, \texttt{myinline} then the listings given in + \cref{lst:nameAsRegex3,lst:nameAsRegex4} are equivalent. + + \begin{cmhtcbraster}[raster column skip=.1\linewidth] + \cmhlistingsfromfile*{demonstrations/nameAsRegex3.yaml}[yaml-TCB]{\texttt{nameAsRegex3.yaml}}{lst:nameAsRegex3} + \cmhlistingsfromfile*{demonstrations/nameAsRegex4.yaml}[yaml-TCB]{\texttt{nameAsRegex4.yaml}}{lst:nameAsRegex4} + \end{cmhtcbraster} + + With reference to \cref{lst:nameAsRegex4}: + \begin{itemize} + \item the \texttt{name} field as specified here means \emph{any word followed by the word + inline}; + \item we have used \texttt{nameAsRegex} to identify this field, but you can use any description + you like; + \item the \texttt{lookForThis} field is optional, and can take the values 0 (off) or 1 (on); by + default, it is assumed to be 1 (on). + \end{itemize} + \yamltitle{noIndentBlock}*{fields} If you have a block of code that you don't want \texttt{latexindent.pl} to touch (even if \index{verbatim!noIndentBlock} it is \emph{not} a verbatim-like environment) then you can @@ -214,6 +262,31 @@ latexindent.pl -l noindent3.yaml noindent1 We will demonstrate this feature later in the documentation in \cref{lst:href3}. + You can, optionally, specify + \announce*{2021-10-30}{noIndentBlock name feature} the + \texttt{noIndentBlock} field using the \texttt{name} field which takes a regular + expression as its argument; thank you to \cite{XuehaiPan} for contributing this feature. + + For demonstration, then assuming that your file contains the environments + \texttt{testnoindent}, \texttt{testnoindent*} then the listings given in + \cref{lst:nameAsRegex5,lst:nameAsRegex6} are equivalent. + + \begin{widepage} + \begin{cmhtcbraster}[raster column skip=.1\linewidth] + \cmhlistingsfromfile*{demonstrations/nameAsRegex5.yaml}[yaml-TCB]{\texttt{nameAsRegex5.yaml}}{lst:nameAsRegex5} + \cmhlistingsfromfile*{demonstrations/nameAsRegex6.yaml}[yaml-TCB]{\texttt{nameAsRegex6.yaml}}{lst:nameAsRegex6} + \end{cmhtcbraster} + \end{widepage} + + With reference to \cref{lst:nameAsRegex6}: + \begin{itemize} + \item the \texttt{name} field as specified here means \emph{any word followed by the word + noindent, optionally followed by *}; + \item we have used \texttt{nameAsRegex} to identify this field, but you can use any description + you like; + \item the \texttt{lookForThis} field is optional, and can take the values 0 (off) or 1 (on); by + default, it is assumed to be 1 (on). + \end{itemize} \subsection{filecontents and preamble} \yamltitle{fileContentsEnvironments}*{field} diff --git a/support/latexindent/documentation/sec-fine-tuning.tex b/support/latexindent/documentation/sec-fine-tuning.tex index 669bff5737..47c186eabb 100644 --- a/support/latexindent/documentation/sec-fine-tuning.tex +++ b/support/latexindent/documentation/sec-fine-tuning.tex @@ -230,3 +230,84 @@ latexindent.pl -m finetuning4.tex -o=+-mod3 -l=href3 is an example of character class. \index{regular expressions!character class demonstration} \end{example} + + \begin{example} + We can use the \texttt{fineTuning} field to assist in the formatting of bibliography files. + \index{bibliography files} + \index{regular expressions!delimiterRegEx} + \index{regular expressions!capturing parenthesis} + \index{regular expressions!ampersand alignment} + \index{delimiters!delimiterRegEx} + + Starting with the file in \cref{lst:bib1} and running the command + \begin{commandshell} +latexindent.pl bib1.tex -o=+-mod1 + \end{commandshell} + gives the output in \cref{lst:bib1-mod1}. + + \begin{widepage} + \begin{cmhtcbraster}[raster column skip=.01\linewidth] + \cmhlistingsfromfile{demonstrations/bib1.bib}{\texttt{bib1.bib}}{lst:bib1} + \cmhlistingsfromfile{demonstrations/bib1-mod1.bib}{\texttt{bib1-mod1.bib}}{lst:bib1-mod1} + \end{cmhtcbraster} + \end{widepage} + + Let's assume that we would like to format the output so as to align the \texttt{=} symbols. + Using the settings in \cref{lst:bibsettings1} and running the command + \begin{commandshell} +latexindent.pl bib1.bib -l bibsettings1.yaml -o=+-mod2 + \end{commandshell} + gives the output in \cref{lst:bib1-mod2}. + + \begin{widepage} + \begin{cmhtcbraster}[raster column skip=.1\linewidth] + \cmhlistingsfromfile{demonstrations/bib1-mod2.bib}{\texttt{bib1.bib} using \cref{lst:bibsettings1}}{lst:bib1-mod2} + \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/bibsettings1.yaml}[yaml-TCB]{\texttt{bibsettings1.yaml}}{lst:bibsettings1} + \end{cmhtcbraster} + \end{widepage} + Some notes about \cref{lst:bibsettings1}: + \begin{itemize} + \item we have populated the \texttt{lookForAlignDelims} field with the \texttt{online} command, + and have used the \texttt{delimiterRegEx}, discussed in \vref{sec:delimiter-reg-ex}; + \item we have tweaked the \texttt{keyEqualsValuesBracesBrackets} code block so that it will + \emph{not} be found following a comma; this means that, in contrast to the default + behaviour, the lines such as \lstinline!date={2013-05-23},! will \emph{not} be treated as + key-equals-value braces; + \item the adjustment to \texttt{keyEqualsValuesBracesBrackets} necessitates the associated + change to the \texttt{UnNamedGroupingBracesBrackets} field so that they will be searched + for following \texttt{=} symbols. + \end{itemize} + \end{example} + + \begin{example} + We can build upon \cref{lst:bibsettings1} for slightly more complicated bibliography files. + + Starting with the file in \cref{lst:bib2} and running the command + \begin{commandshell} +latexindent.pl bib2.bib -l bibsettings1.yaml -o=+-mod1 + \end{commandshell} + gives the output in \cref{lst:bib2-mod1}. + + \begin{widepage} + \cmhlistingsfromfile{demonstrations/bib2.bib}{\texttt{bib2.bib}}{lst:bib2} + \cmhlistingsfromfile{demonstrations/bib2-mod1.bib}{\texttt{bib2-mod1.bib}}{lst:bib2-mod1} + \end{widepage} + + The output in \cref{lst:bib2-mod1} is not ideal, as the \texttt{=} symbol within the url + field has been incorrectly used as an alignment delimiter. + + We address this by tweaking the \texttt{delimiterRegEx} field in \cref{lst:bibsettings2}. + + \cmhlistingsfromfile[style=yaml-LST]*{demonstrations/bibsettings2.yaml}[yaml-TCB]{\texttt{bibsettings2.yaml}}{lst:bibsettings2} + + Upon running the command + \begin{commandshell} +latexindent.pl bib2.bib -l bibsettings1.yaml,bibsettings2.yaml -o=+-mod2 + \end{commandshell} + we receive the \emph{desired} output in \cref{lst:bib2-mod2}. + + \cmhlistingsfromfile{demonstrations/bib2-mod2.bib}{\texttt{bib2-mod2.bib}}{lst:bib2-mod2} + + With reference to \cref{lst:bibsettings2} we note that the \texttt{delimiterRegEx} has been adjusted so that \texttt{=} symbols are used as the delimiter, + but only when they are \emph{not preceeded} by either \texttt{v} or \texttt{spfreload}. + \end{example} diff --git a/support/latexindent/documentation/sec-how-to-use.tex b/support/latexindent/documentation/sec-how-to-use.tex index c297418928..2b9783565b 100644 --- a/support/latexindent/documentation/sec-how-to-use.tex +++ b/support/latexindent/documentation/sec-how-to-use.tex @@ -422,7 +422,7 @@ latexindent.pl -k myfile.tex latexindent.pl -check myfile.tex \end{commandshell} You can% - \announce*{2021-09-16}{-k,-check switch} instruct + \announce{2021-09-16}{-k,-check switch} instruct \texttt{latexindent.pl} to check if the text after indentation matches that given in the original file. @@ -448,9 +448,9 @@ latexindent.pl -check myfile.tex latexindent.pl -kv myfile.tex latexindent.pl -checkv myfile.tex \end{commandshell} - \announce*{2021-09-16}{-kv, -checkv: check verbose switch} The \texttt{check verbose} switch is - exactly the same as the \texttt{-k} switch, except that it is \emph{verbose}, and it will - output the (simple) diff to the terminal, as well as to \texttt{indent.log}. + \announce{2021-09-16}{-kv, -checkv: check verbose switch} The \texttt{check verbose} + switch is exactly the same as the \texttt{-k} switch, except that it is \emph{verbose}, + and it will output the (simple) diff to the terminal, as well as to \texttt{indent.log}. \flagbox{-n, --lines=MIN-MAX} \index{switches!-n, --lines definition and details} @@ -458,7 +458,7 @@ latexindent.pl -checkv myfile.tex latexindent.pl -n 5-8 myfile.tex latexindent.pl -lines 5-8 myfile.tex \end{commandshell} - \announce*{2021-09-16}{-n, -lines switch} The \texttt{lines} switch instructs + \announce{2021-09-16}{-n, -lines switch} The \texttt{lines} switch instructs \texttt{latexindent.pl} to operate only on specific line ranges within \texttt{myfile.tex}. diff --git a/support/latexindent/documentation/sec-the-line-switch.tex b/support/latexindent/documentation/sec-the-line-switch.tex index 0c06daec2d..bd28b70985 100644 --- a/support/latexindent/documentation/sec-the-line-switch.tex +++ b/support/latexindent/documentation/sec-the-line-switch.tex @@ -1,7 +1,7 @@ % arara: pdflatex: {shell: yes, files: [latexindent]} \section{The --lines switch}\label{sec:line-switch} \texttt{latexindent.pl} - \announce*{2021-09-16}{line switch demonstration} can + \announce{2021-09-16}{line switch demonstration} can operate on a \emph{selection} of lines of the file using the \texttt{--lines} or \texttt{-n} switch. @@ -27,7 +27,7 @@ latexindent.pl -n 3-7 myfile.tex We demonstrate this feature, and the available variations in what follows. We will use the file in \cref{lst:myfile}. - \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile.tex}[tex-TCB]{\texttt{myfile.tex}}{lst:myfile} + \cmhlistingsfromfile[style=lineNumbersTeX]*{demonstrations/myfile.tex}[tex-TCB]{\texttt{myfile.tex}}{lst:myfile} \begin{example} We demonstrate the basic usage using the command @@ -36,7 +36,7 @@ latexindent.pl --lines 3-7 myfile.tex -o=+-mod1 \end{commandshell} which instructs \texttt{latexindent.pl} to only operate on lines 3 to 7; the output is given in \cref{lst:myfile-mod1}. - \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile-mod1.tex}[tex-TCB]{\texttt{myfile-mod1.tex}}{lst:myfile-mod1} + \cmhlistingsfromfile[style=lineNumbersTeX]*{demonstrations/myfile-mod1.tex}[tex-TCB]{\texttt{myfile-mod1.tex}}{lst:myfile-mod1} The following two calls to \texttt{latexindent.pl} are equivalent \begin{commandshell} @@ -54,7 +54,7 @@ latexindent.pl --lines 5 myfile.tex -o=+-mod2 \end{commandshell} instructs \texttt{latexindent.pl} to only operate on line 5; the output is given in \cref{lst:myfile-mod2}. - \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile-mod2.tex}[tex-TCB]{\texttt{myfile-mod2.tex}}{lst:myfile-mod2} + \cmhlistingsfromfile[style=lineNumbersTeX]*{demonstrations/myfile-mod2.tex}[tex-TCB]{\texttt{myfile-mod2.tex}}{lst:myfile-mod2} The following two calls are equivalent: \begin{commandshell} @@ -88,7 +88,7 @@ latexindent.pl --lines 3-5,8-10 myfile.tex -o=+-mod3 \end{commandshell} which instructs \texttt{latexindent.pl} to operate upon lines 3 to 5 and lines 8 to 10; the output is given in \cref{lst:myfile-mod3}. - \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile-mod3.tex}[tex-TCB]{\texttt{myfile-mod3.tex}}{lst:myfile-mod3} + \cmhlistingsfromfile[style=lineNumbersTeX]*{demonstrations/myfile-mod3.tex}[tex-TCB]{\texttt{myfile-mod3.tex}}{lst:myfile-mod3} The following calls to \texttt{latexindent.pl} are all equivalent \begin{commandshell} @@ -108,7 +108,7 @@ latexindent.pl --lines 1-2,4-5,9-10,12 myfile.tex -o=+-mod4 \end{commandshell} has four line ranges: lines 1 to 2, lines 4 to 5, lines 9 to 10 and line 12. The output is given in \cref{lst:myfile-mod4}. - \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile-mod4.tex}[tex-TCB]{\texttt{myfile-mod4.tex}}{lst:myfile-mod4} + \cmhlistingsfromfile[style=lineNumbersTeX]*{demonstrations/myfile-mod4.tex}[tex-TCB]{\texttt{myfile-mod4.tex}}{lst:myfile-mod4} As previously, the ordering does not matter, and the following calls to \texttt{latexindent.pl} are all equivalent \begin{commandshell} @@ -137,7 +137,7 @@ latexindent.pl --lines 1-4,8-12 myfile.tex \end{commandshell} The output is given in \cref{lst:myfile-mod5}. - \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile-mod5.tex}[tex-TCB]{\texttt{myfile-mod5.tex}}{lst:myfile-mod5} + \cmhlistingsfromfile[style=lineNumbersTeX]*{demonstrations/myfile-mod5.tex}[tex-TCB]{\texttt{myfile-mod5.tex}}{lst:myfile-mod5} \end{example} @@ -153,7 +153,7 @@ latexindent.pl --lines 1-4,8,11-12 myfile.tex -o=+-mod6 \end{commandshell} The output is given in \cref{lst:myfile-mod6}. - \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile-mod6.tex}[tex-TCB]{\texttt{myfile-mod6.tex}}{lst:myfile-mod6} + \cmhlistingsfromfile[style=lineNumbersTeX]*{demonstrations/myfile-mod6.tex}[tex-TCB]{\texttt{myfile-mod6.tex}}{lst:myfile-mod6} \end{example} \begin{example} @@ -172,7 +172,7 @@ latexindent.pl --lines !y-3 myfile.tex For example, let's use with the file in \cref{lst:myfile1}. - \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile1.tex}[tex-TCB]{\texttt{myfile1.tex}}{lst:myfile1} + \cmhlistingsfromfile[style=lineNumbersTeX]*{demonstrations/myfile1.tex}[tex-TCB]{\texttt{myfile1.tex}}{lst:myfile1} We can demonstrate interaction with the \texttt{-m} switch (see \vref{sec:modifylinebreaks}); in particular, if we use \vref{lst:mlb2}, \vref{lst:env-mlb7} and \vref{lst:env-mlb8} and run @@ -183,5 +183,5 @@ latexindent.pl --lines 6 myfile1.tex -o=+-mod1 -m -l env-mlb2,env-mlb7,env-mlb8 \end{widepage} then we receive the output in \cref{lst:myfile1-mod1}. - \cmhlistingsfromfile*[style=lineNumbersTeX]*{demonstrations/myfile1-mod1.tex}[tex-TCB]{\texttt{myfile1-mod1.tex}}{lst:myfile1-mod1} + \cmhlistingsfromfile[style=lineNumbersTeX]*{demonstrations/myfile1-mod1.tex}[tex-TCB]{\texttt{myfile1-mod1.tex}}{lst:myfile1-mod1} \end{example} diff --git a/support/latexindent/documentation/subsec-remove-para-line-breaks.tex b/support/latexindent/documentation/subsec-remove-para-line-breaks.tex index 2b9de853b1..c95e8ff9b3 100644 --- a/support/latexindent/documentation/subsec-remove-para-line-breaks.tex +++ b/support/latexindent/documentation/subsec-remove-para-line-breaks.tex @@ -133,7 +133,7 @@ latexindent.pl -m shortlines-envs.tex -o shortlines-envs3.tex -l remove-para3.ya settings in \cref{lst:remove-para4-yaml}. Note: - \announce*{2021-09-16}*{removeParagraphLineBreaks: masterDocument now mainDocument} + \announce{2021-09-16}*{removeParagraphLineBreaks: masterDocument now mainDocument} \texttt{mainDocument} replaces \texttt{masterDocument} which was used in previous verions of \texttt{latexindent.pl}. The field \texttt{masterDocument} is still supported, but it is anticipated to be removed in a future version, so I recommend using diff --git a/support/latexindent/documentation/subsec-text-wrap.tex b/support/latexindent/documentation/subsec-text-wrap.tex index 781aeccf73..c07df8ff68 100644 --- a/support/latexindent/documentation/subsec-text-wrap.tex +++ b/support/latexindent/documentation/subsec-text-wrap.tex @@ -177,7 +177,7 @@ latexindent.pl -m textwrap-ts.tex -o=+-mod1 -l tabstop.yaml In particular, note the field \texttt{perCodeBlockBasis: 0}. \index{specialBeginEnd!textWrapOptions} - \cmhlistingsfromfile*[style=textWrapOptionsAll]*{../defaultSettings.yaml}[MLB-TCB,width=.95\linewidth,before=\centering]{\texttt{textWrapOptions}}{lst:textWrapOptionsAll} + \cmhlistingsfromfile[style=textWrapOptionsAll]*{../defaultSettings.yaml}[MLB-TCB,width=.95\linewidth,before=\centering]{\texttt{textWrapOptions}}{lst:textWrapOptionsAll} The code blocks detailed in \cref{lst:textWrapOptionsAll} are with direct reference to those detailed in \vref{tab:code-blocks}. @@ -190,7 +190,7 @@ latexindent.pl -m textwrap-ts.tex -o=+-mod1 -l tabstop.yaml \vref{subsec:removeparagraphlinebreaks:and:textwrap}). Note: - \announce*{2021-09-16}*{textWrapOptions: masterDocument now mainDocument} + \announce{2021-09-16}*{textWrapOptions: masterDocument now mainDocument} \texttt{mainDocument} replaces \texttt{masterDocument} which was used in previous verions of \texttt{latexindent.pl}. The field \texttt{masterDocument} is still supported, but it is anticipated to be removed in a future version, so I recommend using diff --git a/support/latexindent/documentation/title.tex b/support/latexindent/documentation/title.tex index 66f334fcb5..37460001dd 100644 --- a/support/latexindent/documentation/title.tex +++ b/support/latexindent/documentation/title.tex @@ -8,14 +8,14 @@ sharp corners, enhanced, overlay={\node[anchor=north east,outer sep=2pt] at ([xshift=3cm,yshift=4mm]frame.north east) {\includegraphics[width=3cm]{logo}}; }] - \centering\ttfamily\bfseries latexindent.pl\\[1cm] Version 3.12 + \centering\ttfamily\bfseries latexindent.pl\\[1cm] Version 3.13 \end{tcolorbox} } \author{Chris Hughes \thanks{and contributors! See \vref{sec:contributors}. For all communication, please visit \cite{latexindent-home}.}} -\date{2021-09-16} +\date{2021-10-30} \maketitle \begin{adjustwidth}{1cm}{1cm} \small diff --git a/support/latexindent/latexindent.pl b/support/latexindent/latexindent.pl index e27a8be07b..5ba1535efa 100755 --- a/support/latexindent/latexindent.pl +++ b/support/latexindent/latexindent.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# latexindent.pl, version 3.12, 2021-09-16 +# latexindent.pl, version 3.13, 2021-10-30 # # 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 |