From c1a8b81d956d83c61081c33e7455d9efc4b042f3 2014-12-06 19:18:51 From: Nicholas Bollweg (Nick) Date: 2014-12-06 19:18:51 Subject: [PATCH] handling explicitly provided modes from kernelspec.language_info --- diff --git a/IPython/html/static/base/js/utils.js b/IPython/html/static/base/js/utils.js index 2e6fcde..cfbd94e 100644 --- a/IPython/html/static/base/js/utils.js +++ b/IPython/html/static/base/js/utils.js @@ -612,21 +612,19 @@ define([ * require and callback with the resolveable mode string: mime or * custom name */ - if (typeof mode != "string") mode = mode.name; - if (CodeMirror.modes.hasOwnProperty(mode)) { + var modename = (typeof mode == "string") ? mode : + mode.mode || mode.name; + + if (CodeMirror.modes.hasOwnProperty(modename)) { callback(mode); return; } - var info = CodeMirror.findModeByName(mode) || - CodeMirror.findModeByExtension(mode.split(".").slice(-1)) || - CodeMirror.findModeByMIME(mode); - - if(!info){ - errback && errback(); - return; - } + var info = (mode && mode.mode && mode.mime && mode) || + CodeMirror.findModeByName(modename) || + CodeMirror.findModeByExtension(modename.split(".").slice(-1)) || + CodeMirror.findModeByMIME(modename); require([ // might want to use CodeMirror.modeURL here diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index e79bc73..7b09d3d 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -1585,10 +1585,9 @@ define([ } this.codemirror_mode = newmode; codecell.CodeCell.options_default.cm_config.mode = newmode; - var modename = newmode.mode || newmode.name || newmode; var that = this; - utils.requireCodeMirrorMode(modename, function () { + utils.requireCodeMirrorMode(newmode, function () { that.get_cells().map(function(cell, i) { if (cell.cell_type === 'code'){ cell.code_mirror.setOption('mode', newmode);