Merge pull request #126 from molpako/fix-contents-directive

Fix contents directive
This commit is contained in:
Eric Holscher 2019-01-02 19:27:06 -05:00 committed by GitHub
commit eebb02c77a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View file

@ -243,7 +243,7 @@ class AutoStructify(transforms.Transform):
node = nodes.section()
self.state_machine.state.nested_parse(
StringList(content, source=original_node.source),
0, node=node, match_titles=False)
0, node=node, match_titles=True)
return node.children[:]
else:
match = re.search('[ ]?[\w_-]+::.*', language)

View file

@ -13,3 +13,10 @@ A paragraph
Another paragraph
```eval_rst
.. contents:: Contents
```
Header 2
----------

View file

@ -210,3 +210,13 @@ class CustomExtensionTests(SphinxIntegrationTests):
self.assertIn('<th class="head">abc</th>', output)
self.assertIn('<th class="head">data</th>', output)
self.assertIn('</table>', output)
self.assertIn(
('<div class="contents topic" id="contents">\n'
'<p class="topic-title first">Contents</p>\n'
'<ul class="simple">\n'
'<li><a class="reference internal" href="#header" id="id1">Header</a><ul>\n'
'<li><a class="reference internal" href="#header-2" id="id2">Header 2</a></li>\n'
'</ul>\n</li>\n</ul>'),
output
)