url() parsing

This commit is contained in:
cloudhead 2010-02-25 21:27:23 -05:00
parent 6d022858be
commit 8a7747d15b
3 changed files with 18 additions and 1 deletions

View File

@ -8,7 +8,8 @@ process.mixin(less, require('less/parser'));
['color', 'directive', 'operation', 'dimension',
'keyword', 'variable', 'ruleset', 'element',
'selector', 'quoted', 'expression', 'rule', 'call'
'selector', 'quoted', 'expression', 'rule',
'call', 'url'
].forEach(function (n) {
process.mixin(less.parser, require(path.join('less', 'node', n)));
});

9
lib/less/node/url.js Normal file
View File

@ -0,0 +1,9 @@
node.URL = function URL(val) {
this.value = val;
};
node.URL.prototype = {
toCSS: function () {
return "url(" + this.value.toCSS ? this.value.toCSS() : this.value + ")";
}
};

View File

@ -206,6 +206,13 @@ less.parser = {
$(this.entities.string);
},
url: function url() {
var value;
if (! $(/url\(/g)) return;
value = $(this.entities.string) || $(/[-a-zA-Z0-9_%@$\/.&=:;#+?]+/g);
if (! $(')')) throw new(Error)("missing closing ) for url()");
return new(node.URL)(value);
},
font: function font() {
},