Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using references in GitHub wiki with restructured text

I'm trying to use internal references to link an index atop my wiki page with several sections within the document. Here's an example:

 * `My index`_
    + Foreword_
    + `Technical details`_


 My index
 --------

 Foreword
 ~~~~~~~~

 Technical details
 ~~~~~~~~~~~~~~~~~

If I generate the HTML page via rest2html I get the right result. However, GitHub wiki inserts extra words in the references and the links do not work. for example:

 https://github.com/myaccount/myproject/wiki/Page#wiki-my-index
 https://github.com/myaccount/myproject/wiki/Page#wiki-foreword
 https://github.com/myaccount/myproject/wiki/Page#wiki-technical-details

I couldn't find any relevant document in the GitHub page, so I'm kind of lost.

like image 948
Mariano Avatar asked May 31 '26 03:05

Mariano


1 Answers

It looks like the class ids are missing from the generated divs. Check the page source to (not) see them. I think this is what it should look like:

<ul>
  <li><dl class="first docutils">
    <dt><a class="reference internal" href="#my-index">My index</a></dt>
  <li><a class="reference internal" href="#foreword">Foreword</a></li>
  <li><a class="reference internal" href="#technical-details">Technical details</a></li>
</ul>

<div class="section" id="my-index">
  <h1>My index</h1>
</div>
<div class="section" id="foreword">
  <h2>Foreword</h2>
</div>
<div class="section" id="technical-details">
  <h2>Technical details</h2>
</div>

Edit: User intuited mentions the same issue in a GitHub markup issue

I've noticed this problem with README.rst files as well. As well as headings, inline targets in .rst files, e.g. _some target, don't work. The inline target text gets wrapped in a but doesn't get made into any sort of link target. Should I file this as a separate issue?

like image 144
Tim Condit Avatar answered Jun 02 '26 19:06

Tim Condit