Merge pull request #9881 from tk0miya/9878_mathjax_config_should_be_loaded_earlier

Fix #9878: mathjax: MathJax config is placed after loading MathJax
This commit is contained in:
Takeshi KOMIYA 2021-11-23 03:03:14 +09:00 committed by GitHub
commit 634dd395cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -20,6 +20,7 @@ Bugs fixed
---------- ----------
* #9866: autodoc: doccoment for the imported class was ignored * #9866: autodoc: doccoment for the imported class was ignored
* #9878: mathjax: MathJax configuration is placed after loading MathJax itself
* #9857: Generated RFC links use outdated base url * #9857: Generated RFC links use outdated base url
Testing Testing

View File

@ -81,11 +81,6 @@ def install_mathjax(app: Sphinx, pagename: str, templatename: str, context: Dict
domain = cast(MathDomain, app.env.get_domain('math')) domain = cast(MathDomain, app.env.get_domain('math'))
if app.registry.html_assets_policy == 'always' or domain.has_equations(pagename): if app.registry.html_assets_policy == 'always' or domain.has_equations(pagename):
# Enable mathjax only if equations exists # Enable mathjax only if equations exists
options = {'defer': 'defer'}
if app.config.mathjax_options:
options.update(app.config.mathjax_options)
app.add_js_file(app.config.mathjax_path, **options) # type: ignore
if app.config.mathjax2_config: if app.config.mathjax2_config:
if app.config.mathjax_path == MATHJAX_URL: if app.config.mathjax_path == MATHJAX_URL:
logger.warning( logger.warning(
@ -97,6 +92,11 @@ def install_mathjax(app: Sphinx, pagename: str, templatename: str, context: Dict
body = 'window.MathJax = %s' % json.dumps(app.config.mathjax3_config) body = 'window.MathJax = %s' % json.dumps(app.config.mathjax3_config)
app.add_js_file(None, body=body) app.add_js_file(None, body=body)
options = {'defer': 'defer'}
if app.config.mathjax_options:
options.update(app.config.mathjax_options)
app.add_js_file(app.config.mathjax_path, **options) # type: ignore
def setup(app: Sphinx) -> Dict[str, Any]: def setup(app: Sphinx) -> Dict[str, Any]:
app.add_html_math_renderer('mathjax', app.add_html_math_renderer('mathjax',