From 283756ff032e89ec7bd8f626d1d6fddd29b3e16d Mon Sep 17 00:00:00 2001 From: MinRK Date: Tue, 14 Jan 2014 09:15:57 -0800 Subject: [PATCH 1/3] don't require mathjax on the page in mathjax utils required for reusing mathjaxutils in node --- IPython/html/static/notebook/js/mathjaxutils.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/IPython/html/static/notebook/js/mathjaxutils.js b/IPython/html/static/notebook/js/mathjaxutils.js index 0e76ae3e3..fd9e9bba0 100644 --- a/IPython/html/static/notebook/js/mathjaxutils.js +++ b/IPython/html/static/notebook/js/mathjaxutils.js @@ -106,12 +106,11 @@ 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, math, blocks) { - 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 (IPython.utils.browser === 'msie') { block = block.replace(/(%[^\n]*)\n/g, "$1
\n"); } while (j > i) { @@ -133,10 +132,6 @@ IPython.mathjaxutils = (function (IPython) { // (which will be a paragraph). // var remove_math = function (text) { - if (!window.MathJax) { - return [text, null]; - } - var math = []; // stores math strings for later var start; var end; @@ -241,9 +236,6 @@ IPython.mathjaxutils = (function (IPython) { // and clear the math array (no need to keep it around). // var replace_math = function (text, math) { - if (!window.MathJax) { - return text; - } text = text.replace(/@@(\d+)@@/g, function (match, n) { return math[n]; }); From c7a36768044b54a6d31a77316ed3b364ab3220f9 Mon Sep 17 00:00:00 2001 From: MinRK Date: Tue, 14 Jan 2014 10:05:36 -0800 Subject: [PATCH 2/3] allow utils.js to be loaded in node where navigator is undefined --- IPython/html/static/base/js/utils.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/IPython/html/static/base/js/utils.js b/IPython/html/static/base/js/utils.js index b3f7b3a18..90eca6e08 100644 --- a/IPython/html/static/base/js/utils.js +++ b/IPython/html/static/base/js/utils.js @@ -448,6 +448,10 @@ IPython.utils = (function (IPython) { // http://stackoverflow.com/questions/2400935/browser-detection-in-javascript var browser = (function() { + if (typeof navigator === 'undefined') { + // navigator undefined in node + return 'None'; + } var N= navigator.appName, ua= navigator.userAgent, tem; var M= ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i); if (M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1]; From 3050be2795dd92d51b06e67242e122fdce94d449 Mon Sep 17 00:00:00 2001 From: MinRK Date: Tue, 14 Jan 2014 16:46:57 -0800 Subject: [PATCH 3/3] include marked.js in package_data --- setupbase.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setupbase.py b/setupbase.py index 5afbdfe8d..b5c9b2089 100644 --- a/setupbase.py +++ b/setupbase.py @@ -164,6 +164,7 @@ def find_package_data(): 'IPython.qt.console' : ['resources/icon/*.svg'], 'IPython.nbconvert' : nbconvert_templates + ['tests/files/*.*', 'exporters/tests/files/*.*'], + 'IPython.nbconvert.filters' : ['marked.js'], 'IPython.nbformat' : ['tests/*.ipynb'] } return package_data