Merge pull request #1141 from aidistan/fix-issue-1088

Fix Sass beautification
This commit is contained in:
Glavin Wiechert 2016-08-28 11:49:28 -03:00 committed by GitHub
commit 37092edaab
12 changed files with 121 additions and 386 deletions

View File

@ -86,6 +86,8 @@ before_install:
- gem install rubocop - gem install rubocop
- gem install htmlbeautifier - gem install htmlbeautifier
- gem install puppet-lint - gem install puppet-lint
# Sass language support
- gem install sass
# Python language support # Python language support
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install python; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install python; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo chmod 777 -R /opt/python; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo chmod 777 -R /opt/python; fi

View File

@ -63,7 +63,7 @@ See [all supported options in the documentation at `docs/options.md`](https://g
| C++ | `C++` |`.h`, `.hh`, `.cc`, `.cpp`, `.cxx`, `.C`, `.c++`, `.hpp`, `.hxx`, `.h++` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) | | C++ | `C++` |`.h`, `.hh`, `.cc`, `.cpp`, `.cxx`, `.C`, `.c++`, `.hpp`, `.hxx`, `.h++` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) |
| Crystal | `Crystal` |`.cr` | [`Crystal`](http://crystal-lang.org) (Default) | | Crystal | `Crystal` |`.cr` | [`Crystal`](http://crystal-lang.org) (Default) |
| C# | `C#` |`.cs` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) | | C# | `C#` |`.cs` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) |
| CSS | `CSS` |`.css` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | | CSS | `CSS` |`.css` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff), [`SassConvert`](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) |
| CSV | `CSV` |`.csv` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | CSV | `CSV` |`.csv` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| D | `D` |`.d` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`dfmt`](https://github.com/Hackerpilot/dfmt) | | D | `D` |`.d` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`dfmt`](https://github.com/Hackerpilot/dfmt) |
| EJS | `JavaScript Template`, `HTML (Angular)` | | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | EJS | `JavaScript Template`, `HTML (Angular)` | | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
@ -97,8 +97,8 @@ See [all supported options in the documentation at `docs/options.md`](https://g
| Riot.js | `Riot.js`, `HTML (Riot Tag)` |`.tag` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Riot.js | `Riot.js`, `HTML (Riot Tag)` |`.tag` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| Ruby | `Ruby`, `Ruby on Rails` |`.rb` | [`Rubocop`](https://github.com/bbatsov/rubocop) (Default), [`Ruby Beautify`](https://github.com/erniebrodeur/ruby-beautify) | | Ruby | `Ruby`, `Ruby on Rails` |`.rb` | [`Rubocop`](https://github.com/bbatsov/rubocop) (Default), [`Ruby Beautify`](https://github.com/erniebrodeur/ruby-beautify) |
| Rust | `Rust` |`.rs`, `.rlib` | [`rustfmt`](https://github.com/nrc/rustfmt) (Default) | | Rust | `Rust` |`.rs`, `.rlib` | [`rustfmt`](https://github.com/nrc/rustfmt) (Default) |
| Sass | `Sass` |`.sass` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Sass | `Sass` |`.sass` | [`SassConvert`](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) (Default) |
| SCSS | `SCSS` |`.scss` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | SCSS | `SCSS` |`.scss` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default), [`SassConvert`](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) |
| Spacebars | `Spacebars` | | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | Spacebars | `Spacebars` | | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| SQL | `SQL (Rails)`, `SQL` |`.sql` | [`sqlformat`](https://github.com/andialbrecht/sqlparse) (Default) | | SQL | `SQL (Rails)`, `SQL` |`.sql` | [`sqlformat`](https://github.com/andialbrecht/sqlparse) (Default) |
| SVG | `SVG` |`.svg` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) | | SVG | `SVG` |`.svg` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |

View File

@ -93,6 +93,9 @@ install:
# Puppet-Lint # Puppet-Lint
- gem install puppet-lint - gem install puppet-lint
- where puppet-lint - where puppet-lint
# Sass
- gem install sass
- where sass-convert
# emacs # emacs
- cinst emacs -y - cinst emacs -y

View File

@ -1407,27 +1407,27 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
#### [CSS](#css) #### [CSS](#css)
**Supported Beautifiers**: [`CSScomb`](#csscomb) [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) **Supported Beautifiers**: [`CSScomb`](#csscomb) [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) [`SassConvert`](#sassconvert)
| Option | CSScomb | JS Beautify | Pretty Diff | | Option | CSScomb | JS Beautify | Pretty Diff | SassConvert |
| --- | --- | --- | --- | | --- | --- | --- | --- | --- |
| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | | `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| `align_assignments` | :x: | :x: | :white_check_mark: | | `align_assignments` | :x: | :x: | :white_check_mark: | :x: |
| `configPath` | :white_check_mark: | :x: | :x: | | `configPath` | :white_check_mark: | :x: | :x: | :x: |
| `convert_quotes` | :x: | :x: | :white_check_mark: | | `convert_quotes` | :x: | :x: | :white_check_mark: | :x: |
| `end_with_newline` | :x: | :white_check_mark: | :x: | | `end_with_newline` | :x: | :white_check_mark: | :x: | :x: |
| `force_indentation` | :x: | :x: | :white_check_mark: | | `force_indentation` | :x: | :x: | :white_check_mark: | :x: |
| `indent_char` | :x: | :white_check_mark: | :white_check_mark: | | `indent_char` | :x: | :white_check_mark: | :white_check_mark: | :x: |
| `indent_comments` | :x: | :x: | :white_check_mark: | | `indent_comments` | :x: | :x: | :white_check_mark: | :x: |
| `indent_size` | :x: | :white_check_mark: | :white_check_mark: | | `indent_size` | :x: | :white_check_mark: | :white_check_mark: | :x: |
| `newline_between_rules` | :x: | :white_check_mark: | :white_check_mark: | | `newline_between_rules` | :x: | :white_check_mark: | :white_check_mark: | :x: |
| `no_lead_zero` | :x: | :x: | :white_check_mark: | | `no_lead_zero` | :x: | :x: | :white_check_mark: | :x: |
| `predefinedConfig` | :white_check_mark: | :x: | :x: | | `predefinedConfig` | :white_check_mark: | :x: | :x: | :x: |
| `preserve_newlines` | :x: | :white_check_mark: | :white_check_mark: | | `preserve_newlines` | :x: | :white_check_mark: | :white_check_mark: | :x: |
| `selector_separator_newline` | :x: | :white_check_mark: | :x: | | `selector_separator_newline` | :x: | :white_check_mark: | :x: | :x: |
| `wrap_line_length` | :x: | :white_check_mark: | :white_check_mark: | | `wrap_line_length` | :x: | :white_check_mark: | :white_check_mark: | :x: |
**Description**: **Description**:
@ -1458,7 +1458,7 @@ Disable CSS Beautification
**Type**: `string` **Type**: `string`
**Enum**: `CSScomb` `JS Beautify` `Pretty Diff` **Enum**: `CSScomb` `JS Beautify` `Pretty Diff` `SassConvert`
**Description**: **Description**:
@ -8665,25 +8665,13 @@ Path to rustfmt program (Supported by rustfmt)
#### [Sass](#sass) #### [Sass](#sass)
**Supported Beautifiers**: [`CSScomb`](#csscomb) [`Pretty Diff`](#pretty-diff) **Supported Beautifiers**: [`SassConvert`](#sassconvert)
| Option | CSScomb | Pretty Diff | | Option | SassConvert |
| --- | --- | --- | | --- | --- |
| `disabled` | :white_check_mark: | :white_check_mark: | | `disabled` | :white_check_mark: |
| `default_beautifier` | :white_check_mark: | :white_check_mark: | | `default_beautifier` | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: | :white_check_mark: | | `beautify_on_save` | :white_check_mark: |
| `align_assignments` | :x: | :white_check_mark: |
| `configPath` | :white_check_mark: | :x: |
| `convert_quotes` | :x: | :white_check_mark: |
| `force_indentation` | :x: | :white_check_mark: |
| `indent_char` | :x: | :white_check_mark: |
| `indent_comments` | :x: | :white_check_mark: |
| `indent_size` | :x: | :white_check_mark: |
| `newline_between_rules` | :x: | :white_check_mark: |
| `no_lead_zero` | :x: | :white_check_mark: |
| `predefinedConfig` | :white_check_mark: | :x: |
| `preserve_newlines` | :x: | :white_check_mark: |
| `wrap_line_length` | :x: | :white_check_mark: |
**Description**: **Description**:
@ -8710,11 +8698,11 @@ Disable Sass Beautification
**Important**: This option is only configurable from within Atom Beautify's setting panel. **Important**: This option is only configurable from within Atom Beautify's setting panel.
**Default**: `Pretty Diff` **Default**: `SassConvert`
**Type**: `string` **Type**: `string`
**Enum**: `CSScomb` `Pretty Diff` **Enum**: `SassConvert`
**Description**: **Description**:
@ -8744,331 +8732,27 @@ Automatically beautify Sass files on save
2. Go into *Packages* and search for "*Atom Beautify*" package. 2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Beautify On Save*" and change it to your desired configuration. 3. Find the option "*Beautify On Save*" and change it to your desired configuration.
##### [Align assignments](#align-assignments)
**Namespace**: `css`
**Key**: `align_assignments`
**Type**: `boolean`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
If lists of assignments or properties should be vertically aligned for faster and easier reading. (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"css": {
"align_assignments": false
}
}
```
##### [comb custom config file](#comb-custom-config-file)
**Namespace**: `css`
**Key**: `configPath`
**Type**: `string`
**Supported Beautifiers**: [`CSScomb`](#csscomb)
**Description**:
Path to custom CSScomb config file, used in absense of a `.csscomb.json` or `.csscomb.cson` at the root of your project. (Supported by CSScomb)
**Example `.jsbeautifyrc` Configuration**
```json
{
"css": {
"configPath": ""
}
}
```
##### [Convert quotes](#convert-quotes)
**Namespace**: `css`
**Key**: `convert_quotes`
**Default**: `none`
**Type**: `string`
**Enum**: `none` `double` `single`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
Convert the quote characters delimiting strings from either double or single quotes to the other. (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"css": {
"convert_quotes": "none"
}
}
```
##### [Force indentation](#force-indentation)
**Namespace**: `css`
**Key**: `force_indentation`
**Type**: `boolean`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
if indentation should be forcefully applied to markup even if it disruptively adds unintended whitespace to the documents rendered output (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"css": {
"force_indentation": false
}
}
```
##### [Indent char](#indent-char)
**Namespace**: `css`
**Key**: `indent_char`
**Default**: ` `
**Type**: `string`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
Indentation character (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"css": {
"indent_char": " "
}
}
```
##### [Indent comments](#indent-comments)
**Namespace**: `css`
**Key**: `indent_comments`
**Default**: `true`
**Type**: `boolean`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
Determines whether comments should be indented. (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"css": {
"indent_comments": true
}
}
```
##### [Indent size](#indent-size)
**Namespace**: `css`
**Key**: `indent_size`
**Default**: `4`
**Type**: `integer`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
Indentation size/length (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"css": {
"indent_size": 4
}
}
```
##### [Newline between rules](#newline-between-rules)
**Namespace**: `css`
**Key**: `newline_between_rules`
**Default**: `true`
**Type**: `boolean`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
Add a newline between CSS rules (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"css": {
"newline_between_rules": true
}
}
```
##### [No lead zero](#no-lead-zero)
**Namespace**: `css`
**Key**: `no_lead_zero`
**Type**: `boolean`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
If in CSS values leading 0s immediately preceeding a decimal should be removed or prevented. (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"css": {
"no_lead_zero": false
}
}
```
##### [comb predefined config](#comb-predefined-config)
**Namespace**: `css`
**Key**: `predefinedConfig`
**Default**: `csscomb`
**Type**: `string`
**Enum**: `csscomb` `yandex` `zen`
**Supported Beautifiers**: [`CSScomb`](#csscomb)
**Description**:
Used if neither a project or custom config file exists. (Supported by CSScomb)
**Example `.jsbeautifyrc` Configuration**
```json
{
"css": {
"predefinedConfig": "csscomb"
}
}
```
##### [Preserve newlines](#preserve-newlines)
**Namespace**: `css`
**Key**: `preserve_newlines`
**Type**: `boolean`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
Retain empty lines. Consecutive empty lines will be converted to a single empty line. (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"css": {
"preserve_newlines": false
}
}
```
##### [Wrap line length](#wrap-line-length)
**Namespace**: `css`
**Key**: `wrap_line_length`
**Type**: `integer`
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)
**Description**:
Maximum amount of characters per line (0 = disable) (Supported by Pretty Diff)
**Example `.jsbeautifyrc` Configuration**
```json
{
"css": {
"wrap_line_length": 0
}
}
```
#### [SCSS](#scss) #### [SCSS](#scss)
**Supported Beautifiers**: [`CSScomb`](#csscomb) [`Pretty Diff`](#pretty-diff) **Supported Beautifiers**: [`CSScomb`](#csscomb) [`Pretty Diff`](#pretty-diff) [`SassConvert`](#sassconvert)
| Option | CSScomb | Pretty Diff | | Option | CSScomb | Pretty Diff | SassConvert |
| --- | --- | --- | | --- | --- | --- | --- |
| `disabled` | :white_check_mark: | :white_check_mark: | | `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| `default_beautifier` | :white_check_mark: | :white_check_mark: | | `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: | :white_check_mark: | | `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| `align_assignments` | :x: | :white_check_mark: | | `align_assignments` | :x: | :white_check_mark: | :x: |
| `configPath` | :white_check_mark: | :x: | | `configPath` | :white_check_mark: | :x: | :x: |
| `convert_quotes` | :x: | :white_check_mark: | | `convert_quotes` | :x: | :white_check_mark: | :x: |
| `force_indentation` | :x: | :white_check_mark: | | `force_indentation` | :x: | :white_check_mark: | :x: |
| `indent_char` | :x: | :white_check_mark: | | `indent_char` | :x: | :white_check_mark: | :x: |
| `indent_comments` | :x: | :white_check_mark: | | `indent_comments` | :x: | :white_check_mark: | :x: |
| `indent_size` | :x: | :white_check_mark: | | `indent_size` | :x: | :white_check_mark: | :x: |
| `newline_between_rules` | :x: | :white_check_mark: | | `newline_between_rules` | :x: | :white_check_mark: | :x: |
| `no_lead_zero` | :x: | :white_check_mark: | | `no_lead_zero` | :x: | :white_check_mark: | :x: |
| `predefinedConfig` | :white_check_mark: | :x: | | `predefinedConfig` | :white_check_mark: | :x: | :x: |
| `preserve_newlines` | :x: | :white_check_mark: | | `preserve_newlines` | :x: | :white_check_mark: | :x: |
| `wrap_line_length` | :x: | :white_check_mark: | | `wrap_line_length` | :x: | :white_check_mark: | :x: |
**Description**: **Description**:
@ -9099,7 +8783,7 @@ Disable SCSS Beautification
**Type**: `string` **Type**: `string`
**Enum**: `CSScomb` `Pretty Diff` **Enum**: `CSScomb` `Pretty Diff` `SassConvert`
**Description**: **Description**:

View File

@ -1,7 +1,18 @@
a { nav
line-height: 56px; ul
padding: 0
margin: 0
list-style: none
&:hover { li
color: blue; display: inline-block
}
} a
display: block
text-decoration: none
padding: 6px 12px
html, body,
ul, ol
margin: 0
padding: 0

View File

@ -1,6 +1,21 @@
a { nav
line-height: 56px; ul
&:hover { padding: 0
color: blue;
} margin: 0
} list-style: none
li
display: inline-block
a
display: block
text-decoration: none
padding: 6px 12px
html,body,
ul, ol
margin: 0
padding: 0

View File

@ -263,7 +263,8 @@
"erl_tidy", "erl_tidy",
"marko beautifier", "marko beautifier",
"vue", "vue",
"vue beautifier" "vue beautifier",
"sassconvert"
], ],
"devDependencies": { "devDependencies": {
"coffeelint": "^1.10.1", "coffeelint": "^1.10.1",

View File

@ -12,7 +12,6 @@ module.exports = class JSBeautify extends Beautifier
predefinedConfig: true predefinedConfig: true
CSS: true CSS: true
LESS: true LESS: true
Sass: true
SCSS: true SCSS: true
} }

View File

@ -62,6 +62,7 @@ module.exports = class Beautifiers extends EventEmitter
'rubocop' 'rubocop'
'ruby-beautify' 'ruby-beautify'
'rustfmt' 'rustfmt'
'sass-convert'
'sqlformat' 'sqlformat'
'stylish-haskell' 'stylish-haskell'
'tidy-markdown' 'tidy-markdown'

View File

@ -55,7 +55,6 @@ module.exports = class PrettyDiff extends Beautifier
JavaScript: true JavaScript: true
CSS: true CSS: true
SCSS: true SCSS: true
Sass: true
JSON: true JSON: true
TSS: true TSS: true
Twig: true Twig: true
@ -103,7 +102,7 @@ module.exports = class PrettyDiff extends Beautifier
lang = "css" lang = "css"
when "LESS" when "LESS"
lang = "less" lang = "less"
when "SCSS", "Sass" when "SCSS"
lang = "scss" lang = "scss"
when "TSS" when "TSS"
lang = "tss" lang = "tss"

View File

@ -0,0 +1,20 @@
"use strict"
Beautifier = require('./beautifier')
module.exports = class SassConvert extends Beautifier
name: "SassConvert"
link: "http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax"
options:
# TODO: Add support for options
CSS: false
Sass: false
SCSS: false
beautify: (text, language, options, context) ->
lang = language.toLowerCase()
@run("sass-convert", [
@tempFile("input", text),
"--from", lang, "--to", lang
])

View File

@ -2,7 +2,7 @@ module.exports = {
name: "Sass" name: "Sass"
namespace: "sass" namespace: "sass"
fallback: ['css', 'scss'] fallback: ['css']
### ###
Supported Grammars Supported Grammars
@ -18,6 +18,6 @@ module.exports = {
"sass" "sass"
] ]
defaultBeautifier: "Pretty Diff" defaultBeautifier: "SassConvert"
} }