Last active
October 29, 2015 15:16
-
-
Save shellscape/bb8e35c3b38a2a953174 to your computer and use it in GitHub Desktop.
Evaluating AST Tree of PostCSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var postcss = require('postcss'), | |
fs = require('fs'), | |
path = require('path'), | |
css = fs.readFileSync(path.join(__dirname, 'lesstest.less'), 'utf-8'), | |
root = postcss.parse(css); | |
console.log(require('util').inspect(root, { depth: 6 })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.foo { | |
border: none; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.mixin (...) { | |
&[input], | |
[input]& { | |
border: 0; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ raws: { semicolon: false, after: '\n' }, | |
type: 'root', | |
nodes: | |
[ { raws: { before: '', between: ' ', semicolon: false, after: '\n' }, | |
type: 'rule', | |
nodes: | |
[ { raws: { before: '\n ', between: ' ', semicolon: true, after: '\n ' }, | |
type: 'rule', | |
nodes: | |
[ { raws: { before: '\n ', between: ': ' }, | |
type: 'decl', | |
parent: [Circular], | |
source: | |
{ start: { line: 4, column: 5 }, | |
input: | |
{ css: '.mixin (...) {\n &[input],\n [input]& {\n border: 0;\n }\n}\n', | |
id: '<input css 1>' }, | |
end: { line: 4, column: 14 } }, | |
prop: 'border', | |
value: '0' } ], | |
parent: [Circular], | |
source: | |
{ start: { line: 2, column: 3 }, | |
input: | |
{ css: '.mixin (...) {\n &[input],\n [input]& {\n border: 0;\n }\n}\n', | |
id: '<input css 1>' }, | |
end: { line: 5, column: 3 } }, | |
selector: '&[input],\n [input]&' } ], | |
parent: [Circular], | |
source: | |
{ start: { line: 1, column: 1 }, | |
input: | |
{ css: '.mixin (...) {\n &[input],\n [input]& {\n border: 0;\n }\n}\n', | |
id: '<input css 1>' }, | |
end: { line: 6, column: 1 } }, | |
selector: '.mixin (...)' } ], | |
source: | |
{ input: | |
{ css: '.mixin (...) {\n &[input],\n [input]& {\n border: 0;\n }\n}\n', | |
id: '<input css 1>' }, | |
start: { line: 1, column: 1 } } } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ raws: { semicolon: false, after: '\n' }, | |
type: 'root', | |
nodes: | |
[ { raws: { before: '', between: ' ', semicolon: true, after: '\n' }, | |
type: 'rule', | |
nodes: | |
[ { raws: { before: '\n ', between: ': ' }, | |
type: 'decl', | |
parent: [Circular], | |
source: | |
{ start: { line: 2, column: 3 }, | |
input: { css: '.foo {\n border: none;\n}\n', id: '<input css 1>' }, | |
end: { line: 2, column: 15 } }, | |
prop: 'border', | |
value: 'none' } ], | |
parent: [Circular], | |
source: | |
{ start: { line: 1, column: 1 }, | |
input: { css: '.foo {\n border: none;\n}\n', id: '<input css 1>' }, | |
end: { line: 3, column: 1 } }, | |
selector: '.foo' } ], | |
source: | |
{ input: { css: '.foo {\n border: none;\n}\n', id: '<input css 1>' }, | |
start: { line: 1, column: 1 } } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment