-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Is your feature request related to a problem? Please describe.
After #8631 was merged, JS/CSS files for MathJax are only added to those pages that contains math formulas. This is not a problem unless you want to embed the content of one of those pages where the JS/CSS are included from a different page.
This problem is clear on my extension sphinx-hoverxref that shows a tooltip with the content of the linked page when hovering over a link. Example: if you hover on "tooltip with Mathjax" in https://sphinx-hoverxref.readthedocs.io/en/sphinx-35/usage.html#tooltip-with-mathjax you won't see the MathJax rendered properly inside the tooltip
and an error in the console "Not triggering MathJax because it is not defined". This is because MathJax is not included in usage.html page but it's included in target page (mathjax.html)
Note that I'm mentioning the problem only with MathJax for now since it's a known extension that it's using this new feature, but this applies to all the extension that start including the JS/CSS only on pages where the extension is present
Describe the solution you'd like
I think a config to force the old behavior that includes all the JS/CSS in all the pages could work. I know this has some drawbacks, but as far is optional, I think it's good.
Describe alternatives you've considered
sphinx-hoverxrefuses an endpoint from Read the Docs' API to get the content to embed in the tooltip. We are discussing if it's possible to return"extras": ["mathjax.js", "mathjax.css"]together with the content to be included so the JS client knows it has to include these assets before rendering the content. See Embed: design doc for new embed API readthedocs/readthedocs.org#8039 (comment)- Another option could be to detect from the Sphinx extension "what are the assets required in the target page and add them into this page as well". Note that this won't work when using intersphinx.
Additional context
Reference: #8631 (comment)
Downstream issue: readthedocs/sphinx-hoverxref#119
