mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Allow `?config=...
in
mathjax_path
` (#11659)
This commit is contained in:
parent
4692208fde
commit
7d046a862f
1
CHANGES
1
CHANGES
@ -23,6 +23,7 @@ Bugs fixed
|
||||
* #11634: Fixed inheritance diagram relative link resolution
|
||||
for sibling files in a subdirectory.
|
||||
Patch by Albert Shih.
|
||||
* #11659: Allow ``?config=...`` in :confval:`mathjax_path`.
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
@ -1085,7 +1085,13 @@ class StandaloneHTMLBuilder(Builder):
|
||||
return f'<script>{body}</script>'
|
||||
|
||||
uri = pathto(os.fspath(js.filename), resource=True)
|
||||
if checksum := _file_checksum(outdir, js.filename):
|
||||
if 'MathJax.js?' in os.fspath(js.filename):
|
||||
# MathJax v2 reads a ``?config=...`` query parameter,
|
||||
# special case this and just skip adding the checksum.
|
||||
# https://docs.mathjax.org/en/v2.7-latest/configuration.html#considerations-for-using-combined-configuration-files
|
||||
# https://github.com/sphinx-doc/sphinx/issues/11658
|
||||
pass
|
||||
elif checksum := _file_checksum(outdir, js.filename):
|
||||
uri += f'?v={checksum}'
|
||||
if attrs:
|
||||
return f'<script {" ".join(sorted(attrs))} src="{uri}"></script>'
|
||||
|
@ -283,6 +283,34 @@ def test_mathjax_options_defer_for_mathjax2(app, status, warning):
|
||||
assert ('<script defer="defer" src="%s">' % MATHJAX_URL in content)
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'html', testroot='ext-math',
|
||||
confoverrides={
|
||||
'extensions': ['sphinx.ext.mathjax'],
|
||||
'mathjax_path': 'MathJax.js',
|
||||
},
|
||||
)
|
||||
def test_mathjax_path(app):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<script async="async" src="_static/MathJax.js"></script>' in content
|
||||
|
||||
|
||||
@pytest.mark.sphinx(
|
||||
'html', testroot='ext-math',
|
||||
confoverrides={
|
||||
'extensions': ['sphinx.ext.mathjax'],
|
||||
'mathjax_path': 'MathJax.js?config=scipy-mathjax',
|
||||
},
|
||||
)
|
||||
def test_mathjax_path_config(app):
|
||||
app.builder.build_all()
|
||||
|
||||
content = (app.outdir / 'index.html').read_text(encoding='utf8')
|
||||
assert '<script async="async" src="_static/MathJax.js?config=scipy-mathjax"></script>' in content
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-math',
|
||||
confoverrides={'extensions': ['sphinx.ext.mathjax']})
|
||||
def test_mathjax_is_installed_only_if_document_having_math(app, status, warning):
|
||||
|
Loading…
Reference in New Issue
Block a user