Merge pull request #754 from valorkin/fix-correct-behaviour-in-nodejs Fix: node.js hacks for components and prism.js
diff --git a/components/prism-core.js b/components/prism-core.js
index fcccccd..d8e8253 100644
--- a/components/prism-core.js
+++ b/components/prism-core.js
@@ -422,3 +422,8 @@ return _self.Prism;
if (typeof module !== 'undefined' && module.exports) {
module.exports = Prism;
}
+
+// hack for components to work correctly in node.js
+if (typeof global !== 'undefined') {
+ global.Prism = Prism;
+}
diff --git a/plugins/file-highlight/prism-file-highlight.js b/plugins/file-highlight/prism-file-highlight.js
index 1a49254..6a2a540 100644
--- a/plugins/file-highlight/prism-file-highlight.js
+++ b/plugins/file-highlight/prism-file-highlight.js
@@ -1,5 +1,5 @@
(function () {
- if (!self.Prism || !self.document || !document.querySelector) {
+ if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) {
return;
}