Skip to content

Commit c7d56af

Browse files
committed
add example
1 parent 84f63c6 commit c7d56af

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

example.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
var parse = require('./');
3+
var str = "14px 1.5 'proxima-nova', 'Helvetica Neue', Arial, Helvetica, sans-serif";
4+
5+
console.log(parse(str));
6+

index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,16 @@ Parser.prototype.skip = function(m){
1313
this.str = this.str.slice(m[0].length);
1414
};
1515

16+
Parser.prototype.comma = function(){
17+
var m = /^, */.exec(this.str);
18+
if (!m) return;
19+
this.skip(m);
20+
return { type: ',' };
21+
};
22+
1623
Parser.prototype.ident = function(){
1724
var m = /^([\w-]+) */.exec(this.str);
18-
if (!m) return m;
25+
if (!m) return;
1926
this.skip(m);
2027
return {
2128
type: 'ident',
@@ -89,7 +96,8 @@ Parser.prototype.string = function(){
8996
Parser.prototype.value = function(){
9097
return this.number()
9198
|| this.ident()
92-
|| this.string();
99+
|| this.string()
100+
|| this.comma();
93101
};
94102

95103
Parser.prototype.parse = function(){

0 commit comments

Comments
 (0)