Skip to content

Commit

Permalink
Merge pull request #1536 from felixfontein/fix-rst-links
Browse files Browse the repository at this point in the history
Make sure all anchors are created for RST links
  • Loading branch information
jmeridth committed Sep 4, 2024
2 parents f7adf19 + a78c9a7 commit 914839f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/github/commands/rest2html
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ class GitHubHTMLTranslator(HTMLTranslator):
# see also: http://bit.ly/NHtyRx
# the a is to support ::contents with ::sectnums: http://git.io/N1yC
def visit_section(self, node):
id_attribute = node.attributes['ids'][0]
self.body.append('<a name="%s"></a>\n' % id_attribute)
for id_attribute in node.attributes['ids']:
self.body.append('<a name="%s"></a>\n' % id_attribute)
self.section_level += 1

def depart_section(self, node):
Expand Down
4 changes: 4 additions & 0 deletions test/markups/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Example text.

.. contents:: Table of Contents

.. _label_for_header_2:

Header 2
--------

Expand All @@ -17,6 +19,8 @@ Header 2

3. Somé UTF-8°

4. `Link to the above header <label_for_header_2_>`_

The UTF-8 quote character in this table used to cause python to go boom. Now docutils just silently ignores it.

.. csv-table:: Things that are Awesome (on a scale of 1-11)
Expand Down
2 changes: 2 additions & 0 deletions test/markups/README.rst.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ <h2>Subtitle</h2>
</ul>
</div>
<a name="header-2"></a>
<a name="label-for-header-2"></a>
<h2><a href="#toc-entry-1">Header 2</a></h2>
<ol>
<li>Blah blah <code>code</code> blah</li>
<li>More <code>code</code>, hooray</li>
<li>Somé UTF-8°</li>
<li><a href="#label-for-header-2">Link to the above header</a></li>
</ol>
<p>The UTF-8 quote character in this table used to cause python to go boom. Now docutils just silently ignores it.</p>
<table>
Expand Down

0 comments on commit 914839f

Please sign in to comment.