Skip to content

Commit

Permalink
fix(showdown.js): fix showdown extension loader
Browse files Browse the repository at this point in the history
  • Loading branch information
tivie committed Apr 22, 2015
1 parent 9c29f62 commit a38c76d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/showdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,19 @@ showdown.Converter = function (converterOptions) {

// Iterate over each plugin
showdown.helper.forEach(options.extensions, function (plugin) {
var pluginName = plugin;

// Assume it's a bundled plugin if a string is given
if (typeof plugin === 'string') {
plugin = extensions[showdown.helper.stdExtName(plugin)];
var tPluginName = showdown.helper.stdExtName(plugin);

if (!showdown.helper.isUndefined(showdown.extensions[tPluginName]) && showdown.extensions[tPluginName]) {
//Trigger some kind of deprecated alert
plugin = showdown.extensions[tPluginName];

} else if (!showdown.helper.isUndefined(extensions[tPluginName])) {
plugin = extensions[tPluginName];
}
}

if (typeof plugin === 'function') {
Expand All @@ -178,7 +187,11 @@ showdown.Converter = function (converterOptions) {
}
});
} else {
throw 'Extension "' + plugin + '" could not be loaded. It was either not found or is not a valid extension.';
var errMsg = 'An extension could not be loaded. It was either not found or is not a valid extension.';
if (typeof pluginName === 'string') {
errMsg = 'Extension "' + pluginName + '" could not be loaded. It was either not found or is not a valid extension.';
}
throw errMsg;
}
});
}
Expand Down

0 comments on commit a38c76d

Please sign in to comment.