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 or preserve empty line between CSS rules #467

Closed
drewhamlett opened this issue May 20, 2014 · 16 comments
Closed

Add or preserve empty line between CSS rules #467

drewhamlett opened this issue May 20, 2014 · 16 comments

Comments

@drewhamlett
Copy link

Forgive me if this has been asked before but is there a way to keep spacing between CSS rules when formatting?

.login {
    margin-top: 30px;
    padding: 30px;
    background: rgba(255, 255, 255, 0.7);
}

.login.btn {
    border-radius: 0;
    background-color: #5C6166;
    border-color: #4a4a4a;
}

To:

.login {
    margin-top: 30px;
    padding: 30px;
    background: rgba(255, 255, 255, 0.7);
}
.login.btn {
    border-radius: 0;
    background-color: #5C6166;
    border-color: #4a4a4a;
}
@noducks
Copy link

noducks commented Jul 2, 2014

+1

2 similar comments
@ThanosSamarinas
Copy link

+1

@redrbrt
Copy link

redrbrt commented Aug 7, 2014

+1

@Atid-Gharbi
Copy link

There is an option called "end_with_newline", I thought this adds a new line between blocks, but it just puts an empty line at the end of the file :-/

I hope this gets fixed, I love beautify but this issue (as silly as this may sound) is a deal-breaker for me.

@Atid-Gharbi
Copy link

I have fixed this, at least for simple CSS documents, by adding a new line after every }

go to \Packages\HTML-CSS-JS Prettify\scripts\node_modules\js-beautify\js\lib\beautify-css.js
Find this section of code:

print["}"] = function (ch) {
            print.newLine();
            output.push(ch);
            print.newLine();
        };

and change it to

print["}"] = function (ch) {
            print.newLine();
            output.push(ch);
            print.newLine();
            output.push('\n');
        };

@bitwiseman bitwiseman changed the title Space between CSS rules? Add newline between CSS rules Sep 30, 2014
@bitwiseman bitwiseman changed the title Add newline between CSS rules Add or preserve empty line between CSS rules Sep 30, 2014
@bitwiseman bitwiseman added this to the v1.6.0 milestone Sep 30, 2014
@bitwiseman
Copy link
Member

@Atid-G, that's great! Please provide a pull request with tests (and python port).

This was referenced Sep 30, 2014
@malexandre
Copy link

I think the fix from @Atid-G will not be sufficient. In a nested property, we don't need to add a new line after the closing bracket. I know that's for less/scss, but I think this is also used to beautify thos languages.

Example :

.rule-1 {
    display: block;

    .rule-2 {
        float: left;
    } // New line needed after this bracket

    .rule-3 {
        display: none;
    } // No new line needed
}

@bitwiseman
Copy link
Member

@drewhamlett, I just took a merge, but I'm not sure it fully addresses what you wanted here. Could you take a look?

@joseluisq
Copy link

As @bitwiseman says this enhancement is covered at #574 pull request.
Please check it out and close this issue.

Waiting for the next version..

@bitwiseman bitwiseman modified the milestones: v1.5.5, v1.6.0 Mar 6, 2015
@bitwiseman
Copy link
Member

Okay, I'm going to call this good and we can reopen if it turn out not to be so.

@nevace
Copy link

nevace commented Jul 12, 2015

As @malexandre said, would it be possible to add new lines within nested properties? Everything is looking bunched up in sass and the linter is complaining about it too. I have media queries nested in a lot of properties so it's quite hard to read.

@bitwiseman
Copy link
Member

@nevace, it sounds like you're talking about a different issue. Please open a new issue with example of input, current output, and desired output. Please include any pertinent settings.

@evanjmg
Copy link

evanjmg commented Aug 11, 2016

has this been fixed?

@joseluisq
Copy link

has this been fixed?

#574

@alejandroiglesias
Copy link

@bitwiseman: I opened the new ticket myself since I think it's highly relevant #1258.

@ciel
Copy link

ciel commented Sep 22, 2017

This would be so great. I wish js-beautify obeyed sass-lint more explicitly, but this is the only feature that's giving me a lot of trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests