Skip to content
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

Enabling MathJax extensions breaks it completely #279

Closed
matrach opened this issue Aug 21, 2023 · 3 comments · Fixed by #286
Closed

Enabling MathJax extensions breaks it completely #279

matrach opened this issue Aug 21, 2023 · 3 comments · Fixed by #286
Labels
bug Something isn't working

Comments

@matrach
Copy link

matrach commented Aug 21, 2023

Enabling any MathJax extension (for instance, Accessibility) makes the library request modules from a11l and sre directories. The script errors out and aborts processing because these directories are not present in the local cache:

/* Copy mathjax dist */
...["tex-mml-chtml.js", "output/chtml/fonts/woff-v2/*.woff", "../LICENSE"]
.map(pattern => copyAll(pattern, {
from: "node_modules/mathjax/es5",
to: `${base}/bundles/mathjax`
}))

According to the CDN docs:

Reducing the Size of the Components Directory
Since the es5 directory contains all the component files, so if you are only planning one use one configuration, you can reduce the size of the MathJax directory by removing unused components. For example, if you are using the tex-chtml.js component, then you can remove the tex-mml-chtml.js, tex-svg.js, tex-mml-svg.js, tex-chtml-full.js, and tex-svg-full.js configurations, which will save considerable space. Indeed, you should be able to remove everything other than tex-chtml.js, and the input/tex/extensions, output/chtml/fonts/woff-v2, adaptors, a11y, and sre directories. If you are using the results only on the web, you can remove adaptors as well.

If you are not using A11Y support (e.g., speech generation, or semantic enrichment), then you can remove a11y and sre as well (though in this case you may need to disable the assistive tools in the MathJax contextual menu in order to avoid MathJax trying to load them when they aren't there).

But according to my quick research, there is no configuration option to disable fetching those files at all.

How to repreduce

  1. Visit https://jbms.github.io/sphinx-immaterial/additional_samples.html#math
  2. Right click on the math expression -> Accessibility -> Activate
  3. Reload the page

Now the math is not rendered and there is a 404 error from a failed fetching of a11y/sre.js.

How to recover

I had to clear the Local Storage for a given site, because the MathJax context menu is no longer accessible...

@2bndy5 2bndy5 added the bug Something isn't working label Aug 21, 2023
@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 21, 2023

Thanks for the detailed report! I'm guessing the fix is to adjust the list of patterns that are copied to the theme's dist (as you noted in OP). Would you like to submit a PR?

@2bndy5
Copy link
Collaborator

2bndy5 commented Aug 21, 2023

Using SVG renderer causes a similar problem:
image
in web console:

Loading failed for the <script> with source “https://jbms.github.io/sphinx-immaterial/_static/mathjax/output/svg.js”. additional_samples.html:1:1

I'm starting to think everything from mathjax/dist/output needs to be copied over:

-...["tex-mml-chtml.js", "output/chtml/fonts/woff-v2/*.woff", "../LICENSE"]
+...["tex-mml-chtml.js", "output/**", "../LICENSE"]

2bndy5 added a commit that referenced this issue Sep 5, 2023
Now includes all mathjax-needed files in the dist.
This will also fix other features in the mathjax that optionally enabled (svg rendering).
2bndy5 added a commit that referenced this issue Sep 5, 2023
resolves #279

Now includes all mathjax-needed files in the dist.
This will also fix other features in the mathjax that optionally enabled (svg rendering).
2bndy5 added a commit that referenced this issue Sep 5, 2023
resolves #279

Now includes all mathjax-needed files in the dist.
This will also fix other features in the mathjax that optionally enabled (svg rendering).
@2bndy5 2bndy5 added the pending release has been resolved but is pending a new release label Sep 5, 2023
@2bndy5
Copy link
Collaborator

2bndy5 commented Oct 28, 2023

fix available in v0.11.8

@2bndy5 2bndy5 removed the pending release has been resolved but is pending a new release label Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants