Fix CommonJS support

module.exports is not part of CommonJS and only few CommonJS platforms
support it
exports is the standard way to export a module API
changing the reference of the exports object is also not standard and
not always supported
A related fix has also been recently provided on the Mustache.js project
This commit is contained in:
Alexandre Morgaut 2013-07-01 15:09:25 +02:00
parent 2e102c72b2
commit 6b87d38733

View File

@ -64,7 +64,9 @@
// //
// Showdown namespace // Showdown namespace
// //
var Showdown = { extensions: {} }; var Showdown = typeof exports === 'object' ? exports : {};
Showdown.extensions = {};
// //
// forEach // forEach
@ -1441,9 +1443,6 @@ var escapeCharacters_callback = function(wholeMatch,m1) {
} // end of Showdown.converter } // end of Showdown.converter
// export
if (typeof module !== 'undefined') module.exports = Showdown;
// stolen from AMD branch of underscore // stolen from AMD branch of underscore
// AMD define happens at the end for compatibility with AMD loaders // AMD define happens at the end for compatibility with AMD loaders
// that don't enforce next-turn semantics on modules. // that don't enforce next-turn semantics on modules.