Socket
Socket
Sign inDemoInstall

postcss-less

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-less - npm Package Compare versions

Comparing version 0.15.0 to 0.16.0

11

CHANGELOG.md

@@ -0,3 +1,12 @@

## 0.16.0
* added support for PostCSS 5.2+
* fixes output adding superfluous spaces in comments
### PLEASE NOTE
This will be the last version of PostCSS-LESS supporting Node 4.x.
## 0.15.0
* reversed parsing of semicolon after mixin without body fix
* added [shrinkwrap](https://docs.npmjs.com/cli/shrinkwrap) file

@@ -32,2 +41,2 @@ ## 0.14.0

## 0.1
* Initial release.
* Initial release.

2

dist/find-extend-rule.min.js

@@ -1,1 +0,1 @@

"use strict";function findExtendRule(e){for(var t=arguments.length<=1||void 0===arguments[1]?0:arguments[1],d=[],r=e.length,n=t;n<r;){var u=e[n];if(extendRuleKeyWords.indexOf(u[1])>=0)d.push(u[1]);else if("space"!==u[0])break;n++}for(var l=0;l<extendRuleKeyWordsCount;l++)if(d[l]!==extendRuleKeyWords[l])return null;return e.slice(t,n)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=findExtendRule;var extendRuleKeyWords=["&",":","extend"],extendRuleKeyWordsCount=extendRuleKeyWords.length;module.exports=exports["default"];
"use strict";function findExtendRule(e){for(var t=arguments.length<=1||void 0===arguments[1]?0:arguments[1],d=[],r=e.length,n=t;r>n;){var u=e[n];if(extendRuleKeyWords.indexOf(u[1])>=0)d.push(u[1]);else if("space"!==u[0])break;n++}for(var l=0;extendRuleKeyWordsCount>l;l++)if(d[l]!==extendRuleKeyWords[l])return null;return e.slice(t,n)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=findExtendRule;var extendRuleKeyWords=["&",":","extend"],extendRuleKeyWordsCount=extendRuleKeyWords.length;module.exports=exports["default"];

@@ -200,9 +200,16 @@ 'use strict';

}, {
key: 'word',
value: function word() {
key: 'other',
value: function other() {
var end = false;
var colon = false;
var bracket = null;
var brackets = 0;
var brackets = [];
var start = this.pos;
// we need pass "()" as spaces
// However we can override method Parser.loop, but it seems less maintainable
if (this.tokens[start][0] === 'brackets') {
this.spaces += this.tokens[start][1];
return;
}
var isMixin = (0, _isMixinToken2.default)(this.tokens[start]);

@@ -213,3 +220,2 @@ var isExtendRule = Boolean((0, _findExtendRule2.default)(this.tokens, start));

this.pos += 1;
while (this.pos < this.tokens.length) {

@@ -219,3 +225,3 @@ var token = this.tokens[this.pos];

if (type === '(') {
if (type === '(' || type === '[') {
if (!bracket) {

@@ -225,4 +231,4 @@ bracket = token;

brackets += 1;
} else if (brackets === 0) {
brackets.push(type === '(' ? ')' : ']');
} else if (brackets.length === 0) {
if (type === ';') {

@@ -252,5 +258,5 @@ var foundEndOfRule = this.processEndOfRule({

}
} else if (type === ')') {
brackets -= 1;
if (brackets === 0) {
} else if (type === brackets[brackets.length - 1]) {
brackets.pop();
if (brackets.length === 0) {
bracket = null;

@@ -260,3 +266,3 @@ }

if (brackets || type === 'brackets' || params[0]) {
if (brackets.length > 0 || type === 'brackets' || params[0]) {
params.push(token);

@@ -273,3 +279,3 @@ }

if (brackets > 0) {
if (brackets.length > 0) {
this.unclosedBracket(bracket);

@@ -276,0 +282,0 @@ }

@@ -1,1 +0,1 @@

"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),_comment=require("postcss/lib/comment"),_comment2=_interopRequireDefault(_comment),_parser=require("postcss/lib/parser"),_parser2=_interopRequireDefault(_parser),_rule=require("./rule"),_rule2=_interopRequireDefault(_rule),_findExtendRule=require("./find-extend-rule"),_findExtendRule2=_interopRequireDefault(_findExtendRule),_isMixinToken=require("./is-mixin-token"),_isMixinToken2=_interopRequireDefault(_isMixinToken),_lessTokenize=require("./less-tokenize"),_lessTokenize2=_interopRequireDefault(_lessTokenize),blockCommentEndPattern=/\*\/$/,LessParser=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return _inherits(t,e),_createClass(t,[{key:"tokenize",value:function(){this.tokens=(0,_lessTokenize2["default"])(this.input)}},{key:"rule",value:function(e){e.pop();var t=new _rule2["default"];this.init(t,e[0][2],e[0][3]),t.raws.between=this.spacesFromEnd(e),this.raw(t,"selector",e),this.current=t}},{key:"comment",value:function(e){var t=new _comment2["default"],r=e[1],i=r.slice(2).replace(blockCommentEndPattern,"");if(this.init(t,e[2],e[3]),t.source.end={line:e[4],column:e[5]},t.raws.content=r,t.raws.begin=r[0]+r[1],t.inline="inline"===e[6],t.block=!t.inline,/^\s*$/.test(i))t.text="",t.raws.left=i,t.raws.right="";else{var s=i.match(/^(\s*)([^]*[^\s])(\s*)$/);t.text=s[2],t.raws.left=s[1]||" ",t.raws.right=s[3]||" "}}},{key:"createRule",value:function(e){this.rule(this.tokens.slice(e.start,this.pos+1)),e.params[0]&&(e.isMixin||e.isExtendRule)&&this.raw(this.current,"params",e.params)}},{key:"createDeclaration",value:function(e){this.decl(this.tokens.slice(e.start,this.pos+1))}},{key:"ruleWithoutBody",value:function(e){this.createRule(e),this.current.ruleWithoutBody=!0,delete this.current.nodes,this.current.extendRule=this.current.selector.indexOf("&:extend")>=0,this.current.important=this.current.selector.indexOf("!important")>=0,this.pos--,this.end(this.tokens[this.pos])}},{key:"processEndOfRule",value:function(e){var t=e.start;if(e.isExtendRule||e.isMixin)return this.ruleWithoutBody(e),!0;if(e.colon){if(e.isEndOfBlock)for(;this.pos>t;){var r=this.tokens[this.pos][0];if("space"!==r&&"comment"!==r)break;this.pos-=1}return this.createDeclaration({start:t}),!0}return!1}},{key:"word",value:function(){var e=!1,t=!1,r=null,i=0,s=this.pos,n=(0,_isMixinToken2["default"])(this.tokens[s]),o=Boolean((0,_findExtendRule2["default"])(this.tokens,s)),u=[];for(this.pos+=1;this.pos<this.tokens.length;){var l=this.tokens[this.pos],a=l[0];if("("===a)r||(r=l),i+=1;else if(0===i){if(";"===a){var c=this.processEndOfRule({start:s,params:u,colon:t,isMixin:n,isExtendRule:o});if(c)return;break}if("{"===a)return void this.createRule({start:s,params:u,isMixin:n});if("}"===a){this.pos-=1,e=!0;break}":"===a&&(t=!0)}else")"===a&&(i-=1,0===i&&(r=null));(i||"brackets"===a||u[0])&&u.push(l),this.pos+=1}if(this.pos===this.tokens.length&&(this.pos-=1,e=!0),i>0&&this.unclosedBracket(r),e){var f=this.processEndOfRule({start:s,params:u,colon:t,isMixin:n,isExtendRule:o,isEndOfBlock:!0});if(f)return}this.unknownWord(s)}}]),t}(_parser2["default"]);exports["default"]=LessParser,module.exports=exports["default"];
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var s=0;s<t.length;s++){var r=t[s];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,s,r){return s&&e(t.prototype,s),r&&e(t,r),t}}(),_comment=require("postcss/lib/comment"),_comment2=_interopRequireDefault(_comment),_parser=require("postcss/lib/parser"),_parser2=_interopRequireDefault(_parser),_rule=require("./rule"),_rule2=_interopRequireDefault(_rule),_findExtendRule=require("./find-extend-rule"),_findExtendRule2=_interopRequireDefault(_findExtendRule),_isMixinToken=require("./is-mixin-token"),_isMixinToken2=_interopRequireDefault(_isMixinToken),_lessTokenize=require("./less-tokenize"),_lessTokenize2=_interopRequireDefault(_lessTokenize),blockCommentEndPattern=/\*\/$/,LessParser=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return _inherits(t,e),_createClass(t,[{key:"tokenize",value:function(){this.tokens=(0,_lessTokenize2["default"])(this.input)}},{key:"rule",value:function(e){e.pop();var t=new _rule2["default"];this.init(t,e[0][2],e[0][3]),t.raws.between=this.spacesFromEnd(e),this.raw(t,"selector",e),this.current=t}},{key:"comment",value:function(e){var t=new _comment2["default"],s=e[1],r=s.slice(2).replace(blockCommentEndPattern,"");if(this.init(t,e[2],e[3]),t.source.end={line:e[4],column:e[5]},t.raws.content=s,t.raws.begin=s[0]+s[1],t.inline="inline"===e[6],t.block=!t.inline,/^\s*$/.test(r))t.text="",t.raws.left=r,t.raws.right="";else{var i=r.match(/^(\s*)([^]*[^\s])(\s*)$/);t.text=i[2],t.raws.left=i[1]||" ",t.raws.right=i[3]||" "}}},{key:"createRule",value:function(e){this.rule(this.tokens.slice(e.start,this.pos+1)),e.params[0]&&(e.isMixin||e.isExtendRule)&&this.raw(this.current,"params",e.params)}},{key:"createDeclaration",value:function(e){this.decl(this.tokens.slice(e.start,this.pos+1))}},{key:"ruleWithoutBody",value:function(e){this.createRule(e),this.current.ruleWithoutBody=!0,delete this.current.nodes,this.current.extendRule=this.current.selector.indexOf("&:extend")>=0,this.current.important=this.current.selector.indexOf("!important")>=0,this.pos--,this.end(this.tokens[this.pos])}},{key:"processEndOfRule",value:function(e){var t=e.start;if(e.isExtendRule||e.isMixin)return this.ruleWithoutBody(e),!0;if(e.colon){if(e.isEndOfBlock)for(;this.pos>t;){var s=this.tokens[this.pos][0];if("space"!==s&&"comment"!==s)break;this.pos-=1}return this.createDeclaration({start:t}),!0}return!1}},{key:"other",value:function(){var e=!1,t=!1,s=null,r=[],i=this.pos;if("brackets"===this.tokens[i][0])return void(this.spaces+=this.tokens[i][1]);var n=(0,_isMixinToken2["default"])(this.tokens[i]),o=Boolean((0,_findExtendRule2["default"])(this.tokens,i)),u=[];for(this.pos+=1;this.pos<this.tokens.length;){var l=this.tokens[this.pos],a=l[0];if("("===a||"["===a)s||(s=l),r.push("("===a?")":"]");else if(0===r.length){if(";"===a){var c=this.processEndOfRule({start:i,params:u,colon:t,isMixin:n,isExtendRule:o});if(c)return;break}if("{"===a)return void this.createRule({start:i,params:u,isMixin:n});if("}"===a){this.pos-=1,e=!0;break}":"===a&&(t=!0)}else a===r[r.length-1]&&(r.pop(),0===r.length&&(s=null));(r.length>0||"brackets"===a||u[0])&&u.push(l),this.pos+=1}if(this.pos===this.tokens.length&&(this.pos-=1,e=!0),r.length>0&&this.unclosedBracket(s),e){var f=this.processEndOfRule({start:i,params:u,colon:t,isMixin:n,isExtendRule:o,isEndOfBlock:!0});if(f)return}this.unknownWord(i)}}]),t}(_parser2["default"]);exports["default"]=LessParser,module.exports=exports["default"];

@@ -33,10 +33,3 @@ 'use strict';

value: function comment(node) {
var left = this.raw(node, 'left', 'commentLeft');
var right = this.raw(node, 'right', 'commentRight');
if (node.inline) {
this.builder('//' + left + node.text + right, node);
} else {
this.builder('/*' + left + node.text + right + '*/', node);
}
this.builder(node.raws.content, node);
}

@@ -43,0 +36,0 @@ }, {

@@ -1,1 +0,1 @@

"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),_stringifier=require("postcss/lib/stringifier"),_stringifier2=_interopRequireDefault(_stringifier),LessStringifier=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return _inherits(t,e),_createClass(t,[{key:"comment",value:function(e){var t=this.raw(e,"left","commentLeft"),r=this.raw(e,"right","commentRight");e.inline?this.builder("//"+t+e.text+r,e):this.builder("/*"+t+e.text+r+"*/",e)}},{key:"block",value:function(e,t){var r=e.ruleWithoutBody,i=this.raw(e,"between","beforeOpen"),n="";r?this.builder(t+i,e,"start"):this.builder(t+i+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),n=this.raw(e,"after")):n=this.raw(e,"after","emptyBody"),n&&this.builder(n),r||this.builder("}",e,"end")}}]),t}(_stringifier2["default"]);exports["default"]=LessStringifier,module.exports=exports["default"];
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),_stringifier=require("postcss/lib/stringifier"),_stringifier2=_interopRequireDefault(_stringifier),LessStringifier=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return _inherits(t,e),_createClass(t,[{key:"comment",value:function(e){this.builder(e.raws.content,e)}},{key:"block",value:function(e,t){var r=e.ruleWithoutBody,n=this.raw(e,"between","beforeOpen"),i="";r?this.builder(t+n,e,"start"):this.builder(t+n+"{",e,"start"),e.nodes&&e.nodes.length?(this.body(e),i=this.raw(e,"after")):i=this.raw(e,"after","emptyBody"),i&&this.builder(i),r||this.builder("}",e,"end")}}]),t}(_stringifier2["default"]);exports["default"]=LessStringifier,module.exports=exports["default"];

@@ -1,1 +0,1 @@

"use strict";function findEndOfEscaping(e){for(var s=0,l=-1,o=e.pos+1;o<e.length;o++){var a=e.css.charCodeAt(o),r=e.css.charCodeAt(o-1);if(r!==_globals.backslash&&(a===_globals.singleQuote||a===_globals.doubleQuote||a===_globals.backTick))if(l===-1)l=a,s++;else if(a===l&&(s--,!s))return o}return-1}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=findEndOfEscaping;var _globals=require("./globals");module.exports=exports["default"];
"use strict";function findEndOfEscaping(e){for(var s=0,l=-1,o=e.pos+1;o<e.length;o++){var a=e.css.charCodeAt(o),r=e.css.charCodeAt(o-1);if(r!==_globals.backslash&&(a===_globals.singleQuote||a===_globals.doubleQuote||a===_globals.backTick))if(-1===l)l=a,s++;else if(a===l&&(s--,!s))return o}return-1}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=findEndOfEscaping;var _globals=require("./globals");module.exports=exports["default"];

@@ -1,1 +0,1 @@

"use strict";function findEndOfExpression(e,s,r){for(var l=0,a=0;r<s;++r){var o=e[r].charCodeAt(0);if(!(l||a||o!==_globals.semicolon&&o!==_globals.closedCurlyBracket))return r-1;switch(o){case _globals.openedCurlyBracket:a++;break;case _globals.closedCurlyBracket:a--;break;case _globals.openedParenthesis:l++;break;case _globals.closedParenthesis:l--}}return-1}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=findEndOfExpression;var _globals=require("./globals");module.exports=exports["default"];
"use strict";function findEndOfExpression(e,s,r){for(var l=0,a=0;s>r;++r){var o=e[r].charCodeAt(0);if(!(l||a||o!==_globals.semicolon&&o!==_globals.closedCurlyBracket))return r-1;switch(o){case _globals.openedCurlyBracket:a++;break;case _globals.closedCurlyBracket:a--;break;case _globals.openedParenthesis:l++;break;case _globals.closedParenthesis:l--}}return-1}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=findEndOfExpression;var _globals=require("./globals");module.exports=exports["default"];

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var singleQuote=exports.singleQuote="'".charCodeAt(0),doubleQuote=exports.doubleQuote='"'.charCodeAt(0),backslash=exports.backslash="\\".charCodeAt(0),backTick=exports.backTick="`".charCodeAt(0),slash=exports.slash="/".charCodeAt(0),newline=exports.newline="\n".charCodeAt(0),space=exports.space=" ".charCodeAt(0),feed=exports.feed="\f".charCodeAt(0),tab=exports.tab="\t".charCodeAt(0),carriageReturn=exports.carriageReturn="\r".charCodeAt(0),openedParenthesis=exports.openedParenthesis="(".charCodeAt(0),closedParenthesis=exports.closedParenthesis=")".charCodeAt(0),openedCurlyBracket=exports.openedCurlyBracket="{".charCodeAt(0),closedCurlyBracket=exports.closedCurlyBracket="}".charCodeAt(0),semicolon=exports.semicolon=";".charCodeAt(0),asterisk=exports.asterisk="*".charCodeAt(0),colon=exports.colon=":".charCodeAt(0),comma=exports.comma=",".charCodeAt(0),dot=exports.dot=".".charCodeAt(0),atRule=exports.atRule="@".charCodeAt(0),tilde=exports.tilde="~".charCodeAt(0),hash=exports.hash="#".charCodeAt(0),atEndPattern=exports.atEndPattern=/[ \n\t\r\f\{\(\)'"`\\;\/]/g,wordEndPattern=exports.wordEndPattern=/[ \n\t\r\f\(\)\{\}:,;@!'"`\\#]|\/(?=\*)/g,badBracketPattern=exports.badBracketPattern=/.[\\\/\("'\n]/,variablePattern=exports.variablePattern=/^@[^:\(\{]+:/,hashColorPattern=exports.hashColorPattern=/^#[0-9a-fA-F]{6}$|^#[0-9a-fA-F]{3}$/;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var singleQuote=exports.singleQuote="'".charCodeAt(0),doubleQuote=exports.doubleQuote='"'.charCodeAt(0),backslash=exports.backslash="\\".charCodeAt(0),backTick=exports.backTick="`".charCodeAt(0),slash=exports.slash="/".charCodeAt(0),newline=exports.newline="\n".charCodeAt(0),space=exports.space=" ".charCodeAt(0),feed=exports.feed="\f".charCodeAt(0),tab=exports.tab=" ".charCodeAt(0),carriageReturn=exports.carriageReturn="\r".charCodeAt(0),openedParenthesis=exports.openedParenthesis="(".charCodeAt(0),closedParenthesis=exports.closedParenthesis=")".charCodeAt(0),openedCurlyBracket=exports.openedCurlyBracket="{".charCodeAt(0),closedCurlyBracket=exports.closedCurlyBracket="}".charCodeAt(0),semicolon=exports.semicolon=";".charCodeAt(0),asterisk=exports.asterisk="*".charCodeAt(0),colon=exports.colon=":".charCodeAt(0),comma=exports.comma=",".charCodeAt(0),dot=exports.dot=".".charCodeAt(0),atRule=exports.atRule="@".charCodeAt(0),tilde=exports.tilde="~".charCodeAt(0),hash=exports.hash="#".charCodeAt(0),atEndPattern=exports.atEndPattern=/[ \n\t\r\f\{\(\)'"`\\;\/]/g,wordEndPattern=exports.wordEndPattern=/[ \n\t\r\f\(\)\{\}:,;@!'"`\\#]|\/(?=\*)/g,badBracketPattern=exports.badBracketPattern=/.[\\\/\("'\n]/,variablePattern=exports.variablePattern=/^@[^:\(\{]+:/,hashColorPattern=exports.hashColorPattern=/^#[0-9a-fA-F]{6}$|^#[0-9a-fA-F]{3}$/;

@@ -1,1 +0,1 @@

"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function tokenizeAtRule(e){e.css.charCodeAt(e.pos+1)===_globals.openedCurlyBracket?(e.nextPos=e.css.indexOf("}",e.pos+2),e.nextPos===-1&&(0,_unclosed2["default"])(e,"interpolation"),e.cssPart=e.css.slice(e.pos,e.nextPos+1),e.lines=e.cssPart.split("\n"),e.lastLine=e.lines.length-1,e.lastLine>0?(e.nextLine=e.line+e.lastLine,e.nextOffset=e.nextPos-e.lines[e.lastLine].length):(e.nextLine=e.line,e.nextOffset=e.offset),e.tokens.push(["word",e.cssPart,e.line,e.pos-e.offset,e.nextLine,e.nextPos-e.nextOffset]),e.offset=e.nextOffset,e.line=e.nextLine):(_globals.atEndPattern.lastIndex=e.pos+1,_globals.atEndPattern.test(e.css),0===_globals.atEndPattern.lastIndex?e.nextPos=e.css.length-1:e.nextPos=_globals.atEndPattern.lastIndex-2,e.cssPart=e.css.slice(e.pos,e.nextPos+1),e.token="at-word",_globals.variablePattern.test(e.cssPart)&&(_globals.wordEndPattern.lastIndex=e.pos+1,_globals.wordEndPattern.test(e.css),0===_globals.wordEndPattern.lastIndex?e.nextPos=e.css.length-1:e.nextPos=_globals.wordEndPattern.lastIndex-2,e.cssPart=e.css.slice(e.pos,e.nextPos+1),e.token="word"),e.tokens.push([e.token,e.cssPart,e.line,e.pos-e.offset,e.line,e.nextPos-e.offset])),e.pos=e.nextPos}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=tokenizeAtRule;var _globals=require("./globals"),_unclosed=require("./unclosed"),_unclosed2=_interopRequireDefault(_unclosed);module.exports=exports["default"];
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function tokenizeAtRule(e){e.css.charCodeAt(e.pos+1)===_globals.openedCurlyBracket?(e.nextPos=e.css.indexOf("}",e.pos+2),-1===e.nextPos&&(0,_unclosed2["default"])(e,"interpolation"),e.cssPart=e.css.slice(e.pos,e.nextPos+1),e.lines=e.cssPart.split("\n"),e.lastLine=e.lines.length-1,e.lastLine>0?(e.nextLine=e.line+e.lastLine,e.nextOffset=e.nextPos-e.lines[e.lastLine].length):(e.nextLine=e.line,e.nextOffset=e.offset),e.tokens.push(["word",e.cssPart,e.line,e.pos-e.offset,e.nextLine,e.nextPos-e.nextOffset]),e.offset=e.nextOffset,e.line=e.nextLine):(_globals.atEndPattern.lastIndex=e.pos+1,_globals.atEndPattern.test(e.css),0===_globals.atEndPattern.lastIndex?e.nextPos=e.css.length-1:e.nextPos=_globals.atEndPattern.lastIndex-2,e.cssPart=e.css.slice(e.pos,e.nextPos+1),e.token="at-word",_globals.variablePattern.test(e.cssPart)&&(_globals.wordEndPattern.lastIndex=e.pos+1,_globals.wordEndPattern.test(e.css),0===_globals.wordEndPattern.lastIndex?e.nextPos=e.css.length-1:e.nextPos=_globals.wordEndPattern.lastIndex-2,e.cssPart=e.css.slice(e.pos,e.nextPos+1),e.token="word"),e.tokens.push([e.token,e.cssPart,e.line,e.pos-e.offset,e.line,e.nextPos-e.offset])),e.pos=e.nextPos}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=tokenizeAtRule;var _globals=require("./globals"),_unclosed=require("./unclosed"),_unclosed2=_interopRequireDefault(_unclosed);module.exports=exports["default"];

@@ -1,1 +0,1 @@

"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function tokenizeDefault(e){var n=e.css.charCodeAt(e.pos+1);if(e.symbolCode===_globals.slash&&n===_globals.asterisk)(0,_tokenizeMultilineComment2["default"])(e);else if(e.symbolCode===_globals.slash&&n===_globals.slash)(0,_tokenizeInlineComment2["default"])(e);else{if((0,_isEscaping2["default"])(e)){var t=(0,_findEndOfEscaping2["default"])(e);t<0?(0,_unclosed2["default"])(e,"escaping"):e.nextPos=t}else _globals.wordEndPattern.lastIndex=e.pos+1,_globals.wordEndPattern.test(e.css),0===_globals.wordEndPattern.lastIndex?e.nextPos=e.css.length-1:e.nextPos=_globals.wordEndPattern.lastIndex-2;e.cssPart=e.css.slice(e.pos,e.nextPos+1),e.tokens.push(["word",e.cssPart,e.line,e.pos-e.offset,e.line,e.nextPos-e.offset]),e.pos=e.nextPos}}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=tokenizeDefault;var _globals=require("./globals"),_findEndOfEscaping=require("./find-end-of-escaping"),_findEndOfEscaping2=_interopRequireDefault(_findEndOfEscaping),_isEscaping=require("./is-escaping"),_isEscaping2=_interopRequireDefault(_isEscaping),_tokenizeInlineComment=require("./tokenize-inline-comment"),_tokenizeInlineComment2=_interopRequireDefault(_tokenizeInlineComment),_tokenizeMultilineComment=require("./tokenize-multiline-comment"),_tokenizeMultilineComment2=_interopRequireDefault(_tokenizeMultilineComment),_unclosed=require("./unclosed"),_unclosed2=_interopRequireDefault(_unclosed);module.exports=exports["default"];
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function tokenizeDefault(e){var n=e.css.charCodeAt(e.pos+1);if(e.symbolCode===_globals.slash&&n===_globals.asterisk)(0,_tokenizeMultilineComment2["default"])(e);else if(e.symbolCode===_globals.slash&&n===_globals.slash)(0,_tokenizeInlineComment2["default"])(e);else{if((0,_isEscaping2["default"])(e)){var t=(0,_findEndOfEscaping2["default"])(e);0>t?(0,_unclosed2["default"])(e,"escaping"):e.nextPos=t}else _globals.wordEndPattern.lastIndex=e.pos+1,_globals.wordEndPattern.test(e.css),0===_globals.wordEndPattern.lastIndex?e.nextPos=e.css.length-1:e.nextPos=_globals.wordEndPattern.lastIndex-2;e.cssPart=e.css.slice(e.pos,e.nextPos+1),e.tokens.push(["word",e.cssPart,e.line,e.pos-e.offset,e.line,e.nextPos-e.offset]),e.pos=e.nextPos}}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=tokenizeDefault;var _globals=require("./globals"),_findEndOfEscaping=require("./find-end-of-escaping"),_findEndOfEscaping2=_interopRequireDefault(_findEndOfEscaping),_isEscaping=require("./is-escaping"),_isEscaping2=_interopRequireDefault(_isEscaping),_tokenizeInlineComment=require("./tokenize-inline-comment"),_tokenizeInlineComment2=_interopRequireDefault(_tokenizeInlineComment),_tokenizeMultilineComment=require("./tokenize-multiline-comment"),_tokenizeMultilineComment2=_interopRequireDefault(_tokenizeMultilineComment),_unclosed=require("./unclosed"),_unclosed2=_interopRequireDefault(_unclosed);module.exports=exports["default"];

@@ -1,1 +0,1 @@

"use strict";function tokenizeInlineComment(e){e.nextPos=e.css.indexOf("\n",e.pos+2)-1,e.nextPos===-2&&(e.nextPos=e.css.length-1),e.tokens.push(["comment",e.css.slice(e.pos,e.nextPos+1),e.line,e.pos-e.offset,e.line,e.nextPos-e.offset,"inline"]),e.pos=e.nextPos}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=tokenizeInlineComment,module.exports=exports["default"];
"use strict";function tokenizeInlineComment(e){e.nextPos=e.css.indexOf("\n",e.pos+2)-1,-2===e.nextPos&&(e.nextPos=e.css.length-1),e.tokens.push(["comment",e.css.slice(e.pos,e.nextPos+1),e.line,e.pos-e.offset,e.line,e.nextPos-e.offset,"inline"]),e.pos=e.nextPos}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=tokenizeInlineComment,module.exports=exports["default"];

@@ -1,1 +0,1 @@

"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function findClosedParenthesisPosition(e,s,o){for(var t=0,n=o;n<s;n++){var l=e[n];if("("===l)t++;else if(")"===l&&(t--,!t))return n}return-1}function tokenizeOpenedParenthesis(e){var s=e.css.charCodeAt(e.pos+1),o=e.tokens.length,t=o?e.tokens[o-1][1]:"";if("url"===t&&s!==_globals.singleQuote&&s!==_globals.doubleQuote&&s!==_globals.space&&s!==_globals.newline&&s!==_globals.tab&&s!==_globals.feed&&s!==_globals.carriageReturn){e.nextPos=e.pos;do for(e.escaped=!1,e.nextPos=e.css.indexOf(")",e.nextPos+1),e.nextPos===-1&&(0,_unclosed2["default"])(e,"bracket"),e.escapePos=e.nextPos;e.css.charCodeAt(e.escapePos-1)===_globals.backslash;)e.escapePos-=1,e.escaped=!e.escaped;while(e.escaped);e.tokens.push(["brackets",e.css.slice(e.pos,e.nextPos+1),e.line,e.pos-e.offset,e.line,e.nextPos-e.offset]),e.pos=e.nextPos}else{e.nextPos=findClosedParenthesisPosition(e.css,e.length,e.pos),e.cssPart=e.css.slice(e.pos,e.nextPos+1);var n=e.cssPart.indexOf("@")>=0,l=/['"]/.test(e.cssPart);if(0===e.cssPart.length||"..."===e.cssPart||n&&!l)e.nextPos===-1&&(0,_unclosed2["default"])(e,"bracket"),e.tokens.push([e.symbol,e.symbol,e.line,e.pos-e.offset]);else{var a=_globals.badBracketPattern.test(e.cssPart);e.nextPos===-1||a?e.tokens.push([e.symbol,e.symbol,e.line,e.pos-e.offset]):(e.tokens.push(["brackets",e.cssPart,e.line,e.pos-e.offset,e.line,e.nextPos-e.offset]),e.pos=e.nextPos)}}}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=tokenizeOpenedParenthesis;var _globals=require("./globals"),_unclosed=require("./unclosed"),_unclosed2=_interopRequireDefault(_unclosed);module.exports=exports["default"];
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function findClosedParenthesisPosition(e,s,o){for(var t=0,n=o;s>n;n++){var l=e[n];if("("===l)t++;else if(")"===l&&(t--,!t))return n}return-1}function tokenizeOpenedParenthesis(e){var s=e.css.charCodeAt(e.pos+1),o=e.tokens.length,t=o?e.tokens[o-1][1]:"";if("url"===t&&s!==_globals.singleQuote&&s!==_globals.doubleQuote&&s!==_globals.space&&s!==_globals.newline&&s!==_globals.tab&&s!==_globals.feed&&s!==_globals.carriageReturn){e.nextPos=e.pos;do for(e.escaped=!1,e.nextPos=e.css.indexOf(")",e.nextPos+1),-1===e.nextPos&&(0,_unclosed2["default"])(e,"bracket"),e.escapePos=e.nextPos;e.css.charCodeAt(e.escapePos-1)===_globals.backslash;)e.escapePos-=1,e.escaped=!e.escaped;while(e.escaped);e.tokens.push(["brackets",e.css.slice(e.pos,e.nextPos+1),e.line,e.pos-e.offset,e.line,e.nextPos-e.offset]),e.pos=e.nextPos}else{e.nextPos=findClosedParenthesisPosition(e.css,e.length,e.pos),e.cssPart=e.css.slice(e.pos,e.nextPos+1);var n=e.cssPart.indexOf("@")>=0,l=/['"]/.test(e.cssPart);if(0===e.cssPart.length||"..."===e.cssPart||n&&!l)-1===e.nextPos&&(0,_unclosed2["default"])(e,"bracket"),e.tokens.push([e.symbol,e.symbol,e.line,e.pos-e.offset]);else{var a=_globals.badBracketPattern.test(e.cssPart);-1===e.nextPos||a?e.tokens.push([e.symbol,e.symbol,e.line,e.pos-e.offset]):(e.tokens.push(["brackets",e.cssPart,e.line,e.pos-e.offset,e.line,e.nextPos-e.offset]),e.pos=e.nextPos)}}}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=tokenizeOpenedParenthesis;var _globals=require("./globals"),_unclosed=require("./unclosed"),_unclosed2=_interopRequireDefault(_unclosed);module.exports=exports["default"];

@@ -1,1 +0,1 @@

"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function tokenizeQuotes(e){e.nextPos=e.pos;do for(e.escaped=!1,e.nextPos=e.css.indexOf(e.symbol,e.nextPos+1),e.nextPos===-1&&(0,_unclosed2["default"])(e,"quote"),e.escapePos=e.nextPos;e.css.charCodeAt(e.escapePos-1)===_globals.backslash;)e.escapePos-=1,e.escaped=!e.escaped;while(e.escaped);e.tokens.push(["string",e.css.slice(e.pos,e.nextPos+1),e.line,e.pos-e.offset,e.line,e.nextPos-e.offset]),e.pos=e.nextPos}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=tokenizeQuotes;var _globals=require("./globals"),_unclosed=require("./unclosed"),_unclosed2=_interopRequireDefault(_unclosed);module.exports=exports["default"];
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function tokenizeQuotes(e){e.nextPos=e.pos;do for(e.escaped=!1,e.nextPos=e.css.indexOf(e.symbol,e.nextPos+1),-1===e.nextPos&&(0,_unclosed2["default"])(e,"quote"),e.escapePos=e.nextPos;e.css.charCodeAt(e.escapePos-1)===_globals.backslash;)e.escapePos-=1,e.escaped=!e.escaped;while(e.escaped);e.tokens.push(["string",e.css.slice(e.pos,e.nextPos+1),e.line,e.pos-e.offset,e.line,e.nextPos-e.offset]),e.pos=e.nextPos}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=tokenizeQuotes;var _globals=require("./globals"),_unclosed=require("./unclosed"),_unclosed2=_interopRequireDefault(_unclosed);module.exports=exports["default"];
{
"name": "postcss-less",
"version": "0.15.0",
"version": "0.16.0",
"description": "LESS parser for PostCSS",

@@ -19,3 +19,6 @@ "keywords": [

"Andrew Powell <andrew@shellscape.org>",
"Pat Sissons <patricksissons@gmail.com>"
"Pat Sissons <patricksissons@gmail.com>",
"Jeff Lindsey jeffalindsey@gmail.com",
"Denys Kniazevych webschik@gmail.com",
"Andrey Sitnik andrey@sitnik.ru"
],

@@ -36,3 +39,3 @@ "license": "MIT",

"dependencies": {
"postcss": "^5.0.21"
"postcss": "^5.2.16"
},

@@ -39,0 +42,0 @@ "devDependencies": {

@@ -1,3 +0,1 @@

# PostCSS LESS Syntax
[PostCSS]: https://github.com/postcss/postcss

@@ -9,4 +7,6 @@ [PostCSS-SCSS]: https://github.com/postcss/postcss-scss

> This project is not stable and is in development. If you'd like to contribute, please submit a Pull Request.
# PostCSS LESS Syntax [![Build Status](https://img.shields.io/travis/shellscape/postcss-less.svg?branch=develop)](https://travis-ci.org/webschik/postcss-less) [![npm Version](https://img.shields.io/npm/v/postcss-less.svg)](https://www.npmjs.com/package/postcss-less)
[PostCSS] Syntax for parsing [LESS]
<img align="right" width="95" height="95"

@@ -16,28 +16,24 @@ title="Philosopher's stone, logo of PostCSS"

[![Build Status](https://img.shields.io/travis/webschik/postcss-less.svg?branch=develop)](https://travis-ci.org/webschik/postcss-less)
[![npm Downloads](https://img.shields.io/npm/dt/postcss-less.svg)](https://www.npmjs.com/package/postcss-less)
[![npm Version](https://img.shields.io/npm/v/postcss-less.svg)](https://www.npmjs.com/package/postcss-less)
[![npm License](https://img.shields.io/npm/l/postcss-less.svg)](https://www.npmjs.com/package/postcss-less)
[![js-strict-standard-style](https://img.shields.io/badge/code%20style-strict-117D6B.svg)](https://github.com/keithamus/eslint-config-strict)
Please note: poscss-less is not a LESS compiler. For compiling LESS, please use
the official toolset for LESS.
A [LESS] parser for [PostCSS].
## Getting Started
**This module does not compile LESS.** It simply parses mixins and variables so that PostCSS plugins can then transform LESS source code alongside CSS.
First thing's first, install the module:
## Use Cases
```
npm install postcss-less --save-dev
```
* lint your LESS code with 3rd-part plugins.
* apply PostCSS transformations (such as [Autoprefixer](https://github.com/postcss/autoprefixer)) directly to the LESS source code
## LESS Transformations
## Usage
The most common use of `postcss-less` is for applying PostCSS transformations
directly to LESS source. eg. ia theme written in LESS which uses [Autoprefixer]
to add appropriate vendor prefixes.
### LESS Transformations
The main use case of this plugin is to apply PostCSS transformations directly
to LESS source code. For example, if you ship a theme written in LESS and need
[Autoprefixer] to add the appropriate vendor prefixes to it.
```js
const syntax = require('postcss-less');
postcss(plugins).process(lessText, { syntax: syntax }).then(function (result) {
postcss(plugins)
.process(lessText, { syntax: syntax })
.then(function (result) {
result.content // LESS with transformations

@@ -47,9 +43,7 @@ });

### Comments
## Inline Comments
#### Inline comments
Parsing of single-line comments in CSS is also supported.
This module also enables parsing of single-line comments in CSS source code.
````less
```less
:root {

@@ -59,15 +53,16 @@ // Main theme color

}
````
```
Note that you don't need a special stringifier to handle the output; the default
one will automatically convert single line comments into block comments.
If you need to get inline comments, use [custom PostCSSLess stringifier](#stringifier)
Note that you don't need a custom stringifier to handle the output; the default
stringifier will automatically convert single line comments into block comments.
If you need to support inline comments, please use a [custom PostCSSLess stringifier](#stringifier).
### Rule node
## Rule Node
[PostCSS Rule Node](https://github.com/postcss/postcss/blob/master/docs/api.md#rule-node)
#### rule.ruleWithoutBody
It shows that Rule node has body or not.
### rule.ruleWithoutBody
Determines whether or not a rule has a body, or content.
````js
```js
import postCssLess from 'postcss-less';

@@ -84,9 +79,10 @@ const less = `

root.first.nodes[1].ruleWithoutBody // => true for calling of mixin
````
#### rule.nodes
```
### rule.nodes
Array of children nodes.
An `Array` of child nodes.
**Note** that rules without body don't have this property.
````js
```js
import postCssLess from 'postcss-less';

@@ -103,8 +99,10 @@ const less = `

root.first.nodes[1].nodes // => undefined for mixin calling
````
```
#### rule.extendRule
It shows that Rule node is a nested [extend](http://lesscss.org/features/#extend-feature-extend-inside-ruleset) rule.
### rule.extendRule
````js
Determines whether or not a rule is nested (eg.
[extended](http://lesscss.org/features/#extend-feature-extend-inside-ruleset)).
```js
import postCssLess from 'postcss-less';

@@ -119,11 +117,13 @@ const less = `

root.first.nodes[0].extendRule // => true
````
```
### Comment Node
## Comment Node
[PostCSS Comment Node](https://github.com/postcss/postcss/blob/master/docs/api.md#comment-node)
#### comment.inline
It's inline comment or not.
````js
### comment.inline
Determines whether or not a comment is inline.
```js
import postCssLess from 'postcss-less';

@@ -134,7 +134,9 @@

root.first.inline // => true
````
```
#### comment.block
It's block comment or not.
````js
### comment.block
Determines whether or not a comment is a block comment.
```js
import postCssLess from 'postcss-less';

@@ -145,10 +147,13 @@

root.first.block // => true
````
```
#### comment.raws.begin
Precending characters of comment node: `//` or `/*`.
### comment.raws.begin
#### comment.raws.content
Precending characters of a comment node. eg. `//` or `/*`.
### comment.raws.content
Raw content of the comment.
````js
```js
import postCssLess from 'postcss-less';

@@ -159,9 +164,10 @@

root.first.raws.content // => '// Hello world'
````
```
### Stringifier
## Stringifying
If you need to have LESS code without PostCSS transformation, you have to specify a custom stringifier:
To process LESS code without PostCSS transformations, custom stringifier
should be provided.
````js
```js
import postcss from 'postcss';

@@ -173,3 +179,3 @@ import postcssLess from 'postcss-less';

// Non-css comment
.container {

@@ -182,3 +188,3 @@ .mixin-1();

}
.rotation(@deg:5deg){

@@ -189,11 +195,19 @@ .transform(rotate(@deg));

postcss().process(less, {
postcss()
.process(less, {
syntax: postcssLess,
stringifier: stringify
}).then((result) => {
console.log(result.content); // this will be value of `lessCode` without changing of comment nodes and mixins
});
````
})
.then((result) => {
console.log(result.content); // this will be value of `lessCode` without changing comments or mixins
});
```
## Use Cases
* Lint LESS code with 3rd-party plugins.
* Apply PostCSS transformations (such as [Autoprefixer](https://github.com/postcss/autoprefixer)) directly to the LESS source code
## Contribution
Please, check our guidelines: [CONTRIBUTING.md](./CONTRIBUTING.md)

@@ -203,2 +217,6 @@

This module is based on the work of [postcss-scss](https://github.com/postcss/postcss-scss) library and includes the `LESS` parser efforts of [github:gilt/postcss-less](https://github.com/gilt/postcss-less)
This module is based on the [postcss-scss](https://github.com/postcss/postcss-scss) library.
[![npm Downloads](https://img.shields.io/npm/dt/postcss-less.svg)](https://www.npmjs.com/package/postcss-less)
[![npm License](https://img.shields.io/npm/l/postcss-less.svg)](https://www.npmjs.com/package/postcss-less)
[![js-strict-standard-style](https://img.shields.io/badge/code%20style-strict-117D6B.svg)](https://github.com/keithamus/eslint-config-strict)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc