From 6b87d38733d4300b3bc5b49e2ceaabfb1fafd3b5 Mon Sep 17 00:00:00 2001 From: Alexandre Morgaut Date: Mon, 1 Jul 2013 15:09:25 +0200 Subject: [PATCH] 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 --- src/showdown.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/showdown.js b/src/showdown.js index b488bad..9ce7bcb 100644 --- a/src/showdown.js +++ b/src/showdown.js @@ -64,7 +64,9 @@ // // Showdown namespace // -var Showdown = { extensions: {} }; +var Showdown = typeof exports === 'object' ? exports : {}; + +Showdown.extensions = {}; // // forEach @@ -1441,9 +1443,6 @@ var escapeCharacters_callback = function(wholeMatch,m1) { } // end of Showdown.converter -// export -if (typeof module !== 'undefined') module.exports = Showdown; - // stolen from AMD branch of underscore // AMD define happens at the end for compatibility with AMD loaders // that don't enforce next-turn semantics on modules.