Closed tdegeus closed 1 year ago
Please use the issue template, then I'll look at it.
ok. edited.
Starting with
This is some text. That needs formatting
\detail{
\begin{equation}
\begin{split}
a = b \\
c = d
\end{split}
\end{equation}
}
that ends here.
and using
modifyLineBreaks:
oneSentencePerLine:
manipulateSentences: 1
environments:
BeginStartsOnOwnLine: 1
BodyStartsOnOwnLine: 1
EndStartsOnOwnLine: 1
EndFinishesWithLineBreak: 1
DBSFinishesWithLineBreak: 1
commands: # <!--- NEW BIT
detail: # <!--- NEW BIT
CommandStartsOnOwnLine: 1 # <!--- NEW BIT
mandatoryArguments: # <!--- NEW BIT
detail: # <!--- NEW BIT
RCuBFinishesWithLineBreak: 1 # <!--- NEW BIT
gives
This is some text.
That needs formatting
\detail{
\begin{equation}
\begin{split}
a = b \\ c = d
\end{split}
\end{equation}
}
that ends here.
Oh, and if you want the DBSFinishesWithLineBreak
to activate, then you need to use
lookForAlignDelims:
split: 1
Here's the complete YAML
lookForAlignDelims:
split: 1
modifyLineBreaks:
oneSentencePerLine:
manipulateSentences: 1
environments:
BeginStartsOnOwnLine: 1
BodyStartsOnOwnLine: 1
EndStartsOnOwnLine: 1
EndFinishesWithLineBreak: 1
DBSFinishesWithLineBreak: 1
commands: # <!--- NEW BIT
detail: # <!--- NEW BIT
CommandStartsOnOwnLine: 1 # <!--- NEW BIT
mandatoryArguments: # <!--- NEW BIT
detail: # <!--- NEW BIT
RCuBFinishesWithLineBreak: 1 # <!--- NEW BIT
then you receive
This is some text.
That needs formatting
\detail{
\begin{equation}
\begin{split}
a = b \\
c = d
\end{split}
\end{equation}
}
that ends here.
Thanks. However, it does not work for me:
onlyOneBackUp: 1
defaultIndent: ' '
removeTrailingWhitespace: 1
lookForAlignDelims:
align: 0
modifyLineBreaks:
oneSentencePerLine:
manipulateSentences: 1
removeSentenceLineBreaks: 1
textWrapSentences: 1
multipleSpacesToSingle: 1
mandatoryArguments:
footnote:
MandArgBodyStartsOnOwnLine: 1
RCuBFinishesWithLineBreak: 1
detail:
MandArgBodyStartsOnOwnLine: 1
RCuBFinishesWithLineBreak: 1
commands:
label:
CommandStartsOnOwnLine: 1
detail:
CommandStartsOnOwnLine: 1
items:
ItemFinishesWithLineBreak: 1
environments:
BeginStartsOnOwnLine: 1
BodyStartsOnOwnLine: 1
EndStartsOnOwnLine: 1
EndFinishesWithLineBreak: 1
DBSFinishesWithLineBreak: 1
indentRules:
item: ' '
fineTuning:
namedGroupingBracesBrackets:
name: '[0-9\.a-zA-Z@\*><_]+?'
# remove recurrent spaces
replacements:
- substitution: s/([a-zA-Z0-9.}{])\h{2,}([a-zA-Z0-9.}{])/$1 $2/sg
when: before
- substitution: s/([a-zA-Z0-9.()}{])\h{2,}([a-zA-Z0-9.()}{]|(?:\\(?!\\)))/$1 $2/sg
when: after
formats to
This is some text.
That needs formatting
\detail{
\begin{equation}
\begin{split}
a = b \\ c = d
\end{split}
\end{equation}
}
that ends here.
You need this bit
lookForAlignDelims:
split: 1
to give
This is some text.
That needs formatting
\detail{
\begin{equation}
\begin{split}
a = b \\
c = d
\end{split}
\end{equation}
}
that ends here.
I see, thanks. It is not exactly what I hoped to have, that is that
This is some text. That needs formatting
\detail{
\begin{equation}
\begin{split}
a = b + c \\
d = e \\
f = g
\end{split}
\end{equation}
}
that ends here.
would not be formatted with
lookForAlignDelims:
align: 0
split: 0
modifyLineBreaks:
environments:
DBSFinishesWithLineBreak: 1
both split
and equation
are an environment, so I would expect the double backslash to be forced to have a line break. Instead, it is formatted to
This is some text.
That needs formatting
\begin{equation}
\begin{split}
a = b + c \\ d = e \\ f = g
\end{split}
\end{equation}
that ends here.
which I would say to contradict the DBSFinishesWithLineBreak: 1
.
What does work as expected (though not what I wanted), is that with
lookForAlignDelims:
align: 1
split: 1
modifyLineBreaks:
environments:
DBSFinishesWithLineBreak: 1
the text is formatted to:
This is some text.
That needs formatting
\detail{
\begin{equation}
\begin{split}
a = b + c \\
d = e \\
f = g
\end{split}
\end{equation}
}
that ends here.
Ok I got it:
lookForAlignDelims:
align:
delims: 1
alignDoubleBackSlash: 0
split:
delims: 1
alignDoubleBackSlash: 0
but I'm still a bit confused that DBSFinishesWithLineBreak
did not do it.
Great, thanks.
I'm going to consider this a feature request: see if it's possible to enable DBS
poly-switches can work without requiring lookForAlignDelims
.
This came up in https://github.com/cmhughes/latexindent.pl/issues/393 from @ankitp94. I'd hope this won't take too long, but I'm currently working on text wrapping.
As of https://github.com/cmhughes/latexindent.pl/commit/3ef192c9a08ff79ede947f21508f68739e0b3d87, this is implemented. Specifically, there is now no longer a need to specify a code block within lookForAlignDelims
.
This will be part of the next release (early 2023), let's leave this open until then. Demonstrations below.
starting with
This is some text. That needs formatting
\detail{
\begin{equation}
\begin{split}
a = b \\
c = d
\end{split}
\end{equation}
}
that ends here.
and using
defaultIndent: ' '
modifyLineBreaks:
oneSentencePerLine:
manipulateSentences: 1
textWrapSentences: 1
environments:
BeginStartsOnOwnLine: 1
BodyStartsOnOwnLine: 1
EndStartsOnOwnLine: 1
EndFinishesWithLineBreak: 1
DBSFinishesWithLineBreak: 1
gives
This is some text.
That needs formatting \detail{
\begin{equation}
\begin{split}
a = b \\
c = d
\end{split}
\end{equation}
} that ends here.
starting with
This is some text.
That needs formatting
\[
a = b + c \\ d = e \\ f = g
\]
that ends here.
and using
defaultIndent: ' '
modifyLineBreaks:
oneSentencePerLine:
manipulateSentences: 1
textWrapSentences: 1
specialBeginEnd:
DBSFinishesWithLineBreak: 2
SpecialBeginStartsOnOwnLine: 1
SpecialBodyStartsOnOwnLine: 1
SpecialEndStartsOnOwnLine: 1
SpecialEndFinishesWithLineBreak: 1
gives
This is some text.
That needs formatting
\[
a = b + c \\%
d = e \\%
f = g
\]
that ends here.
starting with
This is some text.
That needs formatting
\cmh{
a = b + c \\ d = e \\ f = g
}
that ends here.
and using
defaultIndent: ' '
modifyLineBreaks:
oneSentencePerLine:
manipulateSentences: 1
textWrapSentences: 1
mandatoryArguments:
MandArgBodyStartsOnOwnLine: 1
RCuBStartsOnOwnLine: 1
RCuBFinishesWithLineBreak: 1
DBSFinishesWithLineBreak: 2
gives
This is some text.
That needs formatting \cmh{
a = b + c \\%
d = e \\%
f = g
}
that ends here.
That's amazing, and makes a lot of sense. Thanks a lot!
This is part of V3.20
at https://github.com/cmhughes/latexindent.pl/releases/tag/V3.20. I've uploaded it to ctan
. Many thanks!
original .tex code
yaml settings
actual/given output
desired or expected output