-
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
Keeping New lines #96
Comments
Hmm, what would be achieved by keeping the newlines? This would effectively forbid the beautifier to make any meaningful changes, as e.g
would not be restored to any beautiful form. The preserve_newlines options were implemented to keep the blank lines between the blocks of code intact, but I don't see the use in preserving all existing nl's, but please correct me if i'm wrong, maybe I misunderstood something. |
broadly speaking I'd agree, but if you consider unfixed issues like: which become: or similar, I'd say this feature is worth exposing..unless it breaks something else of course :) That way you wouldn't break original newlines (and original js) but you would still beautify it. Looking forward to your reply |
I mean, newlines are definitely metachars as well, so unless there's the chance to be perfect in js sintax, I'd prefer to have the option to be conservative on newlines. |
+1 on this usually while typing i have newlines the way i want but some spaces are missing var a=1
if(a==1)
b+=x ⇓ var a = 1
if (a == 1)
b += x |
Yes, now I see the point in that. |
Is this already implemented in the python version? It would be cool if if(true)
bar(); wouldnt be converted to if(true) bar(); Some of my colleagues dislike it when I use jsbeautifier, for the above reason. :( |
Maybe using an option like this: |
@hickop +1 :) |
This is at least partially addressed by my recent changes to newline preservation. But I see where you're headed with this - having an option where there would still be some formatting but newlines always kept. |
I'm going to close this. If the new behavior is insufficient, please reopen. |
I know this issue was created with js in mind, but it would be great to have a fix for HTML as well. |
Please file a new issue. |
fix issue beautifier#96 See merge request !36
Would it be possible to keep original newlines by simply adding:
preserve_max_newlines:1
to beautify options?
By modifying n_newlines condition it's "probably" easy to preserve the nl.
What do you think?
Of course if the patch is wrong i'd like to understand why.
Thanks
The text was updated successfully, but these errors were encountered: