-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
bad formatting of .less files using @variable or &:hover syntax #489
Comments
Right now, beautifying LESS (and SASS, or any other flavor of CSS preprocessor) is a bit out of the scope of the js-beautify project. Could you provide us with inputs and expected outputs, at least? Thanks! |
sure,
this is the current output:
|
@guymguym Thanks, I'll try to take a stab at this soon. Pull requests welcome and encouraged! |
Experiencing the same issue (I'm using this with the Sublime HTMLPrettify). Some example I/O
gets modified to:
Or:
to:
|
@evocateur Thanks. I went over the code and there are few issues. The In css syntax
where the new function peekString() is this:
Side question - why does this project has both python and js implementation of the same logic? |
The In css syntax pseudo classes/elements can only appear on top level. In less-css they can appear at any level. The only reason the formatter needs to handle Currently the code maintains the I guess the only way to identify the case correctly is to read the entire line, and detect if it ends with |
@evocateur I wonder - would it be useful if the prettify code will start by splitting the entire source text to statements by the characters |
Same issue using Atom.io. Samples and raw text for testing are in the link: Glavin001/atom-beautify#52 |
@evocateur Would you please review my pull request to fix the |
I have recently switched from Sublime Text 2 to Sublime Text 3. I was using this plugin all the time with LESS and from what I can remember, I never had this issue in ST2. So the later version must have introduced this bug which makes it almost useless for LESS development since you almost always have stuff like @ and : Hope you guys will be able to review the pull request(s) here and figure it out. It's a great beautify project, best one out there IMO. |
@guymguym - Requesting a review the way you are is fruitless. I didn't even know you were asking for one. Please submit a pull request with tests and python port. |
Hi @bitwiseman. I submitted a pull request two months ago, but it was indeed without tests and python port which I simply wasn't aware of because this project's code is new to me. Was it fruitless to discuss this here to get to know the project parts for a first time contributor? Is there a better way to do so? Anyway I just updated my pending pull request with tests and also the python code, and it passed the travis build, so I guess it's ready to pull - #496 However this issue is still not resolved by this fix - the harder problem is with the Cheers |
Ah, I see it. Thanks for you work on this. Could you squash your commits into one commit and point me to some documentation as to the correct syntax in this case? As you've noticed, the beautifier is really lacking in LESS support. On one hand that is by design - it's a CSS beautifier not a LESS beautifier. But it seems like no one works in CSS alone. |
I took your code amended it and made further changes. The fixes are now live in v1.5.3. |
@evocateur - This commit f416b0b seem to break the handling of .less files using
@variable
or&:hover
formatting.When
@var
appears it does very weird things - removes space before the @, add unwanted newline, and more.With
&:hover
it injects a space before the:
which breaks the pseudo class that was intended.This issue makes it completely unusable for .less files :(
Any idea how to overcome?
Thanks!
The text was updated successfully, but these errors were encountered: