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

Beautify CSS - Bug with indent character (indent_char) #171

Closed
yvan-sraka opened this issue Jan 2, 2015 · 9 comments
Closed

Beautify CSS - Bug with indent character (indent_char) #171

yvan-sraka opened this issue Jan 2, 2015 · 9 comments
Assignees
Labels

Comments

@yvan-sraka
Copy link

Hi,

I use Atom Beautify 0.20.1, in my preferences, Css indent size is set to 4.

When I Beautify this file:

$ cat -t test.css
.test {
^Idisplay:none;
}

I get this:

$ cat -t test.css
.test {
^I^I^I^Idisplay: none;
}

I'd rather get this:

$ cat -t test.css
.test {
    display: none;
}

Or just:

$ cat -t test.css
.test {
^Idisplay: none;
}

Thanks,
Yvan

@Glavin001 Glavin001 self-assigned this Jan 2, 2015
@Glavin001 Glavin001 added this to the My Christmas List milestone Jan 2, 2015
@Glavin001
Copy link
Owner

Check your CSS Indent Char ( https://github.com/Glavin001/atom-beautify/blob/master/lib/language-options.coffee#L83 ). It should default to a space character, however maybe there is a setting that has been changed.

@Glavin001
Copy link
Owner

I just noticed the code says css_indent_Char when it should be css_indent_char. This may be causing the problem with js-beautify. Let me know if you are able to resolve this by changing the CSS Indent Char settings, however I will also look into this and see if it's a bug / typo. Thanks

@yvan-sraka
Copy link
Author

The CSS Indent Char parameter is set to Default, change it does not affect the results of my tests.

@Glavin001 Glavin001 added bug and removed question labels Jan 2, 2015
@Glavin001
Copy link
Owner

Do you have a .jsbeautifyrc file? here's an example https://github.com/Glavin001/atom-beautify/blob/master/examples/simple-jsbeautifyrc/.jsbeautifyrc or nested like https://github.com/Glavin001/atom-beautify/blob/master/examples/nested-jsbeautifyrc/.jsbeautifyrc_json

I believe the bug is that the Atom Package option is css_indent_Char and not css_indent_char and my .jsbeautifyrc also uses indent_char for css so I think it is why it works for me. I recommend having a .jsbeautifyrc and I'll push a fix for the Package Settings if the .jsbeautifyrc works for you.

@Glavin001 Glavin001 changed the title Beautify CSS - Bug with tabs Beautify CSS - Bug with indent character (indent_char) Jan 2, 2015
@yvan-sraka
Copy link
Author

My current .jsbeautifyrc is:

$ cat /Users/Yvan/.atom/packages/atom-beautify/.jsbeautifyrc
{
  "indent_size": 2,
  "indent_char": " ",
  "indent_level": 0,
  "indent_with_tabs": false,
  "preserve_newlines": true,
  "max_preserve_newlines": 2,
  "jslint_happy": true
}

@Glavin001
Copy link
Owner

Yeah that's one of mine, however what is yours? And if you do not have one, could you create one and test beautifying your CSS with it?

@yvan-sraka
Copy link
Author

Yes (Sorry, I just forgot to move it in my home folder), it works now:

$ cat -t test.css 
.test {
  display: none;
}

@Glavin001
Copy link
Owner

Okay, then it has been confirmed that typo is the culprit. Publishing in a few minutes.

@Glavin001
Copy link
Owner

Published to v0.20.2

You can now set the css indent char setting in the Atom Beautify package settings and it will translate to css_indent_char which will apply as indent_char for the CSS beautify of js-beautifier. For more options see https://github.com/beautify-web/js-beautify and https://github.com/Glavin001/atom-beautify/blob/v0.20.2/lib/language-options.coffee#L81 and I strongly recommend using a .jsbeautifyrc (supports JSON or YAML).

Thanks for using Atom Beautify! Enjoy.

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

No branches or pull requests

2 participants