Skip to content

Commit

Permalink
Merge pull request readthedocs#126 from molpako/fix-contents-directive
Browse files Browse the repository at this point in the history
Fix contents directive
  • Loading branch information
ericholscher authored Jan 3, 2019
2 parents fdeeda5 + e53321e commit eebb02c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion recommonmark/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def auto_code_block(self, node):
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)
Expand Down
7 changes: 7 additions & 0 deletions tests/sphinx_custom_md/index.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ A paragraph

Another paragraph


```eval_rst
.. contents:: Contents
```

Header 2
----------
10 changes: 10 additions & 0 deletions tests/test_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,13 @@ def test_integration(self):
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
)

0 comments on commit eebb02c

Please sign in to comment.