-
Notifications
You must be signed in to change notification settings - Fork 138
Fix nbsphinx_assume_equations
for newer versions of Sphinx
#840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
nbsphinx_assume_equations
to work with newer versions of Sphinxnbsphinx_assume_equations
for newer versions of Sphinx
Somehow I didn't see PR #822 until today. But as noted, it does not work in all cases. I started seeing un-Jaxified math while working on a different issue in the PyData Sphinx Theme docs. (Specifically, I was trying to figure out why in docs generated by nbsphinx, MathJax is not applied inside an ipywidget Tab.) This led me to creating this PR. We can see that with this PR, the math equations get properly rendered in all three of the examples added in #836. Examples, screenshotsAll three examples share one thing in common: there is no other math in the source document apart from the one featured. Markdown cell with block math equationSource code: nbsphinx/doc/gallery/uno-rst.ipynb Lines 24 to 36 in b743009
Screenshot of docs page with this PR applied: Code cell that outputs a Math objectSource code: nbsphinx/doc/gallery/due-rst.pct.py Lines 23 to 31 in b743009
Screenshot of docs page with this PR applied: Markdown cell with inline mathSource code: nbsphinx/doc/gallery/cinque-rst.ipynb Lines 24 to 32 in b743009
Screenshot of docs page with this PR applied: ![]() |
Even though this PR succeeds with the examples added in #836, it's still worth considering the alternative: app.set_html_assets_policy("always") This alternative has the benefit that it's straightforward. It could allow us to have a single code path, so long as we don't care whether this feature (forcing MathJax on nbsphinx-converted pages) works on older versions of Sphinx - because html assets policy was added in 4.1. I also did a search of GitHub repos for the use of Overall, this PR is a more conservative change that preserves the status quo from before sphinx-doc/sphinx#13044, but comes with the downside of a split code path and a slightly higher cognitive load. |
Thanks for this PR! Before looking into this, I would like to fix the CI errors, but those are quite annoying, so I don't know when I'll get around to doing that ... |
Fixes compatibility issue with newer versions of Sphinx.
See:
has_equations
from the mathematics domain sphinx-doc/sphinx#13044.