});
};
-
CleanCSS.prototype.minify = function (input, maybeSourceMap, maybeCallback) {
var options = this.options;
if (options.returnPromise) {
return new Promise(function (resolve, reject) {
- minify(input, options, maybeSourceMap, function (errors, output) {
+ minify(input, -1, options, maybeSourceMap, function (errors, output) {
return errors ?
reject(errors) :
resolve(output);
});
});
} else {
- return minify(input, options, maybeSourceMap, maybeCallback);
+ return minify(input, -1, options, maybeSourceMap, maybeCallback);
}
};
-function minify(input, options, maybeSourceMap, maybeCallback) {
+CleanCSS.prototype.minifyEmbedded = function (input, embeddedStart, maybeSourceMap, maybeCallback) {
+ var options = this.options;
+
+ if (options.returnPromise) {
+ return new Promise(function (resolve, reject) {
+ minify(input, embeddedStart, options, maybeSourceMap, function (errors, output) {
+ return errors ?
+ reject(errors) :
+ resolve(output);
+ });
+ });
+ } else {
+ return minify(input, embeddedStart, options, maybeSourceMap, maybeCallback);
+ }
+};
+
+
+function minify(input, embeddedStart, options, maybeSourceMap, maybeCallback) {
var sourceMap = typeof maybeSourceMap != 'function' ?
maybeSourceMap :
null;
cache: {
specificity: {}
},
+ embeddedStart: embeddedStart, // Nick
+ embeddedEnd: -1, // Nick
errors: [],
inlinedStylesheets: [],
inputSourceMapTracker: inputSourceMapTracker(),
}
function withMetadata(output, context) {
- output.stats = calculateStatsFrom(output.styles, context);
+ if (Object.prototype.hasOwnProperty.call(output, 'styles')) // Nick
+ output.stats = calculateStatsFrom(output.styles, context);
+ output.embeddedStart = context.embeddedStart; // Nick
+ output.embeddedEnd = context.embeddedEnd; // Nick
output.errors = context.errors;
output.inlinedStylesheets = context.inlinedStylesheets;
output.warnings = context.warnings;
+var assert = require('assert'); // Nick
var Marker = require('./marker');
var Token = require('./token');
source: externalContext.source || undefined,
line: 1,
column: 0,
- index: 0
+ index: //Nick 0
+ externalContext.embeddedStart == -1 ?
+ 0 :
+ externalContext.embeddedStart
}
};
level = levels.pop();
seekingValue = false;
- } else if (character == Marker.CLOSE_CURLY_BRACKET && level == Level.BLOCK && !isNested && position.index <= source.length - 1) {
+ } else if (character == Marker.CLOSE_CURLY_BRACKET && level == Level.BLOCK && !isNested /*&& position.index <= source.length - 1*/) {
+ assert(position.index <= source.length - 1); // Nick
+ if (externalContext.embeddedStart != -1) {
+ externalContext.embeddedEnd = position.index;
+ break;
+ }
// stray close brace at block level, e.g. a{color:red}color:blue}<--
externalContext.warnings.push('Unexpected \'}\' at ' + formatPosition([position.line, position.column, position.source]) + '.');
buffer.push(character);
{
- "name": "clean-css",
+ "name": "@ndcode/clean-css",
"version": "4.2.1",
"author": "Jakub Pawlowicz <contact@jakubpawlowicz.com> (http://twitter.com/jakubpawlowicz)",
- "description": "A well-tested CSS minifier",
+ "maintainer": "Nick Downing <nick@ndcode.org>",
+ "description": "A well-tested CSS minifier, modified to add NDCODE hooks.",
"license": "MIT",
"keywords": [
"css",
"minifier"
],
- "homepage": "https://github.com/jakubpawlowicz/clean-css",
+ "homepage": "https://www.ndcode.org",
"repository": {
"type": "git",
- "url": "https://github.com/jakubpawlowicz/clean-css.git"
+ "url": "https://git.ndcode.org/public/clean-css.git"
},
"bugs": {
- "url": "https://github.com/jakubpawlowicz/clean-css/issues"
+ "email": "nick@ndcode.org"
},
"main": "index.js",
"files": [
"test": "vows"
},
"dependencies": {
+ "assert": "^1.4.1",
"source-map": "~0.6.0"
},
"devDependencies": {