From 41804794cbc1dd1016598ef6f28f775ac041c8e3 Mon Sep 17 00:00:00 2001 From: gregor Date: Tue, 19 May 2015 12:30:18 +0200 Subject: [PATCH 1/2] enable equation numbering on default --- nbviewer/templates/notebook.html | 1 + 1 file changed, 1 insertion(+) diff --git a/nbviewer/templates/notebook.html b/nbviewer/templates/notebook.html index 17bf9233..381eac94 100644 --- a/nbviewer/templates/notebook.html +++ b/nbviewer/templates/notebook.html @@ -55,6 +55,7 @@ if (window.MathJax) { // MathJax loaded MathJax.Hub.Config({ + TeX: { equationNumbers: { autoNumber: "AMS", useLabelIds: true } }, tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ], From 6d63ad5631e1042d4b1e67f7fb3b4d717df19e87 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Tue, 19 May 2015 13:17:23 -0400 Subject: [PATCH 2/2] blocking mathjax, also url --- nbviewer/app.py | 2 ++ nbviewer/formats.py | 1 + nbviewer/providers/base.py | 8 ++++- nbviewer/templates/notebook.html | 55 ++++++++++++++++++-------------- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/nbviewer/app.py b/nbviewer/app.py index 394fc53d..d0af735f 100644 --- a/nbviewer/app.py +++ b/nbviewer/app.py @@ -87,6 +87,7 @@ def main(): define("proxy_port", default="", help="The proxy port.", type=int) define("providers", default=default_providers, help="Full dotted package(s) that provide `default_handlers`", type=str, multiple=True, group="provider") define("provider_rewrites", default=default_rewrites, help="Full dotted package(s) that provide `uri_rewrites`", type=str, multiple=True, group="provider") + define("mathjax_url", default="https://cdn.mathjax.org/mathjax/latest/", help="URL base for mathjax package", type=str) tornado.options.parse_command_line() # NBConvert config @@ -214,6 +215,7 @@ def main(): render_timeout=20, localfile_path=os.path.abspath(options.localfiles), fetch_kwargs=fetch_kwargs, + mathjax_url=options.mathjax_url, ) # handle handlers diff --git a/nbviewer/formats.py b/nbviewer/formats.py index e164984e..d8493aed 100644 --- a/nbviewer/formats.py +++ b/nbviewer/formats.py @@ -9,6 +9,7 @@ from IPython.nbconvert.exporters.export import exporter_map + def default_formats(): """ Return the currently-implemented formats. diff --git a/nbviewer/providers/base.py b/nbviewer/providers/base.py index 35332f55..403c34cd 100644 --- a/nbviewer/providers/base.py +++ b/nbviewer/providers/base.py @@ -116,6 +116,10 @@ def max_cache_uris(self): def frontpage_sections(self): return self.settings.setdefault('frontpage_sections', {}) + @property + def mathjax_url(self): + return self.settings['mathjax_url'] + #--------------------------------------------------------------- # template rendering #--------------------------------------------------------------- @@ -131,7 +135,9 @@ def render_template(self, name, **ns): @property def template_namespace(self): - return {} + return { + "mathjax_url": self.mathjax_url + } def breadcrumbs(self, path, base_url): """Generate a list of breadcrumbs""" diff --git a/nbviewer/templates/notebook.html b/nbviewer/templates/notebook.html index 381eac94..babd4061 100644 --- a/nbviewer/templates/notebook.html +++ b/nbviewer/templates/notebook.html @@ -48,31 +48,38 @@ {% endif %} - - + + init_mathjax(); + + {% endblock mathjax %} {% endblock extra_head %}