Closes #20. Add Sass and LESS support. Update README.

This commit is contained in:
Glavin Wiechert 2014-06-13 01:25:39 -03:00
parent c34f6f9419
commit eacf2329da
2 changed files with 68 additions and 6 deletions

View File

@ -1,14 +1,23 @@
# [atom-beautify](https://github.com/donaldpipowitch/atom-beautify) # [atom-beautify](https://github.com/donaldpipowitch/atom-beautify)
[Beautify](https://github.com/einars/js-beautify) HTML (including Handlebars), CSS and JavaScript in Atom. > [Beautify](https://github.com/einars/js-beautify)
HTML (including [Handlebars](http://handlebarsjs.com/)),
CSS (including [Sass](http://sass-lang.com/) and [LESS](http://lesscss.org/))
and JavaScript in Atom.
*Attention*: A different package with a similar name exist. Maybe you want to visit this one: [Beautifier](https://atom.io/packages/atom-beautifier). ## Language Support
- JavaScript
- HTML, including
- [Handlebars](http://handlebarsjs.com/)
- XML is supported as an *experimental feature*.
- CSS, including
- [Sass](http://sass-lang.com/)
- [LESS](http://lesscss.org/)
## Usage ## Usage
Open the [Command Palette](https://github.com/atom/command-palette), and type `Beautify`. Open the [Command Palette](https://github.com/atom/command-palette), and type `Beautify`.
This will beautify JS, HTML (including Handlebars), or CSS files.
XML is supported as an experimental feature.
It will only beautify selected text, if a selection is found - if not, the whole file will be beautified. It will only beautify selected text, if a selection is found - if not, the whole file will be beautified.
@ -30,9 +39,59 @@ Edit your `.jsbeautifyrc` file in any of the following locations:
`atom-beautify` will recursively look up from the current file's directory to find `.jsbeautifyrc`. `atom-beautify` will recursively look up from the current file's directory to find `.jsbeautifyrc`.
- Your User's Home directory - Your User's Home directory
You can see examples of both way inside [`examples/`](https://github.com/donaldpipowitch/atom-beautify/tree/master/examples) **Note**: *Comments are supported in `.jsbeautifyrc` thanks to [strip-json-comments](https://github.com/sindresorhus/strip-json-comments).*
*Comments are supported in `.jsbeautifyrc` thanks to [strip-json-comments](https://github.com/sindresorhus/strip-json-comments).* See examples of both way inside [`examples/`](https://github.com/donaldpipowitch/atom-beautify/tree/master/examples)
### Simple
See [examples/simple-jsbeautifyrc/.jsbeautifyrc](https://github.com/donaldpipowitch/atom-beautify/blob/master/examples/simple-jsbeautifyrc/.jsbeautifyrc).
```json
{
"indent_size": 2,
"indent_char": " ",
"other": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 2,
"jslint_happy": true,
"indent_handlebars": true
}
```
### Nested
See [examples/nested-jsbeautifyrc/.jsbeautifyrc](https://github.com/donaldpipowitch/atom-beautify/blob/master/examples/nested-jsbeautifyrc/.jsbeautifyrc).
```json
{
"html": {
"brace_style": "collapse",
"indent_char": " ",
"indent_scripts": "normal",
"indent_size": 6,
"max_preserve_newlines": 1,
"preserve_newlines": true,
"unformatted": ["a", "sub", "sup", "b", "i", "u"],
"wrap_line_length": 0
},
"css": {
"indent_char": " ",
"indent_size": 4
},
"js": {
"indent_size": 2,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 2,
"jslint_happy": true
}
}
```
## Contributing ## Contributing

View File

@ -254,6 +254,9 @@ function beautify() {
case 'XML': case 'XML':
text = beautifyHTML(text, getOptions('html', allOptions)); text = beautifyHTML(text, getOptions('html', allOptions));
break; break;
case 'Sass':
case 'SCSS':
case 'LESS':
case 'CSS': case 'CSS':
text = beautifyCSS(text, getOptions('css', allOptions)); text = beautifyCSS(text, getOptions('css', allOptions));
break; break;