comments, wooh!

browser
cloudhead 15 years ago
parent 808bd55a95
commit 2b0853de81

@ -190,12 +190,23 @@ less.parser = {
var node;
while (node = $(this.ruleset, []) || $(this.rule) || $(this.mixin.definition, []) ||
$(this.mixin.call) || $(/\/\*(?:[^*]|\*+[^\/*])*\*+\//g) || $(/\/\/.*/g) ||
$(this.mixin.call) || $(this.comment) ||
$(/[\n\s]+/g) || $(this.directive, [])) {
root.push(node);
}
return root;
},
comment: function () {
var comment;
if (input[i] !== '/') return;
if (comment = $(/\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/g)) {
return new(tree.Comment)(comment);
} else {
return $(/\/\/.*/g);
}
},
entities: {
quoted: function () {
var str;
@ -404,6 +415,7 @@ less.parser = {
selectors.push(s);
if (! $(',')) { break }
}
if (s) $(this.comment);
}
rules = $(this.block, root);

@ -6,7 +6,8 @@ require.paths.unshift(__dirname);
['color', 'directive', 'operation', 'dimension',
'keyword', 'variable', 'ruleset', 'element',
'selector', 'quoted', 'expression', 'rule',
'call', 'url', 'alpha', 'mixin'
'call', 'url', 'alpha',
'mixin', 'comment'
].forEach(function (n) {
process.mixin(tree, require(path.join('less', 'tree', n)));
});

@ -76,6 +76,12 @@ tree.Ruleset.prototype = {
if (rule.rules) {
rulesets.push(rule.toCSS(paths, env));
} else if (rule instanceof tree.Comment) {
if (this.root) {
rulesets.push(rule.toCSS());
} else {
rules.push(rule.toCSS());
}
} else {
if (rule.toCSS && !rule.variable) {
rules.push(rule.toCSS(env));

@ -1,9 +1,49 @@
/******************\
* *
* Comment Header *
* *
\******************/
/*
Comment
*/
/*
* Comment Test
*
* - cloudhead (http://cloudhead.net)
*
*/
/* Colors
* ------
* #EDF8FC (background blue)
* #166C89 (darkest blue)
*
* Text:
* #333 (standard text) // A comment within a comment!
* #1F9EC9 (standard link)
*
*/
/* @group Variables
------------------- */
#comments {
/**/
color: red;
/* A C-style comment */
background-color: orange;
font-size: 12px;
/* lost comment */
content: "content";
border: 1px solid black;
padding: 0;
margin: 2em;
}
/* commented out
#more-comments {
color: grey;
}
*/
#last {
color: blue;
}

@ -55,4 +55,5 @@
}
*/
#last { color: blue }
//

Loading…
Cancel
Save