Skip to content

Commit

Permalink
Merge branch 'RemoveIE8' of https://github.com/zeitgeist87/prism into…
Browse files Browse the repository at this point in the history
… zeitgeist87-RemoveIE8

# Conflicts:
#	components/prism-core.js
#	components/prism-core.min.js
#	plugins/line-highlight/prism-line-highlight.js
#	plugins/line-highlight/prism-line-highlight.min.js
#	prism.js
  • Loading branch information
Golmote committed Sep 9, 2017
2 parents 3426ed1 + f7bdfd2 commit 25788eb
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 207 deletions.
5 changes: 2 additions & 3 deletions components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,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;
Expand Down Expand Up @@ -506,7 +505,7 @@ var script = document.currentScript || [].slice.call(document.getElementsByTagNa
if (script) {
_.filename = script.src;

if (document.addEventListener && !_.manual && !script.hasAttribute('data-manual')) {
if (!_.manual && !script.hasAttribute('data-manual')) {
if(document.readyState !== "loading") {
if (window.requestAnimationFrame) {
window.requestAnimationFrame(_.highlightAll);
Expand Down
2 changes: 1 addition & 1 deletion components/prism-core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h1>Examples</h1>
<p>If you’re still not sold, you can <a href="examples.html">view more examples</a> or <a href="test.html">try it out for yourself</a>.</p>
</section>

<section id="features-full">
<section id="features-full" class="language-markup">
<h1>Full list of features</h1>
<ul>
<li><strong>Only 2KB</strong> minified &amp; gzipped (core). Each language definition adds roughly 300-500 bytes.</li>
Expand Down Expand Up @@ -229,7 +229,7 @@ <h1>Credits</h1>

<footer data-src="templates/footer.html" data-type="text/html"></footer>

<script src="prism.js" data-default-language="markup"></script>
<script src="prism.js"></script>
<script src="utopia.js"></script>
<script src="components.js"></script>
<script src="code.js"></script>
Expand Down
76 changes: 37 additions & 39 deletions plugins/file-highlight/prism-file-highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

};

Expand Down
2 changes: 1 addition & 1 deletion plugins/file-highlight/prism-file-highlight.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 25788eb

Please sign in to comment.