From 3780571bd2b929fb18d1ccc3a9a8b2c002176c9d Mon Sep 17 00:00:00 2001 From: Andreas Rohner Date: Sun, 3 Jul 2016 11:59:59 +0200 Subject: [PATCH 1/2] Remove IE8 plugin --- components/prism-core.js | 5 +- components/prism-core.min.js | 2 +- .../file-highlight/prism-file-highlight.js | 76 +++++++++--------- .../prism-file-highlight.min.js | 2 +- plugins/ie8/index.html | 67 ---------------- plugins/ie8/prism-ie8.css | 3 - plugins/ie8/prism-ie8.js | 42 ---------- plugins/ie8/prism-ie8.min.js | 1 - .../line-highlight/prism-line-highlight.js | 30 ++++--- .../prism-line-highlight.min.js | 2 +- prism.js | 79 +++++++++---------- 11 files changed, 94 insertions(+), 215 deletions(-) delete mode 100644 plugins/ie8/index.html delete mode 100644 plugins/ie8/prism-ie8.css delete mode 100644 plugins/ie8/prism-ie8.js delete mode 100644 plugins/ie8/prism-ie8.min.js diff --git a/components/prism-core.js b/components/prism-core.js index 5fadcd710e..1dd065e7b4 100644 --- a/components/prism-core.js +++ b/components/prism-core.js @@ -58,8 +58,7 @@ var _ = _self.Prism = { return clone; case 'Array': - // Check for existence for IE8 - return o.map && o.map(function(v) { return _.util.clone(v); }); + return o.map(function(v) { return _.util.clone(v); }); } return o; @@ -482,7 +481,7 @@ var script = document.currentScript || [].slice.call(document.getElementsByTagNa if (script) { _.filename = script.src; - if (document.addEventListener && !script.hasAttribute('data-manual')) { + if (!script.hasAttribute('data-manual')) { if(document.readyState !== "loading") { if (window.requestAnimationFrame) { window.requestAnimationFrame(_.highlightAll); diff --git a/components/prism-core.min.js b/components/prism-core.min.js index 5f48cacd41..06cae142e8 100644 --- a/components/prism-core.min.js +++ b/components/prism-core.min.js @@ -1 +1 @@ -var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(\w+)\b/i,t=0,n=_self.Prism={util:{encode:function(e){return e instanceof a?new a(e.type,n.util.encode(e.content),e.alias):"Array"===n.util.type(e)?e.map(n.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(v instanceof a)){u.lastIndex=0;var b=u.exec(v),k=1;if(!b&&h&&m!=r.length-1){if(u.lastIndex=y,b=u.exec(e),!b)break;for(var w=b.index+(g?b[1].length:0),_=b.index+b[0].length,A=m,S=y,P=r.length;P>A&&_>S;++A)S+=(r[A].matchedStr||r[A]).length,w>=S&&(++m,y=S);if(r[m]instanceof a||r[A-1].greedy)continue;k=A-m,v=e.slice(y,S),b.index-=y}if(b){g&&(f=b[1].length);var w=b.index+f,b=b[0].slice(f),_=w+b.length,x=v.slice(0,w),O=v.slice(_),j=[m,k];x&&j.push(x);var N=new a(l,c?n.tokenize(b,c):b,d,b,h);j.push(N),O&&j.push(O),Array.prototype.splice.apply(r,j)}}}}}return r},hooks:{all:{},add:function(e,t){var a=n.hooks.all;a[e]=a[e]||[],a[e].push(t)},run:function(e,t){var a=n.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(t)}}},a=n.Token=function(e,t,n,a,r){this.type=e,this.content=t,this.alias=n,this.matchedStr=a||null,this.greedy=!!r};if(a.stringify=function(e,t,r){if("string"==typeof e)return e;if("Array"===n.util.type(e))return e.map(function(n){return a.stringify(n,t,e)}).join("");var i={type:e.type,content:a.stringify(e.content,t,r),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===n.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}n.hooks.run("wrap",i);var o="";for(var s in i.attributes)o+=(o?" ":"")+s+'="'+(i.attributes[s]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+o+">"+i.content+""},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var t=JSON.parse(e.data),a=t.language,r=t.code,i=t.immediateClose;_self.postMessage(n.highlight(r,n.languages[a],a)),i&&_self.close()},!1),_self.Prism):_self.Prism;var r=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return r&&(n.filename=r.src,document.addEventListener&&!r.hasAttribute("data-manual")&&("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(n.highlightAll):window.setTimeout(n.highlightAll,16):document.addEventListener("DOMContentLoaded",n.highlightAll))),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); \ No newline at end of file +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(\w+)\b/i,t=0,n=_self.Prism={util:{encode:function(e){return e instanceof a?new a(e.type,n.util.encode(e.content),e.alias):"Array"===n.util.type(e)?e.map(n.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(v instanceof a)){u.lastIndex=0;var b=u.exec(v),k=1;if(!b&&h&&m!=r.length-1){if(u.lastIndex=y,b=u.exec(e),!b)break;for(var w=b.index+(c?b[1].length:0),_=b.index+b[0].length,A=m,S=y,P=r.length;P>A&&_>S;++A)S+=(r[A].matchedStr||r[A]).length,w>=S&&(++m,y=S);if(r[m]instanceof a||r[A-1].greedy)continue;k=A-m,v=e.slice(y,S),b.index-=y}if(b){c&&(f=b[1].length);var w=b.index+f,b=b[0].slice(f),_=w+b.length,x=v.slice(0,w),O=v.slice(_),j=[m,k];x&&j.push(x);var N=new a(l,g?n.tokenize(b,g):b,d,b,h);j.push(N),O&&j.push(O),Array.prototype.splice.apply(r,j)}}}}}return r},hooks:{all:{},add:function(e,t){var a=n.hooks.all;a[e]=a[e]||[],a[e].push(t)},run:function(e,t){var a=n.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(t)}}},a=n.Token=function(e,t,n,a,r){this.type=e,this.content=t,this.alias=n,this.matchedStr=a||null,this.greedy=!!r};if(a.stringify=function(e,t,r){if("string"==typeof e)return e;if("Array"===n.util.type(e))return e.map(function(n){return a.stringify(n,t,e)}).join("");var i={type:e.type,content:a.stringify(e.content,t,r),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===n.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}n.hooks.run("wrap",i);var o="";for(var s in i.attributes)o+=(o?" ":"")+s+'="'+(i.attributes[s]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+o+">"+i.content+""},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var t=JSON.parse(e.data),a=t.language,r=t.code,i=t.immediateClose;_self.postMessage(n.highlight(r,n.languages[a],a)),i&&_self.close()},!1),_self.Prism):_self.Prism;var r=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return r&&(n.filename=r.src,r.hasAttribute("data-manual")||("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(n.highlightAll):window.setTimeout(n.highlightAll,16):document.addEventListener("DOMContentLoaded",n.highlightAll))),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); \ No newline at end of file diff --git a/plugins/file-highlight/prism-file-highlight.js b/plugins/file-highlight/prism-file-highlight.js index e8d6c75b15..dd113ebf6f 100644 --- a/plugins/file-highlight/prism-file-highlight.js +++ b/plugins/file-highlight/prism-file-highlight.js @@ -17,58 +17,56 @@ 'tex': 'latex' }; - if(Array.prototype.forEach) { // Check to prevent error in IE8 - Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) { - var src = pre.getAttribute('data-src'); - - var language, parent = pre; - var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; - while (parent && !lang.test(parent.className)) { - parent = parent.parentNode; - } + Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) { + var src = pre.getAttribute('data-src'); - if (parent) { - language = (pre.className.match(lang) || [, ''])[1]; - } + var language, parent = pre; + var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; + while (parent && !lang.test(parent.className)) { + parent = parent.parentNode; + } - if (!language) { - var extension = (src.match(/\.(\w+)$/) || [, ''])[1]; - language = Extensions[extension] || extension; - } + if (parent) { + language = (pre.className.match(lang) || [, ''])[1]; + } + + if (!language) { + var extension = (src.match(/\.(\w+)$/) || [, ''])[1]; + language = Extensions[extension] || extension; + } - var code = document.createElement('code'); - code.className = 'language-' + language; + var code = document.createElement('code'); + code.className = 'language-' + language; - pre.textContent = ''; + pre.textContent = ''; - code.textContent = 'Loading…'; + code.textContent = 'Loading…'; - pre.appendChild(code); + pre.appendChild(code); - var xhr = new XMLHttpRequest(); + var xhr = new XMLHttpRequest(); - xhr.open('GET', src, true); + xhr.open('GET', src, true); - xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { + xhr.onreadystatechange = function () { + if (xhr.readyState == 4) { - if (xhr.status < 400 && xhr.responseText) { - code.textContent = xhr.responseText; + if (xhr.status < 400 && xhr.responseText) { + code.textContent = xhr.responseText; - Prism.highlightElement(code); - } - else if (xhr.status >= 400) { - code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText; - } - else { - code.textContent = '✖ Error: File does not exist or is empty'; - } + Prism.highlightElement(code); } - }; + else if (xhr.status >= 400) { + code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText; + } + else { + code.textContent = '✖ Error: File does not exist or is empty'; + } + } + }; - xhr.send(null); - }); - } + xhr.send(null); + }); }; diff --git a/plugins/file-highlight/prism-file-highlight.min.js b/plugins/file-highlight/prism-file-highlight.min.js index 84bb37447a..acbaf12f05 100644 --- a/plugins/file-highlight/prism-file-highlight.min.js +++ b/plugins/file-highlight/prism-file-highlight.min.js @@ -1 +1 @@ -!function(){"undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.forEach&&Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var a,s=t.getAttribute("data-src"),n=t,r=/\blang(?:uage)?-(?!\*)(\w+)\b/i;n&&!r.test(n.className);)n=n.parentNode;if(n&&(a=(t.className.match(r)||[,""])[1]),!a){var o=(s.match(/\.(\w+)$/)||[,""])[1];a=e[o]||o}var l=document.createElement("code");l.className="language-"+a,t.textContent="",l.textContent="Loading…",t.appendChild(l);var i=new XMLHttpRequest;i.open("GET",s,!0),i.onreadystatechange=function(){4==i.readyState&&(i.status<400&&i.responseText?(l.textContent=i.responseText,Prism.highlightElement(l)):l.textContent=i.status>=400?"✖ Error "+i.status+" while fetching file: "+i.statusText:"✖ Error: File does not exist or is empty")},i.send(null)})},document.addEventListener("DOMContentLoaded",self.Prism.fileHighlight))}(); \ No newline at end of file +!function(){"undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var s,a=t.getAttribute("data-src"),n=t,r=/\blang(?:uage)?-(?!\*)(\w+)\b/i;n&&!r.test(n.className);)n=n.parentNode;if(n&&(s=(t.className.match(r)||[,""])[1]),!s){var o=(a.match(/\.(\w+)$/)||[,""])[1];s=e[o]||o}var l=document.createElement("code");l.className="language-"+s,t.textContent="",l.textContent="Loading…",t.appendChild(l);var i=new XMLHttpRequest;i.open("GET",a,!0),i.onreadystatechange=function(){4==i.readyState&&(i.status<400&&i.responseText?(l.textContent=i.responseText,Prism.highlightElement(l)):l.textContent=i.status>=400?"✖ Error "+i.status+" while fetching file: "+i.statusText:"✖ Error: File does not exist or is empty")},i.send(null)})},document.addEventListener("DOMContentLoaded",self.Prism.fileHighlight))}(); \ No newline at end of file diff --git a/plugins/ie8/index.html b/plugins/ie8/index.html deleted file mode 100644 index 2fef8e9dbd..0000000000 --- a/plugins/ie8/index.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - -IE8 ▲ Prism plugins - - - - - - - - - - - - -
-
- -

IE8 (Work in progress)

-

Adds basic IE8 support to Prism through a series of polyfills.

-
- -
-

How to use

- -
- -
-

Examples

- -

JavaScript

-
/**
- * This is a multiline comment
- */
-var foo = 5; // this is a single line comment
-var str = "A string",
-    r = /and a regex/;
- -

CSS

-
@font-face {
-	src: url(http://lea.verou.me/logo.otf);
-	font-family: 'LeaVerou';
-}
- -

HTML

-
<!-- A comment -->
-<img src="http://prismjs.com/img/spectrum.png" alt="" />
-<p>Some text</p>
-
- - - - - - - - - - \ No newline at end of file diff --git a/plugins/ie8/prism-ie8.css b/plugins/ie8/prism-ie8.css deleted file mode 100644 index b5f7630924..0000000000 --- a/plugins/ie8/prism-ie8.css +++ /dev/null @@ -1,3 +0,0 @@ -.token a { - color: inherit; -} \ No newline at end of file diff --git a/plugins/ie8/prism-ie8.js b/plugins/ie8/prism-ie8.js deleted file mode 100644 index 0cd83eca7e..0000000000 --- a/plugins/ie8/prism-ie8.js +++ /dev/null @@ -1,42 +0,0 @@ -(function(){ - -if (!window.Prism) { - return; -} - -var dummy = document.createElement('header'); - -if (!String.prototype.trim) { - String.prototype.trim = function () { - return this.replace(/^\s+/g, '').replace(/\s+$/g, ''); - }; -} - -// textContent polyfill -if (!('textContent' in dummy) && ('innerText' in dummy) && Object.defineProperty) { - Object.defineProperty(Element.prototype, 'textContent', { - get: function() { - return this.innerText; - }, - set: function(text) { - this.innerText = text; - } - }); -} - -// IE8 doesn't have DOMContentLoaded -if (!document.addEventListener && 'textContent' in dummy) { - setTimeout(Prism.highlightAll, 10); -} - -// Test if innerHTML line break bug is present -dummy.innerHTML = '\r\n'; - -if (dummy.textContent.indexOf('\n') === -1) { - // IE8 innerHTML bug: Discards line breaks - Prism.hooks.add('after-highlight', function(env) { - env.element.innerHTML = env.highlightedCode.replace(/\r?\n/g, '
'); - }); -} - -})(); \ No newline at end of file diff --git a/plugins/ie8/prism-ie8.min.js b/plugins/ie8/prism-ie8.min.js deleted file mode 100644 index 2bd5c628b7..0000000000 --- a/plugins/ie8/prism-ie8.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(){if(window.Prism){var e=document.createElement("header");String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+/g,"").replace(/\s+$/g,"")}),!("textContent"in e)&&"innerText"in e&&Object.defineProperty&&Object.defineProperty(Element.prototype,"textContent",{get:function(){return this.innerText},set:function(e){this.innerText=e}}),!document.addEventListener&&"textContent"in e&&setTimeout(Prism.highlightAll,10),e.innerHTML="\r\n",-1===e.textContent.indexOf("\n")&&Prism.hooks.add("after-highlight",function(e){e.element.innerHTML=e.highlightedCode.replace(/\r?\n/g,"
")})}}(); \ No newline at end of file diff --git a/plugins/line-highlight/prism-line-highlight.js b/plugins/line-highlight/prism-line-highlight.js index 3436c3ac72..f56a720aa7 100644 --- a/plugins/line-highlight/prism-line-highlight.js +++ b/plugins/line-highlight/prism-line-highlight.js @@ -44,12 +44,12 @@ function highlightLines(pre, lines, classes) { for (var i=0, range; range = ranges[i++];) { range = range.split('-'); - + var start = +range[0], end = +range[1] || start; - + var line = document.createElement('div'); - + line.textContent = Array(end - start + 2).join(' \n'); line.className = (classes || '') + ' line-highlight'; @@ -76,25 +76,25 @@ function highlightLines(pre, lines, classes) { function applyHash() { var hash = location.hash.slice(1); - + // Remove pre-existing temporary lines $$('.temporary.line-highlight').forEach(function (line) { line.parentNode.removeChild(line); }); - + var range = (hash.match(/\.([\d,-]+)$/) || [,''])[1]; - + if (!range || document.getElementById(hash)) { return; } - + var id = hash.slice(0, hash.lastIndexOf('.')), pre = document.getElementById(id); - + if (!pre) { return; } - + if (!pre.hasAttribute('data-line')) { pre.setAttribute('data-line', ''); } @@ -109,24 +109,22 @@ var fakeTimer = 0; // Hack to limit the number of times applyHash() runs Prism.hooks.add('complete', function(env) { var pre = env.element.parentNode; var lines = pre && pre.getAttribute('data-line'); - + if (!pre || !lines || !/pre/i.test(pre.nodeName)) { return; } - + clearTimeout(fakeTimer); - + $$('.line-highlight', pre).forEach(function (line) { line.parentNode.removeChild(line); }); - + highlightLines(pre, lines); - + fakeTimer = setTimeout(applyHash, 1); }); -if(window.addEventListener) { window.addEventListener('hashchange', applyHash); -} })(); diff --git a/plugins/line-highlight/prism-line-highlight.min.js b/plugins/line-highlight/prism-line-highlight.min.js index aecd63e2d3..a865a3da81 100644 --- a/plugins/line-highlight/prism-line-highlight.min.js +++ b/plugins/line-highlight/prism-line-highlight.min.js @@ -1 +1 @@ -!function(){function e(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function t(e,t){return t=" "+t+" ",(" "+e.className+" ").replace(/[\n\t]/g," ").indexOf(t)>-1}function n(e,n,i){for(var o,a=n.replace(/\s+/g,"").split(","),l=+e.getAttribute("data-line-offset")||0,d=r()?parseInt:parseFloat,c=d(getComputedStyle(e).lineHeight),s=0;o=a[s++];){o=o.split("-");var u=+o[0],m=+o[1]||u,h=document.createElement("div");h.textContent=Array(m-u+2).join(" \n"),h.className=(i||"")+" line-highlight",t(e,"line-numbers")||(h.setAttribute("data-start",u),m>u&&h.setAttribute("data-end",m)),h.style.top=(u-l-1)*c+"px",t(e,"line-numbers")?e.appendChild(h):(e.querySelector("code")||e).appendChild(h)}}function i(){var t=location.hash.slice(1);e(".temporary.line-highlight").forEach(function(e){e.parentNode.removeChild(e)});var i=(t.match(/\.([\d,-]+)$/)||[,""])[1];if(i&&!document.getElementById(t)){var r=t.slice(0,t.lastIndexOf(".")),o=document.getElementById(r);o&&(o.hasAttribute("data-line")||o.setAttribute("data-line",""),n(o,i,"temporary "),document.querySelector(".temporary.line-highlight").scrollIntoView())}}if("undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector){var r=function(){var e;return function(){if("undefined"==typeof e){var t=document.createElement("div");t.style.fontSize="13px",t.style.lineHeight="1.5",t.style.padding=0,t.style.border=0,t.innerHTML=" 
 ",document.body.appendChild(t),e=38===t.offsetHeight,document.body.removeChild(t)}return e}}(),o=0;Prism.hooks.add("complete",function(t){var r=t.element.parentNode,a=r&&r.getAttribute("data-line");r&&a&&/pre/i.test(r.nodeName)&&(clearTimeout(o),e(".line-highlight",r).forEach(function(e){e.parentNode.removeChild(e)}),n(r,a),o=setTimeout(i,1))}),window.addEventListener&&window.addEventListener("hashchange",i)}}(); \ No newline at end of file +!function(){function e(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function t(e,t){return t=" "+t+" ",(" "+e.className+" ").replace(/[\n\t]/g," ").indexOf(t)>-1}function n(e,n,i){for(var o,l=n.replace(/\s+/g,"").split(","),a=+e.getAttribute("data-line-offset")||0,d=r()?parseInt:parseFloat,c=d(getComputedStyle(e).lineHeight),s=0;o=l[s++];){o=o.split("-");var u=+o[0],m=+o[1]||u,h=document.createElement("div");h.textContent=Array(m-u+2).join(" \n"),h.className=(i||"")+" line-highlight",t(e,"line-numbers")||(h.setAttribute("data-start",u),m>u&&h.setAttribute("data-end",m)),h.style.top=(u-a-1)*c+"px",t(e,"line-numbers")?e.appendChild(h):(e.querySelector("code")||e).appendChild(h)}}function i(){var t=location.hash.slice(1);e(".temporary.line-highlight").forEach(function(e){e.parentNode.removeChild(e)});var i=(t.match(/\.([\d,-]+)$/)||[,""])[1];if(i&&!document.getElementById(t)){var r=t.slice(0,t.lastIndexOf(".")),o=document.getElementById(r);o&&(o.hasAttribute("data-line")||o.setAttribute("data-line",""),n(o,i,"temporary "),document.querySelector(".temporary.line-highlight").scrollIntoView())}}if("undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector){var r=function(){var e;return function(){if("undefined"==typeof e){var t=document.createElement("div");t.style.fontSize="13px",t.style.lineHeight="1.5",t.style.padding=0,t.style.border=0,t.innerHTML=" 
 ",document.body.appendChild(t),e=38===t.offsetHeight,document.body.removeChild(t)}return e}}(),o=0;Prism.hooks.add("complete",function(t){var r=t.element.parentNode,l=r&&r.getAttribute("data-line");r&&l&&/pre/i.test(r.nodeName)&&(clearTimeout(o),e(".line-highlight",r).forEach(function(e){e.parentNode.removeChild(e)}),n(r,l),o=setTimeout(i,1))}),window.addEventListener("hashchange",i)}}(); \ No newline at end of file diff --git a/prism.js b/prism.js index 60e787ba4b..753e2c82bf 100644 --- a/prism.js +++ b/prism.js @@ -63,8 +63,7 @@ var _ = _self.Prism = { return clone; case 'Array': - // Check for existence for IE8 - return o.map && o.map(function(v) { return _.util.clone(v); }); + return o.map(function(v) { return _.util.clone(v); }); } return o; @@ -487,7 +486,7 @@ var script = document.currentScript || [].slice.call(document.getElementsByTagNa if (script) { _.filename = script.src; - if (document.addEventListener && !script.hasAttribute('data-manual')) { + if (!script.hasAttribute('data-manual')) { if(document.readyState !== "loading") { if (window.requestAnimationFrame) { window.requestAnimationFrame(_.highlightAll); @@ -731,58 +730,56 @@ Prism.languages.js = Prism.languages.javascript; 'tex': 'latex' }; - if(Array.prototype.forEach) { // Check to prevent error in IE8 - Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) { - var src = pre.getAttribute('data-src'); + Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) { + var src = pre.getAttribute('data-src'); - var language, parent = pre; - var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; - while (parent && !lang.test(parent.className)) { - parent = parent.parentNode; - } + var language, parent = pre; + var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; + while (parent && !lang.test(parent.className)) { + parent = parent.parentNode; + } - if (parent) { - language = (pre.className.match(lang) || [, ''])[1]; - } + if (parent) { + language = (pre.className.match(lang) || [, ''])[1]; + } - if (!language) { - var extension = (src.match(/\.(\w+)$/) || [, ''])[1]; - language = Extensions[extension] || extension; - } + if (!language) { + var extension = (src.match(/\.(\w+)$/) || [, ''])[1]; + language = Extensions[extension] || extension; + } - var code = document.createElement('code'); - code.className = 'language-' + language; + var code = document.createElement('code'); + code.className = 'language-' + language; - pre.textContent = ''; + pre.textContent = ''; - code.textContent = 'Loading…'; + code.textContent = 'Loading…'; - pre.appendChild(code); + pre.appendChild(code); - var xhr = new XMLHttpRequest(); + var xhr = new XMLHttpRequest(); - xhr.open('GET', src, true); + xhr.open('GET', src, true); - xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { + xhr.onreadystatechange = function () { + if (xhr.readyState == 4) { - if (xhr.status < 400 && xhr.responseText) { - code.textContent = xhr.responseText; + if (xhr.status < 400 && xhr.responseText) { + code.textContent = xhr.responseText; - Prism.highlightElement(code); - } - else if (xhr.status >= 400) { - code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText; - } - else { - code.textContent = '✖ Error: File does not exist or is empty'; - } + Prism.highlightElement(code); + } + else if (xhr.status >= 400) { + code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText; } - }; + else { + code.textContent = '✖ Error: File does not exist or is empty'; + } + } + }; - xhr.send(null); - }); - } + xhr.send(null); + }); }; From f7bdfd26e0c72d337678b3f4e6f75523e48030b3 Mon Sep 17 00:00:00 2001 From: Andreas Rohner Date: Sun, 3 Jul 2016 12:31:13 +0200 Subject: [PATCH 2/2] Fix minor issues in index.html --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index c32319bac6..eff0114046 100644 --- a/index.html +++ b/index.html @@ -88,7 +88,7 @@

Examples

If you’re still not sold, you can view more examples or try it out for yourself.

-
+

Full list of features

  • Only 2KB minified & gzipped (core). Each language definition adds roughly 300-500 bytes.
  • @@ -229,7 +229,7 @@

    Credits

    - +