Permalink
Browse files

fixed error output for unavailable languages

  • Loading branch information...
1 parent 3fe68e1 commit 69c9334950bbd409a2d7d47a131865a448ff0edb @coolaj86 coolaj86 committed Jan 21, 2012
Showing with 11 additions and 5 deletions.
  1. +11 −5 lib/highlight.js
View
@@ -53,10 +53,12 @@ var self = this;
}
Highlight.languages = fsnodes.filter(acceptJsFiles).sort(function (a, b) {
+ // xml must be first (others depend on it)
if ('xml' === a) {
return -100000000;
}
- if ('django.js' === a || 'html-xml.js' === a) {
+ // django should be after xml
+ if ('django.js' === a) {
return 1000000000;
}
@@ -77,15 +79,19 @@ var self = this;
}
function loadLangs(cb, langs) {
+ var err
+ ;
+
if ('string' === typeof langs) {
langs = [langs];
}
if (!Array.isArray(langs)) {
cb(new Error("no array of languages given"));
+ return;
}
- langs.forEach(function (lang) {
+ langs.some(function (lang) {
var addLangToHighlightInstance
;
@@ -96,8 +102,8 @@ var self = this;
addLangToHighlightInstance = availableMap[lang];
if (!addLangToHighlightInstance) {
- cb(new Error("No language pack available for '" + lang + "'"));
- return;
+ err = new Error("No language pack available for '" + lang + "'");
+ return true;
}
try {
@@ -118,7 +124,7 @@ var self = this;
});
// future-proofing for async api
- cb(null);
+ cb(err);
}
function init(cb, langs, opts) {

0 comments on commit 69c9334

Please sign in to comment.