Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: oneSentencePerLine ignore specific commands #419

Closed
tdegeus opened this issue Feb 7, 2023 · 4 comments
Closed

feature request: oneSentencePerLine ignore specific commands #419

tdegeus opened this issue Feb 7, 2023 · 4 comments
Labels
enhancement enhancement which might be to an existing feature or the development of a new feature feature-request user-centred feature request for an enhancement to an existing feature, or for a new feature implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix one-sentence-per-line one sentence per line; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch

Comments

@tdegeus
Copy link
Contributor

tdegeus commented Feb 7, 2023

I like modifyLineBreaks a lot, but I do find that it is a bit too aggressive in some cases.
I would like to be able to exclude specific commands from the line break manipulation.
For example, the settings could be as follows:

modifyLineBreaks:
  oneSentencePerLine:
    manipulateSentences: 1
    removeSentenceLineBreaks: 1
    multipleSpacesToSingle: 1
    ignoreCommands: ['\TG', '\section']
    ignoreEnvironments: ['verbatim', 'myenv']

original .tex code

\section{Foo? Bar?}

I do not\TG{?} want this to change.
But this
should change.

yaml settings

onlyOneBackUp: 1
defaultIndent: '    '
removeTrailingWhitespace: 1

modifyLineBreaks:
  oneSentencePerLine:
    manipulateSentences: 1
    removeSentenceLineBreaks: 1
    multipleSpacesToSingle: 1

actual/given output

\section{Foo?
  Bar?
 }

I do not\TG{?
} want this to change.
But this should change.

desired or expected output

\section{Foo? Bar?}

I do not\TG{?} want this to change.
But this should change.

anything else

@cmhughes Sorry for the amount of issues. They have been accumulating for a while, as I had little time to prepare minimal reproducers.

@cmhughes cmhughes added the one-sentence-per-line one sentence per line; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch label Feb 9, 2023
@cmhughes
Copy link
Owner

This seems related to #418

@tdegeus
Copy link
Contributor Author

tdegeus commented Feb 20, 2023

Here I am suggesting that it would be very nice to have the option to have oneSentencePerLine simply act as if a command is not there altogether everywhere in the formatted file.

Instead, in #418 I am suggesting that it would be good to have the option to switch of (a part of) latexindent.pl on a specific line of code.

@cmhughes cmhughes added feature-request user-centred feature request for an enhancement to an existing feature, or for a new feature enhancement enhancement which might be to an existing feature or the development of a new feature labels May 26, 2023
@cmhughes cmhughes changed the title feature request: modifyLineBreaks ignore specific commands feature request: oneSentencePerLine ignore specific commands Aug 31, 2023
@cmhughes
Copy link
Owner

cmhughes commented Sep 9, 2023

As of 167c88e I've implemented a new feature sentencesDoNOTcontain.

default

The default is

        sentencesDoNOTcontain:
            other: \\begin                  # regex

which means that sentences do not contain \begin

demonstration 1

Starting with your file, and using

modifyLineBreaks:
    oneSentencePerLine:
        manipulateSentences: 1
        sentencesDoNOTcontain:
            other: \\TG

and the output is

\section{Foo?
  Bar?
 }

I do not\TG{?} want this to change.
But this should change.

demonstration 2

If we want the output that you've specified, then we can use

modifyLineBreaks:
    oneSentencePerLine:
        manipulateSentences: 1
        sentencesDoNOTcontain: 
            other: |-
              (?x)
              (?:
                \\begin
                |
                \\TG
              )
        sentencesFollow:
            questionMark: 0                 # 0/1
            other: |-
              (?x)
              \h+[a-zA-Z]+?
              \?

and then we receive

\section{Foo? Bar?}

I do not\TG{?} want this to change.
But this should change.

finally

I'll get this released soon.

@cmhughes cmhughes added the implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix label Sep 9, 2023
@cmhughes
Copy link
Owner

cmhughes commented Sep 9, 2023

@cmhughes cmhughes closed this as completed Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement enhancement which might be to an existing feature or the development of a new feature feature-request user-centred feature request for an enhancement to an existing feature, or for a new feature implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix one-sentence-per-line one sentence per line; documented at https://latexindentpl.readthedocs.io/en/latest/sec-the-m-switch
Projects
None yet
Development

No branches or pull requests

2 participants