Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions myst_parser/sphinx_ext/mathjax.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,28 @@ def override_mathjax(app: Sphinx):

mjax_classes = app.env.myst_config.mathjax_classes # type: ignore[attr-defined]

if "mathjax3_config" in app.config:
mathjax_opt = None
for opt in ("mathjax4_config", "mathjax3_config"):
if getattr(app.config, opt, None):
mathjax_opt = opt
break
if mathjax_opt is not None:
# sphinx 4 + mathjax 3
app.config.mathjax3_config = app.config.mathjax3_config or {}
app.config.mathjax3_config.setdefault("options", {})
# sphinx 9 + mathjax 4
config = getattr(app.config, opt, {}) or {}
config.setdefault("options", {})
if (
"processHtmlClass" in app.config.mathjax3_config["options"]
and app.config.mathjax3_config["options"]["processHtmlClass"]
!= mjax_classes
"processHtmlClass" in config["options"]
and config["options"]["processHtmlClass"] != mjax_classes
):
log_override_warning(
app,
3,
app.config.mathjax3_config["options"]["processHtmlClass"],
config["options"]["processHtmlClass"],
mjax_classes,
)
app.config.mathjax3_config["options"]["processHtmlClass"] = mjax_classes
config["options"]["processHtmlClass"] = mjax_classes
setattr(app.config, opt, config)
elif "mathjax_config" in app.config:
# sphinx 3 + mathjax 2
app.config.mathjax_config = app.config.mathjax_config or {}
Expand Down