gonzales-pe
Advanced tools
Comparing version 2.0.0-rc1 to 2.0.0
Gonzales changelog | ||
================== | ||
11.11.2013, Version 2.0.0 | ||
------------------------- | ||
- Support preprocessors: Sass (both SCSS and indented syntax), LESS. | ||
- New node types: | ||
- `arguments` (less and sass only) | ||
- `commentML` | ||
- `commentSL` (less and sass only) | ||
- `condition` (sass only) | ||
- `default` (sass only) | ||
- `escapedString` (less only) | ||
- `include` (less and sass only) | ||
- `loop` (sass only) | ||
- `mixin` (less and sass only) | ||
- `parentselector` (less and sass only) | ||
- `placeholder` (sass only) | ||
- `propertyDelim` | ||
- `variable` (less and sass only) | ||
- `varialeList` (less and sass only) | ||
- Rename methods: | ||
- `srcToCSSP` -> `cssToAST` | ||
- `csspToSrc` -> `astToCSS` | ||
- `csspToTree` -> `astToTree` | ||
- Pass all arguments as one object: | ||
- `gonzales.cssToAST({css: a, syntax: b, rule: c, needInfo: d})` | ||
- `gonzales.astToCSS({ast: ast, syntax: syntax})` | ||
- Remove built files from VCS | ||
- Move test command from `make` to `npm` | ||
- Build files before running tests | ||
- Divide tests into groups according to syntax | ||
- Add script to test one specific css string | ||
- Add token's index number to info object | ||
11.02.2013, Version 1.0.7 | ||
------------------------- | ||
@@ -9,3 +43,3 @@ - Identifiers like `_0` are identifiers now. | ||
25.11.2012, Version 1.0.6 | ||
25.11.2012, Version 1.0.6 | ||
------------------------- | ||
@@ -17,3 +51,3 @@ | ||
28.10.2012, Version 1.0.5 | ||
28.10.2012, Version 1.0.5 | ||
------------------------- | ||
@@ -23,3 +57,3 @@ | ||
11.10.2012, Version 1.0.4 | ||
11.10.2012, Version 1.0.4 | ||
------------------------- | ||
@@ -29,3 +63,3 @@ | ||
10.10.2012, Version 1.0.3 | ||
10.10.2012, Version 1.0.3 | ||
------------------------- | ||
@@ -38,3 +72,3 @@ | ||
- CSSO issue (filter + important breaks csso v1.3.1): https://github.com/css/csso/issues/87 | ||
- CSSO issue (filter + important breaks csso v1.3.1): https://github.com/css/csso/issues/87 | ||
@@ -49,2 +83,2 @@ 08.10.2012, Version 1.0.1 | ||
- First revision. | ||
- First revision. |
@@ -1,11 +0,7 @@ | ||
### 1. AST — Abstract Syntax Tree | ||
### 1. Gonzales AST — Abstract Syntax Tree | ||
If you don't know what AST is, first read [article at Wikipedia] (http://en.wikipedia.org/wiki/Abstract_syntax_tree). | ||
#### 1.1. Gonzales AST | ||
In general Gonzales AST looks like this: | ||
This AST format is compatible with [CSSP] (https://github.com/css/cssp). | ||
In general it looks like this: | ||
['stylesheet', | ||
@@ -19,3 +15,3 @@ ['atrules', ..], | ||
#### 1.2. Known issues | ||
#### Known issues | ||
@@ -38,5 +34,4 @@ *operator* / *unary* — rather artificial division, in addition *unary* is | ||
In case `info` parameter was `true` when the stylesheet was parsed, the node | ||
includes info object. Now it only contains the token number and token's line | ||
number, but in the future there will be more information: | ||
In case `needInfo` parameter was `true`, the node includes info object. | ||
It contains token's index number and token's line number: | ||
@@ -51,3 +46,2 @@ [{ ln: ln, tn: tn }, <- info object | ||
#### arguments | ||
@@ -115,2 +109,3 @@ | ||
['ident', 'p']], | ||
['propertyDelim'], | ||
['value', | ||
@@ -152,2 +147,3 @@ ['ident', 'v']]]]] | ||
['ident', 'p']], | ||
['propertyDelim'], | ||
['value', | ||
@@ -159,3 +155,3 @@ ['ident', 'v']]]]]]] | ||
Singleline @-rule. | ||
Single-line @-rule. | ||
@@ -211,3 +207,4 @@ Consists of: | ||
Part of the style in the braces. | ||
Part of the style in braces: `{...}`. | ||
For `*.sass` files — code that will be compiled to a block. | ||
@@ -224,2 +221,3 @@ ``` | ||
['ident', 'color']], | ||
['propertyDelim'], | ||
['value', | ||
@@ -289,3 +287,3 @@ ['s', ' '], | ||
Single-line comment. | ||
Valid only for scss syntax. | ||
Valid for less, scss and sass. | ||
@@ -303,3 +301,3 @@ ``` | ||
Condition. | ||
Valid only for scss syntax. | ||
Valid for less, scss and sass. | ||
@@ -328,3 +326,4 @@ ``` | ||
Consists of: | ||
- *property* and | ||
- *property*, | ||
- *propertyDelim* and | ||
- *value* | ||
@@ -342,2 +341,3 @@ | ||
['ident', 'color']], | ||
['propertyDelim'], | ||
['value', | ||
@@ -348,5 +348,5 @@ ['s', ' '], | ||
#### decldelim | ||
#### declDelim | ||
Declaration delimiter in block: `;`. | ||
Declaration delimiter in block: `\n` for sass, `;` for other syntaxes. | ||
@@ -362,6 +362,7 @@ ``` | ||
['ident', 'a']], | ||
['propertyDelim'], | ||
['value', | ||
['s', ' '], | ||
['ident', 'b']]], | ||
['decldelim'], | ||
['declDelim'], | ||
['s', ' '], | ||
@@ -371,2 +372,3 @@ ['declaration', | ||
['ident', 'c']], | ||
['propertyDelim'], | ||
['value', | ||
@@ -380,3 +382,3 @@ ['s', ' '], | ||
`!default` keyword. | ||
Valid only for scss syntax. | ||
Valid only for scss and syntax. | ||
@@ -391,2 +393,3 @@ ``` | ||
['ident', 'a']], | ||
['propertyDelim'], | ||
['value', | ||
@@ -430,2 +433,15 @@ ['s', ' '], | ||
#### escapedString | ||
Escaped string. | ||
Valid only for less. | ||
``` | ||
~"ms:alwaysHasItsOwnSyntax.For.@{what}()" | ||
↓ | ||
['escapedString', '"ms:alwaysHasItsOwnSyntax.For.@{what}()"']] | ||
``` | ||
#### filter, filterv, progid | ||
@@ -448,2 +464,3 @@ | ||
['ident', 'filter']], | ||
['propertyDelim'], | ||
['filterv', | ||
@@ -470,2 +487,3 @@ ['progid', | ||
['ident', 'color']], | ||
['propertyDelim'], | ||
['value', | ||
@@ -495,2 +513,3 @@ ['s', ' '], | ||
['ident', 'left']], | ||
['propertyDelim'], | ||
['value', | ||
@@ -548,2 +567,3 @@ ['functionExpression', 'document.body.offsetWidth+1']]] | ||
['ident', 'a']], | ||
['propertyDelim'], | ||
['value', | ||
@@ -558,16 +578,143 @@ ['s', ' '], | ||
Valid only for scss syntax. | ||
Included mixin. | ||
For scss and sass: | ||
``` | ||
@include nani | ||
↓ | ||
['include', | ||
['atkeyword', | ||
['ident', 'include']], | ||
['s', ' '], | ||
['simpleselector', | ||
['ident', 'nani']]] | ||
``` | ||
For less: | ||
``` | ||
.nani(2px) | ||
↓ | ||
['include', | ||
['class', | ||
['ident', 'nani']], | ||
['arguments', | ||
['dimension', | ||
['number', '2'], | ||
['ident', 'px']]]] | ||
``` | ||
#### interpolatedVariable | ||
Valid only for scss syntax. | ||
Interpolated variable. | ||
For scss and sass: | ||
``` | ||
#{$nani} | ||
↓ | ||
['interpolatedVariable', | ||
['ident', 'nani']] | ||
``` | ||
For less: | ||
``` | ||
@{nani} | ||
↓ | ||
['interpolatedVariable', | ||
['ident', 'nani']] | ||
``` | ||
#### loop | ||
Valid only for scss syntax. | ||
Valid only for scss and sass. | ||
``` | ||
@while 1 > 2 {a{p:v}} | ||
↓ | ||
['loop', | ||
['atkeyword', | ||
['ident', 'while']], | ||
['s', ' '], | ||
['number', '1'], | ||
['s', ' '], | ||
['operator', '>'], | ||
['s', ' '], | ||
['number', '2'], | ||
['s', ' '], | ||
['block', | ||
['ruleset', | ||
['selector', | ||
['simpleselector', | ||
['ident', 'a']]], | ||
['block', | ||
['declaration', | ||
['property', | ||
['ident', 'p']], | ||
['propertyDelim'], | ||
['value', | ||
['ident', 'v']]]]]]] | ||
``` | ||
#### mixin | ||
Valid only for scss syntax. | ||
For scss and sass: | ||
``` | ||
@mixin nani {color:tomato} | ||
↓ | ||
['mixin', | ||
['atkeyword', | ||
['ident', 'mixin']], | ||
['s', ' '], | ||
['ident', 'nani'], | ||
['s', ' '], | ||
['block', | ||
['declaration', | ||
['property', | ||
['ident', 'color']], | ||
['propertyDelim'], | ||
['value', | ||
['ident', 'tomato']]]]] | ||
``` | ||
For less: | ||
``` | ||
.nani (@color) {color:@color} | ||
↓ | ||
['mixin', | ||
['class', | ||
['ident', 'nani']], | ||
['s', ' '], | ||
['arguments', | ||
['variable', | ||
['ident', 'color']]], | ||
['s', ' '], | ||
['block', | ||
['declaration', | ||
['property', | ||
['ident', 'color']], | ||
['propertyDelim'], | ||
['value', | ||
['variable', | ||
['ident', 'color']]]]]] | ||
``` | ||
#### namespace | ||
@@ -656,4 +803,14 @@ | ||
Valid only for scss syntax. | ||
Valid only for less, scss and sass. | ||
``` | ||
&.nani | ||
↓ | ||
['parentselector'], | ||
['class', | ||
['ident', 'nani']] | ||
``` | ||
#### percentage | ||
@@ -674,4 +831,74 @@ | ||
Valid only for scss syntax. | ||
Placeholder. | ||
Valid only for scss and sass. | ||
``` | ||
%button | ||
↓ | ||
['placeholder', | ||
['ident', 'button']] | ||
``` | ||
#### property | ||
CSS property. | ||
``` | ||
top:0 | ||
$color: tomato | ||
↓ | ||
['declaration', | ||
['property', | ||
['ident', 'top']], | ||
['propertyDelim'], | ||
['value', | ||
['number', '0']]] | ||
['declaration', | ||
['property', | ||
['variable', 'color']], | ||
['propertyDelim'], | ||
['value', | ||
['ident', 'tomato']]] | ||
``` | ||
#### propertyDelim | ||
Delimiter `:` between property and value. | ||
``` | ||
color: tomato | ||
↓ | ||
['declaration', | ||
['property', | ||
['ident', 'color']], | ||
['propertyDelim'], | ||
['value', | ||
['s', ' '], | ||
['ident', 'tomato']]] | ||
``` | ||
Sass allows you to put `:` before property: | ||
``` | ||
:color tomato | ||
↓ | ||
['declaration', | ||
['propertyDelim'], | ||
['property', | ||
['ident', 'color'], | ||
['s', ' ']], | ||
['value', | ||
['ident', 'tomato']]] | ||
``` | ||
#### pseudoc | ||
@@ -707,6 +934,2 @@ | ||
#### property | ||
#### raw | ||
@@ -752,2 +975,3 @@ | ||
['ident', 'p']], | ||
['propertyDelim'], | ||
['value', | ||
@@ -878,2 +1102,3 @@ ['ident', 'v']]]]] | ||
['ident', 'p']], | ||
['propertyDelim'], | ||
['value', | ||
@@ -931,12 +1156,74 @@ ['ident', 'v']]]]]] | ||
Value of a property. | ||
``` | ||
color: tomato | ||
↓ | ||
['declaration', | ||
['property', | ||
['ident', 'color']], | ||
['propertyDelim'], | ||
['value', | ||
['s', ' '], | ||
['ident', 'tomato']]] | ||
``` | ||
#### variable | ||
Valid only for scss syntax. | ||
Valid for less, scss and sass. | ||
Sass: | ||
``` | ||
$color | ||
↓ | ||
['variable', | ||
['ident', 'color']] | ||
``` | ||
LESS: | ||
``` | ||
@color | ||
@@foo | ||
↓ | ||
['variable', | ||
['ident', 'color']] | ||
['variable', | ||
['variable', | ||
['ident', 'foo']]] | ||
``` | ||
#### variableslist | ||
Valid only for scss syntax. | ||
Valid for less, scss and sass. | ||
Sass: | ||
``` | ||
$arguments... | ||
↓ | ||
['variableslist', | ||
['variable', | ||
['ident', 'arguments']]] | ||
``` | ||
LESS: | ||
``` | ||
@rest... | ||
↓ | ||
['variableslist', | ||
['variable', | ||
['ident', 'rest']]] | ||
``` | ||
#### vhash | ||
@@ -952,2 +1239,2 @@ | ||
['vhash', 'FFF'] | ||
``` | ||
``` |
@@ -1,2 +0,2 @@ | ||
### Gonzales CSSP usage | ||
### Gonzales usage | ||
@@ -35,33 +35,35 @@ #### 1. Sample | ||
== CSS -> AST: | ||
['stylesheet', | ||
['ruleset', | ||
['selector', | ||
['simpleselector', | ||
['ident', 'a'], | ||
['s', ' ']]], | ||
['block', | ||
['s', ' '], | ||
['declaration', | ||
['property', | ||
['ident', 'color']], | ||
['value', | ||
['s', ' '], | ||
['ident', 'red'], | ||
['stylesheet', | ||
['ruleset', | ||
['selector', | ||
['simpleselector', | ||
['ident', 'a'], | ||
['s', ' ']]], | ||
['block', | ||
['s', ' '], | ||
['declaration', | ||
['property', | ||
['ident', 'color']], | ||
['propertyDelim'], | ||
['value', | ||
['s', ' '], | ||
['ident', 'red'], | ||
['s', ' ']]]]]] | ||
== AST': | ||
['stylesheet', | ||
['ruleset', | ||
['selector', | ||
['simpleselector', | ||
['ident', 'b'], | ||
['s', ' ']]], | ||
['block', | ||
['s', ' '], | ||
['declaration', | ||
['property', | ||
['ident', 'color']], | ||
['value', | ||
['s', ' '], | ||
['ident', 'red'], | ||
['stylesheet', | ||
['ruleset', | ||
['selector', | ||
['simpleselector', | ||
['ident', 'b'], | ||
['s', ' ']]], | ||
['block', | ||
['s', ' '], | ||
['declaration', | ||
['property', | ||
['ident', 'color']], | ||
['propertyDelim'], | ||
['value', | ||
['s', ' '], | ||
['ident', 'red'], | ||
['s', ' ']]]]]] | ||
@@ -90,3 +92,3 @@ | ||
syntax: 'scss' | ||
}) | ||
}); | ||
``` | ||
@@ -96,9 +98,11 @@ where: | ||
- `css` — a string with the CSS style; | ||
- `rule` — a string with the token type (in case the style is not complete); | ||
- `needInfo` — whether to include info object into AST; | ||
- `syntax` — a string with syntax name (`css` is default). | ||
- `rule` — a string with the token type in case the style is not complete | ||
(`'stylesheet'` is default); | ||
- `needInfo` — whether to include info object into AST (`false` is default); | ||
- `syntax` — a string with syntax name (`css` is default, other supported | ||
syntaxes are: `scss`, `sass` and `less`). | ||
Example 1: if you want to parse only *declaration*, you have to call: | ||
``` | ||
cssToAST({ | ||
gonzales.cssToAST({ | ||
css: 'color: red', | ||
@@ -112,5 +116,13 @@ rule: 'declaration' | ||
``` | ||
cssToAST(src); | ||
gonzales.cssToAST(css); | ||
``` | ||
Example 3: if you want to parse a sass file: | ||
``` | ||
gonzales.cssToAST({ | ||
css: css, | ||
syntax: 'sass' | ||
}); | ||
``` | ||
##### AST -> CSS | ||
@@ -117,0 +129,0 @@ |
{ | ||
"name": "gonzales-pe", | ||
"description": "Gonzales Preprocessor Edition (fast CSS parser)", | ||
"version": "2.0.0-rc1", | ||
"version": "2.0.0", | ||
"homepage": "http://github.com/tonyganch/gonzales-pe", | ||
@@ -6,0 +6,0 @@ "bugs": "http://github.com/tonyganch/gonzales-pe/issues", |
Gonzales is a fast CSS parser. | ||
Gonzales PE is a rework with support of preprocessors. | ||
Currently those are supported: SCSS, LESS. | ||
Currently those are supported: SCSS, Sass, LESS. | ||
@@ -18,2 +18,6 @@ For a plan of future work see [issue #4](https://github.com/tonyganch/gonzales-pe/issues/4). | ||
To install dev branch: | ||
npm install git://github.com/tonyganch/gonzales-pe.git#dev | ||
To clone from github: | ||
@@ -25,4 +29,5 @@ | ||
If you cloned the repo from GitHub, make sure to build library files first. | ||
It can be done by running `make` in a projet directory. | ||
If you installed/cloned the repo from GitHub, make sure to build library files | ||
first. | ||
It can be done by running `make` in the module's root directory. | ||
`make` will build both Node.js and web versions (all files are comments-free | ||
@@ -71,3 +76,3 @@ but not compressed). | ||
works, you can use `test/ast.js` file. | ||
Simply change the first two strings (`src` and `syntax` vars) and run: | ||
Simply change the first two strings (`css` and `syntax` vars) and run: | ||
@@ -74,0 +79,0 @@ node test/ast.js |
Sorry, the diff of this file is not supported yet
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
86
0
0
381729
14
9591