diff --git a/IPython/frontend/html/notebook/static/js/cell.js b/IPython/frontend/html/notebook/static/js/cell.js index 6afc852..be63097 100644 --- a/IPython/frontend/html/notebook/static/js/cell.js +++ b/IPython/frontend/html/notebook/static/js/cell.js @@ -50,8 +50,11 @@ var IPython = (function (IPython) { }); }; - // prototype typeset method does nothing, see TextCell typeset Cell.prototype.typeset = function () { + if (window.MathJax){ + var cell_math = this.element.get(0); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,cell_math]); + } }; Cell.prototype.select = function () { diff --git a/IPython/frontend/html/notebook/static/js/mathjaxutils.js b/IPython/frontend/html/notebook/static/js/mathjaxutils.js index 9102616..7c7cb1a 100644 --- a/IPython/frontend/html/notebook/static/js/mathjaxutils.js +++ b/IPython/frontend/html/notebook/static/js/mathjaxutils.js @@ -16,6 +16,18 @@ IPython.mathjaxutils = (function (IPython) { var init = function () { if (window.MathJax) { // MathJax loaded + MathJax.Hub.Config({ + tex2jax: { + inlineMath: [ ['$','$'], ["\\(","\\)"] ], + displayMath: [ ['$$','$$'], ["\\[","\\]"] ], + processEnvironments: true + }, + displayAlign: 'left', // Change this to 'center' to center equations. + "HTML-CSS": { + styles: {'.MathJax_Display': {"margin": 0}} + } + }); + MathJax.Hub.Configured(); } else if (window.mathjax_url != "") { // Don't have MathJax, but should. Show dialog. var dialog = $('
') @@ -89,12 +101,12 @@ IPython.mathjaxutils = (function (IPython) { // math, then push the math string onto the storage array. // The preProcess function is called on all blocks if it has been passed in var process_math = function (i, j, pre_process) { - var HUB = MathJax.Hub; + var hub = MathJax.Hub; var block = blocks.slice(i, j + 1).join("").replace(/&/g, "&") // use HTML entity for & .replace(//g, ">") // use HTML entity for > ; - if (HUB.Browser.isMSIE) { + if (hub.Browser.isMSIE) { block = block.replace(/(%[^\n]*)\n/g, "$1' + code + '
';
- });
- this.typeset()
+ text = IPython.mathjaxutils.remove_math(text)
+ var html = IPython.markdown_converter.makeHtml(text);
+ html = IPython.mathjaxutils.replace_math(html)
+ try {
+ this.set_rendered(html);
+ } catch (e) {
+ console.log("Error running Javascript in Markdown:");
+ console.log(e);
+ this.set_rendered($("").addClass("js-error").html(
+ "Error rendering Markdown!' + code + '
';
+ });
+ this.typeset()
this.rendered = true;
}
};
diff --git a/IPython/frontend/html/notebook/templates/notebook.html b/IPython/frontend/html/notebook/templates/notebook.html
index bb712c6..1868e72 100644
--- a/IPython/frontend/html/notebook/templates/notebook.html
+++ b/IPython/frontend/html/notebook/templates/notebook.html
@@ -2,21 +2,7 @@
{% block stylesheet %}
{% if mathjax_url %}
-
-
-
+
{% end %}
-
-
+
{% end %}