Skip to content

Commit

Permalink
Amended README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsManta authored and Anantachai Saothong (Manta) committed Apr 27, 2017
1 parent c5937b5 commit 08baf36
Showing 1 changed file with 15 additions and 27 deletions.
42 changes: 15 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Stylus Supremacy

**Stylus Supremacy** is a *Node.js* script for formatting *[Stylus](http://stylus-lang.com)* files. You may say this is a beautifier for *Stylus*.
**Stylus Supremacy** is a *Node.js* script for formatting *[Stylus](http://stylus-lang.com)* files. You may say this is a beautifier for *Stylus* language.

## Editor usage

Currently, **Stylus Supremacy** is only available in *Visual Studio Code* as an extension. You can download and install it [here](https://marketplace.visualstudio.com/items?itemName=thisismanta.stylus-supremacy).

## Command-line usage

Expand Down Expand Up @@ -54,27 +58,15 @@ const formattingOptions = {
}

const result = stylusSupremacy.format(stylusContent, formattingOptions)
console.log(result.text)
console.log(result)
```
```

The `result` object above contains 3 values: `text`, `tree` and `warnings`.

The `result.text` is the string of formatted *Stylus* output.
```css
body {
display: none;
}
```

The `result.tree` is an object generated by *Stylus* internal [parser](https://github.com/stylus/stylus/blob/master/lib/parser.js), which represents the whole *Stylus* input in a tree structure. This is useful for debugging purposes.

The `result.warnings` is an array of warning objects genereted by the `format` function. This array should be empty, unless some tokens could not be recognized, which may lead to a lost in translation. In that case, please open an issue in our repository to help improving

## Editor extension usage

If you are using *Visual Studio Code*, you might be interested in [**Stylus Supremacy** extension](https://marketplace.visualstudio.com/items?itemName=thisismanta.stylus-supremacy).

Currently, there are no extensions for other editor.
The `format` function always returns a string of the formatted *Stylus* content. However, it could throw an exception if there is at least one error in parsing the given *Stylus* content or generating the formatted output.

## Formatting options

Expand Down Expand Up @@ -471,16 +463,16 @@ const formattingOptions = {
}

const result = stylusSupremacy.format(stylusContent, formattingOptions)
console.log(result.text)
console.log(result)
```
```

The `result.text` has no colons between `display` and `none` since `insertColons` is `false` eventhough `colons` says otherwise. This is because the values of **Stylus Supremacy** formatting option are more important than *Stylint* options.
```css
body {
display none;
}
```

The result has no colons between `display` and `none` since `insertColons` is `false` eventhough `colons` says otherwise. This is because the values of **Stylus Supremacy** formatting option are more important than *Stylint* options.

Note that `"always"` in *Stylint* is equivalent to `true`; `"never"` is equivalent to `false`, otherwise the default [formatting options](#formatting-options) will be used.

|Stylint options|Equivalent options in Stylus Supremacy|
Expand Down Expand Up @@ -519,7 +511,7 @@ Note that `"always"` in *Stylint* is equivalent to `true`; `"never"` is equivale
|`trailingWhitespace`|Not applicable|
|`universal`|Not applicable|
|`valid`|Not applicable|
|`zeroUnits`|`alwaysUseZeroWithoutUnit`|
|`zeroUnits`|`alwaysUseZeroWithoutUnit`; unlike other options, the values `"always"` and `"never"` will be converted to `false` and `true` respectively.|
|`zIndexNormalize`|Not applicable|

## Release notes
Expand All @@ -530,19 +522,15 @@ See https://github.com/ThisIsManta/stylus-supremacy/releases

- Both single-line and multi-line comments may be dropped out because *Stylus* internal [parser](https://github.com/stylus/stylus/blob/master/lib/parser.js) did not play well with comments as its purpose was to create an input for CSS transpilation.
The original *Stylus* file:
```css
```
.class1 /* comment-1 */, .class2 /* comment-2 */ {
display: none;
}
```
The formatted output:
```css
```
.class1, .class2 { /* comment-2 */
display: none;
}
```
You can see that `/* comment-1 */` is missing in the output.

## Future work

See https://github.com/ThisIsManta/stylus-supremacy/projects/4

0 comments on commit 08baf36

Please sign in to comment.