diff --git a/IPython/frontend/html/notebook/static/js/textcell.js b/IPython/frontend/html/notebook/static/js/textcell.js
index 535c226bb..7732c3ea9 100644
--- a/IPython/frontend/html/notebook/static/js/textcell.js
+++ b/IPython/frontend/html/notebook/static/js/textcell.js
@@ -202,6 +202,18 @@ var IPython = (function (IPython) {
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
this.element.find('div.text_cell_input').hide();
this.element.find("div.text_cell_render").show();
+ var code_snippets = this.element.find("pre > code");
+ code_snippets.replaceWith(function () {
+ var code = $(this).html();
+ /* Substitute br for newlines and for spaces
+ before highlighting, since prettify doesn't
+ preserve those on all browsers */
+ code = code.replace(/(\r\n|\n|\r)/gm, "
");
+ code = code.replace(/ /gm, ' ');
+ code = prettyPrintOne(code);
+
+ return '' + code + '';
+ });
this.rendered = true;
};
};
diff --git a/IPython/frontend/html/notebook/templates/notebook.html b/IPython/frontend/html/notebook/templates/notebook.html
index a114023a6..97bfe603e 100644
--- a/IPython/frontend/html/notebook/templates/notebook.html
+++ b/IPython/frontend/html/notebook/templates/notebook.html
@@ -24,6 +24,8 @@
+
+
@@ -214,6 +216,8 @@
+
+