Skip to content

Commit

Permalink
text wrap: small tweak to 'after' routine, following #444
Browse files Browse the repository at this point in the history
  • Loading branch information
cmhughes committed May 6, 2023
1 parent cd06487 commit f815f57
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 5 deletions.
2 changes: 1 addition & 1 deletion LatexIndent/Wrap.pm
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ sub text_wrap {

# store the text wrap blocks
my @textWrapBlockStorage = split( /($blocksFollow)/, ${$self}{body} );
@textWrapBlockStorage = split( /(\s*$blocksFollow)/, ${$self}{body} )
@textWrapBlockStorage = split( /(\s*$blocksFollow+)/, ${$self}{body} )
if ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after';

# sentences need special treatment
Expand Down
9 changes: 5 additions & 4 deletions documentation/subsubsec-no-add-remaining-code-blocks.tex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ \subsubsection{The remaining code blocks}
\end{example}

\paragraph{namedGroupingBracesBrackets} This type of code block is mostly motivated by
tikz-based code; we define this code block as follows:
tikz-based code; we define this code block as follows:
\begin{itemize}
\item it must immediately follow either \emph{horizontal space} OR \emph{one or more
line breaks} OR \lstinline!{! OR \lstinline![! OR \lstinline!$! OR \lstinline!)!
Expand Down Expand Up @@ -77,8 +77,9 @@ \subsubsection{The remaining code blocks}
\end{itemize}
\end{example}

\paragraph{UnNamedGroupingBracesBrackets} occur in a variety of situations; specifically,
we define this type of code block as satisfying the following criteria:
\paragraph{UnNamedGroupingBracesBrackets} occur in a variety of situations;
specifically, we define this type of code block as satisfying the following
criteria:
\begin{itemize}
\item it must immediately follow either \lstinline!{! OR \lstinline![! OR
\lstinline!,! OR \lstinline!&! OR \lstinline!)! OR \lstinline!(! OR
Expand Down Expand Up @@ -117,7 +118,7 @@ \subsubsection{The remaining code blocks}
\texttt{always-un-named}.

\paragraph{filecontents} code blocks behave just as \texttt{environments}, except that
neither arguments nor items are sought.
neither arguments nor items are sought.

\subsubsection{Summary}
\index{indentation!summary}
Expand Down
11 changes: 11 additions & 0 deletions test-cases/text-wrap/issue-444-mod1.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
\begin{itemize}

\item Let \(G\) be a maximal planar graph; we wish to show that every drawing
of \(G\) has only triangular faces (counting the ``unbounded'' face also
as a triangle).

Recall Euler's formula for planar graphs, \(V+E-F=2\).

\end{itemize}
----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90
11 changes: 11 additions & 0 deletions test-cases/text-wrap/issue-444-mod2.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
\begin{itemize}

\item Let \(G\) be a maximal planar graph; we wish to show that every drawing of
\(G\) has only triangular faces (counting the ``unbounded'' face also as a
triangle).

Recall Euler's formula for planar graphs, \(V+E-F=2\).

\end{itemize}
----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90
12 changes: 12 additions & 0 deletions test-cases/text-wrap/issue-444-mod3.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
\begin{itemize}

\item
Let \(G\) be a maximal planar graph; we wish to show that every drawing of
\(G\) has only triangular faces (counting the ``unbounded'' face also as a
triangle).

Recall Euler's formula for planar graphs, \(V+E-F=2\).

\end{itemize}
----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90
7 changes: 7 additions & 0 deletions test-cases/text-wrap/issue-444.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\begin{itemize}

\item Let \(G\) be a maximal planar graph; we wish to show that every drawing of \(G\) has only triangular faces (counting the ``unbounded'' face also as a triangle).

Recall Euler's formula for planar graphs, \(V+E-F=2\).

\end{itemize}
17 changes: 17 additions & 0 deletions test-cases/text-wrap/issue-444.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defaultIndent: ' '
indentRules:
item: " "
modifyLineBreaks:
textWrapOptions:
columns: 80
when: "after"

replacements:
-
substitution: |-
s!\z!
my $rulerMax = int(80/10 +1.5 )*10;
my $ruler = (("----|"x(int($rulerMax/5))))."\n";
for (my $i=1;$i<=$rulerMax/5;$i++){ $ruler .= " ".$i*5 };
$ruler;!sxe
when: after
10 changes: 10 additions & 0 deletions test-cases/text-wrap/issue-444a-mod1.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\begin{itemize}
\item Let \(G\) be a maximal planar graph; we wish to show that every
drawing of \(G\) has only triangular faces (counting the
``unbounded'' face also as a triangle).

Recall Euler's formula for planar graphs, \(V+E-F=2\).

\end{itemize}
----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90
6 changes: 6 additions & 0 deletions test-cases/text-wrap/issue-444a.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
\begin{itemize}
\item Let \(G\) be a maximal planar graph; we wish to show that every drawing of \(G\) has only triangular faces (counting the ``unbounded'' face also as a triangle).

Recall Euler's formula for planar graphs, \(V+E-F=2\).

\end{itemize}
16 changes: 16 additions & 0 deletions test-cases/text-wrap/issue-444a.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
indentRules:
item: " "
modifyLineBreaks:
textWrapOptions:
columns: 80
when: "before"

replacements:
-
substitution: |-
s!\z!
my $rulerMax = int(80/10 +1.5 )*10;
my $ruler = (("----|"x(int($rulerMax/5))))."\n";
for (my $i=1;$i<=$rulerMax/5;$i++){ $ruler .= " ".$i*5 };
$ruler;!sxe
when: after
19 changes: 19 additions & 0 deletions test-cases/text-wrap/issue-444b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
defaultIndent: ' '
indentRules:
item: " "
modifyLineBreaks:
textWrapOptions:
columns: 80
when: "after"
items:
ItemFinishesWithLineBreak: 1

replacements:
-
substitution: |-
s!\z!
my $rulerMax = int(80/10 +1.5 )*10;
my $ruler = (("----|"x(int($rulerMax/5))))."\n";
for (my $i=1;$i<=$rulerMax/5;$i++){ $ruler .= " ".$i*5 };
$ruler;!sxe
when: after
7 changes: 7 additions & 0 deletions test-cases/text-wrap/text-wrap-remove-PLB.sh
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ latexindent.pl -s -r -m -l wrap-comments5.yaml,addruler1.yaml issue-389l.tex -o=

latexindent.pl -s -m -l issue-412.yaml issue-412.tex -o=+-mod1

# issue 444: text wrap after
latexindent.pl -s -m -r -l issue-444.yaml issue-444.tex -o=+-mod1
latexindent.pl -s -m -r -l issue-444a.yaml issue-444.tex -o=+-mod2
latexindent.pl -s -m -r -l issue-444b.yaml issue-444.tex -o=+-mod3

latexindent.pl -s -m -r -l issue-444.yaml issue-444a.tex -o=+-mod1

set +x
[[ $gitStatus == 1 ]] && git status
[[ $noisyMode == 1 ]] && makenoise
Expand Down

0 comments on commit f815f57

Please sign in to comment.