From 509b6320c620daec021b118983c4612831f72c6a Mon Sep 17 00:00:00 2001 From: Tj Holowaychuk Date: Sat, 8 Oct 2011 14:23:18 -0700 Subject: [PATCH] Added #nn support (#ef -> #efefef) --- lib/lexer.js | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/lexer.js b/lib/lexer.js index 2fd9e27f3..72ea64a66 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -642,16 +642,36 @@ Lexer.prototype = { }, /** - * #rrggbbaa | #rrggbb | #rgba | #rgb + * #rrggbbaa | #rrggbb | #rgba | #rgb | #nn | #n */ color: function() { - return this.rrggbbaa() - || this.rrggbb() - || this.rgba() - || this.rgb() + return this.rrggbbaa() + || this.rrggbb() + || this.rgba() + || this.rgb() + || this.nn() + // || this.n() }, + + /** + * #nn + */ + nn: function() { + var captures; + if (captures = /^#([a-fA-F0-9]{2}) */.exec(this.str)) { + this.skip(captures); + var n = captures[1] + , r = parseInt(n, 16) + , g = parseInt(n, 16) + , b = parseInt(n, 16) + , color = new nodes.RGBA(r, g, b, 1); + color.raw = captures[0]; + return new Token('color', color); + } + }, + /** * #rgb */