Closed dpo closed 1 year ago
I presume this issue is addressed here: https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html?highlight=itemize#lst-manipulate-sentences-yaml
I apologize for raising issues with a documented solution; the documentation is extensive but (to me) intricate to navigate.
I came up with the following to try and account for parenthetical sentences as well:
modifyLineBreaks:
oneSentencePerLine:
manipulateSentences: 1
removeSentenceLineBreaks: 0
sentencesBeginWith:
A-Z: 0
a-z: 0
other: "\([A-Z]|[A-Z]"
sentencesEndWith:
basicFullStop: 0
betterFullStop: 0
exclamationMark: 0
questionMark: 0
other: "\.\)|\?\)|\!\)|\. |\? |\! "
Result:
We compare
\begin{itemize}
\item R2
\item TR-R2 (maybe?)
\item TRDH
\end{itemize}
but, surprisingly, this solution has nothing to do with the itemize
environment! Unfortunately, removeSentenceLineBreaks: 0
would have been useful elsewhere in the document. I'm not sure if it's possible to have it both ways.
Thanks for this.
They key thing is to think about what a sentence is. Your settings say that a sentence can start with an uppercase letter, and can finish with a question mark.
There is not currently a way to say 'sentence does not contain' but it's on the list at https://github.com/cmhughes/latexindent.pl/issues/419 which I'm hoping to get to soon.
In the meantime you can either tweak the sentence routine or otherwise set some poly switches as in https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html#lst-multiple-sentences4-mod3
Does this help?
They key thing is to think about what a sentence is. Your settings say that a sentence can start with an uppercase letter, and can finish with a question mark.
Well, they say more than that, right? A sentence can also start with a left paren followed by a capital letter, and can end with a full stop/question mark/exclamation mark, followed by either a right paren or a space.
Here are some settings for you to consider/explore:
using the settings
modifyLineBreaks:
oneSentencePerLine:
manipulateSentences: 1
items:
ItemStartsOnOwnLine: 1
environments:
BeginStartsOnOwnLine: 1
BodyStartsOnOwnLine: 1
EndStartsOnOwnLine: 1
EndFinishesWithLineBreak: 1
gives
We compare
\begin{itemize}
\item R2
\item TR-R2 (maybe?
)
\item TRDH
\end{itemize}
which isn't quite as we would like. So, to attempt 2.
We customise sentencesEndWith
field (see https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch.html#onesentenceperline-sentencesendwith) as follows
modifyLineBreaks:
oneSentencePerLine:
manipulateSentences: 1
sentencesEndWith:
questionMark: 0 # 0/1
other: |-
(?x)
(?: #
\?\)? # ?) OR ?
)
items:
ItemStartsOnOwnLine: 1
environments:
BeginStartsOnOwnLine: 1
BodyStartsOnOwnLine: 1
EndStartsOnOwnLine: 1
EndFinishesWithLineBreak: 1
We have turned off the basic question mark and used a more sophisticated version
other: |-
(?x)
(?: #
\?\)? # ?) OR ?
)
Let's go through this:
(?x)
says that the regex can have space within it, and that the space will be ignored(?:
opens a non-capturing set of parenthesis\?\)?
means 'a ? possibly followed by a )')
closes the non-capturing set of parenthesisAs of https://github.com/cmhughes/latexindent.pl/commit/167c88ef353ce5bdc2266eb4ff205b1d66715aef I've implemented a new feature sentencesDoNOTcontain.
The default is
sentencesDoNOTcontain:
other: \\begin # regex
and so the default output is now as you request
We compare
\begin{itemize}
\item R2
\item TR-R2 (maybe?)
\item TRDH
\end{itemize}
I'll get this released soon.
Please provide the following when posting an issue:
original .tex code
yaml settings
actual/given output
desired or expected output
Not sure, but I am not expecting the
itemize
environment to be merged with the first line and two\item
s to end up on the same line. I understand that the?
is taken as the end of a sentence, and that a line break is added. Maybe I would expect something likeanything else
With all default settings, the output is
and so I don't expect
oneSentencePerLine
to wreck something that wasn't wrecked before. What is happening here?