Merge branch 'master' into prism-textile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
diff --git a/plugins/file-highlight/prism-file-highlight.min.js b/plugins/file-highlight/prism-file-highlight.min.js
index 17d61bc..a14cc13 100644
--- a/plugins/file-highlight/prism-file-highlight.min.js
+++ b/plugins/file-highlight/prism-file-highlight.min.js
@@ -1 +1 @@
-!function(){if(self.Prism&&self.document&&document.querySelector){var e={js:"javascript",html:"markup",svg:"markup",xml:"markup",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell"};Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){var r=t.getAttribute("data-src"),n=(r.match(/\.(\w+)$/)||[,""])[1],s=e[n]||n,a=document.createElement("code");a.className="language-"+s,t.textContent="",a.textContent="Loading…",t.appendChild(a);var o=new XMLHttpRequest;o.open("GET",r,!0),o.onreadystatechange=function(){4==o.readyState&&(o.status<400&&o.responseText?(a.textContent=o.responseText,Prism.highlightElement(a)):a.textContent=o.status>=400?"✖ Error "+o.status+" while fetching file: "+o.statusText:"✖ Error: File does not exist or is empty")},o.send(null)})}}();
\ No newline at end of file
+!function(){self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",html:"markup",svg:"markup",xml:"markup",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell"};Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){var r=t.getAttribute("data-src"),s=(r.match(/\.(\w+)$/)||[,""])[1],n=e[s]||s,a=document.createElement("code");a.className="language-"+n,t.textContent="",a.textContent="Loading…",t.appendChild(a);var l=new XMLHttpRequest;l.open("GET",r,!0),l.onreadystatechange=function(){4==l.readyState&&(l.status<400&&l.responseText?(a.textContent=l.responseText,Prism.highlightElement(a)):a.textContent=l.status>=400?"✖ Error "+l.status+" while fetching file: "+l.statusText:"✖ Error: File does not exist or is empty")},l.send(null)})},self.Prism.fileHighlight())}();
\ No newline at end of file
diff --git a/prism.js b/prism.js
index 7790bc1..2a5c024 100644
--- a/prism.js
+++ b/prism.js
@@ -609,59 +609,64 @@ if (Prism.languages.markup) {
Begin prism-file-highlight.js
********************************************** */
-(function(){
+(function () {
+ if (!self.Prism || !self.document || !document.querySelector) {
+ return;
+ }
-if (!self.Prism || !self.document || !document.querySelector) {
- return;
-}
+ self.Prism.fileHighlight = function() {
+
+ var Extensions = {
+ 'js': 'javascript',
+ 'html': 'markup',
+ 'svg': 'markup',
+ 'xml': 'markup',
+ 'py': 'python',
+ 'rb': 'ruby',
+ 'ps1': 'powershell',
+ 'psm1': 'powershell'
+ };
-var Extensions = {
- 'js': 'javascript',
- 'html': 'markup',
- 'svg': 'markup',
- 'xml': 'markup',
- 'py': 'python',
- 'rb': 'ruby',
- 'ps1': 'powershell',
- 'psm1': 'powershell'
-};
+ Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function(pre) {
+ var src = pre.getAttribute('data-src');
+ var extension = (src.match(/\.(\w+)$/) || [,''])[1];
+ var language = Extensions[extension] || extension;
-Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function(pre) {
- var src = pre.getAttribute('data-src');
- var extension = (src.match(/\.(\w+)$/) || [,''])[1];
- var language = Extensions[extension] || extension;
-
- var code = document.createElement('code');
- code.className = 'language-' + language;
-
- pre.textContent = '';
-
- code.textContent = 'Loading…';
-
- pre.appendChild(code);
-
- var xhr = new XMLHttpRequest();
-
- xhr.open('GET', src, true);
+ var code = document.createElement('code');
+ code.className = 'language-' + language;
+
+ pre.textContent = '';
+
+ code.textContent = 'Loading…';
+
+ pre.appendChild(code);
+
+ var xhr = new XMLHttpRequest();
+
+ xhr.open('GET', src, true);
+
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == 4) {
+
+ 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';
+ }
+ }
+ };
+
+ xhr.send(null);
+ });
- xhr.onreadystatechange = function() {
- if (xhr.readyState == 4) {
-
- 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';
- }
- }
};
-
- xhr.send(null);
-});
+
+ self.Prism.fileHighlight();
})();