mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Using align brings the benefit when multiple math equations are in one math directive, alignment is provided. We also use "aligned" to wrap the equations since in this way all the equations will be given only one label/tag, while previously only the first equation is labeled.
63 lines
2.3 KiB
Python
63 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
test_ext_math
|
|
~~~~~~~~~~~~~
|
|
|
|
Test math extensions.
|
|
|
|
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
|
:license: BSD, see LICENSE for details.
|
|
"""
|
|
|
|
import re
|
|
|
|
from util import with_app, SkipTest
|
|
|
|
|
|
@with_app('html', testroot='ext-math',
|
|
confoverrides = {'extensions': ['sphinx.ext.imgmath']})
|
|
def test_imgmath_png(app, status, warning):
|
|
app.builder.build_all()
|
|
if "LaTeX command 'latex' cannot be run" in warning.getvalue():
|
|
raise SkipTest('LaTeX command "latex" is not available')
|
|
if "dvipng command 'dvipng' cannot be run" in warning.getvalue():
|
|
raise SkipTest('dvipng command "dvipng" is not available')
|
|
|
|
content = (app.outdir / 'index.html').text()
|
|
html = ('<div class="math">\s*<p>\s*<img src="_images/math/\w+.png"'
|
|
'\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>')
|
|
assert re.search(html, content, re.S)
|
|
|
|
@with_app('html', testroot='ext-math',
|
|
confoverrides={'extensions': ['sphinx.ext.imgmath'],
|
|
'imgmath_image_format': 'svg'})
|
|
def test_imgmath_svg(app, status, warning):
|
|
app.builder.build_all()
|
|
if "LaTeX command 'latex' cannot be run" in warning.getvalue():
|
|
raise SkipTest('LaTeX command "latex" is not available')
|
|
if "dvisvgm command 'dvisvgm' cannot be run" in warning.getvalue():
|
|
raise SkipTest('dvisvgm command "dvisvgm" is not available')
|
|
|
|
content = (app.outdir / 'index.html').text()
|
|
html = ('<div class="math">\s*<p>\s*<img src="_images/math/\w+.svg"'
|
|
'\s*alt="a\^2\+b\^2=c\^2"/>\s*</p>\s*</div>')
|
|
assert re.search(html, content, re.S)
|
|
|
|
@with_app('html', testroot='ext-math',
|
|
confoverrides={'math_number_all': True,
|
|
'extensions': ['sphinx.ext.mathjax']})
|
|
def test_math_number_all(app, status, warning):
|
|
app.builder.build_all()
|
|
|
|
content = (app.outdir / 'index.html').text()
|
|
html = (r'<div class="math">\s*'
|
|
r'<span class="eqno">\(1\)</span>\\\[a\^2\+b\^2=c\^2\\\]</div>')
|
|
assert re.search(html, content, re.S)
|
|
|
|
@with_app('latex', testroot='ext-math',
|
|
confoverrides={'extensions': ['sphinx.ext.mathjax']})
|
|
def test_math_number_all(app, status, warning):
|
|
app.builder.build_all()
|
|
|
|
content = (app.outdir / 'test.tex').text()
|