Skip to content

Commit

Permalink
Fix #9878: mathjax: MathJax config is placed after loading MathJax
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Nov 21, 2021
1 parent 6473141 commit cd18138
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -19,6 +19,7 @@ Features added
Bugs fixed
----------

* #9878: mathjax: MathJax configuration is placed after loading MathJax itself
* #9857: Generated RFC links use outdated base url

Testing
Expand Down
10 changes: 5 additions & 5 deletions sphinx/ext/mathjax.py
Expand Up @@ -81,11 +81,6 @@ def install_mathjax(app: Sphinx, pagename: str, templatename: str, context: Dict
domain = cast(MathDomain, app.env.get_domain('math'))
if app.registry.html_assets_policy == 'always' or domain.has_equations(pagename):
# 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.mathjax_path == MATHJAX_URL:
logger.warning(
Expand All @@ -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)
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]:
app.add_html_math_renderer('mathjax',
Expand Down

0 comments on commit cd18138

Please sign in to comment.