diff --git a/IPython/html/static/base/js/utils.js b/IPython/html/static/base/js/utils.js
index cfbd94e..f974d87 100644
--- a/IPython/html/static/base/js/utils.js
+++ b/IPython/html/static/base/js/utils.js
@@ -624,7 +624,8 @@ define([
var info = (mode && mode.mode && mode.mime && mode) ||
CodeMirror.findModeByName(modename) ||
CodeMirror.findModeByExtension(modename.split(".").slice(-1)) ||
- CodeMirror.findModeByMIME(modename);
+ CodeMirror.findModeByMIME(modename) ||
+ {mode: modename, mime: modename};
require([
// might want to use CodeMirror.modeURL here
diff --git a/IPython/html/static/edit/js/editor.js b/IPython/html/static/edit/js/editor.js
index f2db0c8..53320b6 100644
--- a/IPython/html/static/edit/js/editor.js
+++ b/IPython/html/static/edit/js/editor.js
@@ -41,12 +41,10 @@ function($,
cm.clearHistory();
// Find and load the highlighting mode
- var modeinfo = CodeMirror.findModeByMIME(model.mimetype);
- if (modeinfo) {
- utils.requireCodeMirrorMode(modeinfo.mode, function() {
- cm.setOption('mode', modeinfo.mode);
- });
- }
+ utils.requireCodeMirrorMode(model.mimetype, function(spec) {
+ var mode = CodeMirror.getMode({}, spec);
+ cm.setOption('mode', mode);
+ });
that.save_enabled = true;
},
function(error) {
diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js
index 7b09d3d..3fedb9a 100644
--- a/IPython/html/static/notebook/js/notebook.js
+++ b/IPython/html/static/notebook/js/notebook.js
@@ -1587,14 +1587,14 @@ define([
codecell.CodeCell.options_default.cm_config.mode = newmode;
var that = this;
- utils.requireCodeMirrorMode(newmode, function () {
+ utils.requireCodeMirrorMode(newmode, function (spec) {
that.get_cells().map(function(cell, i) {
if (cell.cell_type === 'code'){
- cell.code_mirror.setOption('mode', newmode);
+ cell.code_mirror.setOption('mode', spec);
// This is currently redundant, because cm_config ends up as
// codemirror's own .options object, but I don't want to
// rely on that.
- cell.cm_config.mode = newmode;
+ cell.cm_config.mode = spec;
}
});
});