From c2ad0c0d882aa534ca4aca6596df61792fd07635 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 27 Jan 2011 10:52:28 -0500 Subject: [PATCH 1/4] Fixing tricky syntax error in font validation. --- lib/mess/tree/reference.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/mess/tree/reference.js b/lib/mess/tree/reference.js index 5dbba5f..4b9ddce 100644 --- a/lib/mess/tree/reference.js +++ b/lib/mess/tree/reference.js @@ -685,8 +685,10 @@ tree.Reference.validValue = function(env, selector, value) { } else { if (tree.Reference.selector(selector).validate) { return tree.Reference.selector(selector).type == value.value[0].is && - tree.Reference._validateValue[tree.Reference.selector(selector).validate]; - (env, value.value[0].value); + tree.Reference + ._validateValue + [tree.Reference.selector(selector).validate] + (env, value.value[0].value); } else { return tree.Reference.selector(selector).type == value.value[0].is; } From 10cf45f42381e7478625bf1a4bb93b7c1ee5f1c9 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 27 Jan 2011 10:58:21 -0500 Subject: [PATCH 2/4] Tweak validation fail language --- lib/mess/tree/rule.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mess/tree/rule.js b/lib/mess/tree/rule.js index 8e690dc..cac5b09 100644 --- a/lib/mess/tree/rule.js +++ b/lib/mess/tree/rule.js @@ -25,8 +25,8 @@ tree.Rule.prototype.toXML = function(env) { return env.error({ message: 'Invalid value for ' + this.name + - ', a ' + - tree.Reference.selector(this.name).type + + ', a valid ' + + tree.Reference.selector(this.name).validate + ' is expected. ' + this.value + ' was given.', index: this.index From b0cec7ca1dc434fa38fd26cfeac75b2adcd344eb Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 27 Jan 2011 11:35:29 -0500 Subject: [PATCH 3/4] Support values separated only by commas, and fix multi-font validation. Fixes #70. --- lib/mess/parser.js | 2 +- lib/mess/tree/reference.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/mess/parser.js b/lib/mess/parser.js index 48d8317..37ccee1 100644 --- a/lib/mess/parser.js +++ b/lib/mess/parser.js @@ -670,7 +670,7 @@ mess.Parser = function Parser(env) { if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') || peek(/^[^{]*(;|})/)) return; - if (match = $(/^([#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+)\s*\(/)) { + if (match = $(/^([#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+)[\s,]*\(/)) { name = match[1]; while (param = $(this.entities.variable) || $(this.entities.literal) diff --git a/lib/mess/tree/reference.js b/lib/mess/tree/reference.js index 4b9ddce..560dd8a 100644 --- a/lib/mess/tree/reference.js +++ b/lib/mess/tree/reference.js @@ -684,11 +684,16 @@ tree.Reference.validValue = function(env, selector, value) { return true; } else { if (tree.Reference.selector(selector).validate) { - return tree.Reference.selector(selector).type == value.value[0].is && - tree.Reference - ._validateValue - [tree.Reference.selector(selector).validate] - (env, value.value[0].value); + for (var i = 0; i < value.value.length; i++) { + if (!(tree.Reference.selector(selector).type == value.value[i].is && + tree.Reference + ._validateValue + [tree.Reference.selector(selector).validate] + (env, value.value[i].value))) { + return false; + } + } + return true; } else { return tree.Reference.selector(selector).type == value.value[0].is; } From 18471b2ab51811b51bfaa37669cda0f84cc69e36 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 27 Jan 2011 11:44:05 -0500 Subject: [PATCH 4/4] Validate font if any font in a fontset is available --- lib/mess/tree/reference.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/mess/tree/reference.js b/lib/mess/tree/reference.js index 560dd8a..9e39e2b 100644 --- a/lib/mess/tree/reference.js +++ b/lib/mess/tree/reference.js @@ -684,16 +684,17 @@ tree.Reference.validValue = function(env, selector, value) { return true; } else { if (tree.Reference.selector(selector).validate) { + var valid = false; for (var i = 0; i < value.value.length; i++) { - if (!(tree.Reference.selector(selector).type == value.value[i].is && + if (tree.Reference.selector(selector).type == value.value[i].is && tree.Reference ._validateValue [tree.Reference.selector(selector).validate] - (env, value.value[i].value))) { - return false; + (env, value.value[i].value)) { + return true; } } - return true; + return valid; } else { return tree.Reference.selector(selector).type == value.value[0].is; }