Repository: sagemath/sage

Issue:
System package information and spkg-configure for mathjax
<div id="comment:0"></div>

After #31035, our `mathjax` spkg is only used in our sphinx documentation.  We currently ship a "stripped" version of mathjax 2.7.4 (see `build/pkgs/mathjax/spkg-src`; #25032, #18596); #25833 proposes an upgrade to 3.x.

We add an `spkg-configure.m4` script for the standard package `mathjax`, as well as corresponding system package information in `build/pkgs/mathjax/distros/` using https://repology.org/projects/?search=mathjax

---

Random references:

py-mathjax/pypi/py-mathjax at master · kiwi0fruit/py-mathjax
https://github.com/kiwi0fruit/py-mathjax/tree/master/pypi/py-mathjax

Debian JavaScript Maintainers / mathjax · GitLab
https://salsa.debian.org/js-team/mathjax

sphinx/setup.py at 3.x · sphinx-doc/sphinx
https://github.com/sphinx-doc/sphinx/blob/3.x/setup.py

Math support for HTML outputs in Sphinx — Sphinx 4.0.0+ documentation
https://www.sphinx-doc.org/en/master/usage/extensions/math.html#module-sphinx.ext.mathjax

sphinx-ext-mathjax - Google Search
https://www.google.com/search?safe=off&sxsrf=ALeKk03spVlQ9ALPLJJCbNfF9EIdC_LYuQ%3A1596929073175&ei=MTQvX8mUCuKU0PEPu-yOiAE&q=sphinx-ext-mathjax&oq=sphinx-ext-mathjax&gs_lcp=CgZwc3ktYWIQAzIFCAAQzQIyBQgAEM0CMggIABDNAhCLAzIICAAQzQIQiwMyCAgAEM0CEIsDOgQIABBHOgcIIxCwAhAnOgcIIRAKEKABOgUIIRCgAToFCCEQqwJQmyhY4UVgtFBoAHABeACAAWqIAeUHkgEDOS4ymAEAoAEBqgEHZ3dzLXdpergBA8ABAQ&sclient=psy-ab&ved=0ahUKEwiJ8Yyx4IzrAhViCjQIHTu2AxEQ4dUDCAw&uact=5

Math support for HTML outputs in Sphinx — Sphinx 4.0.0+ documentation
https://www.sphinx-doc.org/en/master/usage/extensions/math.html#module-sphinx.ext.mathjax

sphinx/mathjax.py at 3.x · sphinx-doc/sphinx
https://github.com/sphinx-doc/sphinx/blob/3.x/sphinx/ext/mathjax.py


CC:  @jcamp0x2a @paulmasson @slel @egourgoulhon @orlitzky @kwankyu @jhpalmieri @nthiery @enriqueartal @kiwifb @antonio-rojas @tobihan @Etn40ff @tobiasdiez

Component: **packages: standard**

Keywords: **mathjax, sd111**

Author: **Samuel Lelièvre, ...**

