Skip to content

Anchors not generated for internal hyperlinks on Wiki using reStructuredText #1219

@chaimkut

Description

@chaimkut

Here is a test Wiki page -- it attempts to use the various formats of internal hyperlinks supported by the reStructuredText format but none of them work in practice. The links in the generated HTML all point to reasonable anchors, but the anchors are never actually inserted into the page.

Here is the markup:

Testing reStructuredText internal links in github:

Some forms documented as valid hyperlink references by http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-targets :

Here is a link to target1_

Here is a link to a `phrase target 2`_ as per http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-references

Here is a link to an `inline internal target 3`_ as per http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-internal-targets

Here is a link to anon-target-4-1__

Here is a link to anon-target-4-2__

Here is a link to `anonymous phrase target 5-1`__

Here is a link to `anonymous phrase target 5-2`__

Anonymous targets as per http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#anonymous-hyperlinks

.. _target1:

Paragraph 1

.. _phrase target 2:

Paragraph 3

Here is a paragraph with an _`inline internal target 3`

.. __: 

Paragraph 4-1

__ 

Paragraph 4-2

.. __: 

Paragraph 5-1

__ 

Paragraph 5-2

If you look at the generated HTML, you will notice that the links point to targets #target1, #phrase-target-2, #inline-internal-target-3, #id1, #id2, #id3, #id4 but corresponding anchors are not actually inserted into the page.

I tested using markup's rest2html script and it renders the HTML as expected (I tested locally with docutils 0.13.1 since that's the last one mentioned being in use as of Mar 22 2017 per #382):

cat /tmp/test_links.rst | ./lib/github/commands/rest2html
<p>Testing reStructuredText internal links in github:</p>
<p>Some forms documented as valid hyperlink references by <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-targets">http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-targets</a> :</p>
<p>Here is a link to <a class="reference internal" href="#target1">target1</a></p>
<p>Here is a link to a <a class="reference internal" href="#phrase-target-2">phrase target 2</a> as per <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-references">http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-references</a></p>
<p>Here is a link to an <a class="reference internal" href="#inline-internal-target-3">inline internal target 3</a> as per <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-internal-targets">http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-internal-targets</a></p>
<p>Here is a link to <a class="reference internal" href="#id1">anon-target-4-1</a></p>
<p>Here is a link to <a class="reference internal" href="#id2">anon-target-4-2</a></p>
<p>Here is a link to <a class="reference internal" href="#id3">anonymous phrase target 5-1</a></p>
<p>Here is a link to <a class="reference internal" href="#id4">anonymous phrase target 5-2</a></p>
<p>Anonymous targets as per <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#anonymous-hyperlinks">http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#anonymous-hyperlinks</a></p>
<p id="target1">Paragraph 1</p>
<p id="phrase-target-2">Paragraph 3</p>
<p>Here is a paragraph with an <span class="target" id="inline-internal-target-3">inline internal target 3</span></p>
<p id="id1">Paragraph 4-1</p>
<p id="id2">Paragraph 4-2</p>
<p id="id3">Paragraph 5-1</p>
<p id="id4">Paragraph 5-2</p>

I don't know why the Wiki does not receive the correctly generated HTML.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions