diff --git a/src/extensions/index.js b/src/extensions/index.js new file mode 100644 index 0000000..2380be3 --- /dev/null +++ b/src/extensions/index.js @@ -0,0 +1,7 @@ +// Return all extensions +module.exports = { + github : require('./github'), + prettify : require('./prettify'), + table : require('./table'), + twitter : require('./twitter') +}; diff --git a/src/showdown.js b/src/showdown.js index b488bad..4ec8082 100644 --- a/src/showdown.js +++ b/src/showdown.js @@ -116,23 +116,8 @@ var g_output_modifiers = []; // // Automatic Extension Loading (node only): // - -if (typeof module !== 'undefind' && typeof exports !== 'undefined' && typeof require !== 'undefind') { - var fs = require('fs'); - - if (fs) { - // Search extensions folder - var extensions = fs.readdirSync((__dirname || '.')+'/extensions').filter(function(file){ - return ~file.indexOf('.js'); - }).map(function(file){ - return file.replace(/\.js$/, ''); - }); - // Load extensions into Showdown namespace - Showdown.forEach(extensions, function(ext){ - var name = stdExtName(ext); - Showdown.extensions[name] = require('./extensions/' + ext); - }); - } +if (typeof window === 'undefined' && typeof module !== 'undefined' && typeof exports !== 'undefined' && typeof require !== 'undefined') { + Showdown.extensions = require('./extensions'); } this.makeHtml = function(text) {