Comparing version 0.9.0 to 0.9.1
@@ -16,3 +16,3 @@ { | ||
], | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"preferGlobal": true, | ||
@@ -19,0 +19,0 @@ "repository": { |
@@ -36,17 +36,20 @@ ![Travis Build Status - Master](https://img.shields.io/travis/cwdoh/cssparser.js/master.svg) | ||
$ npm install cssparser | ||
or | ||
$ npm install cssparser -g | ||
```bash | ||
$ npm install cssparser | ||
``` | ||
or | ||
```bash | ||
$ npm install cssparser -g | ||
``` | ||
Then execute and you can generate JSON file from command-line. | ||
$ cssparser cssFile | ||
or | ||
$ cssparser cssFile -o output_file | ||
```bash | ||
$ cssparser cssFile | ||
``` | ||
or | ||
```bash | ||
$ cssparser cssFile -o output_file | ||
``` | ||
###from CommonJS Module | ||
@@ -56,15 +59,16 @@ | ||
// getting parser module | ||
var cssparser = require("cssparser"); | ||
// create new instance of Parser | ||
var parser = new cssparser.Parser(); | ||
// parse | ||
var ast = parser.parse(raw) | ||
```javascript | ||
// getting parser module | ||
var cssparser = require("cssparser"); | ||
// getting json | ||
var json = ast.toJSON(type) | ||
// create new instance of Parser | ||
var parser = new cssparser.Parser(); | ||
// parse | ||
var ast = parser.parse(raw) | ||
// getting json | ||
var json = ast.toJSON(type) | ||
``` | ||
##Generating parser from source | ||
@@ -74,10 +78,13 @@ | ||
$ git clone https://github.com/cwdoh/cssparser.js.git | ||
$ npm install | ||
```bash | ||
$ git clone https://github.com/cwdoh/cssparser.js.git | ||
$ npm install | ||
``` | ||
###Generating parser from source | ||
$ npm run build | ||
```bash | ||
$ npm run build | ||
``` | ||
##JSON Structure | ||
@@ -98,3 +105,5 @@ | ||
cssparser example/test.css --console -i 4 | ||
```bash | ||
cssparser example/test.css --console -i 4 | ||
``` | ||
@@ -107,10 +116,10 @@ ###Input | ||
@media screen { | ||
* { | ||
position: absolute; | ||
} | ||
* { | ||
position: absolute; | ||
} | ||
} | ||
.footer { | ||
position: fixed; | ||
bottom: 0; | ||
bottom: 0 !important; | ||
width: 1rem; | ||
@@ -144,2 +153,3 @@ } | ||
{ | ||
"type": "rule", | ||
"selectors": [ | ||
@@ -155,2 +165,3 @@ "*" | ||
{ | ||
"type": "rule", | ||
"selectors": [ | ||
@@ -161,3 +172,3 @@ ".footer" | ||
"position": "fixed", | ||
"bottom": 0, | ||
"bottom": "0 !important", | ||
"width": "1rem" | ||
@@ -167,2 +178,3 @@ } | ||
] | ||
``` | ||
@@ -227,3 +239,4 @@ | ||
"property": "bottom", | ||
"value": 0 | ||
"value": 0, | ||
"important": true | ||
}, | ||
@@ -243,2 +256,3 @@ { | ||
} | ||
``` | ||
@@ -367,3 +381,4 @@ | ||
"value": 0 | ||
} | ||
}, | ||
"important": true | ||
}, | ||
@@ -400,3 +415,5 @@ { | ||
* 0.9.0-alpha - March 5th, 2016 | ||
* 0.9.1 - March 8th, 2017 | ||
* Added 'rule' type on the css style node when simple mode. | ||
* 0.9.0 - March 5th, 2017 | ||
* Fully rewrited parser. | ||
@@ -403,0 +420,0 @@ * Supports three modes such as simple, deep, atomic. |
@@ -8,2 +8,3 @@ class QualifiedRule extends CSSObject { | ||
return { | ||
type: 'rule', | ||
selectors: toSimple(this.get('selectors')), | ||
@@ -27,3 +28,7 @@ declarations: toSimple(this.get('value')) | ||
var json = {} | ||
json[toSimple(this.get('property'))] = toSimple(this.get('value')) | ||
var value = toSimple(this.get('value')) | ||
if (this.get('important', false)) { | ||
value += ' !important' | ||
} | ||
json[toSimple(this.get('property'))] = value | ||
@@ -30,0 +35,0 @@ return json |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1003379
43
9356
425
0