Hi, This is v3 which addresses Jon's comments to v2 [1], but slightly different ways from Jon's suggestions. Changes since v2 [1]: - Drop Patch 3/3, which is in docs-fixes now. - Patch 1/2: o Simplify find_command() by using shutil.which(). For guessing available commands, it should be good enough. o Mention find_command() in the changelog. - Patch 2/2: o Instead of silently ignoring unknown setting of SPHINX_IMGMATH, print a warning msg. Acked-bys from Mauro are kept, as I assume these changes wouldn't affect the purpose of each patch. Changes since v1 [2]: - Patch 2/3: Rename LOAD_IMGMATH -> SPHINX_IMGMATH (Mauro). - For the series: Acked-bys from Mauro. Amended coverletter: This was inspired from the discussion on the expected behavior of sphinx-pre-install [3]. There was a mismatch between Mauro's intent and my expectation for the --no-pdf option of sphinx-pre-install. My thought was if I installed all the packages suggested from "./scripts/sphinx-pre-install --no-pdf", "make htmldocs" should run free of complaints of missing commands or packages. However, I got this warning when I tried the procedure on a debian- based container image: WARNING: LaTeX command 'latex' cannot be run (needed for math display), check the imgmath_latex setting , or: WARNING: dvipng command 'dvipng' cannot be run (needed for math display), check the imgmath_dvipng setting Mauro's response to my complaint was this: > The idea of using --no-pdf is to setup an environment without LaTeX, > meaning that math tags would only be partially parsed: basically, the > output would be html with LaTeX-like math expressions (at least last > time I tried). The mismatch can be resolved by using "mathjax" for math rendering and making "make htmldocs" be free of texlive packages. mathjax is the default math renderer since Sphinx 1.8. It delegates math rendering to web browsers. As Mauro has pointed out, "make epubdocs" requires imgmath. So this patch set treats mathjax as a fallback math renderer for html docs when imgmath requirements are not met. Existing systems which meet imgmath requirements are not affected by this change. Summary of math rendering in html: dvipng, browser before after ========================== =============== ================ dvipng imgmath (png) <-- no divpng, with javascript raw math:: code mathjax no dvipng, w/o javascript raw math:: code raw mathjax code Patch 1/2 adds code in conf.py so that for html docs, the imgmath extension will be loaded only when both latex and dvipng are available. For epub docs, imgmath will always be loaded (no change). Patch 2/2 adds code respecting a new env variable "SPHINX_IMGMATH" which will override the math renderer choice. This variable can be helpful on distros such as Arch linux, Mageia, etc. whose packaging policy is coarse-grained. E.g., to test math rendering by mathjax, run: make SPHINX_IMGMATH=no htmldocs I mentioned in the thread of [3] that imgmath can generate scalable math images in SVG. My plan was to implement that option as well. But during tests under Fedora/CentOS/openSUSE, I encountered a couple of warnings from dvisvgm. That would be regressions on existing systems which happen to have not-working dvisvgm along with working dvipng. I'm thinking of adding the SVG option later if I can figure out the minimal requirement for dvisvgm under imgmath. [1] v2: https://lore.kernel.org/r/c41cab17-afd6-bc99-56a1-e4e73b8c1ef6@xxxxxxxxx/ [2] v1: https://lore.kernel.org/r/12d078f5-6995-b039-7076-bdb1f372a799@xxxxxxxxx/ [3]: https://lore.kernel.org/r/3ba5a52e-cab6-05cf-a66e-adc58c467e1f@xxxxxxxxx/ Thanks, Akira -- Akira Yokosawa (2): docs/conf.py: Treat mathjax as fallback math renderer docs/conf.py: Respect env variable SPHINX_IMGMATH Documentation/conf.py | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) base-commit: e1a0cc8865e3152e9fe43c6436b44e64c0359dfb -- 2.25.1