--- IPython/html/notebookapp.py +++ IPython/html/notebookapp.py @@ -218,6 +218,11 @@ class NotebookWebApplication(web.Applica pattern = url_path_join(settings['base_url'], handler[0]) new_handler = tuple([pattern] + list(handler[1:])) new_handlers.append(new_handler) + + if os.path.exists("/usr/share/mathjax/MathJax.js"): + new_handlers.append((r"/mathjax/(.*)", web.StaticFileHandler, + {"path": "/usr/share/mathjax"})) + # add 404 on the end, which will catch everything that falls through new_handlers.append((r'(.*)', Template404)) return new_handlers @@ -514,6 +519,10 @@ class NotebookApp(BaseIPythonApplication url = url_path_join(url_prefix, u"mathjax/MathJax.js") self.log.info("Serving local MathJax from %s at %s", mathjax, url) return url + + if os.path.exists("/usr/share/mathjax/MathJax.js"): + self.log.info("Using system MathJax") + return u"/mathjax/MathJax.js" # no local mathjax, serve from CDN url = u"https://cdn.mathjax.org/mathjax/latest/MathJax.js"