Permalink
Browse files

[source-highlight util] Fix looking up of modes

  • Loading branch information...
1 parent 957c28f commit 70ea4303bc4efcdb7ef1956bb6123667440f0a19 @marijnh marijnh committed Dec 14, 2016
Showing with 5 additions and 8 deletions.
  1. +5 −8 bin/source-highlight
View
@@ -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");

0 comments on commit 70ea430

Please sign in to comment.