refactor: Add testcase for mathjax3_config (refs: #9094)

This commit is contained in:
Takeshi KOMIYA 2021-02-27 18:45:07 +09:00
parent 7e7126a4a8
commit 4582d5a396
2 changed files with 19 additions and 3 deletions

View File

@ -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

View File

@ -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)