From 9f5c93c62d609f6c3b84344268622ca0d5733aad Mon Sep 17 00:00:00 2001 From: Dmitriy Shekhovtsov Date: Thu, 3 Sep 2015 13:45:26 +0300 Subject: [PATCH] Fix: node.js hacks for components and prism.js --- components/prism-core.js | 5 +++++ plugins/file-highlight/prism-file-highlight.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/components/prism-core.js b/components/prism-core.js index 6b5799350b..d59b09e5a7 100644 --- a/components/prism-core.js +++ b/components/prism-core.js @@ -426,3 +426,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 1a49254f27..6a2a540635 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; }