sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.42k stars 2.09k forks source link

Extend `sphinx.ext.mathjax` to support static output #8453

Open HFriberg opened 3 years ago

HFriberg commented 3 years ago

Mathjax is normally processed client-side (dynamically rendered with javascript), but with CommonHTML it is now also possible to process it server-side. From the official MathJax documentation:

The CommonHTML output processor renders your mathematics using HTML with CSS styling. Its major advantage is its quality, consistency, and the fact that its output is independent of the browser, operating system, and user environment. This means you can pre-process mathematics on a server, without needing to know the browser, what fonts are available, and so on.

Rather than implementing server-side postprocessing of the output generated by Sphinx, however, I would much rather have that sphinx.ext.mathjax was extended to support output that needed no additional processing. That is, I would like Sphinx to be able to generate offline readable static documents containing mathematics, without resorting to images (i.e., sphinx.ext.imgmath). I believe this can be done by letting sphinx.ext.mathjax open a connection to the mathjax server specified in the mathjax_path option already available, and replace the sphinx nodes by CommonHTML output one by one. The documentation of this feature should include a kind warning that this mathjax feature only supports modern browsers (currently backported to IE 8).

tk0miya commented 3 years ago

+1: Reasonable