Skip to content

Commit ae6c1b6

Browse files
committed
update README for 1.1.0
1 parent 93bc4e4 commit ae6c1b6

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,27 @@ npm install postcss-values-parser
5353
Using this parser is straightforward and doesn't require callbacks:
5454

5555
```js
56-
// ES6
57-
let parser = require('postcss-values-parser');
58-
let ast = parser('#fff').parse();
56+
const parser = require('postcss-values-parser');
57+
const ast = parser('#fff').parse();
5958

6059
let color = ast // the Root node
6160
.first // the Value node
6261
.first; // a Word node, containing the color value.
6362
```
6463

65-
```js
66-
// ES5
67-
var parser = require('postcss-values-parser');
68-
var ast = parser('#fff').parse();
64+
## CSS-Like Languages
6965

70-
var color = ast // the Root node
71-
.first // the Value node
72-
.first; // a Word node, containing the color value.
66+
If your intent is to use this parser with a CSS-like language (eg. SASS, LESS)
67+
then you can instruct the parser **_not to adhere to strict CSS_** parsing rules as
68+
per [the spec](https://drafts.csswg.org/css-values-3/). For example, the parser
69+
will throw an error by default if `calc` parameters [don't adhere to the spec](https://drafts.csswg.org/css-values-3/#calc-syntax).
70+
71+
We call this `loose` mode. To enable `loose` mode, pass an options object to the
72+
`parser` method:
73+
74+
```js
75+
const parser = require('postcss-values-parser');
76+
const ast = parser('#fff', { loose: true }).parse();
7377
```
7478

7579
## Acknowledgements
@@ -78,4 +82,4 @@ This project was heavily influenced by [postcss-selector-parser](https://github.
7882
and utilized many patterns and logical constructs from the project.
7983

8084
Tests and some tokenizing techniques found in [postcss-value-parser](https://github.com/TrySound/postcss-value-parser)
81-
and were used.
85+
were used.

0 commit comments

Comments
 (0)