Skip to content

Commit 914839f

Browse files
authored
Merge pull request #1536 from felixfontein/fix-rst-links
Make sure all anchors are created for RST links
2 parents f7adf19 + a78c9a7 commit 914839f

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

lib/github/commands/rest2html

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ class GitHubHTMLTranslator(HTMLTranslator):
199199
# see also: http://bit.ly/NHtyRx
200200
# the a is to support ::contents with ::sectnums: http://git.io/N1yC
201201
def visit_section(self, node):
202-
id_attribute = node.attributes['ids'][0]
203-
self.body.append('<a name="%s"></a>\n' % id_attribute)
202+
for id_attribute in node.attributes['ids']:
203+
self.body.append('<a name="%s"></a>\n' % id_attribute)
204204
self.section_level += 1
205205

206206
def depart_section(self, node):

test/markups/README.rst

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Example text.
88

99
.. contents:: Table of Contents
1010

11+
.. _label_for_header_2:
12+
1113
Header 2
1214
--------
1315

@@ -17,6 +19,8 @@ Header 2
1719

1820
3. Somé UTF-8°
1921

22+
4. `Link to the above header <label_for_header_2_>`_
23+
2024
The UTF-8 quote character in this table used to cause python to go boom. Now docutils just silently ignores it.
2125

2226
.. csv-table:: Things that are Awesome (on a scale of 1-11)

test/markups/README.rst.html

+2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ <h2>Subtitle</h2>
99
</ul>
1010
</div>
1111
<a name="header-2"></a>
12+
<a name="label-for-header-2"></a>
1213
<h2><a href="#toc-entry-1">Header 2</a></h2>
1314
<ol>
1415
<li>Blah blah <code>code</code> blah</li>
1516
<li>More <code>code</code>, hooray</li>
1617
<li>Somé UTF-8°</li>
18+
<li><a href="#label-for-header-2">Link to the above header</a></li>
1719
</ol>
1820
<p>The UTF-8 quote character in this table used to cause python to go boom. Now docutils just silently ignores it.</p>
1921
<table>

0 commit comments

Comments
 (0)