Skip to content

Commit 26bc5cf

Browse files
committed
cleanup custom_mathjax_url
1 parent 70f5a59 commit 26bc5cf

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/mkdocs_jupyter/nbconvert2.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def nb2html(
5151
remove_tag_config: dict = {},
5252
highlight_extra_classes: str = "",
5353
include_requirejs: bool = False,
54-
custom_mathjax_url: str = "",
54+
custom_mathjax_url: str = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS_CHTML-full,Safe",
5555
):
5656
"""
5757
Convert a notebook to HTML
@@ -125,19 +125,9 @@ def custom_clean_html(element):
125125
preprocessors=preprocessors_,
126126
filters=filters,
127127
theme=theme,
128+
mathjax_url=custom_mathjax_url,
128129
)
129130

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-
141131
_, extension = os.path.splitext(nb_path)
142132

143133
if extension == ".py":
@@ -168,11 +158,14 @@ def custom_clean_html(element):
168158
}
169159
},
170160
)
171-
content = content + f"""
161+
content = (
162+
content
163+
+ f"""
172164
<style>
173165
{resources["inlining"]["css"]}
174166
</style>
175167
"""
168+
)
176169

177170
if highlight_extra_classes:
178171
content = content.replace(
@@ -327,9 +320,9 @@ def custom_markdown2html(source):
327320
This is done so it's the same HTML structure that for regular non-language
328321
sections.
329322
"""
330-
return MarkdownWithMath(
331-
renderer=CustomMarkdownRendered(escape=False)
332-
).render(source)
323+
return MarkdownWithMath(renderer=CustomMarkdownRendered(escape=False)).render(
324+
source
325+
)
333326

334327

335328
class CustomMarkdownRendered(IPythonRenderer):

0 commit comments

Comments
 (0)