mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add testcase for math directive
This commit is contained in:
parent
5cf84a5505
commit
e5881c2344
@ -52,3 +52,35 @@ def test_code_directive(app):
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(doctree, [nodes.document, nodes.literal_block, 'print("hello world")'])
|
||||
assert_node(doctree[0], language="python", linenos=True, highlight_args={'linenostart': 5})
|
||||
|
||||
|
||||
def test_math_directive(app):
|
||||
# normal case
|
||||
text = '.. math:: E = mc^2'
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(doctree, [nodes.document, nodes.math_block, 'E = mc^2\n\n'])
|
||||
|
||||
# :name: option
|
||||
text = ('.. math:: E = mc^2\n'
|
||||
' :name: eq1\n')
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(doctree, [nodes.document, (nodes.target,
|
||||
[nodes.math_block, "E = mc^2\n\n"])])
|
||||
assert_node(doctree[1], nodes.math_block, docname='index', label="eq1", number=1)
|
||||
|
||||
# :label: option
|
||||
text = ('.. math:: E = mc^2\n'
|
||||
' :label: eq2\n')
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(doctree, [nodes.document, (nodes.target,
|
||||
[nodes.math_block, 'E = mc^2\n\n'])])
|
||||
assert_node(doctree[1], nodes.math_block, docname='index', label="eq2", number=2)
|
||||
|
||||
# :label: option without value
|
||||
text = ('.. math:: E = mc^2\n'
|
||||
' :label:\n')
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(doctree, [nodes.document, (nodes.target,
|
||||
[nodes.math_block, 'E = mc^2\n\n'])])
|
||||
assert_node(doctree[1], nodes.math_block, ids=['equation-index-0'],
|
||||
docname='index', label="index:0", number=3)
|
||||
|
Loading…
Reference in New Issue
Block a user