Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Allow for quoted empty strings with double-quotes (fixes #16) #17

Merged
merged 2 commits into from
Dec 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var output = postcss()
.css;
```

Using this ```input.css```:
Using this ```input.css```:

```css
.foo {
Expand Down Expand Up @@ -70,7 +70,7 @@ and with [postcss-for]:

```css
@for $i from 1 to 3 {
.b-$i {
.b-$i {
width: $i px;
@if $i == 2 {
color: green;
Expand All @@ -79,4 +79,9 @@ and with [postcss-for]:
}
```

[postcss-for]: https://github.com/antyakushev/postcss-for
[postcss-for]: https://github.com/antyakushev/postcss-for

## Development
1. Clone repository
2. Install dependencies `npm install`
3. If `parser.jison` file has been changed, regenerate `parser.js` by running `npm run gen-parser`
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
"postcss": "^5.0.4"
},
"devDependencies": {
"jison": "^0.4.17",
"tap-dot": "^1.0.0",
"tape": "^4.0.2"
},
"scripts": {
"test": "node test/test.js | tap-dot"
"test": "node test/test.js | tap-dot",
"gen-parser": "jison parser.jison"
}
}
1 change: 1 addition & 0 deletions parser.jison
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ hsla\(\s*[0-9]+\s*\,\s*[0-9]+\%\s*\,\s*[0-9]+\%\s*\,\s*([0-1]|0?\.[0-9]+)\s*\)
[0-9]+("."[0-9]+)?\b return 'NUMBER';
[a-zA-Z0-9-_.]+\b return 'STRING';
\'(\\[^\']|[^\'\\])*\' yytext = yytext.slice(1,-1); return 'STRING';
\"(\\[^\"]|[^\"\\])*\" yytext = yytext.slice(1,-1); return 'STRING';
"(" return 'LPAREN';
")" return 'RPAREN';
"==" return 'RELOP';
Expand Down
18 changes: 10 additions & 8 deletions parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ test('@if true { foo: bar } @else if false { bar: baz } @else { bat: quux }', 'f
test('@if false { foo: bar } @else if true { bar: baz } @else { bat: quux }', 'bar: baz');
test('@if false { foo: bar } @else if false { bar: baz } @else { bat: quux }', 'bat: quux');
test('@if \'\' == \'\' { foo: bar }', 'foo: bar');
test('@if "" == "" { foo: bar }', 'foo: bar');
test('@if \'\' == "" { foo: bar }', 'foo: bar');
test('@if "" == \'\' { foo: bar }', 'foo: bar');
test('@if \'foo\\bar\' == \'foo\\bar\' { foo: bar }', 'foo: bar');
test('@if .foo == .foo { foo: bar }', 'foo: bar');
test('@if .foo == .bar { foo: bar }', '');