Force loading MathJax on HTML pages generated from notebooks#551
Force loading MathJax on HTML pages generated from notebooks#551mgeier merged 2 commits intospatialaudio:masterfrom
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.
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.
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.