From 7342cbfa9851f578b38549d2a1f4a86666f01777 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 16 Aug 2023 14:54:29 -0400 Subject: [PATCH 1/4] build/pkgs/mathjax: add Gentoo package information --- build/pkgs/mathjax/distros/gentoo.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 build/pkgs/mathjax/distros/gentoo.txt diff --git a/build/pkgs/mathjax/distros/gentoo.txt b/build/pkgs/mathjax/distros/gentoo.txt new file mode 100644 index 00000000000..e0d633a9b98 --- /dev/null +++ b/build/pkgs/mathjax/distros/gentoo.txt @@ -0,0 +1 @@ +>=dev-libs/mathjax-3 From f435b0275778121f6992c2c67003089fc13a5c93 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 16 Aug 2023 15:22:15 -0400 Subject: [PATCH 2/4] build/pkgs/mathjax: add spkg-configure file --- build/pkgs/mathjax/spkg-configure.m4 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 build/pkgs/mathjax/spkg-configure.m4 diff --git a/build/pkgs/mathjax/spkg-configure.m4 b/build/pkgs/mathjax/spkg-configure.m4 new file mode 100644 index 00000000000..70fb46a2067 --- /dev/null +++ b/build/pkgs/mathjax/spkg-configure.m4 @@ -0,0 +1,26 @@ +SAGE_SPKG_CONFIGURE([mathjax], [ + # Arch: /usr/share/mathjax + # Gentoo: /usr/share/mathjax + # Void: /usr/share/mathjax + AC_MSG_CHECKING([for MathJax-3.x]) + m4_foreach([mathjax_dir], [/usr/share/mathjax], [ + # tex-chtml.hs is used in src/sage_docbuild/conf.py + # and was not present in MathJax-2.x + AS_IF([test -f "mathjax_dir/tex-chtml.js"], [ + SAGE_MATHJAX_DIR="mathjax_dir" + AC_MSG_RESULT([mathjax_dir]) + ]) + ]) + AS_IF([test -z "${SAGE_MATHJAX_DIR}"], [ + AC_MSG_RESULT([no]) + sage_spkg_install_mathjax=yes + ]) +],[],[],[ + # post-check + AS_IF([test x$sage_spkg_install_mathjax = xyes], [ + # Our spkg-src script adds an extra "mathjax" + SAGE_MATHJAX_DIR='${prefix}'/share/mathjax/mathjax + ]) + + AC_SUBST(SAGE_MATHJAX_DIR, "${SAGE_MATHJAX_DIR}") +]) From de55f27f11adcf3b90ebde30a8ea9aa02992852d Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 16 Aug 2023 15:22:40 -0400 Subject: [PATCH 3/4] pkgs/sage-conf: use ./configured MATHJAX_DIR --- pkgs/sage-conf/_sage_conf/_conf.py.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in index f2e197b45ed..87b27ca05cb 100644 --- a/pkgs/sage-conf/_sage_conf/_conf.py.in +++ b/pkgs/sage-conf/_sage_conf/_conf.py.in @@ -50,7 +50,7 @@ SAGE_ARCHFLAGS = "@SAGE_ARCHFLAGS@" SAGE_PKG_CONFIG_PATH = "@SAGE_PKG_CONFIG_PATH@".replace('$SAGE_LOCAL', SAGE_LOCAL) # Used in sage.repl.ipython_kernel.install -MATHJAX_DIR = SAGE_LOCAL + "/share/mathjax" +MATHJAX_DIR = "@SAGE_MATHJAX_DIR@".replace('${prefix}', SAGE_LOCAL) THREEJS_DIR = SAGE_LOCAL + "/share/threejs-sage" # OpenMP flags, if available. From ab1649ca36cdbde23317e5804d8880ec033addc6 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 17 Aug 2023 08:20:33 -0400 Subject: [PATCH 4/4] src/sage_docbuild/conf.py: use absolute path to mathjax Previously we copied mathjax to sphinx's _static output directory and then referenced it with a path relative to _static. This commit references it by absolute path on the filesystem, solving two problems: 1. It doesn't waste space; there are multiple _static directories, and mathjax was copied to all of them 2. It avoids polluting _static with mathjax files Closes: https://github.com/sagemath/sage/issues/30296 --- src/sage_docbuild/conf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py index b493b3b2897..d488a6a13a4 100644 --- a/src/sage_docbuild/conf.py +++ b/src/sage_docbuild/conf.py @@ -374,8 +374,7 @@ def set_intersphinx_mappings(app, config): if os.environ.get('SAGE_USE_CDNS', 'no') == 'yes': mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" else: - mathjax_path = 'mathjax/tex-chtml.js' - html_common_static_path += [MATHJAX_DIR] + mathjax_path = os.path.join(MATHJAX_DIR, 'tex-chtml.js') # A list of glob-style patterns that should be excluded when looking for source # files. They are matched against the source file names relative to the