diff --git a/plugins/file-highlight/prism-file-highlight.js b/plugins/file-highlight/prism-file-highlight.js index 1b7eb9d23e..79893a83b9 100644 --- a/plugins/file-highlight/prism-file-highlight.js +++ b/plugins/file-highlight/prism-file-highlight.js @@ -9,8 +9,6 @@ Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; } - var Prism = window.Prism; - var LOADING_MESSAGE = 'Loading…'; var FAILURE_MESSAGE = function (status, message) { return '✖ Error ' + status + ' while fetching file: ' + message; diff --git a/plugins/file-highlight/prism-file-highlight.min.js b/plugins/file-highlight/prism-file-highlight.min.js index ebbfff3a2c..24de20476b 100644 --- a/plugins/file-highlight/prism-file-highlight.min.js +++ b/plugins/file-highlight/prism-file-highlight.min.js @@ -1 +1 @@ -!function(){if(void 0!==r&&"undefined"!=typeof document){Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var r=window.Prism,h={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},g="data-src-status",c="loading",u="loaded",p="pre[data-src]:not(["+g+'="'+u+'"]):not(['+g+'="'+c+'"])',i=/\blang(?:uage)?-([\w-]+)\b/i;r.hooks.add("before-highlightall",function(e){e.selector+=", "+p}),r.hooks.add("before-sanity-check",function(e){var t=e.element;if(t.matches(p)){e.code="",t.setAttribute(g,c);var n=t.appendChild(document.createElement("CODE"));n.textContent="Loading…";var i=t.getAttribute("data-src"),a=e.language;if("none"===a){var o=(/\.(\w+)$/.exec(i)||[,"none"])[1];a=h[o]||o}d(n,a),d(t,a);var s=r.plugins.autoloader;s&&s.loadLanguages(a);var l=new XMLHttpRequest;l.open("GET",i,!0),l.onreadystatechange=function(){4==l.readyState&&(l.status<400&&l.responseText?(t.setAttribute(g,u),n.textContent=l.responseText,r.highlightElement(n)):(t.setAttribute(g,"failed"),400<=l.status?n.textContent=function(e,t){return"✖ Error "+e+" while fetching file: "+t}(l.status,l.statusText):n.textContent="✖ Error: File does not exist or is empty"))},l.send(null)}});var e=!(r.plugins.fileHighlight={highlight:function(e){for(var t,n=(e||document).querySelectorAll(p),i=0;t=n[i++];)r.highlightElement(t)}});r.fileHighlight=function(){e||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),e=!0),r.plugins.fileHighlight.highlight.apply(this,arguments)}}function d(e,t){var n=e.className;n=n.replace(i," ")+" language-"+t,e.className=n.replace(/\s+/g," ").trim()}}(); \ No newline at end of file +!function(){if("undefined"!=typeof Prism&&"undefined"!=typeof document){Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var o={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},h="data-src-status",g="loading",c="loaded",u="pre[data-src]:not(["+h+'="'+c+'"]):not(['+h+'="'+g+'"])',n=/\blang(?:uage)?-([\w-]+)\b/i;Prism.hooks.add("before-highlightall",function(e){e.selector+=", "+u}),Prism.hooks.add("before-sanity-check",function(e){var t=e.element;if(t.matches(u)){e.code="",t.setAttribute(h,g);var i=t.appendChild(document.createElement("CODE"));i.textContent="Loading…";var n=t.getAttribute("data-src"),s=e.language;if("none"===s){var a=(/\.(\w+)$/.exec(n)||[,"none"])[1];s=o[a]||a}p(i,s),p(t,s);var r=Prism.plugins.autoloader;r&&r.loadLanguages(s);var l=new XMLHttpRequest;l.open("GET",n,!0),l.onreadystatechange=function(){4==l.readyState&&(l.status<400&&l.responseText?(t.setAttribute(h,c),i.textContent=l.responseText,Prism.highlightElement(i)):(t.setAttribute(h,"failed"),400<=l.status?i.textContent=function(e,t){return"✖ Error "+e+" while fetching file: "+t}(l.status,l.statusText):i.textContent="✖ Error: File does not exist or is empty"))},l.send(null)}});var e=!(Prism.plugins.fileHighlight={highlight:function(e){for(var t,i=(e||document).querySelectorAll(u),n=0;t=i[n++];)Prism.highlightElement(t)}});Prism.fileHighlight=function(){e||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),e=!0),Prism.plugins.fileHighlight.highlight.apply(this,arguments)}}function p(e,t){var i=e.className;i=i.replace(n," ")+" language-"+t,e.className=i.replace(/\s+/g," ").trim()}}(); \ No newline at end of file diff --git a/prism.js b/prism.js index c869ff6adc..95455b4963 100644 --- a/prism.js +++ b/prism.js @@ -1632,8 +1632,6 @@ Prism.languages.js = Prism.languages.javascript; Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; } - var Prism = window.Prism; - var LOADING_MESSAGE = 'Loading…'; var FAILURE_MESSAGE = function (status, message) { return '✖ Error ' + status + ' while fetching file: ' + message;