From f068d2da681267dfd08ae5cc3460a2a913fdde1d Mon Sep 17 00:00:00 2001 From: Luke Page Date: Wed, 20 Mar 2013 08:51:47 +0000 Subject: [PATCH] multi comments in selectors and other places --- lib/less/parser.js | 18 ++++++++++++++---- test/css/comments.css | 3 ++- test/less/comments.less | 8 +++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/less/parser.js b/lib/less/parser.js index 40d8e425..7d2fa6bf 100644 --- a/lib/less/parser.js +++ b/lib/less/parser.js @@ -577,6 +577,16 @@ less.Parser = function Parser(env) { } }, + comments: function () { + var comment, comments = []; + + while(comment = $(this.comment)) { + comments.push(comment); + } + + return comments; + }, + // // Entities are tokens which can be found inside an Expression // @@ -893,7 +903,7 @@ less.Parser = function Parser(env) { if (isCall) { arg = $(this.expression); } else { - $(this.comment); + $(this.comments); if (input.charAt(i) === '.' && $(/^\.{3}/)) { returner.variadic = true; if ($(";") && !isSemiColonSeperated) { @@ -1023,7 +1033,7 @@ less.Parser = function Parser(env) { restore(); } - $(this.comment); + $(this.comments); if ($(/^when/)) { // Guard cond = expect(this.conditions, 'expected condition'); @@ -1199,9 +1209,9 @@ less.Parser = function Parser(env) { while (s = $(this.selector)) { selectors.push(s); - $(this.comment); + $(this.comments); if (! $(',')) { break } - $(this.comment); + $(this.comments); } if (selectors.length > 0 && (rules = $(this.block))) { diff --git a/test/css/comments.css b/test/css/comments.css index 03e82de4..de9f6c11 100644 --- a/test/css/comments.css +++ b/test/css/comments.css @@ -26,7 +26,8 @@ */ /* @group Variables ------------------- */ -#comments { +#comments, +.comments { /**/ color: red; /* A C-style comment */ diff --git a/test/less/comments.less b/test/less/comments.less index b803ff75..7859911e 100644 --- a/test/less/comments.less +++ b/test/less/comments.less @@ -34,7 +34,13 @@ /* @group Variables ------------------- */ -#comments /* boo */ { +#comments /* boo *//* boo again*/, +//.commented_out1 +//.commented_out2 +//.commented_out3 +.comments //end of comments1 +//end of comments2 +{ /**/ // An empty comment color: red; /* A C-style comment */ /* A C-style comment */ background-color: orange; // A little comment