Branch/Commit: **[public/30296](https://github.com/sagemath/sagetrac-mirror/tree/public/30296) @ [`5c624ab`](https://github.com/sagemath/sagetrac-mirror/commit/5c624abfd948829125163f91f4bd4b24d0ecb797)**

_Issue created by migration from https://trac.sagemath.org/ticket/30296_




Discussion:
<div id="comment:2" align="right">comment:2</div>

There are numerous unresolved tickets regarding mathjax...

- #30296
- #30226
- #30030
- [#29993 comment:9](https://github.com/sagemath/sage/issues/29993#comment:9)
- #28547 
- #28257 
- #26612 
- #25833
- #24024
- #24367
- #25015
- #25111
- #22394
- #18596 
- 
<div id="comment:4" align="right">comment:4</div>

For availability of mathjax in distributions, see https://repology.org/project/mathjax/versions
Branch: **[u/mkoeppe/system_package_information_and_spkg_configure_for_mathjax](https://github.com/sagemath/sagetrac-mirror/tree/u/mkoeppe/system_package_information_and_spkg_configure_for_mathjax)**
<div id="comment:6" align="right">comment:6</div>

The commit only indicates where the system directory should be inserted.

I don't plan to work on this ticket. 


Hoping that people knowledgeable about the Jupyter notebook and/or documentation building will be interesting in working on it.

---
New commits:
<table><tr><td><a href="https://github.com/sagemath/sagetrac-mirror/commit/68a0dda07f50a127891eee45cb0dbe5852788210"><code>68a0dda</code></a></td><td><code>build/pkgs/sage_conf/src/sage_conf.py.in: Add MATHJAX_DIR</code></td></tr></table>

Commit: **[`68a0dda`](https://github.com/sagemath/sagetrac-mirror/commit/68a0dda07f50a127891eee45cb0dbe5852788210)**
<div id="comment:7" align="right">comment:7</div>

There is also a pip-installable package https://pypi.org/project/py-mathjax/, but I think using it has not benefits for us.
<div id="comment:8" align="right">comment:8</div>

Also `notebook` bundles mathjax ... why do we install another copy?
<div id="comment:10" align="right">comment:10</div>

Replying to [@mkoeppe](#comment%3A8):
> Also `notebook` bundles mathjax ... why do we install another copy?

The change

```diff
diff --git a/build/make/Makefile.in b/build/make/Makefile.in
index ed5294cc4e..3d65767bf7 100644
--- a/build/make/Makefile.in
+++ b/build/make/Makefile.in
@@ -289,7 +289,7 @@ base: $(inst_patch) $(inst_pkgconf)
 # produce plots.
 DOC_DEPENDENCIES = sagelib $(inst_sphinx) \
        | $(SAGERUNTIME) $(inst_maxima) $(inst_networkx) $(inst_scipy) $(inst_sympy) \
-       $(inst_matplotlib) $(inst_pillow) $(inst_mathjax) $(inst_mpmath) \
+       $(inst_matplotlib) $(inst_pillow) $(inst_mpmath) \
        $(inst_ipykernel) $(inst_jupyter_client) $(inst_conway_polynomials) \
        $(inst_tachyon) $(inst_jmol) $(inst_thebe) $(inst_ipywidgets)
 
diff --git a/build/pkgs/mathjax/type b/build/pkgs/mathjax/type
index a6a7b9cd72..134d9bc32d 100644
--- a/build/pkgs/mathjax/type
+++ b/build/pkgs/mathjax/type
@@ -1 +1 @@
-standard
+optional
```
avoids building mathjax, but then Sphinx doesn't find it when building the documentation. So if we want to use the version bundled with `notebook`, we need to make sure that Sphinx knows where to find it.
<div id="comment:11" align="right">comment:11</div>

`src/sage/docs/conf.py` expects `sage.env.MATHJAX_DIR` to be set to the location. This is what we'd have to configure if we take mathjax either from a system installation, or some other source.
Description changed:
``````diff
--- 
+++ 
@@ -1,3 +1,29 @@
 We add an `spkg-configure.m4` script for the standard package `mathjax`, as well as corresponding system package information in `build/pkgs/mathjax/distros/`
 
 
+
+
+---
+
+Random references:
+
+py-mathjax/pypi/py-mathjax at master · kiwi0fruit/py-mathjax
+https://github.com/kiwi0fruit/py-mathjax/tree/master/pypi/py-mathjax
+
+Debian JavaScript Maintainers / mathjax · [GitLab](../wiki/GitLab)
+https://salsa.debian.org/js-team/mathjax
+
+sphinx/setup.py at 3.x · sphinx-doc/sphinx
+https://github.com/sphinx-doc/sphinx/blob/3.x/setup.py
+
+Math support for HTML outputs in Sphinx — Sphinx 4.0.0+ documentation
+https://www.sphinx-doc.org/en/master/usage/extensions/math.html#module-sphinx.ext.mathjax
+
+sphinx-ext-mathjax - Google Search
+https://www.google.com/search?safe=off&sxsrf=ALeKk03spVlQ9ALPLJJCbNfF9EIdC_LYuQ%3A1596929073175&ei=MTQvX8mUCuKU0PEPu-yOiAE&q=sphinx-ext-mathjax&oq=sphinx-ext-mathjax&gs_lcp=CgZwc3ktYWIQAzIFCAAQzQIyBQgAEM0CMggIABDNAhCLAzIICAAQzQIQiwMyCAgAEM0CEIsDOgQIABBHOgcIIxCwAhAnOgcIIRAKEKABOgUIIRCgAToFCCEQqwJQmyhY4UVgtFBoAHABeACAAWqIAeUHkgEDOS4ymAEAoAEBqgEHZ3dzLXdpergBA8ABAQ&sclient=psy-ab&ved=0ahUKEwiJ8Yyx4IzrAhViCjQIHTu2AxEQ4dUDCAw&uact=5
+
+Math support for HTML outputs in Sphinx — Sphinx 4.0.0+ documentation
+https://www.sphinx-doc.org/en/master/usage/extensions/math.html#module-sphinx.ext.mathjax
+
+sphinx/mathjax.py at 3.x · sphinx-doc/sphinx
+https://github.com/sphinx-doc/sphinx/blob/3.x/sphinx/ext/mathjax.py
``````

Changed commit from **[`68a0dda`](https://github.com/sagemath/sagetrac-mirror/commit/68a0dda07f50a127891eee45cb0dbe5852788210)** to none
Changed branch from **[u/mkoeppe/system_package_information_and_spkg_configure_for_mathjax](https://github.com/sagemath/sagetrac-mirror/tree/u/mkoeppe/system_package_information_and_spkg_configure_for_mathjax)** to none
Description changed:
``````diff
--- 
+++ 
@@ -1,7 +1,4 @@
 We add an `spkg-configure.m4` script for the standard package `mathjax`, as well as corresponding system package information in `build/pkgs/mathjax/distros/`
-
-
-
 
 ---
 
@@ -10,7 +7,7 @@
 py-mathjax/pypi/py-mathjax at master · kiwi0fruit/py-mathjax
 https://github.com/kiwi0fruit/py-mathjax/tree/master/pypi/py-mathjax
 
-Debian JavaScript Maintainers / mathjax · [GitLab](../wiki/GitLab)
+Debian JavaScript Maintainers / mathjax · GitLab
 https://salsa.debian.org/js-team/mathjax
 
 sphinx/setup.py at 3.x · sphinx-doc/sphinx
@@ -27,3 +24,4 @@
 
 sphinx/mathjax.py at 3.x · sphinx-doc/sphinx
 https://github.com/sphinx-doc/sphinx/blob/3.x/sphinx/ext/mathjax.py
+
``````

Changed keywords from none to **mathjax**
<div id="comment:16" align="right">comment:16</div>

Replying to [@mkoeppe](#comment%3A8):
> Also `notebook` bundles mathjax ... why do we install another copy?

See

- [Stack Overflow question 28909747: How do I configure mathjax for iPython notebooks?](https://stackoverflow.com/q/28909747)

and the various answers there, including

- [StackOverflow answer 58866858](https://stackoverflow.com/a/58866858)

which states

> Jupyter ships with its own (smaller) version of MathJax.
> This is why it is not able to find the (Computer Modern)
> 'TeX' font -- there only is the STIX font.

So it's possible that the smaller version of MathJax
shipped by Jupyter Notebook is not enough for our Sphinx use.

Configuring Jupyter Notebook to use Sage's fuller MathJax
might have benefits (ability to typeset more math?)
and/or drawbacks (performance?).
<div id="comment:17" align="right">comment:17</div>

Replying to [@slel](#comment%3A16):
> Configuring Jupyter Notebook to use Sage's fuller MathJax
> might have benefits (ability to typeset more math?)

This should be investigated.
Description changed:
``````diff
--- 
+++ 
@@ -1,4 +1,15 @@
+mathjax is used in our sphinx documentation and in the Jupyter notebook.  We currently ship a "stripped" version of mathjax 2.7.4 (see `build/pkgs/mathjax/spkg-src`; #25032, #18596); #25833 proposes an upgrade to 3.x.
+
 We add an `spkg-configure.m4` script for the standard package `mathjax`, as well as corresponding system package information in `build/pkgs/mathjax/distros/`
+
+Open questions:
+
+- Is there any difference in font rendering between the mathjax that comes with Jupyter notebook and our copy of mathjax? Does Jupyter notebook rely on online resources for any font rendering? 
+
+  (This should be apparent in comparing Sage running in system Jupyter notebook vs. the Sage distributions's Jupyter notebook - which uses the configuration in `build/pkgs/notebook/jupyter_notebook_config.py`)
+
+- If no, we can remove this configuration item from our notebook configuration; and this ticket will reduce to sphinx docbuild questions only.
+
 
 ---
 
``````

Changed keywords from **mathjax** to **mathjax, sd111**
<div id="comment:19" align="right">comment:19</div>

Hoping we can make progress on this ticket this week - https://wiki.sagemath.org/days111
<div id="comment:22" align="right">comment:22</div>

FWIW: On Arch we're unbundling mathjax from Jupyter and using the system one:

https://github.com/archlinux/svntogit-community/blob/packages/jupyter-notebook/trunk/PKGBUILD#L40

Everything works fine, even without the /usr/share/jupyter/nbextensions/mathjax symlink installed by sage.
<div id="comment:23" align="right">comment:23</div>

Thanks. I have created #31035 (Remove mathjax configuration/symlink from jupyter notebook), as it seems what Sage is doing is simply not necessary any more after various updates of Jupyter.
Description changed:
``````diff
--- 
+++ 
@@ -8,7 +8,7 @@
 
   (This should be apparent in comparing Sage running in system Jupyter notebook vs. the Sage distributions's Jupyter notebook - which uses the configuration in `build/pkgs/notebook/jupyter_notebook_config.py`)
 
-- If no, we can remove this configuration item from our notebook configuration; and this ticket will reduce to sphinx docbuild questions only.
+- If no, we can remove this configuration item from our notebook configuration; and this ticket will reduce to sphinx docbuild questions only. (Done in #31035)
 
 
 ---
``````

Dependencies: **#31035**
Description changed:
``````diff
--- 
+++ 
@@ -1,15 +1,6 @@
-mathjax is used in our sphinx documentation and in the Jupyter notebook.  We currently ship a "stripped" version of mathjax 2.7.4 (see `build/pkgs/mathjax/spkg-src`; #25032, #18596); #25833 proposes an upgrade to 3.x.
+After #31035, our `mathjax` spkg is only used in our sphinx documentation.  We currently ship a "stripped" version of mathjax 2.7.4 (see `build/pkgs/mathjax/spkg-src`; #25032, #18596); #25833 proposes an upgrade to 3.x.
 
 We add an `spkg-configure.m4` script for the standard package `mathjax`, as well as corresponding system package information in `build/pkgs/mathjax/distros/`
-
-Open questions:
-
-- Is there any difference in font rendering between the mathjax that comes with Jupyter notebook and our copy of mathjax? Does Jupyter notebook rely on online resources for any font rendering? 
-
-  (This should be apparent in comparing Sage running in system Jupyter notebook vs. the Sage distributions's Jupyter notebook - which uses the configuration in `build/pkgs/notebook/jupyter_notebook_config.py`)
-
-- If no, we can remove this configuration item from our notebook configuration; and this ticket will reduce to sphinx docbuild questions only. (Done in #31035)
-
 
 ---
 
``````

Description changed:
``````diff
--- 
+++ 
@@ -1,6 +1,6 @@
 After #31035, our `mathjax` spkg is only used in our sphinx documentation.  We currently ship a "stripped" version of mathjax 2.7.4 (see `build/pkgs/mathjax/spkg-src`; #25032, #18596); #25833 proposes an upgrade to 3.x.
 
-We add an `spkg-configure.m4` script for the standard package `mathjax`, as well as corresponding system package information in `build/pkgs/mathjax/distros/`
+We add an `spkg-configure.m4` script for the standard package `mathjax`, as well as corresponding system package information in `build/pkgs/mathjax/distros/` using https://repology.org/projects/?search=mathjax
 
 ---
 
``````

<div id="comment:28" align="right">comment:28</div>

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.
<div id="comment:29" align="right">comment:29</div>

Here is distro info to hopefully restart things here.

---
New commits:
<table><tr><td><a href="https://github.com/sagemath/sagetrac-mirror/commit/5c624abfd948829125163f91f4bd4b24d0ecb797"><code>5c624ab</code></a></td><td><code>30296: Add distro info for mathjax</code></td></tr></table>

Branch: **[public/30296](https://github.com/sagemath/sagetrac-mirror/tree/public/30296)**
Changed dependencies from **#31035** to none
Author: **Samuel Lelièvre, ...**
Commit: **[`5c624ab`](https://github.com/sagemath/sagetrac-mirror/commit/5c624abfd948829125163f91f4bd4b24d0ecb797)**
<div id="comment:30" align="right">comment:30</div>

Setting a new milestone for this ticket based on a cursory review.
<div id="comment:33" align="right">comment:33</div>

See also #33600: Configure mathjax in sphinx config and upgrade to Mathjax v3
<div id="comment:35" align="right">comment:35</div>

Still no `spkg-configure.m4`?

This script just needs to rewrite `sage.env.MATHJAX_DIR` to the system mathjax2 directory (`/usr/share/mathjax`?) if found in the system.

Perhaps it also needs to decide if it is really mathjax2 or mathjax3...

I am ready to duplicate it to #25833.
<div id="comment:36" align="right">comment:36</div>

Replying to [@kwankyu](#comment%3A35):
> This script just needs to rewrite `sage.env.MATHJAX_DIR` to the system mathjax2 directory (`/usr/share/mathjax`?) if found in the system.

This may not be true since the system mathjax2 would have all fonts and be too large to use for sage documentation. Sphinx will copy the whole to each `_static` directory of every documentation (reference, tutorial, ...).

Then the conclusion would be that we should not try to use the system mathjax???
<div id="comment:37" align="right">comment:37</div>

Replying to [@kwankyu](#comment%3A36):
> This may not be true since the system mathjax2 would have all fonts and be too large to use for sage documentation. Sphinx will copy the whole to each `_static` directory of every documentation (reference, tutorial, ...).
> 
> Then the conclusion would be that we should not try to use the system mathjax??? 

On Arch (and Gentoo, which is where I got the idea from) distro packages we replace all `_static` copies with a symlink to the one in `html/en/_static` post-installation. Perhaps that sould be done on install by default?
<div id="comment:38" align="right">comment:38</div>

Replying to [@antonio-rojas](#comment%3A37):
> On Arch (and Gentoo, which is where I got the idea from) distro packages we replace all `_static` copies with a symlink to the one in `html/en/_static` post-installation. Perhaps that should be done on install by default?

I guess that could be done for sage, independent of this ticket. Then it would reduce the number of times to copy `$SAGE_SHARE/mathjax` to `_static/`.

Nonetheless, `spkg-configure.m4` needs to copy the reduced set of files from the system mathjax to `$SAGE_SHARE/mathjax`.
<div id="comment:39" align="right">comment:39</div>

Replying to [@kwankyu](#comment%3A38):
> Replying to [@antonio-rojas](#comment%3A37):
> > On Arch (and Gentoo, which is where I got the idea from) distro packages we replace all `_static` copies with a symlink to the one in `html/en/_static` post-installation. Perhaps that should be done on install by default?
> 
> 
> I guess that could be done for sage, independent of this ticket. Then it would reduce the number of times to copy `$SAGE_SHARE/mathjax` to `_static/`.
> 
> Nonetheless, `spkg-configure.m4` needs to copy the reduced set of files from the system mathjax to `$SAGE_SHARE/mathjax`.

Well, my point is that once there is just one copy of `_static`, then maybe it's not *that* bad to just copy over the entire contents of the system mathjax dir.
<div id="comment:40" align="right">comment:40</div>

Replying to [@antonio-rojas](#comment%3A39):
> Well, my point is that once there is just one copy of `_static`, then maybe it's not *that* bad to just copy over the entire contents of the system mathjax dir.

It would not be just one copy, because you have `_static` directory for each of languages.
<div id="comment:41" align="right">comment:41</div>

Replying to [@antonio-rojas](#comment%3A39):
> Well, my point is that once there is just one copy of `_static`, then maybe it's not *that* bad to just copy over the entire contents of the system mathjax dir.

One copy to `html/_static` might suffice. 

Other question: the location of the system mathjax is `/usr/share/mathjax` on all linux platforms? Or does it vary?
<div id="comment:42" align="right">comment:42</div>

The mathjax3 tarball is around 5Mb. I think this is not so big. Then is it worth while to detect the system mathjax and copy it instead of downloading the tarball?
<div id="comment:43" align="right">comment:43</div>

Replying to [@kwankyu](#comment%3A41):
> Other question: the location of the system mathjax is `/usr/share/mathjax` on all linux platforms? Or does it vary?

mathjax doesn't provide an install script, so unfortunately there's no standard location and it's up to each distro to decide where to install it. On Arch we use `/usr/share/mathjax`, other distros may use `mathjax3` instead if they also ship v2. (But, according to https://repology.org/project/mathjax/versions, no other distro is shipping mathjax 3 yet)
<div id="comment:44" align="right">comment:44</div>

Replying to [@antonio-rojas](#comment%3A43):
> Replying to [@kwankyu](#comment%3A41):
> > Other question: the location of the system mathjax is `/usr/share/mathjax` on all linux platforms? Or does it vary?
> 
> 
> mathjax doesn't provide an install script, so unfortunately there's no standard location and it's up to each distro to decide where to install it. 

mathjax is a javascript library, and perhaps unique in that among sage spkgs. I doubt if `spkg-configure.m4` script is relevant with mathjax. 

`@`matthias: would you comment?
<div id="comment:45" align="right">comment:45</div>

Given that the spread of mathjax 3 in distributions is so low, I don't think that there is a need to support system packages providing it. If this changes in the future, `spkg-configure.m4` would be the correct mechanism though.
<div id="comment:46" align="right">comment:46</div>

Replying to [@kwankyu](#comment%3A44):
> 
> mathjax is a javascript library, and perhaps unique in that among sage spkgs. I doubt if `spkg-configure.m4` script is relevant with mathjax. 
> 

It is kind of an awkward fit, since there's no reliable way of detecting via `spkg-configure.m4` where the the html/js files might live. But we can at the very least check a list of known locations. The gp2c package does that for lack of a better strategy.
<div id="comment:47" align="right">comment:47</div>

One would probably only want to search for the system library when also system `node` is installed, which would give discoverability.
<div id="comment:48" align="right">comment:48</div>

Replying to [@orlitzky](#comment%3A46):
> Replying to [@kwankyu](#comment%3A44):
> > 
> > mathjax is a javascript library, and perhaps unique in that among sage spkgs. I doubt if `spkg-configure.m4` script is relevant with mathjax. 
> > 
> 
> 
> It is kind of an awkward fit, since there's no reliable way of detecting via `spkg-configure.m4` where the the html/js files might live. But we can at the very least check a list of known locations. The gp2c package does that for lack of a better strategy.

I agree. Still as this mathjax package is not big and does not take time to install, I doubt if it would ever be worth while to put necessary efforts for this package.

Hence I suggest closing this ticket as "won't fix".
<div id="comment:49" align="right">comment:49</div>

Replying to [@kwankyu](#comment%3A48):
>
> Hence I suggest closing this ticket as "won't fix". 
> 

Sage's mathjax has "never" worked for me. This is probably due to font stripping ([#18596 comment:4](https://github.com/sagemath/sage/issues/18596#comment:4)), but undoing that would make the package larger.

So I'd quite like the ability to use the unbroken copy my distro provides, regardless of any time/bandwidth savings. Ultimately I can write the spkg-configure if no one else does it. I'll probably wait until the mathjax-3.x upgrade is done though.
<div id="comment:50" align="right">comment:50</div>

Replying to [@orlitzky](#comment%3A49):
> Replying to [@kwankyu](#comment%3A48):
> >
> > Hence I suggest closing this ticket as "won't fix". 
> > 
> 
> 
> Sage's mathjax has "never" worked for me. This is probably due to font stripping ([#18596 comment:4](https://github.com/sagemath/sage/issues/18596#comment:4)), but undoing that would make the package larger.
> 
> So I'd quite like the ability to use the unbroken copy my distro provides, regardless of any time/bandwidth savings. Ultimately I can write the spkg-configure if no one else does it. I'll probably wait until the mathjax-3.x upgrade is done though.

Okay. Thanks. Does mathjax3 (#25833) work for you?
<div id="comment:51" align="right">comment:51</div>

Replying to [@kwankyu](#comment%3A50):
> 
> Okay. Thanks. Does mathjax3 (#25833) work for you? 

Yes, thanks, replied there.
<div id="comment:53" align="right">comment:53</div>

Replying to [Michael Orlitzky](#comment%3A49):
> Ultimately I can write the spkg-configure if no one else does it. I'll probably wait until the mathjax-3.x upgrade is done though.

Now that mathjax3 is well in place, would you do the work? 

From Matthias: `src/sage/docs/conf.py` expects sage.env.MATHJAX_DIR to be set to the location. This is what we'd have to configure if we take mathjax either from a system installation, or some other source.
<div id="comment:54" align="right">comment:54</div>

Replying to [Kwankyu Lee](#comment%3A53):
> Replying to [Michael Orlitzky](#comment%3A49):
> > Ultimately I can write the spkg-configure if no one else does it. I'll probably wait until the mathjax-3.x upgrade is done though.
> 
> 
> Now that mathjax3 is well in place, would you do the work?

Now I'm waiting for my distro package to be upgraded (https://bugs.gentoo.org/837722), but yes, I'll get to it eventually.
On the question of the many copies of mathjax in `_static`, see https://github.com/sagemath/sage/issues/35538#issuecomment-1514352367
On conda, the `mathjax` package installs into `lib/mathjax/es5/` (https://github.com/conda-forge/mathjax-feedstock/blob/main/recipe/mathjax-path)

Resolving patch:
diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py
--- 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


Test patch: