From: Julian Taylor <jtaylor.debian@googlemail.com>
Date: Sun, 18 Dec 2011 14:04:29 +0100
Subject: use system mathjax if available

---
 IPython/frontend/html/notebook/notebookapp.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

--- a/IPython/frontend/html/notebook/notebookapp.py
+++ b/IPython/frontend/html/notebook/notebookapp.py
@@ -150,6 +150,10 @@
         # Note that the URLs these patterns check against are escaped,
         # and thus guaranteed to be ASCII: 'héllo' is really 'h%C3%A9llo'.
         base_project_url = py3compat.unicode_to_str(base_project_url, 'ascii')
+
+        if os.path.exists("/usr/share/javascript/mathjax/MathJax.js"):
+          handlers.append((r"/mathjax/(.*)", web.StaticFileHandler,
+                           {"path": "/usr/share/javascript/mathjax"}))
         
         settings = dict(
             template_path=os.path.join(os.path.dirname(__file__), "templates"),
@@ -368,6 +372,9 @@
         if os.path.exists(os.path.join(static_path, 'mathjax', "MathJax.js")):
             self.log.info("Using local MathJax")
             return static_url_prefix+u"mathjax/MathJax.js"
+        elif os.path.exists("/usr/share/javascript/mathjax/MathJax.js"):
+            self.log.info("Using system MathJax")
+            return u"/mathjax/MathJax.js"
         else:
             if self.certfile:
                 # HTTPS: load from Rackspace CDN, because SSL certificate requires it
