-
Notifications
You must be signed in to change notification settings - Fork 132
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
Force loading MathJax on HTML pages generated from notebooks #551
Conversation
Haven't reviewed the codebase fully but on first reaction, I'd say unconditionally (even where no |
@casperdcl I initially wanted to only handle display equations (which are currently implemented using the Do you have an idea for an alternative way of fixing #550? Either way, please note that this PR also solves #369. If MathJax is not loaded unconditionally, I would have to load it on each notebook which has at least one non-text cell output, which would still be nearly every notebook. |
I would expect a robust solution would be for Anyway I'm personally fine with unconditional loading... just pointing out that it seems a bit presumptuous/potentially inefficient & unneeded. Maybe make it a config option? |
I'm aware that this might be unnecessarily loading MathJax in some cases. I think using the suggested regex is not very robust, because IIRC there might be more environments than
Any ideas how this would work concretely? I think this PR is better (because it's more correct) than the status quo, but I'm open for suggestions (or future PRs) for avoiding to load MathJax unnecessarily. |
src/nbsphinx.py
Outdated
|
||
def apply(self): | ||
env = self.document.settings.env | ||
env.get_domain('math').data['has_equations'][env.docname] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any ideas how this would work concretely?
being able to set this in conf.py
, i.e. nbsphinx_force_mathjax = False
and then
env.get_domain('math').data['has_equations'][env.docname] = True | |
if nbsphinx_force_mathjax: | |
env.get_domain('math').data['has_equations'][env.docname] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion!
I've implemented it in 001db3d, but since strictly speaking this isn't limited to MathJax (which is just an implementation detail), I've chosen the more generic name nbsphinx_assume_equations
.
btw on a related note (maybe for a different issue?) placing maths in italics doesn't render:
|
I think this comes from the known limitation that reST doesn't support nested markup. See also https://docutils.sourceforge.io/FAQ.html#is-nested-inline-markup-possible. See also #301, #455 and #468 (comment). |
Fixes #550.
See also sphinx-doc/sphinx#6981.