Skip to content

Commit

Permalink
[source-highlight util] Fix looking up of modes
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Dec 14, 2016
1 parent 957c28f commit 70ea430
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions bin/source-highlight
Expand Up @@ -17,14 +17,11 @@ if (sPos == -1 || sPos == process.argv.length - 1) {
process.exit(1);
}
var lang = process.argv[sPos + 1].toLowerCase(), modeName = lang;
CodeMirror.modeInfo.forEach(function(info) {
if (info.mime == lang) {
modeName = info.mode;
} else if (info.name.toLowerCase() == lang) {
modeName = info.mode;
lang = info.mime;
}
});
var found = CodeMirror.findModeByMIME(lang) || CodeMirror.findModeByName(lang)
if (found) {
modeName = found.mode
lang = found.mime
}

if (!CodeMirror.modes[modeName])
require("../mode/" + modeName + "/" + modeName + ".js");
Expand Down

0 comments on commit 70ea430

Please sign in to comment.