Js-beautify: Preserve space between selector and > combinator

Created on 12 Oct 2016  ·  6Comments  ·  Source: beautify-web/js-beautify

When beautifying a CSS rule containing a > combinator, the combinator got stuck to the previous selector. Actually, even if it already formatted correctly, the space is removed. It makes quite difficult to use js-beautify in CSS files containing > combinators because it will produce selectors that won't work.

Input

The code looked like this before beautification:

.foo > h3 {
    ...
}

Expected Output

I would expect the input to not change. The code should have looked like this after beautification:

/* Space here
    V */
.foo > h3 {
    ...
}

Actual Output

The code actually looked like this after beautification:

/* No space 
   V */
.foo> h3 {
    ...
}

Environment

OS: Archlinux with Emacs web-beautify.el

Also tested under command line only outside of Emacs.

Settings

Defaults

css bug

Most helpful comment

Hello! I still have a "no space" around any sibiling selector when I beautify a css file.
I actually use atom-beautify.

All 6 comments

It has been fixed in 1.6.4, it don't happen anymore since I set space_around_combinator to true, my bad. This param should be true by default though.

Hello! I still have a "no space" around any sibiling selector when I beautify a css file.
I actually use atom-beautify.

Me too

@NSExceptional @subfighter3

https://beautifier.io/ with setting:

{
"space_around_combinator": true
}

Formats as expected. Fix will be needed in atom beautifier.

Thanks!

Thank you!

Was this page helpful?
0 / 5 - 0 ratings