From c52e8fdc770adcd4690868767a829f7e4b62a1c2 Mon Sep 17 00:00:00 2001 From: Bernhard Liebl Date: Fri, 29 Apr 2016 23:49:33 +0200 Subject: [PATCH 1/2] make MathJax config parameter configurable (instead of hard coded) --- notebook/base/handlers.py | 4 ++++ notebook/notebook/handlers.py | 1 + notebook/notebookapp.py | 10 ++++++++++ notebook/templates/notebook.html | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/notebook/base/handlers.py b/notebook/base/handlers.py index 686dcb93b6..357401f09a 100644 --- a/notebook/base/handlers.py +++ b/notebook/base/handlers.py @@ -159,6 +159,10 @@ def mathjax_url(self): return url return url_path_join(self.base_url, url) + @property + def mathjax_config(self): + return self.settings.get('mathjax_config', 'TeX-AMS_HTML-full,Safe') + @property def base_url(self): return self.settings.get('base_url', '/') diff --git a/notebook/notebook/handlers.py b/notebook/notebook/handlers.py index 72bbd5a82e..c885a55c94 100644 --- a/notebook/notebook/handlers.py +++ b/notebook/notebook/handlers.py @@ -40,6 +40,7 @@ def get(self, path): notebook_name=name, kill_kernel=False, mathjax_url=self.mathjax_url, + mathjax_config=self.mathjax_config ) ) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index a2b4ee7c6c..79dfb182d2 100644 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -238,6 +238,7 @@ def init_settings(self, ipython_app, kernel_manager, contents_manager, nbextensions_path=ipython_app.nbextensions_path, websocket_url=ipython_app.websocket_url, mathjax_url=ipython_app.mathjax_url, + mathjax_config=ipython_app.mathjax_config, config=ipython_app.config, config_dir=ipython_app.config_dir, jinja2_env=env, @@ -728,6 +729,15 @@ def _mathjax_url_changed(self, name, old, new): else: self.log.info("Using MathJax: %s", new) + mathjax_config = Unicode("", config=True, + help="""The MathJax.js configuration file that is to be used.""" + ) + def _mathjax_config_default(self): + return 'TeX-AMS_HTML-full,Safe' + + def _mathjax_config_changed(self, name, old, new): + self.log.info("Using MathJax configuration file: %s", new) + contents_manager_class = Type( default_value=FileContentsManager, klass=ContentsManager, diff --git a/notebook/templates/notebook.html b/notebook/templates/notebook.html index 10e6095fce..f8e4f3c075 100644 --- a/notebook/templates/notebook.html +++ b/notebook/templates/notebook.html @@ -3,7 +3,7 @@ {% block stylesheet %} {% if mathjax_url %} - + {% endif %} + {% endif %}