Skip to content

Conversation

@randolf-scholz
Copy link
Contributor

@randolf-scholz randolf-scholz commented Nov 3, 2025

Fixes #14023

Note: git was telling me that these two files were modified, I'm not sure what's going on:

(sphinx) rscholz@Z890:~/github/CONTRIBUTING/sphinx$ git reset --hard
error: failed to encode 'tests/roots/test-root/wrongenc.inc' from UTF-8 to latin-1
error: failed to encode 'tests/roots/test-warnings/wrongenc.inc' from UTF-8 to latin-1
HEAD is now at e5cf9e0da allow mathjax3_config to point to a JS file
(sphinx) rscholz@Z890:~/github/CONTRIBUTING/sphinx$ git status
On branch mathjax_custom_js
Your branch is up to date with 'origin/mathjax_custom_js'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   tests/roots/test-root/wrongenc.inc
        modified:   tests/roots/test-warnings/wrongenc.inc

@AA-Turner AA-Turner added the extensions:mathematics The `sphinx.ext.imgmath`, `sphinx.ext.jsmath`, or `sphinx.ext.mathjax` extensions label Nov 7, 2025
Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good based on a desk review (on mobile)!

I've left a few comments, but all minor.

A

randolf-scholz and others added 3 commits November 7, 2025 08:38
@mgeier
Copy link
Contributor

mgeier commented Nov 23, 2025

Is this really necessary?

As I said in #13147, the reason why it doesn't work is MyST-Parser, not Sphinx.

@randolf-scholz
Copy link
Contributor Author

Is this really necessary?

What a weird thing to ask for a feature PR. Almost no features are strictly necessary. They are added because they are useful. This feature is useful because it solves a problem (#13147) without affecting 3rd party extension compatibility.

@AA-Turner
Copy link
Member

@randolf-scholz I think we can resolve these concerns in the extra docs I suggested in #14023 (comment), also noting that MyST does non-standard things with MathJax config.

A

@randolf-scholz
Copy link
Contributor Author

randolf-scholz commented Nov 23, 2025

@AA-Turner It's still unclear to me what exactly you want me to add in terms of documentation and where to put it. My latest commit adds a (blue) info box:

image

And also .. versionchanged:: 8.3 Now also accepts a string with the path to a JavaScript file. to the mathjax3_config description.

@randolf-scholz
Copy link
Contributor Author

I added mathjax4_config in this box in anticipation of #14080.

@AA-Turner AA-Turner changed the title allow mathjax3_config to point to a JS file Add mathjax_config_file to load MathJax configuration from a file Nov 24, 2025
@AA-Turner
Copy link
Member

Following @mgeier pointing out MyST's monkeypatching, I note that changing mathjax3_config to a str would break MyST: https://github.com/executablebooks/MyST-Parser/blob/8a44f5d35197b19aab2f1fe35b6f1dce4960bce5/myst_parser/sphinx_ext/mathjax.py#L67

As such, I've adjusted this PR to instead introduce a new config option, mathjax_config_path.

A

@AA-Turner AA-Turner enabled auto-merge (squash) November 24, 2025 20:58
@AA-Turner AA-Turner merged commit 67762d8 into sphinx-doc:master Nov 24, 2025
29 of 30 checks passed
@AA-Turner AA-Turner added this to the 9.0.0 milestone Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions:mathematics The `sphinx.ext.imgmath`, `sphinx.ext.jsmath`, or `sphinx.ext.mathjax` extensions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MathJax: allow passing custom JS config

3 participants