Closed tdegeus closed 1 year ago
Thanks for using the issue template :)
Using the settings
defaultIndent: ' '
modifyLineBreaks:
oneSentencePerLine:
manipulateSentences: 1
sentencesBeginWith:
other: |-
(?x)
\\emph\{[A-Z]
sentencesEndWith:
questionMark: 0 # 0/1
other: |-
(?x)
(?<! # not *preceeded by*
(?: #
[A-Z] #
) #
)
\? # ?
(?! # NOT *followed by* ---|
(?: # |
\) # ) |
| # |
\} # } |
) # |
\h* # possible horizontal space |
[a-z] # a-z ---
) #
[})]? # possible } or )
gives
\emph{First sentence?}
Second (third?) sentence?
\emph{Third sentence?}
Fourth sentence?
I've incorporated the settings from https://github.com/cmhughes/latexindent.pl/issues/408 and https://github.com/cmhughes/latexindent.pl/issues/406 as I'm assuming they're related... delete if not.
Let's start with the easiest part:
sentencesBeginWith:
other: |-
(?x)
\\emph\{[A-Z]
This says that sentences can begin with \emph{
and then a capital letter. Adjust as necessary.
The harder part is:
sentencesEndWith:
questionMark: 0 # 0/1
other: |-
(?x)
(?<! # not *preceeded by*
(?: #
[A-Z] #
) #
)
\? # ?
(?! # NOT *followed by* ---|
(?: # |
\) # ) |
| # |
\} # } |
) # |
\h* # possible horizontal space |
[a-z] # a-z ---
) #
[})]? # possible } or )
We first of all need to turn off the 'basic' question mark.
Then we need to ensure that:
?
can not be followed by } [a-z]
or ) [a-z]
so that, for example the ?
in (third?) sentence
is not the end of a sentence?
can be followed by either }
or )
I hope this helps, let me know if not.
I'm assuming this is resolved, let me know if not!
Thanks. What was a bit hidden at the at of my question is if there is a way to manually help latexindent for some edge-cases. Like for example in Python one can add a comment to the end of the line with noqa
As always, please provide before and after
Any update on before /after?
Hi. Sorry for the radio silence. My perspective is that:
It should be great to have a switch to turn-off grouping comments.
If that is unwanted, if would still be good to have a way to manually format a line if you want to. So in that case for example the following example should not be formatted (before == after):
\emph{First sentence?}
Second (third?) sentence?
\emph{Third sentence?} % noqa: oneSentencePerLine
Fourth sentence?
So you want oneSentencePerLine to leave comments in place? And I'm assuming you want to text wrapping to obey all of this as well?
Indeed, I would like the option to leave the comments where they are
OK, so comments staying on same line at the end of sentence.
Keeping them exactly where they are won't happen.
On Fri, 6 Jan 2023, 15:01 Tom de Geus, @.***> wrote:
Indeed, I would like the option to leave the comments where they are
— Reply to this email directly, view it on GitHub https://github.com/cmhughes/latexindent.pl/issues/409#issuecomment-1373741336, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ7CYHP7ZE4N5J7WGV3L3DWRAXTLANCNFSM6AAAAAATOWZFO4 . You are receiving this because you modified the open/close state.Message ID: @.***>
I would say that the 'issue' here is fixed. Not to mix things, I have started a general discussion in https://github.com/cmhughes/latexindent.pl/issues/418 .
Please provide the following when posting an issue:
original .tex code
yaml settings
actual/given output
desired or expected output
anything else
As observed, the output of this example is quite a mess. The second sentence is broken where is grammatically should not have been, whereas the third and fourth sentences are not broken and even merged.
There is the solution of https://github.com/cmhughes/latexindent.pl/issues/406 to have
which formats the original example somewhat better
but still not what I desire above.
Then I thought. Well ok, there is some difficulty, let's manually help
latexindent
. But there is no such way without switching off formatting in the entire block. What would be ideal that in certain edge cases one could(or so)