Skip to content

Commit 6867505

Browse files
dr-brSamuel Braundanielfrg
authored
added custom_mathjax_url option (#201)
Co-authored-by: Samuel Braun <samuel.braun@kit.edu> Co-authored-by: Daniel Rodriguez <daniel@danielfrg.com>
1 parent 1570e74 commit 6867505

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

demo/mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ plugins:
5454
- mkdocs-jupyter:
5555
execute: false
5656
include_requirejs: true
57-
57+
custom_mathjax_url: "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS_CHTML-full,Safe"
5858
extra:
5959
analytics:
6060
provider: google

src/mkdocs_jupyter/nbconvert2.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def nb2html(
5151
remove_tag_config: dict = {},
5252
highlight_extra_classes: str = "",
5353
include_requirejs: bool = False,
54+
custom_mathjax_url: str = "",
5455
):
5556
"""
5657
Convert a notebook to HTML
@@ -126,6 +127,17 @@ def custom_clean_html(element):
126127
theme=theme,
127128
)
128129

130+
if custom_mathjax_url != "":
131+
exporter = HTMLExporter(
132+
config=app.config,
133+
template_file=template_file,
134+
extra_template_paths=extra_template_paths,
135+
preprocessors=preprocessors_,
136+
filters=filters,
137+
theme=theme,
138+
mathjax_url=custom_mathjax_url,
139+
)
140+
129141
_, extension = os.path.splitext(nb_path)
130142

131143
if extension == ".py":

src/mkdocs_jupyter/plugin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class Plugin(mkdocs.plugins.BasePlugin):
4949
("remove_tag_config", config_options.Type(dict, default={})),
5050
("highlight_extra_classes", config_options.Type(str, default="")),
5151
("include_requirejs", config_options.Type(bool, default=False)),
52+
("custom_mathjax_url", config_options.Type(str, default="")),
5253
("toc_depth", config_options.Type(int, default=6)),
5354
)
5455
_supported_extensions = [".ipynb", ".py"]
@@ -91,6 +92,7 @@ def on_pre_page(self, page, config, files):
9192
remove_tag_config = self.config["remove_tag_config"]
9293
highlight_extra_classes = self.config["highlight_extra_classes"]
9394
include_requirejs = self.config["include_requirejs"]
95+
custom_mathjax_url = self.config["custom_mathjax_url"]
9496
toc_depth = self.config["toc_depth"]
9597

9698
if (
@@ -118,6 +120,7 @@ def new_render(self, config, files):
118120
remove_tag_config=remove_tag_config,
119121
highlight_extra_classes=highlight_extra_classes,
120122
include_requirejs=include_requirejs,
123+
custom_mathjax_url=custom_mathjax_url,
121124
)
122125
self.content = body
123126
toc, title = get_nb_toc(page.file.abs_src_path, toc_depth)

0 commit comments

Comments
 (0)