UNPKG

1.77 kBJavaScriptView Raw
1!function(){if("undefined"!=typeof self&&self.Prism&&self.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 s=(/\.(\w+)$/.exec(i)||[,"none"])[1];a=h[s]||s}d(n,a),d(t,a);var l=r.plugins.autoloader;l&&l.loadLanguages(a);var o=new XMLHttpRequest;o.open("GET",i,!0),o.onreadystatechange=function(){4==o.readyState&&(o.status<400&&o.responseText?(t.setAttribute(g,u),n.textContent=o.responseText,r.highlightElement(n)):(t.setAttribute(g,"failed"),400<=o.status?n.textContent=function(e,t){return"✖ Error "+e+" while fetching file: "+t}(o.status,o.statusText):n.textContent="✖ Error: File does not exist or is empty"))},o.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