From 75d8dfa80524727ddb7d8ae217ed6463efba84cf Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 22 Mar 2020 03:00:48 +0000 Subject: CTAN sync 202003220300 --- .../LatexIndent/AlignmentAtAmpersand.pm | 1401 +++++++++++++++----- support/latexindent/LatexIndent/Document.pm | 2 +- support/latexindent/LatexIndent/GetYamlSettings.pm | 4 + support/latexindent/LatexIndent/LogFile.pm | 8 +- support/latexindent/LatexIndent/Sentence.pm | 11 +- support/latexindent/LatexIndent/Version.pm | 4 +- support/latexindent/README | 2 +- support/latexindent/defaultSettings.yaml | 8 +- support/latexindent/documentation/latexindent.pdf | Bin 858722 -> 873258 bytes support/latexindent/documentation/latexindent.tex | 54 +- .../sec-conclusions-know-limitations.tex | 2 +- .../documentation/sec-default-user-local.tex | 327 ++++- .../latexindent/documentation/sec-fine-tuning.tex | 74 +- .../latexindent/documentation/sec-how-to-use.tex | 17 +- .../latexindent/documentation/sec-introduction.tex | 8 +- .../latexindent/documentation/sec-replacements.tex | 79 +- .../latexindent/documentation/sec-the-m-switch.tex | 189 +-- .../subsubsec-no-add-remaining-code-blocks.tex | 6 +- support/latexindent/documentation/title.tex | 2 +- support/latexindent/latexindent.pl | 2 +- 20 files changed, 1643 insertions(+), 557 deletions(-) (limited to 'support') diff --git a/support/latexindent/LatexIndent/AlignmentAtAmpersand.pm b/support/latexindent/LatexIndent/AlignmentAtAmpersand.pm index 8b8e387d09..95f2389e80 100644 --- a/support/latexindent/LatexIndent/AlignmentAtAmpersand.pm +++ b/support/latexindent/LatexIndent/AlignmentAtAmpersand.pm @@ -20,15 +20,20 @@ use utf8; use Unicode::GCString; use Data::Dumper; use Exporter qw/import/; -use List::Util qw(max); +use List::Util qw/max min sum/; use LatexIndent::TrailingComments qw/$trailingCommentRegExp/; use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active/; use LatexIndent::GetYamlSettings qw/%masterSettings/; use LatexIndent::Tokens qw/%tokens/; use LatexIndent::LogFile qw/$logger/; our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321 -our @EXPORT_OK = qw/align_at_ampersand find_aligned_block double_back_slash_else/; +our @EXPORT_OK = qw/align_at_ampersand find_aligned_block double_back_slash_else main_formatting individual_padding multicolumn_padding multicolumn_pre_check multicolumn_post_check dont_measure/; our $alignmentBlockCounter; +our @cellStorage; # two-dimensional storage array containing the cell information +our @formattedBody; # array for the new body +our @minMultiColSpan; +our @maxColumnWidth; +our @maxDelimiterWidth; sub find_aligned_block{ my $self = shift; @@ -127,27 +132,60 @@ sub align_at_ampersand{ my $self = shift; return if(${$self}{bodyLineBreaks}==0); - # calculate the maximum number of ampersands in a row in the body my $maximumNumberOfAmpersands = 0; - foreach(split("\n",${$self}{body})){ - my $numberOfAmpersands = () = $_ =~ /(?$maximumNumberOfAmpersands); - } - # create an array of zeros - my @maximumColumnWidth = (0) x ($maximumNumberOfAmpersands+1); - my @maximumColumnWidthMC = (0) x ($maximumNumberOfAmpersands+1); + # clear the global arrays + @formattedBody = (); + @cellStorage = (); + @minMultiColSpan = (); + @maxColumnWidth = (); + @maxDelimiterWidth = (); + + # maximum column widths + my @maximumColumnWidths; - # array for the new body - my @formattedBody; + my $rowCounter = -1; + my $columnCounter = -1; - # now loop back through the body, and store the maximum column size + $logger->trace("*dontMeasure routine, row mode") if(${$self}{dontMeasure} and $is_t_switch_active); + + # initial loop for column storage and measuring + # initial loop for column storage and measuring + # initial loop for column storage and measuring foreach(split("\n",${$self}{body})){ + $rowCounter++; + + # default is to measure this row, but it can be switched off by the dont_measure routine + ${$self}{measureRow} = 1; + + # call the dont_measure routine + $self->dont_measure(mode=>"row",row=>$_) if ${$self}{dontMeasure}; + # remove \\ and anything following it - my $endPiece; + my $endPiece = q(); if($_ =~ m/(\\\\.*)/){ - $_ =~ s/(\\\\.*)//; - $endPiece = $1; + if(${$self}{alignFinalDoubleBackSlash} ){ + # for example, if we want: + # + # Name & \shortstack{Hi \\ Lo} \\