godgetfun / pagedown

Automatically exported from code.google.com/p/pagedown
Other
0 stars 0 forks source link

Sanitizer fails to find Markdown in certain requirejs environments #49

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
When building a bundle using some requireje-based tools each file is loaded in 
a separate closure, with the result that Markdown.Convertor creates a Markdown 
in a different scope than window and Markdown.Sanitizer then fails to find it. 
This can be fixed by modifying the converter to explicitly create 
window.Markdown as well:

diff --git a/src/3rdparty/pagedown/Markdown.Converter.js 
b/src/3rdparty/pagedown/Markdown.Converter.js
index 58fc54a..8c1a909 100755
--- a/src/3rdparty/pagedown/Markdown.Converter.js
+++ b/src/3rdparty/pagedown/Markdown.Converter.js
@@ -3,7 +3,7 @@ var Markdown;
 if (typeof exports === "object" && typeof require === "function") // we're in a CommonJS (e.g. Node.js) module
     Markdown = exports;
 else
-    Markdown = {};
+    Markdown = window.Markdown = {};

 // The following text is included for historical reasons, but should
 // be taken with a pinch of salt; it's not all true anymore.

Original issue reported on code.google.com by wich...@outlook.com on 4 Jan 2013 at 3:41