From 5f17bfa386507c84cb59ea8e88caca62f0902881 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 29 Apr 2017 22:25:00 +0000 Subject: latexindent (29apr17) git-svn-id: svn://tug.org/texlive/trunk@44120 c570f23f-e606-0410-a88d-b1316a301751 --- .../doc/support/latexindent/appendices.tex | 32 +++++++++-------- .../doc/support/latexindent/latexindent.pdf | Bin 524530 -> 525320 bytes .../doc/support/latexindent/latexindent.tex | 2 +- .../doc/support/latexindent/sec-how-to-use.tex | 2 +- .../LatexIndent/AlignmentAtAmpersand.pm | 38 ++++++++++++++++++--- .../scripts/latexindent/LatexIndent/Document.pm | 2 ++ .../latexindent/LatexIndent/FileExtension.pm | 5 ++- .../scripts/latexindent/LatexIndent/LogFile.pm | 6 ++-- 8 files changed, 62 insertions(+), 25 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/support/latexindent/appendices.tex b/Master/texmf-dist/doc/support/latexindent/appendices.tex index cc77004e45b..bd011ec388b 100644 --- a/Master/texmf-dist/doc/support/latexindent/appendices.tex +++ b/Master/texmf-dist/doc/support/latexindent/appendices.tex @@ -6,20 +6,24 @@ need to install the missing modules. \begin{cmhlistings}[language=Perl]{\texttt{helloworld.pl}}{lst:helloworld} - #!/usr/bin/perl - - use strict; - use warnings; - use FindBin; - use YAML::Tiny; - use File::Copy; - use File::Basename; - use File::HomeDir; - use Getopt::Long; - use Data::Dumper; - - print "hello world"; - exit; +#!/usr/bin/perl + +use strict; +use warnings; +use utf8; +use PerlIO::encoding; +use Unicode::GCString; +use open ':std', ':encoding(UTF-8)'; +use FindBin; +use YAML::Tiny; +use File::Copy; +use File::Basename; +use File::HomeDir; +use Getopt::Long; +use Data::Dumper; + +print "hello world"; +exit; \end{cmhlistings} My default installation on Ubuntu 12.04 did \emph{not} come with all of these modules as standard, but Strawberry Perl for Windows \cite{strawberryperl} diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent.pdf b/Master/texmf-dist/doc/support/latexindent/latexindent.pdf index 7c912e4b0fa..03ca111bc3a 100644 Binary files a/Master/texmf-dist/doc/support/latexindent/latexindent.pdf and b/Master/texmf-dist/doc/support/latexindent/latexindent.pdf differ diff --git a/Master/texmf-dist/doc/support/latexindent/latexindent.tex b/Master/texmf-dist/doc/support/latexindent/latexindent.tex index b31a22b7141..4a1a4163254 100644 --- a/Master/texmf-dist/doc/support/latexindent/latexindent.tex +++ b/Master/texmf-dist/doc/support/latexindent/latexindent.tex @@ -407,7 +407,7 @@ 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.0 + \centering\ttfamily\bfseries latexindent.pl\\[1cm] Version 3.0.1 \end{tcolorbox} } \author{Chris Hughes \thanks{and contributors! See \vref{sec:contributors}. For diff --git a/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex b/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex index 8e76e5d8fbf..90b6d8222c9 100644 --- a/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex +++ b/Master/texmf-dist/doc/support/latexindent/sec-how-to-use.tex @@ -217,7 +217,7 @@ latexindent.pl myfile \documentclass{article} ... \end{cmhlistings} -%(*@@*) arara: indent: { modifylinebreaks: yes } + %(*@@*) arara: indent: { modifylinebreaks: yes } Hopefully the use of these rules is fairly self-explanatory, but for completeness \cref{tab:orbsandswitches} shows the relationship between \texttt{arara} directive arguments and the diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm index 3f86cffd10f..195909ac280 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/AlignmentAtAmpersand.pm @@ -16,12 +16,14 @@ package LatexIndent::AlignmentAtAmpersand; # For all communication, please visit: https://github.com/cmhughes/latexindent.pl use strict; use warnings; +use utf8; +use Unicode::GCString; +use Data::Dumper; +use Exporter qw/import/; 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 Data::Dumper; -use Exporter qw/import/; our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321 our @EXPORT_OK = qw/align_at_ampersand find_aligned_block/; our $alignmentBlockCounter; @@ -170,10 +172,13 @@ sub align_at_ampersand{ $column .= ($column =~ m/\\$/ ? " ": q()); # store the column size - $columnSizes[$columnCount] = length($column) if(length($column)>$columnSizes[$columnCount]); + # reference: http://www.perl.com/pub/2012/05/perlunicook-unicode-column-width-for-printing.html + my $gcs = Unicode::GCString->new($column); + my $columnWidth = $gcs->columns(); + $columnSizes[$columnCount] = $columnWidth if($columnWidth > $columnSizes[$columnCount]); # put the row back together, using " " if the column is empty - $strippedRow .= ($columnCount>0 ? "&" : q() ).(length($column)>0 ? $column: " "); + $strippedRow .= ($columnCount>0 ? "&" : q() ).($columnWidth > 0 ? $column: " "); # move on to the next column $columnCount++; @@ -217,8 +222,31 @@ sub align_at_ampersand{ # finally, reformat the body foreach(@formattedBody){ if(${$_}{format} and ${$_}{row} !~ m/^\h*$/){ + + my $columnCount=0; + my $tmpRow = q(); + foreach my $column (split(/(?new($column); + my $columnWidth = $gcs->columns(); + + # reset the padding + my $padding = q(); + if($columnWidth < $columnSizes[$columnCount]){ + $padding = " " x ($columnSizes[$columnCount] - $columnWidth); + } + $tmpRow .= $column.$padding." & "; + $columnCount++; + } + + # remove the final & + $tmpRow =~ s/\s&\s$/ /; + + # replace the row with the formatted row + ${$_}{row} = $tmpRow; + # format the row, and put the trailing \\ and trailing comments back into the row - ${$_}{row} = sprintf($fmtstring,split(/(?logger("$FindBin::Script version 3.0, a script to indent .tex files",'heading'); + $self->logger("$FindBin::Script version 3.0.1, a script to indent .tex files",'heading'); $self->logger("$FindBin::Script lives here: $FindBin::RealBin/"); # time the script is used @@ -50,7 +50,7 @@ sub processSwitches{ if(scalar(@ARGV) < 1 or $switches{showhelp}) { print <logger("Perl modules are being loaded from the following directories:",'heading'); foreach my $moduleName (@listOfModules) { (my $file = $moduleName) =~ s|::|/|g; -- cgit v1.2.3