From b3cab90e9a216524f7ce0f3a09a83019b740c654 Mon Sep 17 00:00:00 2001 From: Min RK Date: Sat, 6 Feb 2016 20:34:19 +0100 Subject: [PATCH] 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 7848da810..3c1c7a03a 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 6e90cec07..c51bba916 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')