From b3cab90e9a216524f7ce0f3a09a83019b740c654 Mon Sep 17 00:00:00 2001 From: Min RK Date: Sat, 6 Feb 2016 20:34:19 +0100 Subject: [PATCH 1/3] only scrub SVG output which is the largest rather than white-listing HTML-CSS. This means the various other renderers (perhaps most importantly, MML) are available, not just HTML-CSS This increases the size of a notebook install by ~800k/19MB or 5%. Alternately, we could *only* add MML, which would have a negligible affect on install size. --- notebook/static/notebook/js/mathjaxutils.js | 8 +++++--- setupbase.py | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/notebook/static/notebook/js/mathjaxutils.js b/notebook/static/notebook/js/mathjaxutils.js index 7848da8108..3c1c7a03a0 100644 --- a/notebook/static/notebook/js/mathjaxutils.js +++ b/notebook/static/notebook/js/mathjaxutils.js @@ -29,9 +29,11 @@ define([ styles: {'.MathJax_Display': {"margin": 0}}, linebreaks: { automatic: true } }, - MathMenu: { - showRenderer: false, - }, + }); + MathJax.Hub.Register.StartupHook("MathMenu Ready", function () { + var renderers = MathJax.Menu.menu.Find("Math Settings").submenu.Find("Math Renderer").submenu; + // disable SVG output, which we don't ship + renderers.Find("SVG").disabled = true; }); MathJax.Hub.Configured(); } else if (window.mathjax_url !== "") { diff --git a/setupbase.py b/setupbase.py index 6e90cec07a..c51bba916d 100644 --- a/setupbase.py +++ b/setupbase.py @@ -158,21 +158,30 @@ def find_package_data(): mj('MathJax.js'), mj('config', 'TeX-AMS_HTML-full.js'), mj('config', 'Safe.js'), - mj('extensions', 'Safe.js'), - mj('jax', 'output', 'HTML-CSS', '*.js'), ]) - for tree in [ + + trees = [] + mj_out = mj('jax', 'output') + for output in os.listdir(mj_out): + if output == 'SVG': + # strip SVG output + continue + path = pjoin(mj_out, output) + static_data.append(pjoin(path, '*.js')) + autoload = pjoin(path, 'autoload') + if os.path.isdir(autoload): + trees.append(autoload) + + for tree in trees + [ mj('localization'), # limit to en? mj('fonts', 'HTML-CSS', 'STIX-Web', 'woff'), - mj('extensions', 'TeX'), + mj('extensions'), mj('jax', 'input', 'TeX'), - mj('jax', 'output', 'HTML-CSS', 'autoload'), mj('jax', 'output', 'HTML-CSS', 'fonts', 'STIX-Web'), ]: for parent, dirs, files in os.walk(tree): for f in files: static_data.append(pjoin(parent, f)) - os.chdir(os.path.join('tests',)) js_tests = glob('*.js') + glob('*/*.js') From bb6368a54531f24243cef3f450b5ba23cd590940 Mon Sep 17 00:00:00 2001 From: Min RK Date: Sat, 6 Feb 2016 21:14:13 +0100 Subject: [PATCH 2/3] package data may be computed prior to components being fetched trust that it will be re-run after npm/bower --- setupbase.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/setupbase.py b/setupbase.py index c51bba916d..7bfce0bc48 100644 --- a/setupbase.py +++ b/setupbase.py @@ -162,16 +162,18 @@ def find_package_data(): trees = [] mj_out = mj('jax', 'output') - for output in os.listdir(mj_out): - if output == 'SVG': - # strip SVG output - continue - path = pjoin(mj_out, output) - static_data.append(pjoin(path, '*.js')) - autoload = pjoin(path, 'autoload') - if os.path.isdir(autoload): - trees.append(autoload) + if os.path.exists(mj_out): + for output in os.listdir(mj_out): + if output == 'SVG': + # strip SVG output + continue + path = pjoin(mj_out, output) + static_data.append(pjoin(path, '*.js')) + autoload = pjoin(path, 'autoload') + if os.path.isdir(autoload): + trees.append(autoload) + for tree in trees + [ mj('localization'), # limit to en? mj('fonts', 'HTML-CSS', 'STIX-Web', 'woff'), From b0772dd3c7ac305dfd8834dada4be04a7f052034 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 22 Feb 2016 11:22:34 +0100 Subject: [PATCH 3/3] include SVG mathjax output we now ship all mathjax output formats We still strip down to a single font (STIX-Web) --- notebook/static/notebook/js/mathjaxutils.js | 5 ----- setupbase.py | 4 +--- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/notebook/static/notebook/js/mathjaxutils.js b/notebook/static/notebook/js/mathjaxutils.js index 3c1c7a03a0..cfbe266d8a 100644 --- a/notebook/static/notebook/js/mathjaxutils.js +++ b/notebook/static/notebook/js/mathjaxutils.js @@ -30,11 +30,6 @@ define([ linebreaks: { automatic: true } }, }); - MathJax.Hub.Register.StartupHook("MathMenu Ready", function () { - var renderers = MathJax.Menu.menu.Find("Math Settings").submenu.Find("Math Renderer").submenu; - // disable SVG output, which we don't ship - renderers.Find("SVG").disabled = true; - }); MathJax.Hub.Configured(); } else if (window.mathjax_url !== "") { // Don't have MathJax, but should. Show dialog. diff --git a/setupbase.py b/setupbase.py index 7bfce0bc48..77554b738c 100644 --- a/setupbase.py +++ b/setupbase.py @@ -165,9 +165,6 @@ def find_package_data(): if os.path.exists(mj_out): for output in os.listdir(mj_out): - if output == 'SVG': - # strip SVG output - continue path = pjoin(mj_out, output) static_data.append(pjoin(path, '*.js')) autoload = pjoin(path, 'autoload') @@ -180,6 +177,7 @@ def find_package_data(): mj('extensions'), mj('jax', 'input', 'TeX'), mj('jax', 'output', 'HTML-CSS', 'fonts', 'STIX-Web'), + mj('jax', 'output', 'SVG', 'fonts', 'STIX-Web'), ]: for parent, dirs, files in os.walk(tree): for f in files: