postcss-less
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -222,9 +222,19 @@ 'use strict'; | ||
node.raws.between = tokn[1]; | ||
} else if (node.urlFunc) { | ||
node.raws.beforeUrl = tokn[1]; | ||
} else if (node.importPath) { | ||
node.raws.after = tokn[1]; | ||
if (node.urlFunc) { | ||
node.raws.afterUrl = tokn[1]; | ||
} else { | ||
node.raws.after = tokn[1]; | ||
} | ||
} else { | ||
node.raws.afterName = tokn[1]; | ||
} | ||
} else if (tokn[0] === 'word' && tokn[1] === 'url') { | ||
node.urlFunc = true; | ||
} else { | ||
node.importPath = tokn[1]; | ||
if (tokn[0] !== '(' && tokn[0] !== ')') { | ||
node.importPath = tokn[1]; | ||
} | ||
} | ||
@@ -231,0 +241,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 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}}(),_get=function e(t,r,n){null===t&&(t=Function.prototype);var s=Object.getOwnPropertyDescriptor(t,r);if(void 0===s){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,r,n)}if("value"in s)return s.value;var o=s.get;if(void 0!==o)return o.call(n)},_comment=require("postcss/lib/comment"),_comment2=_interopRequireDefault(_comment),_import2=require("./import"),_import3=_interopRequireDefault(_import2),_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:"atrule",value:function(e){"@import"===e[1]?this.import(e):_get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"atrule",this).call(this,e)}},{key:"comment",value:function(e){var t=new _comment2.default,r=e[1],n=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(n))t.text="",t.raws.left=n,t.raws.right="";else{var s=n.match(/^(\s*)([^]*[^\s])(\s*)$/);t.text=s[2],t.raws.left=s[1]||" ",t.raws.right=s[3]||" "}}},{key:"createDeclaration",value:function(e){this.decl(this.tokens.slice(e.start,this.pos+1))}},{key:"createRule",value:function(e){var t=";"===this.tokens[this.pos][0],r=this.pos+(e.empty&&t?2:1),n=this.tokens.slice(e.start,r),s=this.rule(n);e.params[0]&&(e.mixin||e.extend)&&this.raw(s,"params",e.params),e.empty&&(t&&(s.raws.semicolon=this.semicolon=!0,s.selector=s.selector.replace(/;$/,"")),e.extend&&(s.extend=!0),e.mixin&&(s.mixin=!0),s.empty=!0,delete this.current.nodes,s.selector.indexOf("!important")>=0&&(s.important=!0,s.selector=s.selector.replace(/\s!important/,"")),t||this.pos--,this.end(this.tokens[this.pos]))}},{key:"end",value:function(e){var r=this.current;r.nodes&&r.nodes.length&&r.last.raws.semicolon&&!r.last.nodes&&(this.semicolon=!0),_get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"end",this).call(this,e)}},{key:"import",value:function(e){var t=!1,r=!1,n={line:0,column:0},s=[],i=new _import3.default;for(i.name=e[1].slice(1),this.init(i,e[2],e[3]),this.pos+=1;this.pos<this.tokens.length;){var o=this.tokens[this.pos];if(";"===o[0]){n={line:o[2],column:o[3]},i.raws.semicolon=!0;break}if("{"===o[0]){r=!0;break}if("}"===o[0]){this.end(o);break}if("brackets"===o[0]?s.push(o):"space"===o[0]?s.length?i.raws.between=o[1]:i.importPath?i.raws.after=o[1]:i.raws.afterName=o[1]:i.importPath=o[1],this.pos===this.tokens.length){t=!0;break}this.pos+=1}i.raws.between&&!i.raws.afterName&&(i.raws.afterName=i.raws.between,i.raws.between=""),i.source.end=n,s.length?(this.raw(i,"directives",s),t&&(e=s[s.length-1],i.source.end={line:e[4],column:e[5]},this.spaces=i.raws.between,i.raws.between="")):i.directives="",r&&(i.nodes=[],this.current=i)}},{key:"other",value:function(){var e=[],t=[],r=this.pos,n=!1,s=!1,i=null;if("brackets"===this.tokens[r][0])return void(this.spaces+=this.tokens[r][1]);for(var o=(0,_isMixinToken2.default)(this.tokens[r]),a=Boolean((0,_findExtendRule2.default)(this.tokens,r));this.pos<this.tokens.length;){var l=this.tokens[this.pos],u=l[0];if("("===u||"["===u)i||(i=l),e.push("("===u?")":"]");else if(0===e.length){if(";"===u){var c=this.ruleEnd({start:r,params:t,colon:s,mixin:o,extend:a});if(c)return;break}if("{"===u)return void this.createRule({start:r,params:t,mixin:o});if("}"===u){this.pos-=1,n=!0;break}":"===u&&(s=!0)}else u===e[e.length-1]&&(e.pop(),0===e.length&&(i=null));!a&&s||!(e.length>0||"brackets"===u||t[0])||t.push(l),this.pos+=1}if(this.pos===this.tokens.length&&(this.pos-=1,n=!0),e.length>0&&this.unclosedBracket(i),n&&this.tokens.length>1){if(this.ruleEnd({start:r,params:t,colon:s,mixin:o,extend:a,isEndOfBlock:!0}))return}this.unknownWord(r)}},{key:"rule",value:function(e){e.pop();var t=new _rule2.default;return this.init(t,e[0][2],e[0][3]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,"selector",e),this.current=t,t}},{key:"ruleEnd",value:function(e){var t=e.start;if(e.extend||e.mixin)return this.createRule(Object.assign(e,{empty:!0})),!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:"tokenize",value:function(){this.tokens=(0,_lessTokenize2.default)(this.input)}}]),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 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}}(),_get=function e(t,r,n){null===t&&(t=Function.prototype);var s=Object.getOwnPropertyDescriptor(t,r);if(void 0===s){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,r,n)}if("value"in s)return s.value;var o=s.get;if(void 0!==o)return o.call(n)},_comment=require("postcss/lib/comment"),_comment2=_interopRequireDefault(_comment),_import2=require("./import"),_import3=_interopRequireDefault(_import2),_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:"atrule",value:function(e){"@import"===e[1]?this.import(e):_get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"atrule",this).call(this,e)}},{key:"comment",value:function(e){var t=new _comment2.default,r=e[1],n=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(n))t.text="",t.raws.left=n,t.raws.right="";else{var s=n.match(/^(\s*)([^]*[^\s])(\s*)$/);t.text=s[2],t.raws.left=s[1]||" ",t.raws.right=s[3]||" "}}},{key:"createDeclaration",value:function(e){this.decl(this.tokens.slice(e.start,this.pos+1))}},{key:"createRule",value:function(e){var t=";"===this.tokens[this.pos][0],r=this.pos+(e.empty&&t?2:1),n=this.tokens.slice(e.start,r),s=this.rule(n);e.params[0]&&(e.mixin||e.extend)&&this.raw(s,"params",e.params),e.empty&&(t&&(s.raws.semicolon=this.semicolon=!0,s.selector=s.selector.replace(/;$/,"")),e.extend&&(s.extend=!0),e.mixin&&(s.mixin=!0),s.empty=!0,delete this.current.nodes,s.selector.indexOf("!important")>=0&&(s.important=!0,s.selector=s.selector.replace(/\s!important/,"")),t||this.pos--,this.end(this.tokens[this.pos]))}},{key:"end",value:function(e){var r=this.current;r.nodes&&r.nodes.length&&r.last.raws.semicolon&&!r.last.nodes&&(this.semicolon=!0),_get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"end",this).call(this,e)}},{key:"import",value:function(e){var t=!1,r=!1,n={line:0,column:0},s=[],i=new _import3.default;for(i.name=e[1].slice(1),this.init(i,e[2],e[3]),this.pos+=1;this.pos<this.tokens.length;){var o=this.tokens[this.pos];if(";"===o[0]){n={line:o[2],column:o[3]},i.raws.semicolon=!0;break}if("{"===o[0]){r=!0;break}if("}"===o[0]){this.end(o);break}if("brackets"===o[0]?s.push(o):"space"===o[0]?s.length?i.raws.between=o[1]:i.urlFunc?i.raws.beforeUrl=o[1]:i.importPath?i.urlFunc?i.raws.afterUrl=o[1]:i.raws.after=o[1]:i.raws.afterName=o[1]:"word"===o[0]&&"url"===o[1]?i.urlFunc=!0:"("!==o[0]&&")"!==o[0]&&(i.importPath=o[1]),this.pos===this.tokens.length){t=!0;break}this.pos+=1}i.raws.between&&!i.raws.afterName&&(i.raws.afterName=i.raws.between,i.raws.between=""),i.source.end=n,s.length?(this.raw(i,"directives",s),t&&(e=s[s.length-1],i.source.end={line:e[4],column:e[5]},this.spaces=i.raws.between,i.raws.between="")):i.directives="",r&&(i.nodes=[],this.current=i)}},{key:"other",value:function(){var e=[],t=[],r=this.pos,n=!1,s=!1,i=null;if("brackets"===this.tokens[r][0])return void(this.spaces+=this.tokens[r][1]);for(var o=(0,_isMixinToken2.default)(this.tokens[r]),a=Boolean((0,_findExtendRule2.default)(this.tokens,r));this.pos<this.tokens.length;){var l=this.tokens[this.pos],u=l[0];if("("===u||"["===u)i||(i=l),e.push("("===u?")":"]");else if(0===e.length){if(";"===u){var c=this.ruleEnd({start:r,params:t,colon:s,mixin:o,extend:a});if(c)return;break}if("{"===u)return void this.createRule({start:r,params:t,mixin:o});if("}"===u){this.pos-=1,n=!0;break}":"===u&&(s=!0)}else u===e[e.length-1]&&(e.pop(),0===e.length&&(i=null));!a&&s||!(e.length>0||"brackets"===u||t[0])||t.push(l),this.pos+=1}if(this.pos===this.tokens.length&&(this.pos-=1,n=!0),e.length>0&&this.unclosedBracket(i),n&&this.tokens.length>1){if(this.ruleEnd({start:r,params:t,colon:s,mixin:o,extend:a,isEndOfBlock:!0}))return}this.unknownWord(r)}},{key:"rule",value:function(e){e.pop();var t=new _rule2.default;return this.init(t,e[0][2],e[0][3]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,"selector",e),this.current=t,t}},{key:"ruleEnd",value:function(e){var t=e.start;if(e.extend||e.mixin)return this.createRule(Object.assign(e,{empty:!0})),!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:"tokenize",value:function(){this.tokens=(0,_lessTokenize2.default)(this.input)}}]),t}(_parser2.default);exports.default=LessParser,module.exports=exports.default; |
@@ -41,3 +41,3 @@ 'use strict'; | ||
this.builder('@' + node.name); | ||
this.builder((node.raws.afterName || '') + (node.directives || '') + (node.raws.between || '') + (node.importPath || '') + (node.raws.after || '')); | ||
this.builder((node.raws.afterName || '') + (node.directives || '') + (node.raws.between || '') + (node.urlFunc ? 'url(' : '') + (node.raws.beforeUrl || '') + (node.importPath || '') + (node.raws.afterUrl || '') + (node.urlFunc ? ')' : '') + (node.raws.after || '')); | ||
@@ -44,0 +44,0 @@ if (node.raws.semicolon) { |
@@ -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}}(),_get=function e(t,r,i){null===t&&(t=Function.prototype);var n=Object.getOwnPropertyDescriptor(t,r);if(void 0===n){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,r,i)}if("value"in n)return n.value;var s=n.get;if(void 0!==s)return s.call(i)},_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:"import",value:function(e){this.builder("@"+e.name),this.builder((e.raws.afterName||"")+(e.directives||"")+(e.raws.between||"")+(e.importPath||"")+(e.raws.after||"")),e.raws.semicolon&&this.builder(";")}},{key:"rule",value:function(e){_get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"rule",this).call(this,e),e.empty&&e.raws.semicolon&&(e.important&&this.builder(" !important"),e.raws.semicolon&&this.builder(";"))}},{key:"block",value:function(e,t){var r=e.empty,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 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}}(),_get=function e(t,r,i){null===t&&(t=Function.prototype);var n=Object.getOwnPropertyDescriptor(t,r);if(void 0===n){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,r,i)}if("value"in n)return n.value;var s=n.get;if(void 0!==s)return s.call(i)},_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:"import",value:function(e){this.builder("@"+e.name),this.builder((e.raws.afterName||"")+(e.directives||"")+(e.raws.between||"")+(e.urlFunc?"url(":"")+(e.raws.beforeUrl||"")+(e.importPath||"")+(e.raws.afterUrl||"")+(e.urlFunc?")":"")+(e.raws.after||"")),e.raws.semicolon&&this.builder(";")}},{key:"rule",value:function(e){_get(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"rule",this).call(this,e),e.empty&&e.raws.semicolon&&(e.important&&this.builder(" !important"),e.raws.semicolon&&this.builder(";"))}},{key:"block",value:function(e,t){var r=e.empty,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; |
{ | ||
"name": "postcss-less", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "LESS parser for PostCSS", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86683
1094