If loading a new language, don't attempt highlight until it's actually downloaded.
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
diff --git a/test.html b/test.html
index bdde7e1..d9524ae 100644
--- a/test.html
+++ b/test.html
@@ -84,7 +84,8 @@ textarea {
<script>
(function() {
var form = $('form'), code = $('code', form),
- languages = components.languages;
+ languages = components.languages,
+ highlightCode = function() { Prism.highlightElement(code); };
for (var id in languages) {
if (id == 'meta') {
@@ -107,10 +108,11 @@ for (var id in languages) {
code.textContent = code.textContent;
if (!Prism.languages[lang]) {
- $u.script('components/prism-' + lang + '.js');
+ $u.script('components/prism-' + lang + '.js', highlightCode);
+ }
+ else {
+ highlightCode();
}
-
- Prism.highlightElement(code);
}
}
}, name
@@ -127,7 +129,7 @@ var textarea = $('textarea', form);
(textarea.oninput = function() {
code.textContent = this.value || '';
- Prism.highlightElement(code);
+ highlightCode();
}).call(textarea);
})();