Add support for unicode descriptors. Fixes #1107

This commit is contained in:
Luke Page
2012-11-05 20:30:49 +00:00
parent 8930ad3a44
commit dddda0b0d3
5 changed files with 32 additions and 6 deletions

View File

@@ -89,7 +89,7 @@ var less = {
'call', 'url', 'alpha', 'import',
'mixin', 'comment', 'anonymous', 'value',
'javascript', 'assignment', 'condition', 'paren',
'media', 'ratio'
'media', 'ratio', 'unicode-descriptor'
].forEach(function (n) {
require('./tree/' + n);
});

View File

@@ -631,7 +631,8 @@ less.Parser = function Parser(env) {
return $(this.entities.ratio) ||
$(this.entities.dimension) ||
$(this.entities.color) ||
$(this.entities.quoted);
$(this.entities.quoted) ||
$(this.entities.unicodeDescriptor);
},
// Assignments are argument entities for calls.
@@ -734,6 +735,19 @@ less.Parser = function Parser(env) {
return new(tree.Ratio)(value[1]);
}
},
//
// A unicode descriptor, as is used in unicode-range
//
// U+0?? or U+00A1-00A9
//
unicodeDescriptor: function () {
var ud;
if (ud = $(/^U\+[0-9a-fA-F?]+(\-[0-9a-fA-F?]+)?/)) {
return new(tree.UnicodeDescriptor)(ud[0]);
}
},
//
// JavaScript code to be evaluated
@@ -962,7 +976,7 @@ less.Parser = function Parser(env) {
//
entity: function () {
return $(this.entities.literal) || $(this.entities.variable) || $(this.entities.url) ||
$(this.entities.call) || $(this.entities.keyword) || $(this.entities.javascript) ||
$(this.entities.call) || $(this.entities.keyword) ||$(this.entities.javascript) ||
$(this.comment);
},
@@ -1073,9 +1087,6 @@ less.Parser = function Parser(env) {
if (elements.length > 0) { return new(tree.Selector)(elements) }
},
tag: function () {
return $(/^[A-Za-z][A-Za-z-]*[0-9]?/) || $('*');
},
attribute: function () {
var attr = '', key, val, op;

View File

@@ -0,0 +1,13 @@
(function (tree) {
tree.UnicodeDescriptor = function (value) {
this.value = value;
};
tree.UnicodeDescriptor.prototype = {
toCSS: function (env) {
return this.value;
},
eval: function () { return this }
};
})(require('../tree'));

View File

@@ -6,6 +6,7 @@
@font-face {
font-family: Headline;
src: local(Futura-Medium), url(fonts.svg#MyGeometricModern) format("svg");
unicode-range: U+??????, U+0???, U+0-7F, U+A5;
}
.other {
-moz-transform: translate(0, 11em) rotate(-90deg);

View File

@@ -8,6 +8,7 @@
font-family: Headline;
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
unicode-range: U+??????, U+0???, U+0-7F, U+A5;
}
.other {
-moz-transform: translate(0, 11em) rotate(-90deg);