Skip to content

Commit

Permalink
bug fix to delimeter alignment and brace matching
Browse files Browse the repository at this point in the history
  • Loading branch information
cmhughes committed Dec 30, 2015
1 parent bf40100 commit b5b0309
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 11 deletions.
30 changes: 19 additions & 11 deletions latexindent.pl
Original file line number Diff line number Diff line change
Expand Up @@ -697,15 +697,15 @@
# tracing mode
if($inpreamble)
{
print $logfile "Line $lineCounter\t still in PREAMBLE, doing nothing\n" if($tracingMode);
print $logfile "Line $lineCounter\t still in PREAMBLE, leaving exisiting leading space\n" if($tracingMode);
}
elsif($inverbatim)
{
print $logfile "Line $lineCounter\t in VERBATIM-LIKE environment, doing nothing\n" if($tracingMode);
print $logfile "Line $lineCounter\t in VERBATIM-LIKE environment, leaving exisiting leading space\n" if($tracingMode);
}
elsif($inIndentBlock)
{
print $logfile "Line $lineCounter\t in NO INDENT BLOCK, doing nothing\n" if($tracingMode);
print $logfile "Line $lineCounter\t in NO INDENT BLOCK, leaving exisiting leading space\n" if($tracingMode);
}
}
}
Expand All @@ -714,7 +714,15 @@
# \END{ENVIRONMENTS}, or CLOSING } or CLOSING ]
# \END{ENVIRONMENTS}, or CLOSING } or CLOSING ]

print $logfile "Line $lineCounter\t $masterSettings{logFilePreferences}{traceModeDecreaseIndent} PHASE 1: looking for reasons to DECREASE indentation of CURRENT line \n" if($tracingMode);
if($inverbatim){
print $logfile "Line $lineCounter\t $masterSettings{logFilePreferences}{traceModeDecreaseIndent} PHASE 1: in VERBATIM-LIKE environment, looking for \\end{$environmentStack[-1]}\n" if($tracingMode);
} elsif($inIndentBlock) {
print $logfile "Line $lineCounter\t in NO INDENT BLOCK, doing nothing\n" if($tracingMode);
} elsif($delimiters) {
print $logfile "Line $lineCounter\t $masterSettings{logFilePreferences}{traceModeDecreaseIndent} PHASE 1: in ALIGNMENT BLOCK environment, looking for \\end{$environmentStack[-1]}\n" if($tracingMode);
} else {
print $logfile "Line $lineCounter\t $masterSettings{logFilePreferences}{traceModeDecreaseIndent} PHASE 1: looking for reasons to DECREASE indentation of CURRENT line \n" if($tracingMode);
}
# check to see if we have \end{something} or \]
&at_end_of_env_or_eq() unless ($inpreamble or $inIndentBlock);

Expand Down Expand Up @@ -822,7 +830,7 @@
push(@block,$_);

# tracing mode
print $logfile "Line $lineCounter\t In delimeter block, waiting for block formatting\n" if($tracingMode);
print $logfile "Line $lineCounter\t In delimeter block ($environmentStack[-1]), waiting for block formatting\n" if($tracingMode);
}

# \BEGIN{ENVIRONMENT} or OPEN { or OPEN [
Expand Down Expand Up @@ -872,27 +880,27 @@
print $logfile "Line $lineCounter\t Removing trailing comments for brace count (line is already stored)\n" if($tracingMode);

# check to see if we have \begin{something} or \[
&at_beg_of_env_or_eq();
&at_beg_of_env_or_eq() if(!($inverbatim or $inpreamble or $inIndentBlock or $delimiters));

# check to see if we have \parbox, \marginpar, or
# something similar that might split braces {} across lines,
# specified in %checkunmatched hash table
&start_command_or_key_unmatched_braces();
&start_command_or_key_unmatched_braces() if(!($inverbatim or $inpreamble or $inIndentBlock or $delimiters));

# check for an else statement (braces, not \else)
&check_for_else();
&check_for_else() if(!($inverbatim or $inpreamble or $inIndentBlock or $delimiters));

# check for a command that splits [] across lines
&start_command_or_key_unmatched_brackets();

# check for a heading
&indent_after_heading();
&indent_after_heading() if(!($inverbatim or $inpreamble or $inIndentBlock or $delimiters));

# check for \item
&indent_after_item();
&indent_after_item() if(!($inverbatim or $inpreamble or $inIndentBlock or $delimiters));

# check for \if or \else command
&indent_after_if_else_fi();
&indent_after_if_else_fi() if(!($inverbatim or $inpreamble or $inIndentBlock or $delimiters));

# tracing mode
print $logfile "Line $lineCounter\t Environments: ",join(", ",@environmentStack),"\n" if($tracingMode and scalar(@environmentStack));
Expand Down
22 changes: 22 additions & 0 deletions success/table4.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
% arara: indent: {overwrite: true, silent: on, localSettings: on}
\documentclass{article}
\usepackage{siunitx}

\begin{document}
\begin{tabular}{%
l
S[table-format=3.0]
S[table-format=3.2]
S[table-format=2.2]
S[table-format=3.2]
S[table-format=-2.2]
S[table-format=3.2]
}
Latex & 360 & 101.77 & 10.71 & 101.86 & 64.60 & 127.20 \\
Manufacturing & 360 & -7.33 & 12.59 & -7.24 & -49.00 & 22.00 \\
Cons & 360 & -17.19 & 23.4 & -17.22 & -79.00 & 43.00 \\
Apple and Orange & 360 & 3.38 & 13.84 & 3.60 & -47.00 & 29.00 \\
Services and Harry & 104 & -4.96 & 20.8 & -4.81 & -57.00 & 30.00 \\
Manchester & 360 & -9.29 & 8.64 & -9.26 & -35.00 & 8.00 \\
\end{tabular}
\end{document}
21 changes: 21 additions & 0 deletions success/verbatim1.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
% arara: indent: {overwrite: true, silent: on}
\documentclass{article}

\begin{document}
\begin{verbatim}{%
l
S[table-format=3.0]
S[table-format=3.2]
S[table-format=2.2]
S[table-format=3.2]
S[table-format=-2.2]
S[table-format=3.2]
}
Latex & 360 & 101.77 & 10.71 & 101.86 & 64.60 & 127.20 \\
Manufacturing & 360 & -7.33 & 12.59 & -7.24 & -49.00 & 22.00 \\
Cons & 360 & -17.19 & 23.4 & -17.22 & -79.00 & 43.00 \\
Apple and Orange & 360 & 3.38 & 13.84 & 3.60 & -47.00 & 29.00 \\
Services and Harry & 104 & -4.96 & 20.8 & -4.81 & -57.00 & 30.00 \\
Manchester & 360 & -9.29 & 8.64 & -9.26 & -35.00 & 8.00 \\
\end{verbatim}
\end{document}

0 comments on commit b5b0309

Please sign in to comment.