mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
Load extensions using simple require() and index.js
Also don't load anything if we're in a browser
This commit is contained in:
parent
053288f2fe
commit
fd771cc7e8
7
src/extensions/index.js
Normal file
7
src/extensions/index.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
// Return all extensions
|
||||
module.exports = {
|
||||
github : require('./github'),
|
||||
prettify : require('./prettify'),
|
||||
table : require('./table'),
|
||||
twitter : require('./twitter')
|
||||
};
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user