-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Describe the bug
The reStructuredText Primer (doc/usage/restructuredtext/basics.rst) starts the section on External links with
Use ```Link text <https://domain.invalid/>`_`` for inline web links.
which is, according to the reStructuredText Markup Specification the syntax for a "named hyperlink reference with embedded URI", the most complex and most misunderstood link syntax variant.
Users thus primed will be surprised when a subsequent "inline link" with the same link text results in a WARNING Duplicate explicit target name: "link text"
because the syntax is equivalent to the link–target pair ("reference link")
Use ```Link text`_`` for hyperlinks. Add a target block::
.. _link text: https://domain.invalid/
at a suitable place.
and generates two Doctree elements:
<reference name="Link text" refuri="https://domain.invalid/">Link text</reference>
<target ids="link-text" names="link\ text" refuri="https://domain.invalid/"></target>
The rST analogon to Markup "inline links" is an "anonymous hyperlink reference with embedded URI/alias" which uses a double trailing underline.
There is actually no good reason to use a named link with embedded href
(with single trailing underline):
-
If the established reference name is used at several places, a separate named target adds clarity.
-
One-off use cases are better served with the anonymous variant (with double trailing underline) or an "normal" anonymous reference – target pair.
Suggestion:
- Start the "primer" documentation section with "reference links". In rST, they are easier than "inline links".
- For "inline links", write
Use ```Link text <https://domain.invalid/>`__`` for inline web links (**mind the double underline at the end**, for details see the `rST specification`__). __ https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#embedded-uris-and-aliases`__
How to Reproduce
index.rst:
The references `link text <https://domain.invalid/>`_
and `link text <https://example.com/>`_ generate a warning.
Environment Information
The bug is in the current online documentation
https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#external-links