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

CSS: Preserve white space before pseudo-class and pseudo-element selectors #985

Conversation

Konamiman
Copy link
Contributor

This issue was raised in a question in Meta Stack Overflow - Stack Overflow uses js-beautify in the code snippets editor.

As explained in the question, the CSS beautifier is converting tr :first-child {...} into tr:first-child {...}, which is incorrect since both things don't mean the same. This change fixes this.

…preserved, since "a :b" is not the same as "a:b"
@Konamiman
Copy link
Contributor Author

I have changed the beautify-css.js file and added the appropriate js tests. Python tests have been automatically added but they fail. Why?

@bitwiseman
Copy link
Member

Ah, you need to update the python implementation as well. It is really easy.
https://github.com/beautify-web/js-beautify/blob/master/python/cssbeautifier/__init__.py

@@ -409,6 +409,10 @@ def beautify(self):
else:
# sass/less parent reference don't use a space
# sass nested pseudo-class don't use a space

# preserve space before pseudoclasses/pseudoelements, as it means "in any child"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alignment.

@bitwiseman
Copy link
Member

Alignment of the comment in the python code. Then I can merge!

@Konamiman
Copy link
Contributor Author

@bitwiseman Ok, done. Python is really tricky with that tabs vs spaces thing. Thank you!

@bitwiseman
Copy link
Member

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

Successfully merging this pull request may close these issues.

2 participants