mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
Merge branch 'master' of https://github.com/less/less.js
This commit is contained in:
@@ -92,14 +92,23 @@ var Parser = function Parser(context, imports, fileInfo) {
|
||||
// @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply
|
||||
//
|
||||
parse: function (str, callback, additionalData) {
|
||||
var root, error = null, globalVars, modifyVars, preText = "";
|
||||
var root, error = null, globalVars, modifyVars, ignored, preText = "";
|
||||
|
||||
globalVars = (additionalData && additionalData.globalVars) ? Parser.serializeVars(additionalData.globalVars) + '\n' : '';
|
||||
modifyVars = (additionalData && additionalData.modifyVars) ? '\n' + Parser.serializeVars(additionalData.modifyVars) : '';
|
||||
|
||||
if (context.pluginManager) {
|
||||
var preProcessors = context.pluginManager.getPreProcessors();
|
||||
for (var i = 0; i < preProcessors.length; i++) {
|
||||
str = preProcessors[i].process(str, { context: context, imports: imports, fileInfo: fileInfo });
|
||||
}
|
||||
}
|
||||
|
||||
if (globalVars || (additionalData && additionalData.banner)) {
|
||||
preText = ((additionalData && additionalData.banner) ? additionalData.banner : "") + globalVars;
|
||||
imports.contentsIgnoredChars[fileInfo.filename] = preText.length;
|
||||
ignored = imports.contentsIgnoredChars;
|
||||
ignored[fileInfo.filename] = ignored[fileInfo.filename] || 0;
|
||||
ignored[fileInfo.filename] += preText.length;
|
||||
}
|
||||
|
||||
str = str.replace(/\r\n?/g, '\n');
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
var PluginManager = function(less) {
|
||||
this.less = less;
|
||||
this.visitors = [];
|
||||
this.preProcessors = [];
|
||||
this.postProcessors = [];
|
||||
this.installedPlugins = [];
|
||||
this.fileManagers = [];
|
||||
@@ -35,6 +36,20 @@ PluginManager.prototype.addPlugin = function(plugin) {
|
||||
PluginManager.prototype.addVisitor = function(visitor) {
|
||||
this.visitors.push(visitor);
|
||||
};
|
||||
/**
|
||||
* Adds a pre processor object
|
||||
* @param {object} preProcessor
|
||||
* @param {number} priority - guidelines 1 = before import, 1000 = import, 2000 = after import
|
||||
*/
|
||||
PluginManager.prototype.addPreProcessor = function(preProcessor, priority) {
|
||||
var indexToInsertAt;
|
||||
for (indexToInsertAt = 0; indexToInsertAt < this.preProcessors.length; indexToInsertAt++) {
|
||||
if (this.preProcessors[indexToInsertAt].priority >= priority) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.preProcessors.splice(indexToInsertAt, 0, {preProcessor: preProcessor, priority: priority});
|
||||
};
|
||||
/**
|
||||
* Adds a post processor object
|
||||
* @param {object} postProcessor
|
||||
@@ -56,6 +71,18 @@ PluginManager.prototype.addPostProcessor = function(postProcessor, priority) {
|
||||
PluginManager.prototype.addFileManager = function(manager) {
|
||||
this.fileManagers.push(manager);
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @returns {Array}
|
||||
* @private
|
||||
*/
|
||||
PluginManager.prototype.getPreProcessors = function() {
|
||||
var preProcessors = [];
|
||||
for (var i = 0; i < this.preProcessors.length; i++) {
|
||||
preProcessors.push(this.preProcessors[i].preProcessor);
|
||||
}
|
||||
return preProcessors;
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @returns {Array}
|
||||
|
||||
@@ -30,8 +30,12 @@ module.exports = function (SourceMapOutput, environment) {
|
||||
};
|
||||
|
||||
SourceMapBuilder.prototype.getCSSAppendage = function() {
|
||||
|
||||
var sourceMapURL = this.sourceMapURL;
|
||||
if (this.options.sourceMapFileInline) {
|
||||
if (this.sourceMap === undefined) {
|
||||
return "";
|
||||
}
|
||||
sourceMapURL = "data:application/json;base64," + environment.encodeBase64(this.sourceMap);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user