From a49fc092fb0d2063a83cdc8bb917df9d2a4a9453 Mon Sep 17 00:00:00 2001 From: Ben Blank Date: Thu, 19 Apr 2012 16:46:36 -0700 Subject: [PATCH] add CommonJS module exports for Showdown and make its GFM extensions sandboxable --- node_modules/gfm/showdown.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/node_modules/gfm/showdown.js b/node_modules/gfm/showdown.js index 498bb8ed..324b81db 100644 --- a/node_modules/gfm/showdown.js +++ b/node_modules/gfm/showdown.js @@ -68,6 +68,13 @@ // Modifications are tagged with "GFM" // ************************************************** +// ================================================== +// CommonJS modifications by benblank +// http://www.commonjs.org/specs/modules/1.0/ +// +// Modifications are tagged with "CJS" +// ================================================== + // // Showdown namespace // @@ -154,6 +161,12 @@ this.makeHtml = function(text) { // attacklab: Restore tildes text = text.replace(/~T/g,"~"); + // == CJS == Create local `GitHub` object for use by GFM + var GitHub = this.githubRepoName && this.githubRepoOwner ? { + nameWithOwner: this.githubRepoOwner + "/" + this.githubRepoName, + repoName: this.githubRepoName + } : typeof window !== "undefined" ? window.GitHub : undefined; + // ** GFM ** Auto-link URLs and emails text = text.replace(/https?\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!]/g, function(wholeMatch,matchIndex){ var left = text.slice(0, matchIndex), right = text.slice(matchIndex) @@ -1359,4 +1372,7 @@ var escapeCharacters_callback = function(wholeMatch,m1) { return "~E"+charCodeToEscape+"E"; } -} // end of Showdown.converter \ No newline at end of file +} // end of Showdown.converter + +// == CJS == Export the converter +if (typeof exports !== "undefined") exports.Converter = Showdown.converter;