summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-02-27 18:45:07 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-04-25 22:22:13 +0900
commit4582d5a396d378abc2de0c83a7ed6028678eeebf (patch)
tree9c2d62a547aac3be44df22d0dce443152c954847
parent7e7126a4a87827f51a734835a64d752178a93086 (diff)
downloadsphinx-git-4582d5a396d378abc2de0c83a7ed6028678eeebf.tar.gz
refactor: Add testcase for mathjax3_config (refs: #9094)
-rw-r--r--sphinx/builders/html/__init__.py6
-rw-r--r--tests/test_ext_math.py16
2 files changed, 19 insertions, 3 deletions
diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py
index a78d54a16..87b9c5c45 100644
--- a/sphinx/builders/html/__init__.py
+++ b/sphinx/builders/html/__init__.py
@@ -1166,7 +1166,11 @@ def setup_js_tag_helper(app: Sphinx, pagename: str, templatename: str,
else:
# str value (old styled)
attrs.append('src="%s"' % pathto(js, resource=True))
- return '<script %s>%s</script>' % (' '.join(attrs), body)
+
+ if attrs:
+ return '<script %s>%s</script>' % (' '.join(attrs), body)
+ else:
+ return '<script>%s</script>' % body
context['js_tag'] = js_tag
diff --git a/tests/test_ext_math.py b/tests/test_ext_math.py
index bd124c8c6..ebe2c0f38 100644
--- a/tests/test_ext_math.py
+++ b/tests/test_ext_math.py
@@ -215,11 +215,23 @@ def test_math_compat(app, status, warning):
@pytest.mark.sphinx('html', testroot='ext-math',
confoverrides={'extensions': ['sphinx.ext.mathjax'],
- 'mathjax_config': {'extensions': ['tex2jax.js']}})
-def test_mathjax_config(app, status, warning):
+ 'mathjax3_config': {'extensions': ['tex2jax.js']}})
+def test_mathjax3_config(app, status, warning):
app.builder.build_all()
content = (app.outdir / 'index.html').read_text()
+ assert MATHJAX_URL in content
+ assert ('<script>window.MathJax = {"extensions": ["tex2jax.js"]}</script>' in content)
+
+
+@pytest.mark.sphinx('html', testroot='ext-math',
+ confoverrides={'extensions': ['sphinx.ext.mathjax'],
+ 'mathjax2_config': {'extensions': ['tex2jax.js']}})
+def test_mathjax2_config(app, status, warning):
+ app.builder.build_all()
+
+ content = (app.outdir / 'index.html').read_text()
+ assert MATHJAX_URL in content
assert ('<script type="text/x-mathjax-config">'
'MathJax.Hub.Config({"extensions": ["tex2jax.js"]})'
'</script>' in content)