Skip to content

Commit 70ea430

Browse files
committed
[source-highlight util] Fix looking up of modes
1 parent 957c28f commit 70ea430

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

bin/source-highlight

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@ if (sPos == -1 || sPos == process.argv.length - 1) {
1717
process.exit(1);
1818
}
1919
var lang = process.argv[sPos + 1].toLowerCase(), modeName = lang;
20-
CodeMirror.modeInfo.forEach(function(info) {
21-
if (info.mime == lang) {
22-
modeName = info.mode;
23-
} else if (info.name.toLowerCase() == lang) {
24-
modeName = info.mode;
25-
lang = info.mime;
26-
}
27-
});
20+
var found = CodeMirror.findModeByMIME(lang) || CodeMirror.findModeByName(lang)
21+
if (found) {
22+
modeName = found.mode
23+
lang = found.mime
24+
}
2825

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

0 commit comments

Comments
 (0)