diff options
Diffstat (limited to 'support')
19 files changed, 525 insertions, 202 deletions
diff --git a/support/latexindent/LatexIndent/AlignmentAtAmpersand.pm b/support/latexindent/LatexIndent/AlignmentAtAmpersand.pm index 45307a90b6..479fb14a46 100644 --- a/support/latexindent/LatexIndent/AlignmentAtAmpersand.pm +++ b/support/latexindent/LatexIndent/AlignmentAtAmpersand.pm @@ -26,8 +26,10 @@ 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/; +use LatexIndent::HiddenChildren qw/%familyTree/; +use LatexIndent::Verbatim qw/%verbatimStorage/; our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321 -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 @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 hidden_child_cell_row_width hidden_child_row_width /; our $alignmentBlockCounter; our @cellStorage; # two-dimensional storage array containing the cell information our @formattedBody; # array for the new body @@ -132,6 +134,9 @@ sub align_at_ampersand{ my $self = shift; return if(${$self}{bodyLineBreaks}==0); + # some blocks may contain verbatim to be measured + ${$self}{measureVerbatim} = (${$self}{body}=~m/$tokens{verbatim}/ ? 1 : 0); + my $maximumNumberOfAmpersands = 0; # clear the global arrays @@ -278,6 +283,12 @@ sub align_at_ampersand{ delimiterLength=>0, measureThis=> ($numberOfAmpersands>0 ? ${$self}{measureRow} : 0) }); + # possible hidden children, see https://github.com/cmhughes/latexindent.pl/issues/85 + if ( (${$self}{measureHiddenChildren} or ${$self}{measureVerbatim} ) + and $column =~m/.*?$tokens{beginOfToken}/s){ + $self->hidden_child_cell_row_width($column,$rowCounter,$columnCounter); + } + # store the maximum column width $maxColumnWidth[$columnCounter] = (defined $maxColumnWidth[$columnCounter] ? @@ -424,15 +435,16 @@ sub align_at_ampersand{ # \end{align*} # # see https://github.com/cmhughes/latexindent.pl/issues/223 for example + if (!${${$self}{linebreaksAtEnd}}{begin} and ${$cellStorage[0][0]}{type} eq "X" and ${$cellStorage[0][0]}{measureThis}){ - my $partToMeasure = ${$self}{begin}; + my $lengthOfBegin = ${$self}{begin}; if( (${$self}{begin} eq '{' | ${$self}{begin} eq '[') and ${$self}{parentBegin}){ - $partToMeasure = ${$self}{parentBegin}."{"; + $lengthOfBegin = ${$self}{parentBegin}."{"; } - ${$self}{indentation} = " " x Unicode::GCString->new($partToMeasure)->columns(); + ${$self}{indentation} = " " x Unicode::GCString->new($lengthOfBegin)->columns(); $logger->trace("Adjusting indentation of ${$self}{name} in AlignAtAmpersand routine") if($is_t_switch_active); } } @@ -530,6 +542,10 @@ sub main_formatting { # objective (2): calculate row width and update maximumRowWidth # objective (2): calculate row width and update maximumRowWidth my $rowWidth = Unicode::GCString->new($tmpRow)->columns(); + + # possibly update rowWidth if there are hidden children; see test-cases/alignment/hidden-child1.tex and friends + $rowWidth = $self->hidden_child_row_width($tmpRow,$rowCount,$rowWidth) if(${$self}{measureHiddenChildren} or ${$self}{measureVerbatim}); + ${$formattedBody[$rowCount]}{rowWidth} = $rowWidth; # update the maximum row width @@ -538,6 +554,19 @@ sub main_formatting { ${$self}{maximumRowWidth} = $rowWidth; } } + + # log file information + if($is_tt_switch_active and ${$self}{measureHiddenChildren}){ + $logger->info('*FamilyTree after align for ampersand'); + $logger->trace(Dumper(\%familyTree)) if($is_tt_switch_active); + + $rowCount = -1; + # row loop + foreach my $row (@cellStorage) { + $rowCount++; + $logger->trace("row $rowCount row width: ${$formattedBody[$rowCount]}{rowWidth}"); + } + } } sub dont_measure{ @@ -1344,4 +1373,211 @@ sub double_back_slash_else{ logName=>"double-back-slash-block (for align at ampersand, see lookForAlignDelims)", ); } + +# possible hidden children, see test-cases/alignment/issue-162.tex and friends +# +# \begin{align} +# A & =\begin{array}{cc} % <!--- Hidden child +# BBB & CCC \\ % <!--- Hidden child +# E & F % <!--- Hidden child +# \end{array} \\ % <!--- Hidden child +# +# Z & =\begin{array}{cc} % <!--- Hidden child +# Y & X \\ % <!--- Hidden child +# W & V % <!--- Hidden child +# \end{array} % <!--- Hidden child +# \end{align} +# + +# PURPOSE: +# +# measure CELL width that has hidden children +# +# A & =\begin{array}{cc} +# BBB & CCC \\ +# E & F +# \end{array} \\ +# +# ^^^^^^^^^^^^^^^^^^ +# |||||||||||||||||| +# +# Cell +# +sub hidden_child_cell_row_width{ + my $self = shift; + + my ($tmpCellEntry, $rowCounter, $columnCounter) = @_; + + for my $hiddenChildToMeasure (@{${$self}{measureHiddenChildren}}){ + if($tmpCellEntry =~m/.*?$hiddenChildToMeasure/s and defined $familyTree{$hiddenChildToMeasure}{bodyForMeasure}){ + $tmpCellEntry =~ s/$hiddenChildToMeasure/$familyTree{$hiddenChildToMeasure}{bodyForMeasure}/s; + } + } + + if ($tmpCellEntry =~ m/$tokens{verbatim}/){ + # + # verbatim example: + # + # \begin{tabular}{ll} + # Testing & Line 1 \\ + # Testing & Line 2 \\ + # Testing & Line 3 \verb|X| \\ + # Testing & Line 4 \\ + # \end{tabular} + while( my ($verbatimID,$child)= each %verbatimStorage){ + if($tmpCellEntry =~m/.*?$verbatimID/s){ + $tmpCellEntry =~ s/$verbatimID/${$child}{begin}${$child}{body}${$child}{end}/s; + } + } + } + my $bodyLineBreaks = 0; + $bodyLineBreaks++ while($tmpCellEntry =~ m/\R/sg); + if($bodyLineBreaks>0){ + my $maxRowWidthWithinCell = 0; + foreach(split("\n",$tmpCellEntry)){ + my $currentRowWidth = Unicode::GCString->new($_)->columns(); + $maxRowWidthWithinCell = $currentRowWidth if ($currentRowWidth > $maxRowWidthWithinCell ); + } + ${$cellStorage[$rowCounter][$columnCounter]}{width} = $maxRowWidthWithinCell; + } else { + ${$cellStorage[$rowCounter][$columnCounter]}{width} = Unicode::GCString->new($tmpCellEntry)->columns(); + } +} + +# PURPOSE: +# +# measure ROW width that has hidden children +# +# A & =\begin{array}{cc} +# BBB & CCC \\ +# E & F +# \end{array} \\ +# +# ^^^^^^^^^^^^^^^^^^^^^^ +# |||||||||||||||||||||| +# +# row +# +sub hidden_child_row_width{ + my $self = shift; + + my ($tmpRow,$rowCount,$rowWidth) = @_; + + # some alignment blocks have the 'begin' statement on the opening line: + # + # this bit + # |||||||||||||| + # `````````````` + # \begin{align*}1 & 2 \\ + # 3 & 4 \\ + # 5 & 6 + # \end{align*} + # + my $lengthOfBegin = 0; + if (!${${$self}{linebreaksAtEnd}}{begin} + and ${$cellStorage[0][0]}{type} eq "X" + and ${$cellStorage[0][0]}{measureThis}){ + + my $beginToMeasure = ${$self}{begin}; + if( (${$self}{begin} eq '{' | ${$self}{begin} eq '[') and ${$self}{parentBegin}){ + $beginToMeasure = ${$self}{parentBegin}."{"; + } + $lengthOfBegin = Unicode::GCString->new($beginToMeasure)->columns(); + $tmpRow = $beginToMeasure.$tmpRow if $rowCount == 0; + } + + if ($tmpRow =~m/.*?$tokens{beginOfToken}/s){ + + $tmpRow = ("."x$lengthOfBegin).$tmpRow; + + for my $hiddenChildToMeasure (@{${$self}{measureHiddenChildren}}){ + if($tmpRow=~m/(^.*)?$hiddenChildToMeasure/m and defined $familyTree{$hiddenChildToMeasure}{bodyForMeasure}){ + my $partBeforeId = $1; + my $lengthPartBeforeId = Unicode::GCString->new($partBeforeId)->columns(); + + foreach (@{$familyTree{$hiddenChildToMeasure}{ancestors}}){ + if (${$_}{ancestorID} eq ${$self}{id}){ + if($lengthOfBegin>0){ + ${$_}{ancestorIndentation} = (" " x ($lengthPartBeforeId)); + } else { + ${$_}{ancestorIndentation} = ${$_}{ancestorIndentation}.(" " x ($lengthPartBeforeId)); + } + } + } + my $tmpBodyToMeasure = join( "\n".("."x($lengthPartBeforeId)), + split("\n",$familyTree{$hiddenChildToMeasure}{bodyForMeasure})); + + # remove trailing \\ + $tmpBodyToMeasure =~ s/(\\\\\h*$)//mg; + + $tmpRow =~ s/$hiddenChildToMeasure/$tmpBodyToMeasure/s; + } + } + + if ($tmpRow =~ m/$tokens{verbatim}/){ + # + # verbatim example: + # + # \begin{tabular}{ll} + # Testing & Line 1 \\ + # Testing & Line 2 \\ + # Testing & Line 3 \verb|X| \\ + # Testing & Line 4 \\ + # \end{tabular} + while( my ($verbatimID,$child)= each %verbatimStorage){ + if($tmpRow =~m/.*?$verbatimID/s){ + $tmpRow =~ s/$verbatimID/${$child}{begin}${$child}{body}${$child}{end}/s; + } + } + } + + my $bodyLineBreaks = 0; + $bodyLineBreaks++ while($tmpRow =~ m/\R/sg); + if($bodyLineBreaks>0){ + my $maxRowWidth = 0; + + foreach(split("\n",$tmpRow)){ + my $currentRowWidth = Unicode::GCString->new($_)->columns(); + $maxRowWidth = $currentRowWidth if ($currentRowWidth > $maxRowWidth ); + } + $rowWidth = $maxRowWidth; + } else { + $rowWidth = Unicode::GCString->new($tmpRow)->columns(); + } + } elsif (!${${$self}{linebreaksAtEnd}}{begin} + and ${$cellStorage[0][0]}{type} eq "X" + and ${$cellStorage[0][0]}{measureThis}){ + $rowWidth = Unicode::GCString->new($tmpRow)->columns(); + } + + # possibly draw ruler to log file + &draw_ruler_to_logfile($tmpRow,$rowWidth) if ($is_t_switch_active); + return $rowWidth; +} + +sub draw_ruler_to_logfile{ + # draw a ruler to the log file, useful for debugging + # + # example: + # + # ----|----|----|----|----|----|----|----|----|----|----|----|----|----| + # 5 10 15 20 25 30 35 40 45 50 55 60 65 70 + # + + my ($tmpRow,$maxRowWidth) = @_; + $logger->trace("*tmpRow:"); + + foreach(split("\n",$tmpRow)){ + my $currentRowWidth = Unicode::GCString->new($_)->columns(); + $logger->trace("$_ \t(length: $currentRowWidth)"); + } + + my $rulerMax = int($maxRowWidth/10 +1.5 )*10; + $logger->trace(("----|"x(int($rulerMax/5)))); + + my $ruler = q(); + for (my $i=1;$i<=$rulerMax/5;$i++){ $ruler .= " ".$i*5 }; + $logger->trace($ruler); + +} 1; diff --git a/support/latexindent/LatexIndent/Document.pm b/support/latexindent/LatexIndent/Document.pm index b6e609edc0..85a0557950 100644 --- a/support/latexindent/LatexIndent/Document.pm +++ b/support/latexindent/LatexIndent/Document.pm @@ -29,18 +29,18 @@ use LatexIndent::GetYamlSettings qw/yaml_read_settings yaml_modify_line_breaks_s use LatexIndent::FileExtension qw/file_extension_check/; use LatexIndent::BackUpFileProcedure qw/create_back_up_file/; use LatexIndent::BlankLines qw/protect_blank_lines unprotect_blank_lines condense_blank_lines/; -use LatexIndent::ModifyLineBreaks qw/modify_line_breaks_body modify_line_breaks_end remove_line_breaks_begin adjust_line_breaks_end_parent text_wrap remove_paragraph_line_breaks construct_paragraph_reg_exp text_wrap_remove_paragraph_line_breaks verbatim_modify_line_breaks/; +use LatexIndent::ModifyLineBreaks qw/modify_line_breaks_body modify_line_breaks_end modify_line_breaks_end_after remove_line_breaks_begin adjust_line_breaks_end_parent text_wrap remove_paragraph_line_breaks construct_paragraph_reg_exp text_wrap_remove_paragraph_line_breaks verbatim_modify_line_breaks/; use LatexIndent::Sentence qw/one_sentence_per_line/; use LatexIndent::TrailingComments qw/remove_trailing_comments put_trailing_comments_back_in add_comment_symbol construct_trailing_comment_regexp/; use LatexIndent::HorizontalWhiteSpace qw/remove_trailing_whitespace remove_leading_space/; use LatexIndent::Indent qw/indent wrap_up_statement determine_total_indentation indent_begin indent_body indent_end_statement final_indentation_check get_surrounding_indentation indent_children_recursively check_for_blank_lines_at_beginning put_blank_lines_back_in_at_beginning add_surrounding_indentation_to_begin_statement post_indentation_check/; use LatexIndent::Tokens qw/token_check %tokens/; -use LatexIndent::HiddenChildren qw/find_surrounding_indentation_for_children update_family_tree get_family_tree check_for_hidden_children/; -use LatexIndent::AlignmentAtAmpersand 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/; +use LatexIndent::HiddenChildren qw/find_surrounding_indentation_for_children update_family_tree get_family_tree check_for_hidden_children hidden_children_preparation_for_alignment unpack_children_into_body/; +use LatexIndent::AlignmentAtAmpersand 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 hidden_child_cell_row_width hidden_child_row_width /; use LatexIndent::DoubleBackSlash qw/dodge_double_backslash un_dodge_double_backslash/; # code blocks -use LatexIndent::Verbatim qw/put_verbatim_back_in find_verbatim_environments find_noindent_block find_verbatim_commands find_verbatim_special verbatim_common_tasks/; +use LatexIndent::Verbatim qw/put_verbatim_back_in find_verbatim_environments find_noindent_block find_verbatim_commands find_verbatim_special verbatim_common_tasks %verbatimStorage/; use LatexIndent::Environment qw/find_environments $environmentBasicRegExp construct_environments_regexp/; use LatexIndent::IfElseFi qw/find_ifelsefi construct_ifelsefi_regexp $ifElseFiBasicRegExp/; use LatexIndent::Else qw/check_for_else_statement/; @@ -95,6 +95,8 @@ sub operate_on_file{ $self->remove_trailing_comments; $self->find_verbatim_environments; $self->find_verbatim_special; + $logger->trace("*Verbatim storage:") if $is_tt_switch_active; + $logger->trace(Dumper(\%verbatimStorage)) if $is_tt_switch_active; $self->verbatim_modify_line_breaks if $is_m_switch_active; $self->make_replacements(when=>"before") if $is_rv_switch_active; $self->text_wrap if ($is_m_switch_active and !${$masterSettings{modifyLineBreaks}{textWrapOptions}}{perCodeBlockBasis} and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1); @@ -311,10 +313,14 @@ sub get_settings_and_store_new_object{ # store children in special hash push(@{${$self}{children}},$latexIndentObject); + # possible alignment preparation for hidden children + $self->hidden_children_preparation_for_alignment($latexIndentObject) if(${$latexIndentObject}{lookForAlignDelims} and ${$latexIndentObject}{measureHiddenChildren}); + # possible decoration in log file $logger->trace(${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}) if ${$masterSettings{logFilePreferences}}{showDecorationFinishCodeBlockTrace}; } + sub tasks_common_to_each_object{ my $self = shift; @@ -358,7 +364,8 @@ sub tasks_common_to_each_object{ # text wrapping can make the ID split across lines ${$self}{idRegExp} = ${$self}{id}; - if($is_m_switch_active){ + if($is_m_switch_active + and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{huge} ne "overflow"){ my $IDwithLineBreaks = join("\\R?\\h*",split(//,${$self}{id})); ${$self}{idRegExp} = qr/$IDwithLineBreaks/s; } @@ -371,16 +378,21 @@ sub tasks_common_to_each_object{ $self->adjust_replacement_text_line_breaks_at_end; # modify line breaks on body and end statements - $self->modify_line_breaks_body if ($is_m_switch_active and defined ${$self}{BodyStartsOnOwnLine}); + $self->modify_line_breaks_body if ($is_m_switch_active and defined ${$self}{BodyStartsOnOwnLine} and ${$self}{BodyStartsOnOwnLine}!=0); # modify line breaks end statements - $self->modify_line_breaks_end if $is_m_switch_active; + $self->modify_line_breaks_end if ($is_m_switch_active and defined ${$self}{EndStartsOnOwnLine} and ${$self}{EndStartsOnOwnLine}!=0); + $self->modify_line_breaks_end_after if ($is_m_switch_active and defined ${$self}{EndFinishesWithLineBreak} and ${$self}{EndFinishesWithLineBreak}!=0); # check the body for current children $self->check_for_hidden_children if ${$self}{body} =~ m/$tokens{beginOfToken}/; # double back slash poly-switch check $self->double_back_slash_else if ($is_m_switch_active and ${$self}{lookForAlignDelims}); + + # some objects can format their body to align at the & character + $self->align_at_ampersand if (${$self}{lookForAlignDelims} and !${$self}{measureHiddenChildren}); + return; } diff --git a/support/latexindent/LatexIndent/Else.pm b/support/latexindent/LatexIndent/Else.pm index 26d8014f5a..a213d7b247 100644 --- a/support/latexindent/LatexIndent/Else.pm +++ b/support/latexindent/LatexIndent/Else.pm @@ -121,6 +121,10 @@ sub yaml_get_indentation_information{ return q(); } +sub check_for_hidden_children{ + return q(); +} + sub create_unique_id{ my $self = shift; diff --git a/support/latexindent/LatexIndent/FileContents.pm b/support/latexindent/LatexIndent/FileContents.pm index d870f16c41..ff7b0eeb18 100644 --- a/support/latexindent/LatexIndent/FileContents.pm +++ b/support/latexindent/LatexIndent/FileContents.pm @@ -24,6 +24,7 @@ use LatexIndent::Environment qw/$environmentBasicRegExp/; use LatexIndent::IfElseFi qw/$ifElseFiBasicRegExp/; use LatexIndent::Special qw/$specialBeginAndBracesBracketsBasicRegExp/; use LatexIndent::Heading qw/$allHeadingsRegexp/; +use LatexIndent::Verbatim qw/%verbatimStorage/; use Data::Dumper; use Exporter qw/import/; our @EXPORT_OK = qw/find_file_contents_environments_and_preamble/; @@ -179,7 +180,7 @@ sub find_file_contents_environments_and_preamble{ # indentPreamble set to 0 $logger->trace("NOT storing ${$preamble}{id} for indentation -- will store as VERBATIM object (because indentPreamble:0)") if $is_t_switch_active; $preamble->unprotect_blank_lines; - ${$self}{verbatim}{${$preamble}{id}} = $preamble; + $verbatimStorage{${$preamble}{id}} = $preamble; } } else { ${$self}{preamblePresent} = 0; @@ -198,7 +199,7 @@ sub find_file_contents_environments_and_preamble{ } else { # indentPreamble set to 0 $logger->trace("Storing ${$_}{id} as a VERBATIM object (indentPreamble is 0)") if $is_t_switch_active; - ${$self}{verbatim}{${$_}{id}}=$_; + $verbatimStorage{${$_}{id}} = $_; } } else { $logger->trace("storing ${$_}{id} for indentation (${$_}{name} found outside of preamble)") if $is_t_switch_active; diff --git a/support/latexindent/LatexIndent/HiddenChildren.pm b/support/latexindent/LatexIndent/HiddenChildren.pm index 878939fd41..a402a7cbce 100644 --- a/support/latexindent/LatexIndent/HiddenChildren.pm +++ b/support/latexindent/LatexIndent/HiddenChildren.pm @@ -21,7 +21,7 @@ use LatexIndent::Tokens qw/%tokens/; use LatexIndent::LogFile qw/$logger/; use Data::Dumper; use Exporter qw/import/; -our @EXPORT_OK = qw/find_surrounding_indentation_for_children update_family_tree get_family_tree check_for_hidden_children %familyTree/; +our @EXPORT_OK = qw/find_surrounding_indentation_for_children update_family_tree get_family_tree check_for_hidden_children %familyTree hidden_children_preparation_for_alignment unpack_children_into_body/; # hiddenChildren can be stored in a global array, it doesn't matter what level they're at our %familyTree; @@ -173,13 +173,15 @@ sub check_for_hidden_children{ } # log file - $logger->trace("*Hidden children check") if $is_t_switch_active; + $logger->trace("*Hidden children check for ${$self}{name}") if $is_t_switch_active; $logger->trace(join("|",@matched)) if $is_t_switch_active; my $naturalAncestors = ${$self}{naturalAncestors}; # loop through the hidden children foreach my $match (@matched){ + next if $match =~ m/$tokens{verbatim}/; + # update the family tree with ancestors of self if(${$self}{ancestors}){ foreach(@{${$self}{ancestors}}){ @@ -197,9 +199,82 @@ sub check_for_hidden_children{ my $type = ($naturalAncestors =~ m/${$self}{id}/ ) ? "natural" : "adopted"; $logger->trace("Adding ${$self}{id} to the $type family tree of hiddenChild $match") if($is_t_switch_active); push(@{$familyTree{$match}{ancestors}},{ancestorID=>${$self}{id},ancestorIndentation=>${$self}{indentation},type=>$type}); + + if(${$self}{lookForAlignDelims}){ + $logger->trace("$match needs measuring for ${$self}{name} (see lookForAlignDelims)") if($is_t_switch_active); + push(@{${$self}{measureHiddenChildren}},$match); + } + } + } + +} + +# +# AlignmentAtAmpersand routine calculations are below +# +# PURPOSE: +# +# Consider the following example, which contains hidden children +# +# \begin{align} +# A & =\begin{array}{cc} % <!--- Hidden child +# BBB & CCC \\ % <!--- Hidden child +# E & F % <!--- Hidden child +# \end{array} \\ % <!--- Hidden child +# +# Z & =\begin{array}{cc} % <!--- Hidden child +# Y & X \\ % <!--- Hidden child +# W & V % <!--- Hidden child +# \end{array} % <!--- Hidden child +# \end{align} +# +# the approach that we adopt is: +# +# 1. for the *original* object (align in the above), we loop through +# its hidden children (array in the above) and unpack their contents +# for measuring +# +# see hidden_children_preparation_for_alignment +# unpack_children_into_body +# +# 2. we store the unpacked body in the familyTree hash, using 'bodyForMeasure' +# +# see $familyTree{${$_}{id}}{bodyForMeasure} = $bodyForMeasure; +# +# 3. during the alignment routine, we use 'bodyForMeasure' for measuring the cells +# +sub hidden_children_preparation_for_alignment{ + + my $self = shift; + my $latexIndentObject = shift; + for my $hiddenChildToMeasure (@{${$latexIndentObject}{measureHiddenChildren}}){ + for (@{${$self}{children}}){ + if(${$_}{id} eq $hiddenChildToMeasure){ + + my $bodyForMeasure = ${$_}{begin}.${$_}{body}.${$_}{end}; + for my $child (${$_}{children}){ + $bodyForMeasure = &unpack_children_into_body(\@{$child},$bodyForMeasure); + } + $familyTree{${$_}{id}}{bodyForMeasure} = $bodyForMeasure; + } } } + return; +} + +sub unpack_children_into_body{ + my $child = shift; + my $body = shift; + for my $individualChild (@{$child}){ + $body =~ s/${$individualChild}{id}/${$individualChild}{begin}${$individualChild}{body}${$individualChild}{end}/s; + if(${$individualChild}{children}){ + for my $nextlevelchild (${$individualChild}{children}){ + $body = &unpack_children_into_body(\@{$nextlevelchild},$body); + } + } + } + return $body; } 1; diff --git a/support/latexindent/LatexIndent/Indent.pm b/support/latexindent/LatexIndent/Indent.pm index ffb4d3f737..bf1216d5b1 100644 --- a/support/latexindent/LatexIndent/Indent.pm +++ b/support/latexindent/LatexIndent/Indent.pm @@ -118,7 +118,7 @@ sub indent_body{ $self->check_for_blank_lines_at_beginning if $is_m_switch_active; # some objects can format their body to align at the & character - $self->align_at_ampersand if ${$self}{lookForAlignDelims}; + $self->align_at_ampersand if (${$self}{lookForAlignDelims} and !${$self}{dontMeasure}); # grab the indentation of the object # NOTE: we need this here, as ${$self}{indentation} can be updated by the align_at_ampersand routine, @@ -324,7 +324,7 @@ sub indent_children_recursively{ :q(); # line break checks before <begin statement> - if(defined ${$child}{BeginStartsOnOwnLine}){ + if(defined ${$child}{BeginStartsOnOwnLine} and ${$child}{BeginStartsOnOwnLine} !=0 ){ my $BeginStringLogFile = ${$child}{aliases}{BeginStartsOnOwnLine}||"BeginStartsOnOwnLine"; # diff --git a/support/latexindent/LatexIndent/ModifyLineBreaks.pm b/support/latexindent/LatexIndent/ModifyLineBreaks.pm index 8b00c52272..1b3f948645 100644 --- a/support/latexindent/LatexIndent/ModifyLineBreaks.pm +++ b/support/latexindent/LatexIndent/ModifyLineBreaks.pm @@ -24,7 +24,8 @@ use LatexIndent::TrailingComments qw/$trailingCommentRegExp/; use LatexIndent::Switches qw/$is_m_switch_active $is_t_switch_active $is_tt_switch_active/; use LatexIndent::Item qw/$listOfItems/; use LatexIndent::LogFile qw/$logger/; -our @EXPORT_OK = qw/modify_line_breaks_body modify_line_breaks_end adjust_line_breaks_end_parent remove_line_breaks_begin text_wrap remove_paragraph_line_breaks construct_paragraph_reg_exp text_wrap_remove_paragraph_line_breaks verbatim_modify_line_breaks/; +use LatexIndent::Verbatim qw/%verbatimStorage/; +our @EXPORT_OK = qw/modify_line_breaks_body modify_line_breaks_end modify_line_breaks_end_after adjust_line_breaks_end_parent remove_line_breaks_begin text_wrap remove_paragraph_line_breaks construct_paragraph_reg_exp text_wrap_remove_paragraph_line_breaks verbatim_modify_line_breaks/; our $paragraphRegExp = q(); sub modify_line_breaks_body{ @@ -105,7 +106,7 @@ sub modify_line_breaks_end{ # switch EndStartsOnOwnLine back to 4 # - my @polySwitchValues =(defined ${$self}{EndStartsOnOwnLine} and ${$self}{EndStartsOnOwnLine}==4) ?(-1,3):(${$self}{EndStartsOnOwnLine}); + my @polySwitchValues =(${$self}{EndStartsOnOwnLine}==4) ?(-1,3):(${$self}{EndStartsOnOwnLine}); foreach(@polySwitchValues){ # possibly modify line break *before* \end{statement} if(defined ${$self}{EndStartsOnOwnLine}){ @@ -153,6 +154,10 @@ sub modify_line_breaks_end{ } } + } + +sub modify_line_breaks_end_after{ + my $self = shift; # # Blank line poly-switch notes (==4) # @@ -161,7 +166,7 @@ sub modify_line_breaks_end{ # temporarily change EndFinishesWithLineBreak to 3, make adjustments # switch EndFinishesWithLineBreak back to 4 # - @polySwitchValues =(defined ${$self}{EndFinishesWithLineBreak} and ${$self}{EndFinishesWithLineBreak}==4) ?(-1,3):(${$self}{EndFinishesWithLineBreak}); + my @polySwitchValues =(${$self}{EndFinishesWithLineBreak}==4) ?(-1,3):(${$self}{EndFinishesWithLineBreak}); foreach(@polySwitchValues){ last if !(defined $_); ${$self}{linebreaksAtEnd}{end} = 0 if($_==3 and (defined ${$self}{EndFinishesWithLineBreak} and ${$self}{EndFinishesWithLineBreak}==4)); @@ -242,7 +247,7 @@ sub verbatim_modify_line_breaks{ # verbatim modify line breaks are a bit special, as they happen before # any of the main processes have been done my $self = shift; - while ( my ($key,$child)= each %{${$self}{verbatim}}){ + while ( my ($key,$child)= each %verbatimStorage){ if(defined ${$child}{BeginStartsOnOwnLine}){ my $BeginStringLogFile = ${$child}{aliases}{BeginStartsOnOwnLine}; $logger->trace("*$BeginStringLogFile is ${$child}{BeginStartsOnOwnLine} for ${$child}{name}") if $is_t_switch_active ; diff --git a/support/latexindent/LatexIndent/Verbatim.pm b/support/latexindent/LatexIndent/Verbatim.pm index 1657f41521..2d8fe0e2d8 100644 --- a/support/latexindent/LatexIndent/Verbatim.pm +++ b/support/latexindent/LatexIndent/Verbatim.pm @@ -22,9 +22,10 @@ use LatexIndent::Tokens qw/%tokens/; use LatexIndent::GetYamlSettings qw/%masterSettings/; use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_m_switch_active/; use LatexIndent::LogFile qw/$logger/; -our @EXPORT_OK = qw/put_verbatim_back_in find_verbatim_environments find_noindent_block find_verbatim_commands find_verbatim_special verbatim_common_tasks/; +our @EXPORT_OK = qw/put_verbatim_back_in find_verbatim_environments find_noindent_block find_verbatim_commands find_verbatim_special verbatim_common_tasks %verbatimStorage/; our @ISA = "LatexIndent::Document"; # class inheritance, Programming Perl, pg 321 our $verbatimCounter; +our %verbatimStorage; sub find_noindent_block{ my $self = shift; @@ -111,7 +112,7 @@ sub find_noindent_block{ $noIndentBlockObj->create_unique_id; # verbatim children go in special hash - ${$self}{verbatim}{${$noIndentBlockObj}{id}}=$noIndentBlockObj; + $verbatimStorage{${$noIndentBlockObj}{id}}=$noIndentBlockObj; # log file output $logger->trace("NOINDENTBLOCK found: $noIndentBlock") if $is_t_switch_active; @@ -180,7 +181,7 @@ sub find_verbatim_environments{ $verbatimBlock->verbatim_common_tasks; # verbatim children go in special hash - ${$self}{verbatim}{${$verbatimBlock}{id}}=$verbatimBlock; + $verbatimStorage{${$verbatimBlock}{id}}=$verbatimBlock; # log file output $logger->trace("*VERBATIM environment found: $verbEnv") if $is_t_switch_active; @@ -269,7 +270,7 @@ sub find_verbatim_commands{ $logger->trace(Dumper($verbatimCommand),'ttrace') if($is_tt_switch_active); # verbatim children go in special hash - ${$self}{verbatim}{${$verbatimCommand}{id}}=$verbatimCommand; + $verbatimStorage{${$verbatimCommand}{id}}=$verbatimCommand; # log file output $logger->trace("*VERBATIM command found: $verbCommand") if $is_t_switch_active; @@ -338,7 +339,7 @@ sub find_verbatim_special{ $verbatimBlock->verbatim_common_tasks; # verbatim children go in special hash - ${$self}{verbatim}{${$verbatimBlock}{id}}=$verbatimBlock; + $verbatimStorage{${$verbatimBlock}{id}}=$verbatimBlock; # log file output $logger->trace("*VERBATIM special found: $specialName") if $is_t_switch_active; @@ -359,29 +360,21 @@ sub put_verbatim_back_in { my $self = shift; my %input = @_; - # if there are no verbatim children, return - return unless(${$self}{verbatim}); - my $verbatimCount=0; my $toMatch = q(); if($input{match} eq "everything-except-commands"){ $toMatch = "noindentblockenvironmentspecial"; - - # count the number of non-command verbatim objects - while( my ($key,$child)= each %{${$self}{verbatim}}){ - ${$child}{type} = "environment" if !(defined ${$child}{type}); - $verbatimCount++ if($toMatch =~ m/${$child}{type}/); - } - return unless($verbatimCount>0); } else { $toMatch = "command"; - # count the number of command verbatim objects - while( my ($key,$child)= each %{${$self}{verbatim}}){ - ${$child}{type} = "environment" if !(defined ${$child}{type}); - $verbatimCount++ if($toMatch =~ m/${$child}{type}/); - } - return unless($verbatimCount>0); } + + # count the number of non-command verbatim objects + while( my ($key,$child)= each %verbatimStorage){ + ${$child}{type} = "environment" if !(defined ${$child}{type}); + $verbatimCount++ if($toMatch =~ m/${$child}{type}/); + } + + return unless($verbatimCount>0); # search for environments/commands $logger->trace('*Putting verbatim back in') if $is_t_switch_active; @@ -391,31 +384,34 @@ sub put_verbatim_back_in { # loop through document children hash my $verbatimFound=0; while($verbatimFound < $verbatimCount){ - while( my ($key,$child)= each %{${$self}{verbatim}}){ + while( my ($verbatimID,$child)= each %verbatimStorage){ if($toMatch =~ m/${$child}{type}/){ - if(${$self}{body} =~ m/${$child}{id}/mx){ + if(${$self}{body} =~ m/$verbatimID/mx){ # possibly remove trailing line break if(defined ${$child}{EndFinishesWithLineBreak} and ${$child}{EndFinishesWithLineBreak}==-1 - and ${$self}{body} =~ m/${$child}{id}\h*\R/s){ + and ${$self}{body} =~ m/$verbatimID\h*\R/s){ $logger->trace("m-switch active, removing trailing line breaks from ${$child}{name}") if $is_t_switch_active; - ${$self}{body} =~ s/${$child}{id}(\h*)?(\R|\h)*/${$child}{id} /s; + ${$self}{body} =~ s/$verbatimID(\h*)?(\R|\h)*/$verbatimID /s; } # replace ids with body - ${$self}{body} =~ s/${$child}{id}/${$child}{begin}${$child}{body}${$child}{end}/s; + ${$self}{body} =~ s/$verbatimID/${$child}{begin}${$child}{body}${$child}{end}/s; # log file info $logger->trace('Body now looks like:') if $is_tt_switch_active; $logger->trace(${$self}{body},'ttrace') if($is_tt_switch_active); # delete the child so it won't be operated upon again - delete ${$self}{verbatim}{${$child}{id}}; + delete $verbatimStorage{$verbatimID}; $verbatimFound++; - } elsif ($is_m_switch_active and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1 and ${$self}{body} !~ m/${$child}{id}/){ - $logger->trace("${$child}{id} not found in body using /m matching, it may have been split across line (see modifyLineBreaks: textWrapOptions)") if($is_t_switch_active); + } elsif ($is_m_switch_active + and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{columns}>1 + and ${$masterSettings{modifyLineBreaks}{textWrapOptions}}{huge} ne "overflow" + and ${$self}{body} !~ m/${$child}{id}/){ + $logger->trace("$verbatimID not found in body using /m matching, it may have been split across line (see modifyLineBreaks: textWrapOptions)") if($is_t_switch_active); # search for a version of the verbatim ID that may have line breaks - my $verbatimIDwithLineBreaks = join("\\R?",split(//,${$child}{id})); + my $verbatimIDwithLineBreaks = join("\\R?",split(//,$verbatimID)); my $verbatimIDwithLineBreaksRegExp = qr/$verbatimIDwithLineBreaks/s; # replace the line-broken verbatim ID with a non-broken verbatim ID @@ -452,7 +448,8 @@ sub verbatim_common_tasks{ $self->adjust_replacement_text_line_breaks_at_end; # modify line breaks end statements - $self->modify_line_breaks_end if $is_m_switch_active; + $self->modify_line_breaks_end if ($is_m_switch_active and defined ${$self}{EndStartsOnOwnLine} and ${$self}{EndStartsOnOwnLine}!=0); + $self->modify_line_breaks_end_after if ($is_m_switch_active and defined ${$self}{EndFinishesWithLineBreak} and ${$self}{EndFinishesWithLineBreak}!=0); } sub create_unique_id{ diff --git a/support/latexindent/LatexIndent/Version.pm b/support/latexindent/LatexIndent/Version.pm index eb1b1226dc..41ff54c12b 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.10'; -our $versionDate = '2021-06-19'; +our $versionNumber = '3.10.1'; +our $versionDate = '2021-07-23'; 1 diff --git a/support/latexindent/README b/support/latexindent/README index afe8bbbd84..a49f1a231f 100644 --- a/support/latexindent/README +++ b/support/latexindent/README @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - latexindent.pl, version 3.10, 2021-06-19 + latexindent.pl, version 3.10.1, 2021-07-23 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 1d4c370484..94a3a9f4c6 100644 --- a/support/latexindent/defaultSettings.yaml +++ b/support/latexindent/defaultSettings.yaml @@ -1,4 +1,4 @@ -# defaultSettings.yaml for latexindent.pl, version 3.10, 2021-06-19 +# defaultSettings.yaml for latexindent.pl, version 3.10.1, 2021-07-23 # a script that aims to # beautify .tex, .sty, .cls files # @@ -509,7 +509,7 @@ modifyLineBreaks: other: 0 textWrapOptions: columns: 0 - # huge: overflow # forbid mid-word line breaks + huge: overflow # forbid mid-word line breaks separator: "" perCodeBlockBasis: 0 all: 0 diff --git a/support/latexindent/documentation/latexindent.pdf b/support/latexindent/documentation/latexindent.pdf Binary files differindex f57535e9c7..09cd1d6f4f 100644 --- a/support/latexindent/documentation/latexindent.pdf +++ b/support/latexindent/documentation/latexindent.pdf diff --git a/support/latexindent/documentation/logo.tex b/support/latexindent/documentation/logo.tex index 5bc31e0a4f..d80dfec721 100644 --- a/support/latexindent/documentation/logo.tex +++ b/support/latexindent/documentation/logo.tex @@ -14,8 +14,8 @@ \begin{document} \begin{tikzpicture}[logo/.style={draw=blue,circle,fill=white}] \matrix{ - \node[logo,dash pattern=on .5pt off 1.0pt,thick,draw=purple!75!white]{}; & \node[logo,draw=burntorange]{}; \\ - \node[logo,fill,draw=bakeoffgreen,fill=bakeoffblue]{}; & \node[logo,double,draw=cmhgold,fill=harvestgold]{};\\}; + \node[logo,dash pattern=on .5pt off 1.0pt,thick,draw=purple!75!white]{}; & \node[logo,draw=burntorange]{}; \\ + \node[logo,fill,draw=bakeoffgreen,fill=bakeoffblue]{}; & \node[logo,double,draw=cmhgold,fill=harvestgold]{};\\}; \end{tikzpicture} \end{document} @@ -24,8 +24,8 @@ \pagecolor{white} \begin{tikzpicture}[logo/.style={draw=blue,circle,fill=none,fill opacity=0.75}] \matrix{% - \node[logo,dash pattern=on .5pt off 1.0pt,thick,draw=purple!75!white]{}; & \node[logo,draw=burntorange]{}; \\ - \node[logo,fill,draw=bakeoffgreen,fill=bakeoffblue]{}; & \node[logo,double,draw=cmhgold,fill=harvestgold]{};\\}; + \node[logo,dash pattern=on .5pt off 1.0pt,thick,draw=purple!75!white]{}; & \node[logo,draw=burntorange]{}; \\ + \node[logo,fill,draw=bakeoffgreen,fill=bakeoffblue]{}; & \node[logo,double,draw=cmhgold,fill=harvestgold]{};\\}; \begin{scope}[on background layer] %\node [yshift=0.01em,xshift=0.07em] {\resizebox{1cm}{!}{\color{gray!50!white}\faGithub}}; \node {\resizebox{1cm}{!}{\color{gray!25!white}\faGithub}}; diff --git a/support/latexindent/documentation/sec-conclusions-know-limitations.tex b/support/latexindent/documentation/sec-conclusions-know-limitations.tex index 5f20a13d17..938a0d6f53 100644 --- a/support/latexindent/documentation/sec-conclusions-know-limitations.tex +++ b/support/latexindent/documentation/sec-conclusions-know-limitations.tex @@ -3,29 +3,16 @@ There are a number of known limitations of the script, and almost certainly quite a few that are \emph{unknown}! - The main limitation is to do with the alignment routine discussed in - \cpageref{lst:aligndelims:advanced}; for example, consider the file given in \cref{lst:matrix2}. - - \cmhlistingsfromfile{demonstrations/matrix2.tex}{\texttt{matrix2.tex}}{lst:matrix2} - - The default output is given in \cref{lst:matrix2-default}, and it is clear that the alignment - routine has not worked as hoped, but it is \emph{expected}. \cmhlistingsfromfile{demonstrations/matrix2-default.tex}{\texttt{matrix2.tex} default output}{lst:matrix2-default} - - The reason for the problem is that when \texttt{latexindent.pl} stores its code blocks - (see \vref{tab:code-blocks}) it uses replacement tokens. The alignment routine is using - the \emph{length of the replacement token} in its measuring -- I hope to be able to address this in the - future. - - There are other limitations to do with the multicolumn alignment routine (see - \vref{lst:tabular2-mod2}); in particular, when working with code blocks in which - multicolumn commands overlap, the algorithm can fail. + For example, with reference to the multicolumn alignment routine in + \vref{lst:tabular2-mod2}), when working with code blocks in which multicolumn commands + overlap, the algorithm can fail. Another limitation is to do with efficiency, particularly when the \texttt{-m} switch is active, as this adds many checks and processes. The current implementation relies upon finding and storing \emph{every} code block (see the discussion on - \cpageref{page:phases}); it is hoped that, in a future version, only - \emph{nested} code blocks will need to be stored in the `packing' phase, and - that this will improve the efficiency of the script. + \cpageref{page:phases}); I hope that, in a future version, only \emph{nested} code + blocks will need to be stored in the `packing' phase, and that this will improve the + efficiency of the script. You can run \texttt{latexindent} on any file;% \announce{2019-07-13}*{ability to call latexindent on any file} if you don't specify an extension, then the extensions that you diff --git a/support/latexindent/documentation/sec-default-user-local.tex b/support/latexindent/documentation/sec-default-user-local.tex index 426c0c9b78..89a0596fd5 100644 --- a/support/latexindent/documentation/sec-default-user-local.tex +++ b/support/latexindent/documentation/sec-default-user-local.tex @@ -12,6 +12,12 @@ \emph{integer} in \emph{this} section, assume that it must be greater than or equal to \texttt{0} unless otherwise stated. + For most of the settings in \texttt{defaultSettings.yaml} that are specified as integers, then + we understand \texttt{0} to represent `off' and \texttt{1} to + represent `on'. For fields that allow values other than \texttt{0} or + \texttt{1}, it is hoped that the specific context and associated commentary + should make it clear which values are allowed. + \yamltitle{fileExtensionPreference}*{fields} \texttt{latexindent.pl} can be called to act on a file without specifying the file extension. For example we can call @@ -109,11 +115,11 @@ copy myfile.bak4 to myfile.bak3 \announce{2021-03-14}*{no longer using log4perl} Some of the options% - \announce*{2021-06-19}*{logFilePreferences updated to include Dumper options}for Perl's \texttt{Dumper} module can - be specified in \cref{lst:logFilePreferences}; see \cite{dumper} and - \cite{dumperdemo} for more information. These options will mostly be helpful for - those calling \texttt{latexindent.pl} with the \texttt{-tt} option described - in \cref{sec:commandline}. + \announce*{2021-06-19}*{logFilePreferences updated to include Dumper options}for Perl's + \texttt{Dumper} module can be specified in \cref{lst:logFilePreferences}; see + \cite{dumper} and \cite{dumperdemo} for more information. These options + will mostly be helpful for those calling \texttt{latexindent.pl} with the + \texttt{-tt} option described in \cref{sec:commandline}. \subsection{Verbatim code blocks} \yamltitle{verbatimEnvironments}*{fields} @@ -139,6 +145,11 @@ copy myfile.bak4 to myfile.bak3 breaking routines (only relevant if the \texttt{-m} is active, see \vref{sec:modifylinebreaks}). + With reference to \cref{lst:verbatimCommands}, by default \texttt{latexindent.pl} looks for + \lstinline|\verb| immediately followed by another character, and then it takes the + 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}. + \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 @@ -153,17 +164,18 @@ copy myfile.bak4 to myfile.bak3 \cmhlistingsfromfile{demonstrations/noindentblock.tex}{\texttt{noIndentBlock.tex}}{lst:noIndentBlockdemo} - Important note: it is assumed that the \texttt{noindent} block statements appear on - their own line. + Important note: it is assumed that the \texttt{noindent} block statements specified + in this way appear on their own line. The% \announce*{2021-06-19}{noIndentBlock specified as regex} \texttt{noIndentBlock} fields can also be specified in terms of \texttt{begin} and - \texttt{end} fields. We begin with the file given in \cref{lst:noIndentBlock1} + \texttt{end} fields. We use the code in \cref{lst:noIndentBlock1} to demonstrate + this feature. \cmhlistingsfromfile*{demonstrations/noindentblock1.tex}{\texttt{noIndentBlock1.tex}}{lst:noIndentBlock1} - The settings given in \cref{lst:noindent1,lst:noindent2} are equivalent + The settings given in \cref{lst:noindent1,lst:noindent2} are equivalent: \begin{cmhtcbraster}[raster columns=3, raster left skip=-3.5cm, @@ -186,7 +198,9 @@ latexindent.pl -l noindent2.yaml noindent1 The \texttt{begin}, \texttt{body} and \texttt{end} fields for \texttt{noIndentBlock} are all \emph{regular expressions}. If the \texttt{body} field is not specified, then it takes a default value of - \lstinline!.*?! which is written explicitly in \cref{lst:noindent1}. + \lstinline!.*?! which is written explicitly in \cref{lst:noindent1}. In this + context, + we interpret \lstinline!.*?! in words as \emph{the fewest number of characters (possibly none) until the `end' field is reached}. 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). @@ -518,8 +532,8 @@ latexindent.pl aligned1.tex -l sba4.yaml \item \cref{lst:sba3} demonstrates the new \emph{advanced} way to specify \texttt{spacesBeforeAmpersand}, and for us to set the \texttt{default} value that sets the number of spaces before - ampersands which are \emph{not} in leading blank columns. The default - value is \texttt{1}. + ampersands which are \emph{not} in leading blank columns. The + default value is \texttt{1}. We note that \texttt{leadingBlankColumn} has not been specified in \cref{lst:sba3}, and it will inherit the value from \texttt{default}; @@ -1168,33 +1182,33 @@ latexindent.pl mult-nested.tex -l=max-indentation1 \caption{Code blocks known to \texttt{latexindent.pl}}\label{tab:code-blocks} \begin{tabular}{m{.3\linewidth}@{\hspace{.25cm}}m{.4\linewidth}@{\hspace{.25cm}}m{.2\linewidth}} \toprule - Code block & characters allowed in name & example \\ + Code block & characters allowed in name & example \\ \midrule - environments & \lstinline!a-zA-Z@\*0-9_\\! & + environments & \lstinline!a-zA-Z@\*0-9_\\! & \begin{lstlisting}[,nolol=true,] \begin{myenv} body of myenv \end{myenv} \end{lstlisting} \\\cmidrule{2-3} - optionalArguments & \emph{inherits} name from parent (e.g environment name) & + optionalArguments & \emph{inherits} name from parent (e.g environment name) & \begin{lstlisting}[,nolol=true,] [ opt arg text ] \end{lstlisting} \\\cmidrule{2-3} - mandatoryArguments & \emph{inherits} name from parent (e.g environment name) & + mandatoryArguments & \emph{inherits} name from parent (e.g environment name) & \begin{lstlisting}[,nolol=true,] { mand arg text } \end{lstlisting} \\\cmidrule{2-3} - commands & \lstinline!+a-zA-Z@\*0-9_\:! & \lstinline!\mycommand!$\langle$\itshape{arguments}$\rangle$ \\\cmidrule{2-3} - keyEqualsValuesBracesBrackets & \lstinline!a-zA-Z@\*0-9_\/.\h\{\}:\#-! & \lstinline!my key/.style=!$\langle$\itshape{arguments}$\rangle$ \\\cmidrule{2-3} - namedGroupingBracesBrackets & \lstinline!0-9\.a-zA-Z@\*><! & \lstinline!in!$\langle$\itshape{arguments}$\rangle$ \\\cmidrule{2-3} - UnNamedGroupingBracesBrackets & \centering\emph{No name!} & \lstinline!{! or \lstinline![! or \lstinline!,! or \lstinline!&! or \lstinline!)! or \lstinline!(! or \lstinline!$! followed by $\langle$\itshape{arguments}$\rangle$ \\\cmidrule{2-3} + commands & \lstinline!+a-zA-Z@\*0-9_\:! & \lstinline!\mycommand!$\langle$\itshape{arguments}$\rangle$ \\\cmidrule{2-3} + keyEqualsValuesBracesBrackets & \lstinline!a-zA-Z@\*0-9_\/.\h\{\}:\#-! & \lstinline!my key/.style=!$\langle$\itshape{arguments}$\rangle$ \\\cmidrule{2-3} + namedGroupingBracesBrackets & \lstinline!0-9\.a-zA-Z@\*><! & \lstinline!in!$\langle$\itshape{arguments}$\rangle$ \\\cmidrule{2-3} + UnNamedGroupingBracesBrackets & \centering\emph{No name!} & \lstinline!{! or \lstinline![! or \lstinline!,! or \lstinline!&! or \lstinline!)! or \lstinline!(! or \lstinline!$! followed by $\langle$\itshape{arguments}$\rangle$ \\\cmidrule{2-3} ifElseFi & \lstinline!@a-zA-Z! but must begin with either \newline \lstinline!\if! of \lstinline!\@if! & \begin{lstlisting}[,nolol=true,] \ifnum... @@ -1202,31 +1216,31 @@ mand arg text \else ... \fi - \end{lstlisting} \\\cmidrule{2-3} - items & User specified, see \vref{lst:indentafteritems,lst:itemNames} & + \end{lstlisting} \\\cmidrule{2-3} + items & User specified, see \vref{lst:indentafteritems,lst:itemNames} & \begin{lstlisting}[,nolol=true,] \begin{enumerate} \item ... \end{enumerate} - \end{lstlisting} \\\cmidrule{2-3} - specialBeginEnd & User specified, see \vref{lst:specialBeginEnd} & + \end{lstlisting} \\\cmidrule{2-3} + specialBeginEnd & User specified, see \vref{lst:specialBeginEnd} & \begin{lstlisting}[,nolol=true,] \[ ... \] - \end{lstlisting} \\\cmidrule{2-3} - afterHeading & User specified, see \vref{lst:indentAfterHeadings} & + \end{lstlisting} \\\cmidrule{2-3} + afterHeading & User specified, see \vref{lst:indentAfterHeadings} & \begin{lstlisting}[,morekeywords={chapter},nolol=true,] \chapter{title} ... \section{title} - \end{lstlisting} \\\cmidrule{2-3} - filecontents & User specified, see \vref{lst:fileContentsEnvironments} & + \end{lstlisting} \\\cmidrule{2-3} + filecontents & User specified, see \vref{lst:fileContentsEnvironments} & \begin{lstlisting}[,nolol=true,] \begin{filecontents} ... \end{filecontents} - \end{lstlisting} \\ + \end{lstlisting} \\ \bottomrule \end{tabular} \end{widepage} diff --git a/support/latexindent/documentation/sec-fine-tuning.tex b/support/latexindent/documentation/sec-fine-tuning.tex index 928b3a0909..0510e8e66c 100644 --- a/support/latexindent/documentation/sec-fine-tuning.tex +++ b/support/latexindent/documentation/sec-fine-tuning.tex @@ -209,10 +209,10 @@ latexindent.pl -m finetuning4.tex -o=+-mod2 -l=href2 first comment symbol, which has meant that everything following it has been moved to the end of the line; this is undesirable, clearly! \item \cref{lst:finetuning4-mod2} has fine-tuned the trailing comment matching, and says that - \lstinline!%! cannot + \% cannot be immediately preceeded by the words `Handbook', `for' or `Spoken', which means that - none of the \lstinline!%! symbols have been treated as trailing comments, and - the output is desirable. + none of the \% symbols have been treated as trailing comments, and the output is + desirable. \end{itemize} Another approach to this situation, which does not use \texttt{fineTuning}, is to use \texttt{noIndentBlock} @@ -226,7 +226,7 @@ latexindent.pl -m finetuning4.tex -o=+-mod3 -l=href3 \cmhlistingsfromfile*[style=yaml-LST]*{demonstrations/href3.yaml}[MLB-TCB]{\texttt{href3.yaml}}{lst:href3} - With reference to the \texttt{body} field in \cref{lst:href3}, we note that \lstinline![^}]*?! can + With reference to the \texttt{body} field in \cref{lst:href3}, we note that the \texttt{body} field can be interpreted as: the fewest number of zero or more characters that are not right braces. This is an example of character class. \index{regular expressions!character class demonstration} diff --git a/support/latexindent/documentation/sec-the-m-switch.tex b/support/latexindent/documentation/sec-the-m-switch.tex index c77ed24ec4..d8cdbe62c6 100644 --- a/support/latexindent/documentation/sec-the-m-switch.tex +++ b/support/latexindent/documentation/sec-the-m-switch.tex @@ -136,35 +136,26 @@ latexindent.pl -m textwrap3.tex -o textwrap3-mod1.tex -l textwrap1.yaml \cmhlistingsfromfile{demonstrations/textwrap3-mod1.tex}{\texttt{textwrap3-mod1.tex}}{lst:textwrap3-mod1} - The text wrapping routine of \texttt{latexindent.pl} is performed by the - \texttt{Text::Wrap} module, which provides a \texttt{separator} feature - to separate lines with characters other than a new line (see - \cite{textwrap}). By default, the separator is empty which means that a new - line token will be used, but you can change it as you see fit. - - For example starting with the file in \cref{lst:textwrap4} - - \cmhlistingsfromfile{demonstrations/textwrap4.tex}{\texttt{textwrap4.tex}}{lst:textwrap4} - and using \texttt{textwrap2.yaml} from \cref{lst:textwrap2-yaml} with the following - command - \index{switches!-l demonstration} - \index{switches!-m demonstration} - \index{switches!-o demonstration} - \begin{commandshell} -latexindent.pl -m textwrap4.tex -o textwrap4-mod2.tex -l textwrap2.yaml -\end{commandshell} - then we obtain the output in \cref{lst:textwrap4-mod2}. + The% + \announce*{2021-07-23}*{huge:overflow is now default} default value of + \texttt{huge} is \texttt{overflow}, which means that words will + \emph{not} be broken by the text wrapping routine, implemented by the + \texttt{Text::Wrap} \cite{textwrap}. There are options to change the + \texttt{huge} option for the \texttt{Text::Wrap} module to either + \texttt{wrap} or \texttt{die}. Before modifying the value of + \texttt{huge}, please bear in mind the following warning: + \index{warning!changing huge (textwrap)} + \begin{warning} + \raggedright + Changing the value of \texttt{huge} to anything other than \texttt{overflow} will slow down + \texttt{latexindent.pl} significantly when the \texttt{-m} switch is active. - \begin{cmhtcbraster}[raster column skip=.1\linewidth] - \cmhlistingsfromfile{demonstrations/textwrap4-mod2.tex}{\texttt{textwrap4-mod2.tex}}{lst:textwrap4-mod2} - \cmhlistingsfromfile{demonstrations/textwrap2.yaml}[MLB-TCB]{\texttt{textwrap2.yaml}}{lst:textwrap2-yaml} - \end{cmhtcbraster} + Furthermore, changing \texttt{huge} means that you may have some words \emph{or commands}(!) + split across lines in your .tex file, which may affect your output. I do not recommend + changing this field. + \end{warning} - There are options to specify the \texttt{huge} option for the - \texttt{Text::Wrap} module \cite{textwrap} - \announce{2019-09-07}{huge option for text wrap module}. This can be helpful if you would like to forbid the - \texttt{Text::Wrap} routine from breaking words. For example, using the settings - in \cref{lst:textwrap2A-yaml,lst:textwrap2B-yaml} and running the commands + For example, using the settings in \cref{lst:textwrap2A-yaml,lst:textwrap2B-yaml} and running the commands \index{switches!-l demonstration} \index{switches!-m demonstration} \index{switches!-o demonstration} @@ -176,10 +167,10 @@ latexindent.pl -m textwrap4.tex -o=+-mod2B -l textwrap2B.yaml \begin{cmhtcbraster}[raster column skip=.1\linewidth] \cmhlistingsfromfile{demonstrations/textwrap4-mod2A.tex}{\texttt{textwrap4-mod2A.tex}}{lst:textwrap4-mod2A} - \cmhlistingsfromfile{demonstrations/textwrap2A.yaml}[MLB-TCB]{\texttt{textwrap2A.yaml}}{lst:textwrap2A-yaml} + \cmhlistingsfromfile*{demonstrations/textwrap2A.yaml}[MLB-TCB]{\texttt{textwrap2A.yaml}}{lst:textwrap2A-yaml} \cmhlistingsfromfile{demonstrations/textwrap4-mod2B.tex}{\texttt{textwrap4-mod2B.tex}}{lst:textwrap4-mod2B} - \cmhlistingsfromfile{demonstrations/textwrap2B.yaml}[MLB-TCB]{\texttt{textwrap2B.yaml}}{lst:textwrap2B-yaml} + \cmhlistingsfromfile*{demonstrations/textwrap2B.yaml}[MLB-TCB]{\texttt{textwrap2B.yaml}}{lst:textwrap2B-yaml} \end{cmhtcbraster} You can also specify the \texttt{tabstop} @@ -204,10 +195,11 @@ latexindent.pl -m textwrap-ts.tex -o=+-mod1 -l tabstop.yaml \cmhlistingsfromfile[showtabs=true]*{demonstrations/textwrap-ts-mod1.tex}{\texttt{textwrap-ts-mod1.tex}}{lst:textwrap-ts-mod1} \end{cmhtcbraster} - You can specify \texttt{break} and \texttt{unexpand} options in - your settings in analogous ways to those demonstrated in \cref{lst:textwrap2B-yaml,lst:tabstop}, and - they will be passed to the \texttt{Text::Wrap} module. I have not found a useful - reason to do this; see \cite{textwrap} for more details. + You can specify \texttt{separator}, \texttt{break} and + \texttt{unexpand} options in your settings in analogous ways to those + demonstrated in \cref{lst:textwrap2B-yaml,lst:tabstop}, and they will be passed to the + \texttt{Text::Wrap} module. I have not found a useful reason to do this; see + \cite{textwrap} for more details. \subsubsection{text wrapping on a per-code-block basis} By default, if the value of \texttt{columns} is greater than 0 and the @@ -223,7 +215,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=.85\linewidth,before=\centering]{\texttt{textWrapOptions}}{lst:textWrapOptionsAll} + \cmhlistingsfromfile*[style=textWrapOptionsAll]*{../defaultSettings.yaml}[MLB-TCB,width=.85\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}. The only special case is the @@ -375,7 +367,7 @@ latexindent.pl -s textwrap6.tex -l=textwrap11.yaml -m \begin{widepage} \cmhlistingsfromfile{demonstrations/textwrap6-mod9.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap9-yaml}}{lst:textwrap6-mod9} - \cmhlistingsfromfile{demonstrations/textwrap6-mod11.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap11-yaml}}{lst:textwrap6-mod11} + \cmhlistingsfromfile*{demonstrations/textwrap6-mod11.tex}{\texttt{textwrap6.tex} using \cref{lst:textwrap11-yaml}}{lst:textwrap6-mod11} \end{widepage} Notice that: @@ -1897,70 +1889,70 @@ latexindent.pl -m pmatrix3.tex -l DBS3.yaml \clearpage \begin{longtable}{llll} - \caption{Poly-switch mappings for all code-block types}\label{tab:poly-switch-mapping} \\ + \caption{Poly-switch mappings for all code-block types}\label{tab:poly-switch-mapping} \\ \toprule - Code block & Sample & \multicolumn{2}{c}{Poly-switch mapping} \\ + Code block & Sample & \multicolumn{2}{c}{Poly-switch mapping} \\ \midrule - environment & \verb!before words!$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & BeginStartsOnOwnLine \\ + environment & \verb!before words!$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & BeginStartsOnOwnLine \\ & \verb!\begin{myenv}!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & BodyStartsOnOwnLine \\ & \verb!body of myenv!$\EndStartsOnOwnLine$ & $\EndStartsOnOwnLine$ & EndStartsOnOwnLine \\ - & \verb!\end{myenv}!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & EndFinishesWithLineBreak \\ - & \verb!after words! & & \\ + & \verb!\end{myenv}!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & EndFinishesWithLineBreak \\ + & \verb!after words! & & \\ \cmidrule{2-4} - ifelsefi & \verb!before words!$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & IfStartsOnOwnLine \\ - & \verb!\if...!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & BodyStartsOnOwnLine \\ - & \verb!body of if/or statement!$\OrStartsOnOwnLine$ & $\OrStartsOnOwnLine$ & OrStartsOnOwnLine % - \announce{2018-04-27}{new ifElseFi code block poly-switches} \\ - & \verb!\or!$\OrFinishesWithLineBreak$ & $\OrFinishesWithLineBreak$ & OrFinishesWithLineBreak \\ - & \verb!body of if/or statement!$\ElseStartsOnOwnLine$ & $\ElseStartsOnOwnLine$ & ElseStartsOnOwnLine \\ - & \verb!\else!$\ElseFinishesWithLineBreak$ & $\ElseFinishesWithLineBreak$ & ElseFinishesWithLineBreak \\ - & \verb!body of else statement!$\EndStartsOnOwnLine$ & $\EndStartsOnOwnLine$ & FiStartsOnOwnLine \\ - & \verb!\fi!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & FiFinishesWithLineBreak \\ - & \verb!after words! & & \\ + ifelsefi & \verb!before words!$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & IfStartsOnOwnLine \\ + & \verb!\if...!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & BodyStartsOnOwnLine \\ + & \verb!body of if/or statement!$\OrStartsOnOwnLine$ & $\OrStartsOnOwnLine$ & OrStartsOnOwnLine % + \announce{2018-04-27}{new ifElseFi code block poly-switches} \\ + & \verb!\or!$\OrFinishesWithLineBreak$ & $\OrFinishesWithLineBreak$ & OrFinishesWithLineBreak \\ + & \verb!body of if/or statement!$\ElseStartsOnOwnLine$ & $\ElseStartsOnOwnLine$ & ElseStartsOnOwnLine \\ + & \verb!\else!$\ElseFinishesWithLineBreak$ & $\ElseFinishesWithLineBreak$ & ElseFinishesWithLineBreak \\ + & \verb!body of else statement!$\EndStartsOnOwnLine$ & $\EndStartsOnOwnLine$ & FiStartsOnOwnLine \\ + & \verb!\fi!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & FiFinishesWithLineBreak \\ + & \verb!after words! & & \\ \cmidrule{2-4} - optionalArguments & \verb!...!$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & LSqBStartsOnOwnLine\footnote{LSqB stands for Left Square Bracket} \\ - & \verb![!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & OptArgBodyStartsOnOwnLine \\ - \announce{2019-07-13}{new comma-related poly-switches} & \verb!value before comma!$\ElseStartsOnOwnLine$, & $\ElseStartsOnOwnLine$ & CommaStartsOnOwnLine \\ - & $\ElseFinishesWithLineBreak$ & $\ElseFinishesWithLineBreak$ & CommaFinishesWithLineBreak \\ - & \verb!end of body of opt arg!$\EndStartsOnOwnLine$ & $\EndStartsOnOwnLine$ & RSqBStartsOnOwnLine \\ - & \verb!]!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & RSqBFinishesWithLineBreak \\ - & \verb!...! & & \\ + optionalArguments & \verb!...!$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & LSqBStartsOnOwnLine\footnote{LSqB stands for Left Square Bracket} \\ + & \verb![!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & OptArgBodyStartsOnOwnLine \\ + \announce{2019-07-13}{new comma-related poly-switches} & \verb!value before comma!$\ElseStartsOnOwnLine$, & $\ElseStartsOnOwnLine$ & CommaStartsOnOwnLine \\ + & $\ElseFinishesWithLineBreak$ & $\ElseFinishesWithLineBreak$ & CommaFinishesWithLineBreak \\ + & \verb!end of body of opt arg!$\EndStartsOnOwnLine$ & $\EndStartsOnOwnLine$ & RSqBStartsOnOwnLine \\ + & \verb!]!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & RSqBFinishesWithLineBreak \\ + & \verb!...! & & \\ \cmidrule{2-4} - mandatoryArguments & \verb!...!$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & LCuBStartsOnOwnLine\footnote{LCuB stands for Left Curly Brace} \\ - & \verb!{!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & MandArgBodyStartsOnOwnLine \\ - \announce{2019-07-13}{new comma-related poly-switches} & \verb!value before comma!$\ElseStartsOnOwnLine$, & $\ElseStartsOnOwnLine$ & CommaStartsOnOwnLine \\ - & $\ElseFinishesWithLineBreak$ & $\ElseFinishesWithLineBreak$ & CommaFinishesWithLineBreak \\ - & \verb!end of body of mand arg!$\EndStartsOnOwnLine$ & $\EndStartsOnOwnLine$ & RCuBStartsOnOwnLine \\ - & \verb!}!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & RCuBFinishesWithLineBreak \\ - & \verb!...! & & \\ + mandatoryArguments & \verb!...!$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & LCuBStartsOnOwnLine\footnote{LCuB stands for Left Curly Brace} \\ + & \verb!{!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & MandArgBodyStartsOnOwnLine \\ + \announce{2019-07-13}{new comma-related poly-switches} & \verb!value before comma!$\ElseStartsOnOwnLine$, & $\ElseStartsOnOwnLine$ & CommaStartsOnOwnLine \\ + & $\ElseFinishesWithLineBreak$ & $\ElseFinishesWithLineBreak$ & CommaFinishesWithLineBreak \\ + & \verb!end of body of mand arg!$\EndStartsOnOwnLine$ & $\EndStartsOnOwnLine$ & RCuBStartsOnOwnLine \\ + & \verb!}!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & RCuBFinishesWithLineBreak \\ + & \verb!...! & & \\ \cmidrule{2-4} - commands & \verb!before words!$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & CommandStartsOnOwnLine \\ - & \verb!\mycommand!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & CommandNameFinishesWithLineBreak \\ - & $\langle$\itshape{arguments}$\rangle$ & & \\ + commands & \verb!before words!$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & CommandStartsOnOwnLine \\ + & \verb!\mycommand!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & CommandNameFinishesWithLineBreak \\ + & $\langle$\itshape{arguments}$\rangle$ & & \\ \cmidrule{2-4} - namedGroupingBraces Brackets & before words$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & NameStartsOnOwnLine \\ - & myname$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & NameFinishesWithLineBreak \\ - & $\langle$\itshape{braces/brackets}$\rangle$ & & \\ + namedGroupingBraces Brackets & before words$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & NameStartsOnOwnLine \\ + & myname$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & NameFinishesWithLineBreak \\ + & $\langle$\itshape{braces/brackets}$\rangle$ & & \\ \cmidrule{2-4} - keyEqualsValuesBraces\newline Brackets & before words$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & KeyStartsOnOwnLine \\ - & key$\EqualsStartsOnOwnLine$=$\BodyStartsOnOwnLine$ & $\EqualsStartsOnOwnLine$ & EqualsStartsOnOwnLine \\ - & $\langle$\itshape{braces/brackets}$\rangle$ & $\BodyStartsOnOwnLine$ & EqualsFinishesWithLineBreak \\ + keyEqualsValuesBraces\newline Brackets & before words$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & KeyStartsOnOwnLine \\ + & key$\EqualsStartsOnOwnLine$=$\BodyStartsOnOwnLine$ & $\EqualsStartsOnOwnLine$ & EqualsStartsOnOwnLine \\ + & $\langle$\itshape{braces/brackets}$\rangle$ & $\BodyStartsOnOwnLine$ & EqualsFinishesWithLineBreak \\ \cmidrule{2-4} - items & before words$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & ItemStartsOnOwnLine \\ - & \verb!\item!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & ItemFinishesWithLineBreak \\ - & \verb!...! & & \\ + items & before words$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & ItemStartsOnOwnLine \\ + & \verb!\item!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & ItemFinishesWithLineBreak \\ + & \verb!...! & & \\ \cmidrule{2-4} - specialBeginEnd & before words$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & SpecialBeginStartsOnOwnLine \\ - & \verb!\[!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & SpecialBodyStartsOnOwnLine \\ - & \verb!body of special/middle!$\ElseStartsOnOwnLine$ & $\ElseStartsOnOwnLine$ & SpecialMiddleStartsOnOwnLine % - \announce{2018-04-27}{new special code block poly-switches} \\ - & \verb!\middle!$\ElseFinishesWithLineBreak$ & $\ElseFinishesWithLineBreak$ & SpecialMiddleFinishesWithLineBreak \\ - & body of special/middle $\EndStartsOnOwnLine$ & $\EndStartsOnOwnLine$ & SpecialEndStartsOnOwnLine \\ - & \verb!\]!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & SpecialEndFinishesWithLineBreak \\ - & after words & & \\ + specialBeginEnd & before words$\BeginStartsOnOwnLine$ & $\BeginStartsOnOwnLine$ & SpecialBeginStartsOnOwnLine \\ + & \verb!\[!$\BodyStartsOnOwnLine$ & $\BodyStartsOnOwnLine$ & SpecialBodyStartsOnOwnLine \\ + & \verb!body of special/middle!$\ElseStartsOnOwnLine$ & $\ElseStartsOnOwnLine$ & SpecialMiddleStartsOnOwnLine % + \announce{2018-04-27}{new special code block poly-switches} \\ + & \verb!\middle!$\ElseFinishesWithLineBreak$ & $\ElseFinishesWithLineBreak$ & SpecialMiddleFinishesWithLineBreak \\ + & body of special/middle $\EndStartsOnOwnLine$ & $\EndStartsOnOwnLine$ & SpecialEndStartsOnOwnLine \\ + & \verb!\]!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & SpecialEndFinishesWithLineBreak \\ + & after words & & \\ \cmidrule{2-4} - verbatim & before words$\BeginStartsOnOwnLine$\verb!\begin{verbatim}! & $\BeginStartsOnOwnLine$ & VerbatimBeginStartsOnOwnLine \\ + verbatim & before words$\BeginStartsOnOwnLine$\verb!\begin{verbatim}! & $\BeginStartsOnOwnLine$ & VerbatimBeginStartsOnOwnLine \\ \announce{2019-05-05}{verbatim poly-switches} & body of verbatim \verb!\end{verbatim}!$\EndFinishesWithLineBreak$ & $\EndFinishesWithLineBreak$ & VerbatimEndFinishesWithLineBreak \\ - & after words & & \\ + & after words & & \\ \bottomrule \end{longtable} diff --git a/support/latexindent/documentation/title.tex b/support/latexindent/documentation/title.tex index 06bbb12c35..fcbb6f6324 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.10 + \centering\ttfamily\bfseries latexindent.pl\\[1cm] Version 3.10.1 \end{tcolorbox} } \author{Chris Hughes \thanks{and contributors! See \vref{sec:contributors}. For all communication, please visit \cite{latexindent-home}.}} -\date{2021-06-19} +\date{2021-07-23} \maketitle \begin{adjustwidth}{1cm}{1cm} \small diff --git a/support/latexindent/latexindent.pl b/support/latexindent/latexindent.pl index 838b15f9dd..7813b3a657 100755 --- a/support/latexindent/latexindent.pl +++ b/support/latexindent/latexindent.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# latexindent.pl, version 3.10, 2021-06-19 +# latexindent.pl, version 3.10.1, 2021-07-23 # # 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 |