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

Add blank line before every section marker? #146

Closed
alok opened this issue Oct 18, 2018 · 7 comments
Closed

Add blank line before every section marker? #146

alok opened this issue Oct 18, 2018 · 7 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

Comments

@alok
Copy link

alok commented Oct 18, 2018

I want something like

\section
...

to always have a blank line inserted between if there isn't one already. I looked at the modifyLineBreaks settings but wasn't able to figure it out.

@cmhughes
Copy link
Owner

Please provide examples of what your code looks like before and what you would like it to look like after.

@alok
Copy link
Author

alok commented Oct 18, 2018

before

\section{Introduction}
A sentence

after

\section{Introduction}

A sentence.

@cmhughes
Copy link
Owner

This is not possible with the current implementation of latexindent.

If you started with

\section{introduction} a sentence

then we could produce

\section{introduction}

a sentence

using

modifyLineBreaks:
    mandatoryArguments:
        RCuBFinishesWithLineBreak: 3

I'm not in a position to say that I can take this on. It would mean the full development of a new polyswitch; furthermore, every single one of the core regular expressions would need overhauling, which would represent an absolutely massive task. Sorry about this.

@cmhughes
Copy link
Owner

A work around is to run latexindent twice, as follows:

alok1.yaml

modifyLineBreaks:
    mandatoryArguments:
        section:
            RCuBFinishesWithLineBreak: -1

and

alok2.yaml

modifyLineBreaks:
    mandatoryArguments:
        section:
            RCuBFinishesWithLineBreak: 3

and then run

latexindent -m -o=+-mod1 -l=alok1.yaml myfile.tex
latexindent -m -l=alok2.yaml myfile-mod1.tex

and you'll receive your desired output.

@cmhughes
Copy link
Owner

I've been thinking about this a lot.

Since I posted my work around, I've been wondering if the internal calls to the relevant polyswitch/line break parts could be tweaked in such a way so that if, for example, a polyswitch is specified as 4 could the polyswitch/line break parts be called first of all with a temporary value of -1 (line break removal) and then with a value of 3 (add blank line mode)....

This would mean that the core regular expressions would be left alone (win!) and that the testing would not be too arduous because the new polyswitch is formed by combining existing ones....

I'm going to reopen this issue, and commit to exploring this idea. I'll report back.

@cmhughes cmhughes reopened this Oct 21, 2018
@cmhughes cmhughes added 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 labels Nov 3, 2018
@cmhughes
Copy link
Owner

cmhughes commented Jul 7, 2019

As of cd8312d, a new poly-switch value of 4 is implemented which facilitates the feature you describe.

If you start with

section1.tex

\section{Introduction}
A sentence

and the YAML:

tmp.yaml

modifyLineBreaks:
    mandatoryArguments:
        RCuBFinishesWithLineBreak: 4

and run

latexindent.pl -m  section1.tex -l=tmp.yaml

then you receive

\section{Introduction}

A sentence

I'm preparing a new release soon.

Thanks for getting in touch!

@cmhughes cmhughes added the implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix label Jul 7, 2019
@cmhughes cmhughes mentioned this issue Jul 13, 2019
@cmhughes
Copy link
Owner

Implemented as of #169 upload to ctan soon.

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
Projects
None yet
Development

No branches or pull requests

2 participants