From e0982de54d24bdd6677bbed9454dfdf96d5e3ae4 Mon Sep 17 00:00:00 2001 From: Constantine Khrulev Date: Tue, 14 Sep 2021 14:49:34 -0800 Subject: [PATCH] Support both Sphinx 3.x and Sphinx 4.x --- doc/sphinx/conf.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/doc/sphinx/conf.py b/doc/sphinx/conf.py index 5694c5c6ec..c269205f75 100644 --- a/doc/sphinx/conf.py +++ b/doc/sphinx/conf.py @@ -149,7 +149,9 @@ def git(command): 'preamble': r'\usepackage{txfonts}' } -mathjax_config = {"TeX": {"Macros": {}}} +# -- Add custom math definitions ---------------- + +mathjax3_config = {"tex": {"macros": {}}} # Add math definitions to the LaTeX preamble and MathJax settings: for line in open("math-definitions.tex"): @@ -162,9 +164,15 @@ def git(command): args = M.group(3) if M.group(4): default = M.group(5) - mathjax_config["TeX"]["Macros"][name] = [definition, args, default] + mathjax3_config["tex"]["macros"][name] = [definition, args, default] else: - mathjax_config["TeX"]["Macros"][name] = [definition, args] + mathjax3_config["tex"]["macros"][name] = [definition, args] else: - mathjax_config["TeX"]["Macros"][name] = definition + mathjax3_config["tex"]["macros"][name] = definition latex_elements["preamble"] += line + +# Support Sphinx 3.x: +import sphinx +if sphinx.version_info[0] < 4: + mathjax_config = {"TeX" : {"Macros" : {}}} + mathjax_config["TeX"]["Macros"] = mathjax3_config["tex"]["macros"]