From 7846000e0ad5713463469e76cc876d2903835a65 Mon Sep 17 00:00:00 2001 From: Andrew Gibiansky Date: Fri, 3 Jan 2014 20:22:29 -0500 Subject: [PATCH] fixing python3 bug and weird highlighting bug --- profile/ipython_config.py | 4 ++-- profile/static/custom/custom.js | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/profile/ipython_config.py b/profile/ipython_config.py index 50f7748b..06fe2a50 100644 --- a/profile/ipython_config.py +++ b/profile/ipython_config.py @@ -2,8 +2,8 @@ # exe: Path to IHaskell kernel. c = get_config() c.KernelManager.kernel_cmd = [exe, 'kernel', '{connection_file}'] -c.Session.key = '' -c.Session.keyfile = '' +c.Session.key = b'' +c.Session.keyfile = b'' # Syntax highlight properly in Haskell notebooks. c.NbConvertBase.default_language = "haskell" diff --git a/profile/static/custom/custom.js b/profile/static/custom/custom.js index 0d737d4c..483be911 100644 --- a/profile/static/custom/custom.js +++ b/profile/static/custom/custom.js @@ -53,7 +53,7 @@ $([IPython.events]).on('notebook_loaded.Notebook', function(){ // add here logic that should be run once per **notebook load** // (!= page load), like restarting a checkpoint - var md = IPython.notebook.metadata + var md = IPython.notebook.metadata; if(md.language){ console.log('language already defined and is :', md.language); } else { @@ -71,14 +71,21 @@ $([IPython.events]).on('app_initialized.NotebookApp', function(){ cells = IPython.notebook.get_cells(); for(var i in cells){ c = cells[i]; - if (c.cell_type === 'code'){ + if (c.cell_type === 'code') { + // Force the mode to be Haskell + // This is necessary, otherwise sometimes highlighting just doesn't happen. + // This may be an IPython bug. + c.code_mirror.setOption('mode', 'haskell'); + c.auto_highlight() } } - }) + + // We can only load the conceal scripts once all cells have mode 'haskell' + require(['/static/custom/conceal/conceal.js']); + }); IPython.CodeCell.options_default['cm_config']['mode'] = 'haskell'; - require(['/static/custom/conceal/conceal.js']); }); var highlightCodes = function() {