Js-beautify: CSS: Preserve Newlines

Created on 25 Sep 2014  ·  17Comments  ·  Source: beautify-web/js-beautify

Maybe I'm not configuring it correctly, or maybe it's missing, but I have a great need for preserving my newlines in my css and can't seem to get it to work.

Here's my config:

"css": {
  "allowed_file_extensions": ["css", "scss", "sass", "less"],
  "end_with_newline": true,
  "indent_char": " ",
  "indent_size": 2,
  "selector_separator": " ",
  "selector_separator_newline": false,
  "preserve_newlines": true
}
css enhancement

Most helpful comment

+1² for SCSS files.

Issue #563 also has a similar problem. When I save/format a .scss file, the variables at the top and the import calls are all put together, making it hard to maintain. Would be super to just detect empty lines and keep them :+1:

Just for reference:

@import "config";

$background: #ececec;
$color: #00aec8;

body {
    font-size: $font-size;
}

... goes like this:

@import "config";
$background: #ececec;
$color: #00aec8;
body {
    font-size: $font-size;
}

All 17 comments

Nope, css-beautifier does not have a preserve_newlines option yet.

+1

+1
would be nice to have

+1² for SCSS files.

Issue #563 also has a similar problem. When I save/format a .scss file, the variables at the top and the import calls are all put together, making it hard to maintain. Would be super to just detect empty lines and keep them :+1:

Just for reference:

@import "config";

$background: #ececec;
$color: #00aec8;

body {
    font-size: $font-size;
}

... goes like this:

@import "config";
$background: #ececec;
$color: #00aec8;
body {
    font-size: $font-size;
}

+1

+1 !!

Since HTML/CSS/JS Prettify plugin apparently draws on this? using that to clean up CSS and SCSS is kind of wonky, basically useless for a long time now -- cleaning up a large enough file by hand and leaving spaces, only to it all mashed back up together by this process is a frustration .. would be really awesome to get a fix in there thanks!

:+1:

+1

+1

+1

+1

+1

+1

Is there an alternative, like an active library or something?

"Active library"?

+1

@reza3vi What are you +1-ing? This is fixed.

Was this page helpful?
0 / 5 - 0 ratings